Spaces:
Sleeping
Sleeping
Update src/module/Data_Exploration.py
Browse files- src/module/Data_Exploration.py +35 -35
src/module/Data_Exploration.py
CHANGED
|
@@ -97,50 +97,50 @@ class AdvancedAnalyzer: # <--- RENOMMAGE ICI
|
|
| 97 |
|
| 98 |
|
| 99 |
def plot_numeric_summary(self, table_keyword, top_n=8):
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
|
| 115 |
|
| 116 |
#----Corrélation (heatmap) pour numériques
|
| 117 |
|
| 118 |
def plot_correlation(self, table_keyword):
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
|
| 129 |
# ----- Vérification d'intégrité référentielle (join rates)
|
| 130 |
|
| 131 |
def referential_check(self, left_table, right_table, key='patient_id'):
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
|
| 145 |
|
| 146 |
# --- VUES ANALYTIQUES AVANCÉES ---
|
|
|
|
| 97 |
|
| 98 |
|
| 99 |
def plot_numeric_summary(self, table_keyword, top_n=8):
|
| 100 |
+
df = self.get_df(table_keyword)
|
| 101 |
+
if df is None: return
|
| 102 |
+
num_cols = df.select_dtypes(include='number').columns.tolist()
|
| 103 |
+
if not num_cols:
|
| 104 |
+
st.info("Aucune colonne numérique.")
|
| 105 |
+
return
|
| 106 |
+
num_cols = num_cols[:top_n]
|
| 107 |
+
for col in num_cols:
|
| 108 |
+
c1, c2 = st.columns([2,1])
|
| 109 |
+
with c1:
|
| 110 |
+
fig = px.histogram(df, x=col, nbins=60, marginal='box', title=f"Distribution : {col}")
|
| 111 |
+
st.plotly_chart(fig, use_container_width=True)
|
| 112 |
+
with c2:
|
| 113 |
+
st.write(df[col].describe().to_frame().T)
|
| 114 |
|
| 115 |
|
| 116 |
#----Corrélation (heatmap) pour numériques
|
| 117 |
|
| 118 |
def plot_correlation(self, table_keyword):
|
| 119 |
+
df = self.get_df(table_keyword)
|
| 120 |
+
if df is None: return
|
| 121 |
+
num = df.select_dtypes(include='number').dropna(axis=1, how='all')
|
| 122 |
+
if num.shape[1] < 2:
|
| 123 |
+
st.info("Pas assez de colonnes numériques pour corrélation.")
|
| 124 |
+
return
|
| 125 |
+
corr = num.corr()
|
| 126 |
+
fig = px.imshow(corr, text_auto=".2f", title=f"Heatmap corrélations ({table_keyword})")
|
| 127 |
+
st.plotly_chart(fig, use_container_width=True)
|
| 128 |
|
| 129 |
# ----- Vérification d'intégrité référentielle (join rates)
|
| 130 |
|
| 131 |
def referential_check(self, left_table, right_table, key='patient_id'):
|
| 132 |
+
left = self.get_df(left_table); right = self.get_df(right_table)
|
| 133 |
+
if left is None or right is None:
|
| 134 |
+
st.warning("Tables introuvables pour check référentiel.")
|
| 135 |
+
return
|
| 136 |
+
left_keys = set(left[key].dropna().unique())
|
| 137 |
+
right_keys = set(right[key].dropna().unique())
|
| 138 |
+
in_left_not_right = len(left_keys - right_keys)
|
| 139 |
+
in_right_not_left = len(right_keys - left_keys)
|
| 140 |
+
st.write(f"- Clés {key} dans {left_table}: {len(left_keys):,}")
|
| 141 |
+
st.write(f"- Clés {key} dans {right_table}: {len(right_keys):,}")
|
| 142 |
+
st.metric("Dans left mais pas right", f"{in_left_not_right:,}")
|
| 143 |
+
st.metric("Dans right mais pas left", f"{in_right_not_left:,}")
|
| 144 |
|
| 145 |
|
| 146 |
# --- VUES ANALYTIQUES AVANCÉES ---
|