Spaces:
Sleeping
Sleeping
Download check_model_summary.py from winsweb/teleprocessinggh: direct link, hf CLI and curl.
- Browser
- Download file 1.55 kB
-
https://huggingface.co/spaces/winsweb/teleprocessinggh/resolve/main/check_model_summary.py
- Command line
-
hf download hf://spaces/winsweb/teleprocessinggh/check_model_summary.py
-
curl -L -o check_model_summary.py https://huggingface.co/spaces/winsweb/teleprocessinggh/resolve/main/check_model_summary.py
1.55 kB
| """Print the full model_summary block the API will emit at the end of | |
| every detection that runs the iforest. Verifies every key the planning | |
| doc promises is populated and well-formed. | |
| """ | |
| import json | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).parent)) | |
| from telecom_anomaly.core.detector import TelecomAnomalyDetector | |
| from telecom_anomaly.core.models import TelecomConfig | |
| CSV = ( | |
| r"C:\my_project\work\GH_Police\main project\backend" | |
| r"\telecom_anomaly_detection\data\strictly_cleaned_data" | |
| r"\591296805 calls (1)_strictly_cleaned.csv" | |
| ) | |
| cfg = TelecomConfig() | |
| det = TelecomAnomalyDetector(cfg) | |
| det.load_data([CSV]) | |
| # Cover all three modes. | |
| for label, kwargs in [ | |
| ("Rules-only", {"use_model": False, "run_rules": True}), | |
| ("AI-only", {"use_model": True, "run_rules": False}), | |
| ("Both", {"use_model": True, "run_rules": True}), | |
| ]: | |
| # Reset tracking between modes. | |
| det.anomalies = [] | |
| det.rows_with_anomalies = set() | |
| det.row_anomaly_map.clear() | |
| det.row_anomaly_reasons.clear() | |
| det.row_anomaly_attribution.clear() | |
| det.subscriber_anomalies.clear() | |
| det.detect_anomalies(**kwargs) | |
| stats = det.get_statistics() | |
| print(f"\n=== {label} ({kwargs}) ===") | |
| print(f"total_anomalies_detected: {stats.total_anomalies_detected}") | |
| print(f"anomaly_types : {stats.anomaly_types}") | |
| print(f"model_feature_drivers : {stats.model_feature_drivers}") | |
| print("model_summary:") | |
| print(json.dumps(stats.model_summary, indent=2, default=str)) | |