Download app/monitoring/data_loader.py from LeonardoMdSA/ML-Inference-Service-with-Drift-Detection: direct link, hf CLI and curl.
- Browser
- Download file 637 Bytes
-
https://huggingface.co/spaces/LeonardoMdSA/ML-Inference-Service-with-Drift-Detection/resolve/main/app/monitoring/data_loader.py
- Command line
-
hf download hf://spaces/LeonardoMdSA/ML-Inference-Service-with-Drift-Detection/app/monitoring/data_loader.py
-
curl -L -o data_loader.py https://huggingface.co/spaces/LeonardoMdSA/ML-Inference-Service-with-Drift-Detection/resolve/main/app/monitoring/data_loader.py
637 Bytes
| #Load Production data from SQLite | |
| import sqlite3 | |
| import json | |
| import pandas as pd | |
| from app.core.config import DB_PATH | |
| def load_production_data(limit: int = 1000) -> pd.DataFrame: | |
| conn = sqlite3.connect(DB_PATH) | |
| cursor = conn.cursor() | |
| cursor.execute( | |
| """ | |
| SELECT input_features | |
| FROM predictions | |
| ORDER BY id DESC | |
| LIMIT ? | |
| """, | |
| (limit,) | |
| ) | |
| rows = cursor.fetchall() | |
| conn.close() | |
| if not rows: | |
| raise ValueError("No production data available for drift detection.") | |
| records = [json.loads(row[0]) for row in rows] | |
| return pd.DataFrame(records) | |