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
model.graphviz() also needs the system Graphviz
binaries (e.g. brew install graphviz on macOS).
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 viaPanelColumns(group_columns=...),period/region(datetimeperiodrequired fortrend/seasonality)
Column names are configurable via PanelColumns. Internally the model uses
log(price) and log(max(quantity, quantity_floor)) (default floor 1.0).
When to use pypricing (and when not to use it)
pypricing assumes products have posted prices that changed over time, and you observe the units sold at each price.
Retail, consumer goods and e-commerce are good use cases: many products, regular sales volume, frequent price or promo changes.
Bad use cases include one-off prices, very low volume, or sales limited by capacity (hotels, airlines).
Metadata
Release files for pypricing 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pypricing-0.0.3.tar.gz | 49.1 kB | With provenance | Details for pypricing-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pypricing-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for pypricing-0.0.3-py3-none-any.whl |
Total release size: 108.0 kB
Release files / pypricing-0.0.3.tar.gz
| Download URL | pypricing-0.0.3.tar.gz |
|---|---|
| Size | 49.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e49c99f554d65e5ee506bfbd118eb5c5456d88d5fe5f3dd483335d31c9c2a1d7
|
|
BLAKE2b-256 checksum How to use checksums |
55df8239a363661037ceddcafda1bc6a7a7e1a764fa6d569e436734fa6ab7ed7
|
| 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 Oct 2, 2026.
Transparency logRelease files / pypricing-0.0.3-py3-none-any.whl
| Download URL | pypricing-0.0.3-py3-none-any.whl |
|---|---|
| Size | 58.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0d2da999474e75994ff1d2abcaa737d1bb0f83528271d0af3d475f61900be62f
|
|
BLAKE2b-256 checksum How to use checksums |
8e354b79db02731a97f076dbba96d5b2863c783c7b3041b2d68e92032e0d1f9b
|
| 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 Oct 2, 2026.
Transparency logSecurity for pypricing 0.0.3
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.
Attestation for pypricing-0.0.3.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 Oct 2, 2026.
Transparency logA 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.