Spaces:
Sleeping
Sleeping
File size: 582 Bytes
758f9f6 010071f 139e188 010071f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
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"
|