File size: 1,227 Bytes
d7f258e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""Ejemplo de uso de EDA Express descargado del Hub.

    pip install huggingface_hub pandas numpy tabulate requests
    python example.py
"""

import sys

import pandas as pd
from huggingface_hub import snapshot_download

path = snapshot_download("aitziberluis/eda-express")
sys.path.insert(0, path)
from eda import alerts, profiler, report  # noqa: E402

# El repo incluye el dataset del Titanic como ejemplo.
df = pd.read_csv(f"{path}/datasets/titanic.csv")

print("=== Visión general ===")
for k, v in profiler.overview(df).items():
    print(f"  {k}: {v}")

print("\n=== Alertas ===")
for a in alerts.run_all_checks(df, target="survived"):
    print(f"  [{a['nivel'].upper()}] {a['columna']}: {a['mensaje']}")

print("\n=== Eta² respecto a 'survived' ===")
print(profiler.eta_squared_table(df, "survived").to_string(index=False))

pca = profiler.pca_summary(df)
if pca:
    v = pca["varianza_explicada"]
    print(f"\n=== PCA === PC1 {v[0]:.0%} + PC2 {v[1]:.0%} de la varianza")

md = report.build_report(df, "titanic", alerts.run_all_checks(df, "survived"), "survived")
with open("informe_titanic.md", "w", encoding="utf-8") as f:
    f.write(md)
print(f"\nInforme guardado: informe_titanic.md ({len(md)} caracteres)")