felipekitamura commited on
Commit
7c8dbb9
·
verified ·
1 Parent(s): ab31c05

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -4
app.py CHANGED
@@ -5,7 +5,7 @@ import shutil
5
  from omnibin import generate_binary_classification_report
6
 
7
  # Define results directory
8
- RESULTS_DIR = "/tmp/results"
9
 
10
  def process_csv(csv_file):
11
  # Read the CSV file
@@ -33,14 +33,33 @@ def process_csv(csv_file):
33
  dpi=72
34
  )
35
 
36
- # Return the PDF file
37
- return report_path
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  # Create the Gradio interface
40
  iface = gr.Interface(
41
  fn=process_csv,
42
  inputs=gr.File(label="Upload CSV file with 'y_true' and 'y_pred' columns"),
43
- outputs=gr.File(label="Classification Report PDF"),
 
 
 
 
 
 
 
 
44
  title="Binary Classification Report Generator",
45
  description="Upload a CSV file containing 'y_true' and 'y_pred' columns to generate a comprehensive classification report with 6 figures.",
46
  examples=[],
 
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
 
33
  dpi=72
34
  )
35
 
36
+ # Get paths to individual plots
37
+ plots_dir = os.path.join(RESULTS_DIR, "plots")
38
+ plot_paths = {
39
+ "ROC and PR Curves": os.path.join(plots_dir, "roc_pr.png"),
40
+ "Metrics vs Threshold": os.path.join(plots_dir, "metrics_threshold.png"),
41
+ "Confusion Matrix": os.path.join(plots_dir, "confusion_matrix.png"),
42
+ "Calibration Plot": os.path.join(plots_dir, "calibration.png"),
43
+ "Prediction Distribution": os.path.join(plots_dir, "prediction_distribution.png"),
44
+ "Metrics Summary": os.path.join(plots_dir, "metrics_summary.png")
45
+ }
46
+
47
+ # Return both the PDF and the plot images
48
+ return report_path, *plot_paths.values()
49
 
50
  # Create the Gradio interface
51
  iface = gr.Interface(
52
  fn=process_csv,
53
  inputs=gr.File(label="Upload CSV file with 'y_true' and 'y_pred' columns"),
54
+ outputs=[
55
+ gr.File(label="Classification Report PDF"),
56
+ gr.Image(label="ROC and PR Curves"),
57
+ gr.Image(label="Metrics vs Threshold"),
58
+ gr.Image(label="Confusion Matrix"),
59
+ gr.Image(label="Calibration Plot"),
60
+ gr.Image(label="Prediction Distribution"),
61
+ gr.Image(label="Metrics Summary")
62
+ ],
63
  title="Binary Classification Report Generator",
64
  description="Upload a CSV file containing 'y_true' and 'y_pred' columns to generate a comprehensive classification report with 6 figures.",
65
  examples=[],