Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -86,12 +86,12 @@ def get_scatter_plot(feature1, feature2):
|
|
| 86 |
return "scatter_plot.png"
|
| 87 |
|
| 88 |
def get_anomaly_samples():
|
| 89 |
-
"""Returns top, middle, and bottom 10 records based on anomaly score."""
|
| 90 |
sorted_df = df.sort_values("Anomaly_Score", ascending=False)
|
| 91 |
-
top_10 = sorted_df.head(10)
|
| 92 |
-
middle_10 = sorted_df.iloc[len(sorted_df) // 2 - 5: len(sorted_df) // 2 + 5]
|
| 93 |
-
bottom_10 = sorted_df.tail(10)
|
| 94 |
-
return
|
| 95 |
|
| 96 |
# Create Gradio interface
|
| 97 |
with gr.Blocks() as demo:
|
|
@@ -119,10 +119,15 @@ with gr.Blocks() as demo:
|
|
| 119 |
scatter_button.click(get_scatter_plot, inputs=[feature1_dropdown, feature2_dropdown], outputs=scatter_image)
|
| 120 |
|
| 121 |
with gr.Tab("Anomaly Samples"):
|
| 122 |
-
gr.Markdown("###
|
| 123 |
-
anomaly_samples_button = gr.Button("
|
| 124 |
-
|
| 125 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
# Launch the Gradio app
|
| 128 |
demo.launch()
|
|
|
|
| 86 |
return "scatter_plot.png"
|
| 87 |
|
| 88 |
def get_anomaly_samples():
|
| 89 |
+
"""Returns formatted top, middle, and bottom 10 records based on anomaly score."""
|
| 90 |
sorted_df = df.sort_values("Anomaly_Score", ascending=False)
|
| 91 |
+
top_10 = sorted_df.head(10)
|
| 92 |
+
middle_10 = sorted_df.iloc[len(sorted_df) // 2 - 5: len(sorted_df) // 2 + 5]
|
| 93 |
+
bottom_10 = sorted_df.tail(10)
|
| 94 |
+
return top_10, middle_10, bottom_10
|
| 95 |
|
| 96 |
# Create Gradio interface
|
| 97 |
with gr.Blocks() as demo:
|
|
|
|
| 119 |
scatter_button.click(get_scatter_plot, inputs=[feature1_dropdown, feature2_dropdown], outputs=scatter_image)
|
| 120 |
|
| 121 |
with gr.Tab("Anomaly Samples"):
|
| 122 |
+
gr.Markdown("### Anomaly Samples")
|
| 123 |
+
anomaly_samples_button = gr.Button("Show Anomaly Samples")
|
| 124 |
+
top_table = gr.Dataframe(label="Top 10 Records")
|
| 125 |
+
middle_table = gr.Dataframe(label="Middle 10 Records")
|
| 126 |
+
bottom_table = gr.Dataframe(label="Bottom 10 Records")
|
| 127 |
+
anomaly_samples_button.click(
|
| 128 |
+
get_anomaly_samples,
|
| 129 |
+
outputs=[top_table, middle_table, bottom_table]
|
| 130 |
+
)
|
| 131 |
|
| 132 |
# Launch the Gradio app
|
| 133 |
demo.launch()
|