Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -134,11 +134,21 @@ def detect_anomalies(input_data, n_samples, outliers_fraction, model_name):
|
|
| 134 |
|
| 135 |
# Function to get anomaly samples
|
| 136 |
def get_anomaly_samples(input_data, n_samples, outliers_fraction, model_name):
|
|
|
|
| 137 |
df = detect_anomalies(input_data, n_samples, outliers_fraction, model_name)
|
| 138 |
|
| 139 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
top_10 = df[df["Anomaly_Label"] == "Anomaly"].head(10)
|
| 141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
# Middle 10 (mixed)
|
| 143 |
mid_start = len(df) // 2 - 5
|
| 144 |
middle_10 = df.iloc[mid_start: mid_start + 10]
|
|
|
|
| 134 |
|
| 135 |
# Function to get anomaly samples
|
| 136 |
def get_anomaly_samples(input_data, n_samples, outliers_fraction, model_name):
|
| 137 |
+
# Detect anomalies
|
| 138 |
df = detect_anomalies(input_data, n_samples, outliers_fraction, model_name)
|
| 139 |
|
| 140 |
+
# Debugging: Check the distribution of anomaly labels
|
| 141 |
+
print("Anomaly Label Counts:")
|
| 142 |
+
print(df["Anomaly_Label"].value_counts())
|
| 143 |
+
|
| 144 |
+
# Ensure filtering for anomalies works as expected
|
| 145 |
top_10 = df[df["Anomaly_Label"] == "Anomaly"].head(10)
|
| 146 |
|
| 147 |
+
# If no anomalies are found, show a message
|
| 148 |
+
if top_10.empty:
|
| 149 |
+
print("No anomalies found in the top 10 results.")
|
| 150 |
+
top_10 = pd.DataFrame({"Message": ["No anomalies found"]})
|
| 151 |
+
|
| 152 |
# Middle 10 (mixed)
|
| 153 |
mid_start = len(df) // 2 - 5
|
| 154 |
middle_10 = df.iloc[mid_start: mid_start + 10]
|