Spaces:
Runtime error
Runtime error
Commit
•
52c374a
1
Parent(s):
4ca00a8
Update app.py
Browse files
app.py
CHANGED
@@ -45,7 +45,7 @@ def get_prediction_result():
|
|
45 |
df.loc[df['forecast_point'].isnull(), 'forecast_point'] = df['target_date'].apply(lambda x:x-relativedelta(months=1))
|
46 |
df = df.loc[~((df['target_date']<(today+relativedelta(months=1)))&(df['電気代'].isnull()))]
|
47 |
df = df.rename(columns={'電気代':'電気代_予測'})
|
48 |
-
return df[['forecast_point', 'target_date', '電気代_予測']]
|
49 |
|
50 |
def plot_prediction_result():
|
51 |
update = gr.LinePlot.update(
|
@@ -115,6 +115,9 @@ def get_featuredrift():
|
|
115 |
])
|
116 |
start_point = (target_drift.period['start']+relativedelta(hours=9)).strftime("%Y / %m / %d %H:%M:%S")
|
117 |
end_point = (target_drift.period['end']+relativedelta(hours=9)).strftime("%Y / %m / %d %H:%M:%S")
|
|
|
|
|
|
|
118 |
|
119 |
return drift_df, start_point, end_point
|
120 |
|
@@ -133,11 +136,10 @@ with gr.Blocks() as electoric_ploting:
|
|
133 |
"""
|
134 |
)
|
135 |
with gr.Tab("予測結果"):
|
136 |
-
with gr.Row():
|
137 |
-
reload_btn= gr.Button(value="再読み込み")
|
138 |
with gr.Row():
|
139 |
with gr.Column():
|
140 |
plot = gr.LinePlot(show_label=False)
|
|
|
141 |
with gr.Column():
|
142 |
df = get_prediction_result()
|
143 |
gr.Textbox(df['電気代_予測'].max(),
|
@@ -149,7 +151,7 @@ with gr.Blocks() as electoric_ploting:
|
|
149 |
gr.Textbox(df['電気代_予測'].median(),
|
150 |
label='現在までの予測値の中央値')
|
151 |
with gr.Row():
|
152 |
-
|
153 |
|
154 |
|
155 |
with gr.Tab("モデル情報"):
|
@@ -219,7 +221,6 @@ with gr.Blocks() as electoric_ploting:
|
|
219 |
gr.Textbox(f"{start_point}〜{end_point}",label=f'データドリフト確認期間')
|
220 |
with gr.Row():
|
221 |
if len(drift_df["drift_score"].unique())!=1:
|
222 |
-
print(drift_df["drift_score"].unique())
|
223 |
gr.ScatterPlot(
|
224 |
drift_df,
|
225 |
x="feature_impact",
|
@@ -243,15 +244,14 @@ with gr.Blocks() as electoric_ploting:
|
|
243 |
)
|
244 |
|
245 |
retrain_btn.click(retrain, inputs=None, outputs = [output_model_type, output_acc, output_plot])
|
246 |
-
retrain_btn.click(retrain, inputs=None, outputs = [output_model_type, output_acc, output_plot])
|
247 |
|
248 |
|
249 |
-
electoric_ploting.load(
|
250 |
None,
|
251 |
-
|
252 |
every=3600)
|
253 |
-
|
254 |
|
255 |
-
electoric_ploting.launch()
|
256 |
|
257 |
-
|
|
|
45 |
df.loc[df['forecast_point'].isnull(), 'forecast_point'] = df['target_date'].apply(lambda x:x-relativedelta(months=1))
|
46 |
df = df.loc[~((df['target_date']<(today+relativedelta(months=1)))&(df['電気代'].isnull()))]
|
47 |
df = df.rename(columns={'電気代':'電気代_予測'})
|
48 |
+
return df[['forecast_point', 'target_date', '電気代_予測']]
|
49 |
|
50 |
def plot_prediction_result():
|
51 |
update = gr.LinePlot.update(
|
|
|
115 |
])
|
116 |
start_point = (target_drift.period['start']+relativedelta(hours=9)).strftime("%Y / %m / %d %H:%M:%S")
|
117 |
end_point = (target_drift.period['end']+relativedelta(hours=9)).strftime("%Y / %m / %d %H:%M:%S")
|
118 |
+
# drift_df.loc[(drift_df['drift_score']>drift_threshold)&(drift_df['feature_impact']>impact_threshold), 'alert'] = '重要性の高く、大きなドリフト'
|
119 |
+
# drift_df.loc[(drift_df['drift_score']>drift_threshold)&(drift_df['feature_impact']<=impact_threshold), 'alert'] = '重要性低いが、大きなドリフト'
|
120 |
+
# drift_df.loc[(drift_df['drift_score']<=drift_threshold), 'alert'] = '正常'
|
121 |
|
122 |
return drift_df, start_point, end_point
|
123 |
|
|
|
136 |
"""
|
137 |
)
|
138 |
with gr.Tab("予測結果"):
|
|
|
|
|
139 |
with gr.Row():
|
140 |
with gr.Column():
|
141 |
plot = gr.LinePlot(show_label=False)
|
142 |
+
# plot = gr.Plot(label="昨日までの魚の卸売り量から予測された、来月の2人世帯の平均電気料金の推移")
|
143 |
with gr.Column():
|
144 |
df = get_prediction_result()
|
145 |
gr.Textbox(df['電気代_予測'].max(),
|
|
|
151 |
gr.Textbox(df['電気代_予測'].median(),
|
152 |
label='現在までの予測値の中央値')
|
153 |
with gr.Row():
|
154 |
+
gr.DataFrame(get_prediction_result)
|
155 |
|
156 |
|
157 |
with gr.Tab("モデル情報"):
|
|
|
221 |
gr.Textbox(f"{start_point}〜{end_point}",label=f'データドリフト確認期間')
|
222 |
with gr.Row():
|
223 |
if len(drift_df["drift_score"].unique())!=1:
|
|
|
224 |
gr.ScatterPlot(
|
225 |
drift_df,
|
226 |
x="feature_impact",
|
|
|
244 |
)
|
245 |
|
246 |
retrain_btn.click(retrain, inputs=None, outputs = [output_model_type, output_acc, output_plot])
|
|
|
247 |
|
248 |
|
249 |
+
electoric_ploting.load(lambda: datetime.datetime.now(),
|
250 |
None,
|
251 |
+
# c_time2,
|
252 |
every=3600)
|
253 |
+
dep = electoric_ploting.load(plot_prediction_result, None, plot, every=3600)
|
254 |
|
255 |
+
electoric_ploting.queue().launch()
|
256 |
|
257 |
+
plt.close()
|