Spaces:
Sleeping
Sleeping
File size: 688 Bytes
010071f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import pandas as pd
import matplotlib.pyplot as plt
from statsmodels.tsa.arima.model import ARIMA
from google.adk.tools import Tool
@Tool(name="forecast_tool", description="Forecast future sales using ARIMA")
def forecast(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"
|