The `pypricetrend` package provides tools to analyze and forecast product demand based on historical sales data
Project description
pypricetrend
Introduction
The pypricetrend package provides tools to analyze and forecast product demand based on historical sales data. It includes the DemandCurve class for generating demand curves and the Forecast class for predicting future demand.
Classes
DemandCurve
The DemandCurve class generates demand curves for a given product.
Initialization
To initialize the DemandCurve class, you need to provide a DataFrame containing the columns price, quantity, and date, as well as the landed_cost and fulfillment_cost of the product.
from pypricetrend import DemandCurve
import pandas as pd
# Sample data
data = {
'price': [10, 20, 15, 25, 30],
'quantity': [100, 80, 90, 70, 60],
'date': pd.to_datetime(['2023-01-01', '2023-01-02', '2023-01-03', '2023-01-04', '2023-01-05'])
}
orders_df = pd.DataFrame(data)
# Initialize the DemandCurve class
landed_cost = 5.0
fulfillment_cost = 2.0
demand_curve = DemandCurve(orders_df, landed_cost, fulfillment_cost)
Predicting Demand
You can predict the demand for a given price using the predict_demand method.
price = 22.5
predicted_demand = demand_curve.predict_demand(price)
print(f"Predicted demand for price {price}: {predicted_demand}")
Plotting the Demand Curve
You can plot the demand curve for the given product using the plot_demand_curve method.
demand_curve.plot_demand_curve()
Saving and Loading the Model
You can save the demand curve model to a file and load it later.
# Save the model
demand_curve.save_model('demand_curve_model.npy')
# Load the model
demand_curve.load_model('demand_curve_model.npy')
Forecast
The Forecast class predicts future demand based on historical sales data.
Initialization
To initialize the Forecast class, you need to provide a DataFrame containing the columns price, quantity, and date
from pypricetrend import Forecast
import pandas as pd
# Sample data
data = {
'price': [10, 20, 15, 25, 30],
'quantity': [100, 80, 90, 70, 60],
'date': pd.to_datetime(['2023-01-01', '2023-01-02', '2023-01-03', '2023-01-04', '2023-01-05'])
}
orders_df = pd.DataFrame(data)
# Initialize the Forecast class
forecast = Forecast(orders_df)
Forecasting Demand
You can forecast the demand for a given price and sale date using the forcast_demand method.
Forecasting Demand
You can forecast the demand for a given price and sale date using the forcast_demand method.
Forecasting for the Next 30 Days
You can forecast the demand for the next 30 days using the forecast_thrity_days method.
Installation
pip install pypricetrend
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pypricetrend-0.1.0.tar.gz.
File metadata
- Download URL: pypricetrend-0.1.0.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e472d9504bcbd0c7c3af2f8d91fe90b526b402042a955311d1a583b0bcc7e8c
|
|
| MD5 |
a852f652ac972697440c3b0089d33453
|
|
| BLAKE2b-256 |
f16ad4ce9af503564e6d893aad551480d9d5caac84be923554f85e68affb1057
|
File details
Details for the file pypricetrend-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pypricetrend-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8cd1424c34f4569f335cf85fe5c3bf1238d290307e0fb5cc2c75e658ce65f08
|
|
| MD5 |
96d08b61b8885d8553cbb1b1702e1de3
|
|
| BLAKE2b-256 |
6bf2c942ee326d12c6feda7ba59eb2fc5adc6eccc6ccb8c308868bff81f9eb58
|