Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
import numpy as np
|
| 4 |
import json
|
|
@@ -57,7 +58,8 @@ def plot_anomalies(df_test_value, data, anomalies):
|
|
| 57 |
ax.set_ylabel("Value")
|
| 58 |
ax.set_title("Anomalous Data Points")
|
| 59 |
return fig
|
| 60 |
-
|
|
|
|
| 61 |
def master(file):
|
| 62 |
# read file
|
| 63 |
data = pd.read_csv(file, parse_dates=True, index_col="timestamp")
|
|
@@ -68,9 +70,18 @@ def master(file):
|
|
| 68 |
anomalies = get_anomalies(df_test_value)
|
| 69 |
#plot anomalous data points
|
| 70 |
plot2 = plot_anomalies(df_test_value, data, anomalies)
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
iface = gr.Interface(
|
| 76 |
fn=master,
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from huggingface_hub import from_pretrained_keras
|
| 3 |
import pandas as pd
|
| 4 |
import numpy as np
|
| 5 |
import json
|
|
|
|
| 58 |
ax.set_ylabel("Value")
|
| 59 |
ax.set_title("Anomalous Data Points")
|
| 60 |
return fig
|
| 61 |
+
|
| 62 |
+
|
| 63 |
def master(file):
|
| 64 |
# read file
|
| 65 |
data = pd.read_csv(file, parse_dates=True, index_col="timestamp")
|
|
|
|
| 70 |
anomalies = get_anomalies(df_test_value)
|
| 71 |
#plot anomalous data points
|
| 72 |
plot2 = plot_anomalies(df_test_value, data, anomalies)
|
| 73 |
+
# Get the indices of detected outliers
|
| 74 |
+
outlier_indices = np.where(anomalies)[0]
|
| 75 |
+
# Create dataframe with outlier timestamps and values
|
| 76 |
+
outliers_df = data.iloc[outlier_indices]
|
| 77 |
+
return plot2, outliers_df
|
| 78 |
|
| 79 |
+
# Interface
|
| 80 |
+
inputs = gr.inputs.File(label="Upload CSV File")
|
| 81 |
+
outputs = [
|
| 82 |
+
gr.outputs.Image(label="Anomalous Data Points"),
|
| 83 |
+
gr.outputs.Dataframe(label="Detected Outliers")
|
| 84 |
+
]
|
| 85 |
|
| 86 |
iface = gr.Interface(
|
| 87 |
fn=master,
|