UCS2014 commited on
Commit
fd24fec
·
verified ·
1 Parent(s): c2d183f

Upload app_revised_with_r_value.py

Browse files
Files changed (1) hide show
  1. app_revised_with_r_value.py +26 -0
app_revised_with_r_value.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Replace this function in your utils or metric section
2
+ def r_value(y_true, y_pred):
3
+ y_true = np.asarray(y_true)
4
+ y_pred = np.asarray(y_pred)
5
+ mask = np.isfinite(y_true) & np.isfinite(y_pred)
6
+ return float(np.corrcoef(y_true[mask], y_pred[mask])[0, 1])
7
+
8
+ # Replace your metrics assignment for train/test/validate like this:
9
+ # Old:
10
+ # "R2": r2_score(...)
11
+ # New:
12
+ "R": r_value(...)
13
+
14
+ # In all metric displays like:
15
+ # c1.metric("R²", f"{m['R2']:.4f}")
16
+ # Change to:
17
+ c1.metric("R", f"{m['R']:.2f}")
18
+
19
+ # In all metric panels for Train, Test, Validate
20
+ c1.metric("R", f"{m['R']:.2f}")
21
+ c2.metric("RMSE", f"{m['RMSE']:.2f}")
22
+ c3.metric("MAE", f"{m['MAE']:.2f}")
23
+
24
+ # Also replace in the 'Validation' and 'Prediction' sections accordingly.
25
+ # Ensure all table metrics and summary stats (pred_min, pred_max, etc.) use 2 decimal digits:
26
+ f"{value:.2f}"