Spaces:
Sleeping
Sleeping
Update: More transformations
Browse files
app.py
CHANGED
@@ -1,18 +1,26 @@
|
|
1 |
import gradio as gr
|
2 |
import pickle
|
|
|
3 |
|
4 |
def make_prediction(months):
|
5 |
with open("model.pkl", "rb") as f:
|
6 |
clf = pickle.load(f)
|
7 |
preds = clf.forecast(months)
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
# input
|
11 |
-
months_input = gr.Number(label = "Enter months to predict:")
|
12 |
|
13 |
# output
|
14 |
-
|
15 |
|
16 |
# interface
|
17 |
-
app = gr.Interface(fn=make_prediction, inputs=months_input, outputs=
|
18 |
-
app.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import pickle
|
3 |
+
import pandas as pd
|
4 |
|
5 |
def make_prediction(months):
|
6 |
with open("model.pkl", "rb") as f:
|
7 |
clf = pickle.load(f)
|
8 |
preds = clf.forecast(months)
|
9 |
+
df_preds = pd.DataFrame(preds)
|
10 |
+
df_preds.reset_index(inplace=True)
|
11 |
+
y_2021 = df_preds[df_preds['index'].dt.year == 2021]
|
12 |
+
y_2021_mean = y_2021['predicted_mean'].mean()
|
13 |
+
return int(round(y_2021_mean, 0))
|
14 |
+
|
15 |
+
# y_hat_2021 = make_prediction(24)
|
16 |
+
# y_hat_2021
|
17 |
|
18 |
# input
|
19 |
+
months_input = gr.Number(label = "Enter months (from 12) to predict for 2021:")
|
20 |
|
21 |
# output
|
22 |
+
output = gr.Number()
|
23 |
|
24 |
# interface
|
25 |
+
app = gr.Interface(fn = make_prediction, inputs=months_input, outputs=output)
|
26 |
+
app.launch()
|