Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,8 +1,11 @@
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
import os
|
|
|
4 |
from omnibin import generate_binary_classification_report
|
5 |
-
|
|
|
|
|
6 |
|
7 |
def process_csv(csv_file):
|
8 |
# Read the CSV file
|
@@ -13,20 +16,25 @@ def process_csv(csv_file):
|
|
13 |
if not all(col in df.columns for col in required_columns):
|
14 |
raise ValueError("CSV file must contain 'y_true' and 'y_pred' columns")
|
15 |
|
16 |
-
#
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
# Create the Gradio interface
|
32 |
iface = gr.Interface(
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
import os
|
4 |
+
import shutil
|
5 |
from omnibin import generate_binary_classification_report
|
6 |
+
|
7 |
+
# Define results directory
|
8 |
+
RESULTS_DIR = os.path.join(os.path.dirname(os.path.dirname(__file__)), "results")
|
9 |
|
10 |
def process_csv(csv_file):
|
11 |
# Read the CSV file
|
|
|
16 |
if not all(col in df.columns for col in required_columns):
|
17 |
raise ValueError("CSV file must contain 'y_true' and 'y_pred' columns")
|
18 |
|
19 |
+
# Clean up results directory if it exists
|
20 |
+
if os.path.exists(RESULTS_DIR):
|
21 |
+
shutil.rmtree(RESULTS_DIR)
|
22 |
+
|
23 |
+
# Create fresh results directory
|
24 |
+
os.makedirs(RESULTS_DIR, exist_ok=True)
|
25 |
+
|
26 |
+
# Generate the report
|
27 |
+
report_path = generate_binary_classification_report(
|
28 |
+
y_true=df['y_true'].values,
|
29 |
+
y_scores=df['y_pred'].values,
|
30 |
+
output_path=os.path.join(RESULTS_DIR, "classification_report.pdf"),
|
31 |
+
n_bootstrap=1000,
|
32 |
+
random_seed=42,
|
33 |
+
dpi=72
|
34 |
+
)
|
35 |
+
|
36 |
+
# Return the PDF file
|
37 |
+
return report_path
|
38 |
|
39 |
# Create the Gradio interface
|
40 |
iface = gr.Interface(
|