|
| 1 | +""" |
| 2 | +Example: structured report for fairness-aware classification. |
| 3 | +
|
| 4 | +What this script does: |
| 5 | +- Trains AutoML with sensitive features and fairness constraints. |
| 6 | +- Prints the compact structured report output. |
| 7 | +- Selects one model from leaderboard and prints detailed output for that model. |
| 8 | +
|
| 9 | +Why this helps: |
| 10 | +- Keeps default report concise. |
| 11 | +- Allows targeted fairness/metrics inspection only for a chosen model. |
| 12 | +""" |
| 13 | + |
1 | 14 | import os |
2 | 15 |
|
3 | 16 | import pandas as pd |
@@ -37,16 +50,22 @@ def main(): |
37 | 50 | ) |
38 | 51 | automl.fit(X, y, sensitive_features=sensitive_features) |
39 | 52 |
|
40 | | - print("\n=== report_structured(model_details=False) ===\n") |
41 | | - print(automl.report_structured(model_details=False)) |
| 53 | + print("\n=== report_structured() ===\n") |
| 54 | + print(automl.report_structured()) |
42 | 55 |
|
43 | | - print("\n=== report_structured(model_details=True) ===\n") |
44 | | - print(automl.report_structured(model_details=True)) |
45 | | - |
46 | | - payload = automl.report_structured(format="dict", model_details=False) |
| 56 | + payload = automl.report_structured(format="dict") |
47 | 57 | print("\nTop-level keys:", sorted(payload.keys())) |
48 | | - print("Number of models in report:", len(payload.get("models", []))) |
49 | | - print("Fairness summary available:", payload.get("fairness_summary") is not None) |
| 58 | + selected_model_name = None |
| 59 | + leaderboard = payload.get("leaderboard", []) |
| 60 | + if len(leaderboard) > 1: |
| 61 | + selected_model_name = leaderboard[1].get("name") |
| 62 | + elif leaderboard: |
| 63 | + selected_model_name = leaderboard[0].get("name") |
| 64 | + print("Selected model:", selected_model_name) |
| 65 | + |
| 66 | + if selected_model_name: |
| 67 | + print(f"\n=== report_structured(model_name='{selected_model_name}') ===\n") |
| 68 | + print(automl.report_structured(model_name=selected_model_name)) |
50 | 69 |
|
51 | 70 | report_path = os.path.join(results_path, "report_structured.json") |
52 | 71 | print("Structured report JSON:", report_path) |
|
0 commit comments