Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import time
|
|
|
2 |
|
3 |
import pandas as pd
|
4 |
import matplotlib.pyplot as plt
|
@@ -53,10 +54,20 @@ def check_model_drift():
|
|
53 |
sample_df = get_data()
|
54 |
p_pos_label_training_data = 0.03475
|
55 |
training_data_size = 8000
|
56 |
-
p_pos_label_sample_logs = sample_df.prediction.value_counts()
|
57 |
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
with gr.Blocks() as demo:
|
62 |
gr.Markdown("# Real-time Monitoring Dashboard")
|
@@ -65,6 +76,6 @@ with gr.Blocks() as demo:
|
|
65 |
|
66 |
with gr.Row():
|
67 |
with gr.Column():
|
68 |
-
gr.Textbox(
|
69 |
|
70 |
demo.queue().launch()
|
|
|
1 |
import time
|
2 |
+
import math
|
3 |
|
4 |
import pandas as pd
|
5 |
import matplotlib.pyplot as plt
|
|
|
54 |
sample_df = get_data()
|
55 |
p_pos_label_training_data = 0.03475
|
56 |
training_data_size = 8000
|
|
|
57 |
|
58 |
+
p_0 = sample_df.prediction.value_counts()[0]
|
59 |
+
p_1 = sample_df.prediction.value_counts()[1]
|
60 |
+
|
61 |
+
p_pos_label_sample_logs = p_1/(p_0+p_1)
|
62 |
+
|
63 |
+
variance = (p_pos_label_training_data * (1-p_pos_label_training_data))/training_data_size
|
64 |
+
p_diff = abs(p_pos_label_training_data - p_pos_label_sample_logs)
|
65 |
|
66 |
+
if p_diff > 2 * math.sqrt(variance):
|
67 |
+
print("Model Drift Detected!")
|
68 |
+
else:
|
69 |
+
print("No Model Drift!")
|
70 |
+
|
71 |
|
72 |
with gr.Blocks() as demo:
|
73 |
gr.Markdown("# Real-time Monitoring Dashboard")
|
|
|
76 |
|
77 |
with gr.Row():
|
78 |
with gr.Column():
|
79 |
+
gr.Textbox(check_model_drift, every=5)
|
80 |
|
81 |
demo.queue().launch()
|