Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -157,12 +157,34 @@ def _plot_pr(y_true: np.ndarray, y_proba: np.ndarray) -> plt.Figure:
|
|
| 157 |
return fig
|
| 158 |
|
| 159 |
def _plot_missing(df: pd.DataFrame, o2a: Dict[str, str]) -> plt.Figure:
|
| 160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
fig = plt.figure(figsize=(6, 3.5))
|
| 162 |
-
|
|
|
|
| 163 |
plt.ylabel("% faltantes")
|
| 164 |
plt.xticks(rotation=45, ha="right")
|
| 165 |
plt.title("Faltantes por coluna")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
plt.tight_layout()
|
| 167 |
return fig
|
| 168 |
|
|
|
|
| 157 |
return fig
|
| 158 |
|
| 159 |
def _plot_missing(df: pd.DataFrame, o2a: Dict[str, str]) -> plt.Figure:
|
| 160 |
+
# porcentual de faltantes por coluna
|
| 161 |
+
miss = df.isna().mean().reindex(df.columns) # garante ordem original
|
| 162 |
+
miss_pct = (miss * 100).fillna(0)
|
| 163 |
+
|
| 164 |
+
# Caso especial: tudo 0% -> mostra mensagem amigável
|
| 165 |
+
if (miss_pct <= 0).all():
|
| 166 |
+
fig = plt.figure(figsize=(6, 3.5))
|
| 167 |
+
plt.axis("off")
|
| 168 |
+
plt.text(
|
| 169 |
+
0.5, 0.5,
|
| 170 |
+
"Sem valores faltantes (0%)",
|
| 171 |
+
ha="center", va="center", fontsize=12, fontweight="bold"
|
| 172 |
+
)
|
| 173 |
+
plt.title("Faltantes por coluna")
|
| 174 |
+
return fig
|
| 175 |
+
|
| 176 |
+
# Plot normal
|
| 177 |
fig = plt.figure(figsize=(6, 3.5))
|
| 178 |
+
labels = [_alias_of(c, o2a) for c in miss_pct.index]
|
| 179 |
+
plt.bar(labels, miss_pct.values)
|
| 180 |
plt.ylabel("% faltantes")
|
| 181 |
plt.xticks(rotation=45, ha="right")
|
| 182 |
plt.title("Faltantes por coluna")
|
| 183 |
+
|
| 184 |
+
# Deixa um topo mínimo pra barras muito baixas aparecerem
|
| 185 |
+
ymax = float(miss_pct.max())
|
| 186 |
+
plt.ylim(0, max(1.0, ymax * 1.15)) # pelo menos 1%
|
| 187 |
+
|
| 188 |
plt.tight_layout()
|
| 189 |
return fig
|
| 190 |
|