Spaces:
Sleeping
Sleeping
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" | |