| """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 |
|
|
| |
| 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)") |
|
|