Skip to main content

pypricing

Bayesian log-demand pricing analytics with PyMC for long-format panels (one row per SKU–time observation): own-price elasticity, optional controls, instruments, hierarchy, trend/seasonality, and counterfactual prediction.

Install

pip install pypricing

Optional model-graph rendering (also needs the system Graphviz binaries):

pip install 'pypricing[graphviz]'

Full docs (guides + API + notebooks): pypricing.readthedocs.io

Quickstart

import numpy as np

from pypricing import LogLogDemandModel, generate_mock_data

df = generate_mock_data(
    n_periods=20,
    n_skus=5,
    n_controls=2,
    include_seasonality=False,
    random_state=0,
)

model = LogLogDemandModel()
model.fit(df, draws=1000, tune=1000, chains=4, random_seed=42)

df_scenario = df.drop(columns=["quantity"]).copy()
df_scenario["price"] = df_scenario["price"] * 1.05
print(model.predict(df_scenario, hdi_prob=0.9, random_seed=123).head())

Data contract

fit(df) expects level-scale columns:

  • Required: sku, price (strictly positive), quantity (non-negative)
  • Optional: control_*, iv_*, hierarchy via PanelColumns(group_columns=...), period / region (datetime period required for trend / seasonality)

Column names are configurable via PanelColumns. Internally the model uses log(price) and log(max(quantity, quantity_floor)) (default floor 1.0).

When this is not identified

If prices respond to the same shocks that move demand, a regression of quantity on price mixes the demand slope with that feedback. More regressors do not fix it. You need exogenous price variation: a randomized experiment, cost / commodity shocks, or other valid instruments (iv_*). See Identification.

Metadata

Release files for pypricing 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pypricing 0.0.2
File Size Uploaded Provenance Actions
pypricing-0.0.2.tar.gz 49.5 kB With provenance Details for pypricing-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pypricing 0.0.2
File Interpreter ABI Platform Actions
pypricing-0.0.2-py3-none-any.whl Python 3 none any Details for pypricing-0.0.2-py3-none-any.whl

Total release size: 108.5 kB

Release files / pypricing-0.0.2.tar.gz

Download URL pypricing-0.0.2.tar.gz
Size 49.5 kB
Tags Source
SHA-256 checksum
How to use checksums
fcc13069b594f74241d5789aacf23fdd3ac3e666134a47aee104f062763cdb81
BLAKE2b-256 checksum
How to use checksums
741b1fe97f0555e9a5a86d88f8743b3d0ad2e95fafdfac4f0860bc3c79747045
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release files / pypricing-0.0.2-py3-none-any.whl

Download URL pypricing-0.0.2-py3-none-any.whl
Size 59.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
26bb3f2dd58a9a4395fcff3b2384acb45498c3b42c6fce19c2bd96ccdea17ff0
BLAKE2b-256 checksum
How to use checksums
55c514de340c9d95bd38c82cc584a6415a482d178699c83f4239f1f7c5d228c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Security for pypricing 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pypricing-0.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page