Download pricing_engine/data.py from PranavSharma/pricing-decision-lite: direct link, hf CLI and curl.
- Browser
- Download file 962 Bytes
-
https://huggingface.co/spaces/PranavSharma/pricing-decision-lite/resolve/main/pricing_engine/data.py
- Command line
-
hf download hf://spaces/PranavSharma/pricing-decision-lite/pricing_engine/data.py
-
curl -L -o data.py https://huggingface.co/spaces/PranavSharma/pricing-decision-lite/resolve/main/pricing_engine/data.py
962 Bytes
| import numpy as np | |
| import pandas as pd | |
| def generate_synthetic_sku( | |
| n_periods: int = 52, | |
| base_price: float = 10.0, | |
| base_demand: float = 120.0, | |
| elasticity: float = -1.5, | |
| noise_std: float = 0.1, | |
| seed: int = 42, | |
| ) -> pd.DataFrame: | |
| """ | |
| Generate a single-SKU synthetic price–demand time series. | |
| Elasticity is constant and known (ground truth). | |
| """ | |
| rng = np.random.default_rng(seed) | |
| # price variation around base price | |
| prices = base_price * (1 + rng.normal(0, 0.15, size=n_periods)) | |
| prices = np.clip(prices, base_price * 0.6, base_price * 1.4) | |
| # demand model: q = A * p^elasticity * noise | |
| noise = np.exp(rng.normal(0, noise_std, size=n_periods)) | |
| demand = base_demand * (prices ** elasticity) * noise | |
| df = pd.DataFrame( | |
| { | |
| "t": np.arange(n_periods), | |
| "price": prices, | |
| "qty": demand, | |
| } | |
| ) | |
| return df | |