Spaces:
Running
Running
Upload 3 files
Browse files- tools/csv_parser.py +8 -0
- tools/forecaster.py +18 -0
- tools/plot_generator.py +16 -0
tools/csv_parser.py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import pandas as pd
|
3 |
+
from google.adk.tools import Tool
|
4 |
+
|
5 |
+
@Tool(name="parse_csv_tool", description="Parse and summarize business CSV data")
|
6 |
+
def parse_csv(file_path: str) -> str:
|
7 |
+
df = pd.read_csv(file_path)
|
8 |
+
return f"Schema: {list(df.columns)}\n\nStats:\n{df.describe().to_string()}"
|
tools/forecaster.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import pandas as pd
|
3 |
+
import matplotlib.pyplot as plt
|
4 |
+
from statsmodels.tsa.arima.model import ARIMA
|
5 |
+
from google.adk.tools import Tool
|
6 |
+
|
7 |
+
@Tool(name="forecast_tool", description="Forecast future sales using ARIMA")
|
8 |
+
def forecast(file_path: str) -> str:
|
9 |
+
df = pd.read_csv(file_path)
|
10 |
+
df['Month'] = pd.to_datetime(df['Month'])
|
11 |
+
df.set_index('Month', inplace=True)
|
12 |
+
model = ARIMA(df['Sales'], order=(1, 1, 1))
|
13 |
+
model_fit = model.fit()
|
14 |
+
forecast = model_fit.forecast(steps=3)
|
15 |
+
df_forecast = pd.DataFrame(forecast, columns=['Forecast'])
|
16 |
+
df_forecast.plot(title="Sales Forecast", figsize=(10, 6))
|
17 |
+
plt.savefig("forecast_plot.png")
|
18 |
+
return "Generated forecast_plot.png"
|
tools/plot_generator.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
import pandas as pd
|
3 |
+
import matplotlib.pyplot as plt
|
4 |
+
from google.adk.tools import Tool
|
5 |
+
|
6 |
+
@Tool(name="plot_sales_tool", description="Plot sales trend over time")
|
7 |
+
def plot_sales(file_path: str) -> str:
|
8 |
+
df = pd.read_csv(file_path)
|
9 |
+
if 'Month' not in df.columns or 'Sales' not in df.columns:
|
10 |
+
return "Missing 'Month' or 'Sales' columns."
|
11 |
+
plt.figure(figsize=(10, 6))
|
12 |
+
plt.plot(df['Month'], df['Sales'], marker='o')
|
13 |
+
plt.xticks(rotation=45)
|
14 |
+
plt.title("Sales Trend")
|
15 |
+
plt.savefig("sales_plot.png")
|
16 |
+
return "Generated sales_plot.png"
|