Ten scikit-learn models for smart-city and infrastructure tasks framed around Kuwait: traffic flow, grid load, water-network leaks, waste collection, public-safety incidents, air quality, parking demand, infrastructure maintenance risk, emergency response time and building energy. One script, gcc_smartcity_ai.py, generates a synthetic dataset for each task (12,000 rows each). It then compares five candidate algorithms with 3-fold cross-validation and saves the best one per task as a joblib pickle. No real sensor, utility or incident data was used. The models are demonstrations and templates.
Author: AgenThink, Kuwait City
Test metrics are on a 20% held-out split of the same synthetic data (random_state=42). CV is the mean 3-fold cross-validation score on the 80% training split. All numbers come from automl_results.json.
| # | File | Task | Type | Selected algorithm | CV score | Test score | Test MAE |
|---|---|---|---|---|---|---|---|
| 1 | model_traffic_flow.pkl |
Traffic Flow Prediction | Regression | Ridge | R² 0.8675 | R² 0.8616 | 82.43 (volume) |
| 2 | model_grid_load.pkl |
Smart Grid Load Forecasting | Regression | Ridge | R² 0.9630 | R² 0.9613 | 91.17 (load units) |
| 3 | model_water_leak.pkl |
Water Network Leak Detection | Classification | GradientBoosting | Acc 0.9663 | Acc 0.9654 | – |
| 4 | model_waste_collection.pkl |
Waste Collection Optimization | Regression | Ridge | R² 0.9681 | R² 0.968 | 4.08 kg |
| 5 | model_safety_incident.pkl |
Public Safety Incident Prediction | Classification | GradientBoosting | Acc 0.9561 | Acc 0.9546 | – |
| 6 | model_air_quality.pkl |
Air Quality Index Forecasting | Regression | Ridge | R² 0.8964 | R² 0.8914 | 16.32 AQI |
| 7 | model_smart_parking.pkl |
Smart Parking Demand Prediction | Regression | GradientBoosting | R² 0.9912 | R² 0.9903 | 36.13 spaces |
| 8 | model_infra_maintenance.pkl |
Infrastructure Maintenance Risk | Classification | GradientBoosting | Acc 0.9520 | Acc 0.9525 | – |
| 9 | model_emergency_response.pkl |
Emergency Response Time Prediction | Regression | GradientBoosting | R² 0.9679 | R² 0.9704 | 1.76 min |
| 10 | model_smart_building.pkl |
Smart Building Energy Optimization | Regression | GradientBoosting | R² 0.9867 | R² 0.9929 | 2.05 kWh |
The candidates were RandomForest, GradientBoosting, ExtraTrees, DecisionTree, and either Ridge (for regression) or LogisticRegression (for classification). The CV score of every candidate is stored under all_scores in automl_results.json. The saved estimator classes match the best_algo values in the JSON.
The script generates this dashboard. It shows the test score for each model, plots of the synthetic data, feature importances and a heatmap of the algorithm comparison.
| File | Description |
|---|---|
README.md |
This model card |
gcc_smartcity_ai.py |
Full pipeline: synthetic data generation, AutoML selection, evaluation, dashboard, and saving of models and results |
automl_results.json |
For each model: task, type, selected algorithm, CV and test metrics, CV scores of all candidates, ordered feature list, feature importances, and a free-text gcc_note |
gcc_smartcity_ai_dashboard.png |
Performance and data dashboard (about 0.8 MB) |
model_*.pkl (10 files) |
Fitted scikit-learn estimators saved with joblib. The pickles record scikit-learn 1.8.0 as the training version |
All training data is synthetic. The script generates it with NumPy (np.random.seed(42)); running it recreates the data. Each task has 12,000 independent rows and 14–16 features.
1 if its score is at or above a quantile: 0.82 for leaks (about 18% positives), 0.80 for safety incidents (about 20%) and 0.75 for maintenance risk (about 25%).expat_dense and economic_stress have no effect on the synthetic safety-incident label.gcc_note strings in the JSON are the author's contextual remarks. They are not derived from data.Important: these models were trained on plain NumPy arrays, so they store no feature names. Pass a 2-D array whose columns follow exactly this order, which matches features in automl_results.json.
hour, day_of_week, temp, rain, sandstorm, is_ramadan, is_eid, school_day, prayer_time, accident, road_work, pop_zone, signal_phase, merge_lanes, holiday, peak. peak is 1 when hour ∈ {8, 17, 18}, following the script's definition.hour, temp, humidity, is_summer, is_ramadan, is_eid, population_k, prev_hour_load, solar_rad, ev_pct, industry_load, desalination_load, smart_meter_pct, ac_setpointpressure, pipe_age, material, soil_type, temp, prev_leak, flow_anomaly, pressure_drop, night_flow, days_since_repair, corrosion_idx, pipe_depth, joint_type, vibration, salinity_soilwaste_kg (5–500). Inputs (14): zone, day_of_week, population, bin_fill_pct, temp, is_ramadan, is_eid, days_since_last_collect, commercial_pct, hospital_nearby, hotel_nearby, recycling_rate, smart_bin, food_waste_pcthour, day_of_week, temp, is_ramadan, is_eid, crowd_density, outdoor_event, is_night, prev_incident, expat_dense, patrol_density, cctv_coverage, heat_stress, economic_stress, road_rage. Here is_night = hour < 4 or hour > 22, and heat_stress = temp > 42.temp, humidity, wind_speed, sand_aod, sandstorm, traffic_vol, industry_emissions, oil_flaring, hour, month, inversion, desalination_em, construction_dust, humidity_inversion. Here humidity_inversion = humidity > 70.total_spaces). Inputs (14): hour, day_of_week, location_type, total_spaces, temp, is_ramadan, is_eid, nearby_event, is_peak, ev_charging, app_guidance, is_weekend, school_nearby, valet_available. Here is_peak = 10 < hour < 22. A code comment maps location_type 1–5 to mall, hospital, office, govt and mixed.infra_type, age_years, condition_score, days_since_maintenance, traffic_load, salt_exposure, uv_exposure, sand_abrasion, heat_cycles_yr, budget_adequacy, prev_failures, design_standard, contractor_quality, subsidence_riskincident_type, severity, hour, day_of_week, distance_km, traffic_level, sandstorm, is_ramadan, is_eid, units_available, road_quality, dispatch_time_min, gated_community, address_clarityenergy_kwh, bounded between 0.02× and 0.25× floor area; the time period is not specified. Inputs (14): building_type, floor_area_sqm, occupancy_rate, outdoor_temp_c, solar_radiation, shading_coefficient, ac_cop, insulation_grade, smart_controls, has_solar_panels, occupancy_sensors, bms_installed, glazing_ratio, district_cooling# pip install scikit-learn==1.8.* numpy joblib huggingface_hub
import json, joblib, numpy as np
from huggingface_hub import hf_hub_download
repo = "agenthinkmesh/gcc_smartcity_ai"
results = json.load(open(hf_hub_download(repo, "automl_results.json"), encoding="utf-8"))
model = joblib.load(hf_hub_download(repo, "model_traffic_flow.pkl"))
print(results["traffic_flow"]["features"]) # column order
hour = 17
x = np.array([[
hour, 2, 44, # hour, day_of_week, temp
0, 1, 0, 0, # rain, sandstorm, is_ramadan, is_eid
1, 0, 0, 0, # school_day, prayer_time, accident, road_work
3, 90, 2, 0, # pop_zone, signal_phase, merge_lanes, holiday
int(hour in (8, 17, 18)), # peak, as defined in the training script
]], dtype=float)
print("predicted traffic volume:", model.predict(x)[0])
The classifiers (water_leak, safety_incident, infra_maintenance) expose predict_proba. Class 1 is the high-risk / event class. Loading a pickle can execute arbitrary code, so only load files from sources you trust.
pip install numpy pandas matplotlib scikit-learn joblib
# The output directory is hard-coded: edit OUT="/home/claude/gcc_smartcity_ai" near the top of the script first
python gcc_smartcity_ai.py
The script regenerates the data, all 10 models, automl_results.json, the dashboard and a short README.md. It will overwrite a README in the output directory.
Out of scope: live traffic control, grid dispatch, emergency dispatch, public-health alerts or policing decisions.
expat_dense, an area indicator related to nationality, plus economic_stress and patrol density. Although expat_dense has no effect on the synthetic label, any real deployment of incident prediction for policing risks discriminatory outcomes and feedback loops. It requires legal review, bias auditing and human oversight, and it should not be used to target individuals or communities.MIT
@misc{agenthink2026gccsmartcity,
author = {AgenThink},
title = {GCC Smart City \& Infrastructure AI},
year = {2026},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/agenthinkmesh/gcc_smartcity_ai}}
}