Spaces:
Sleeping
Sleeping
Update app.py
Browse filesModif pearson vers spearman
app.py
CHANGED
|
@@ -9,7 +9,8 @@ from sklearn.linear_model import LinearRegression, LogisticRegression
|
|
| 9 |
from sklearn.feature_selection import mutual_info_regression, mutual_info_classif
|
| 10 |
from sklearn.metrics import r2_score, accuracy_score
|
| 11 |
from sklearn.model_selection import train_test_split
|
| 12 |
-
from scipy.stats import pearsonr
|
|
|
|
| 13 |
|
| 14 |
# ------------------------------------------------------------
|
| 15 |
# Configuration Globale
|
|
@@ -217,14 +218,19 @@ if df is not None and X is not None and len(X.columns) > 0:
|
|
| 217 |
"Sens": np.where(coefs > 0, "+", "-")
|
| 218 |
})
|
| 219 |
|
|
|
|
|
|
|
|
|
|
| 220 |
if task == "Regression":
|
| 221 |
-
res["Lien direct (Corr)"] = [
|
| 222 |
|
| 223 |
# Normalisation pour Score Synthétique
|
| 224 |
def normalize(s): return (s - s.min()) / (s.max() - s.min() + 1e-10)
|
| 225 |
mi_n = normalize(res["Importance seule (MI)"])
|
| 226 |
poids_n = normalize(res["Poids dans le modèle"])
|
| 227 |
|
|
|
|
|
|
|
| 228 |
if task == "Regression":
|
| 229 |
corr_n = normalize(res["Lien direct (Corr)"].abs())
|
| 230 |
res["Score synthétique"] = ((mi_n + corr_n) / 2 + poids_n) / 2
|
|
|
|
| 9 |
from sklearn.feature_selection import mutual_info_regression, mutual_info_classif
|
| 10 |
from sklearn.metrics import r2_score, accuracy_score
|
| 11 |
from sklearn.model_selection import train_test_split
|
| 12 |
+
#from scipy.stats import pearsonr
|
| 13 |
+
from scipy.stats import spearmanr
|
| 14 |
|
| 15 |
# ------------------------------------------------------------
|
| 16 |
# Configuration Globale
|
|
|
|
| 218 |
"Sens": np.where(coefs > 0, "+", "-")
|
| 219 |
})
|
| 220 |
|
| 221 |
+
#if task == "Regression":
|
| 222 |
+
# res["Lien direct (Corr)"] = [pearsonr(X_train_proc[:, i], y_train)[0] for i in range(len(feature_names))]
|
| 223 |
+
|
| 224 |
if task == "Regression":
|
| 225 |
+
res["Lien direct (Corr)"] = [spearmanr(X_train_proc[:, i], y_train)[0] for i in range(len(feature_names))]
|
| 226 |
|
| 227 |
# Normalisation pour Score Synthétique
|
| 228 |
def normalize(s): return (s - s.min()) / (s.max() - s.min() + 1e-10)
|
| 229 |
mi_n = normalize(res["Importance seule (MI)"])
|
| 230 |
poids_n = normalize(res["Poids dans le modèle"])
|
| 231 |
|
| 232 |
+
|
| 233 |
+
|
| 234 |
if task == "Regression":
|
| 235 |
corr_n = normalize(res["Lien direct (Corr)"].abs())
|
| 236 |
res["Score synthétique"] = ((mi_n + corr_n) / 2 + poids_n) / 2
|