Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -60,21 +60,32 @@ def plot_anomalies(df_test_value, data, anomalies):
|
|
60 |
return fig
|
61 |
|
62 |
def format_output(plot, indices):
|
|
|
|
|
|
|
63 |
# Create a new figure and axis for the combined output
|
64 |
-
fig_combined
|
|
|
65 |
|
66 |
# Add the plot to the top axis
|
67 |
-
|
68 |
-
|
|
|
|
|
|
|
|
|
|
|
69 |
ax_plot.axis('off')
|
70 |
|
71 |
# Add the text to the bottom axis
|
|
|
72 |
ax_text.text(0.5, 0, f"Anomalous Data Indices: {', '.join(indices)}", fontsize=12, ha='center')
|
73 |
ax_text.axis('off')
|
74 |
|
75 |
return fig_combined, None
|
76 |
|
77 |
|
|
|
78 |
def master(file):
|
79 |
# read file
|
80 |
data = pd.read_csv(file, parse_dates=True, index_col="timestamp")
|
|
|
60 |
return fig
|
61 |
|
62 |
def format_output(plot, indices):
|
63 |
+
if plot is None:
|
64 |
+
return None, None
|
65 |
+
|
66 |
# Create a new figure and axis for the combined output
|
67 |
+
fig_combined = plt.figure(figsize=(12, 8))
|
68 |
+
gs = fig_combined.add_gridspec(2, 1, height_ratios=[6, 1])
|
69 |
|
70 |
# Add the plot to the top axis
|
71 |
+
ax_plot = fig_combined.add_subplot(gs[0])
|
72 |
+
if isinstance(plot, tuple):
|
73 |
+
fig, ax = plot
|
74 |
+
ax.plot()
|
75 |
+
ax_plot.imshow(fig.canvas.renderer.buffer_rgba())
|
76 |
+
else:
|
77 |
+
ax_plot.imshow(plot)
|
78 |
ax_plot.axis('off')
|
79 |
|
80 |
# Add the text to the bottom axis
|
81 |
+
ax_text = fig_combined.add_subplot(gs[1])
|
82 |
ax_text.text(0.5, 0, f"Anomalous Data Indices: {', '.join(indices)}", fontsize=12, ha='center')
|
83 |
ax_text.axis('off')
|
84 |
|
85 |
return fig_combined, None
|
86 |
|
87 |
|
88 |
+
|
89 |
def master(file):
|
90 |
# read file
|
91 |
data = pd.read_csv(file, parse_dates=True, index_col="timestamp")
|