Spaces:
Sleeping
Sleeping
Download tools/forecaster.py from mgbam/BizIntel_AI: direct link, hf CLI and curl.
- Browser
- Download file 582 Bytes
-
https://huggingface.co/spaces/mgbam/BizIntel_AI/resolve/3ccfe79572bdb77cc30fb8aa71996697c8f135cc/tools/forecaster.py
- Command line
-
hf download hf://spaces/mgbam/BizIntel_AI@3ccfe79572bdb77cc30fb8aa71996697c8f135cc/tools/forecaster.py
-
curl -L -o forecaster.py https://huggingface.co/spaces/mgbam/BizIntel_AI/resolve/3ccfe79572bdb77cc30fb8aa71996697c8f135cc/tools/forecaster.py
582 Bytes
| import pandas as pd | |
| import matplotlib.pyplot as plt | |
| from statsmodels.tsa.arima.model import ARIMA | |
| def forecast_tool(file_path: str) -> str: | |
| df = pd.read_csv(file_path) | |
| df['Month'] = pd.to_datetime(df['Month']) | |
| df.set_index('Month', inplace=True) | |
| model = ARIMA(df['Sales'], order=(1, 1, 1)) | |
| model_fit = model.fit() | |
| forecast = model_fit.forecast(steps=3) | |
| df_forecast = pd.DataFrame(forecast, columns=['Forecast']) | |
| df_forecast.plot(title="Sales Forecast", figsize=(10, 6)) | |
| plt.savefig("forecast_plot.png") | |
| return "Generated forecast_plot.png" | |