harbor run -t LiteCoder/weather-crime-analysis-modelharbor download LiteCoder/weather-crime-analysis-modelA city council wants to understand how weather conditions affect daily crime counts to inform seasonal police staffing. You are given two datasets — daily weather observations and individual crime incidents — for a metropolitan city covering 2022–2023. Clean, merge, analyze, and model the data using Python.
/app/solution.pypython solution.py from /app and produce all required output files.| File | Path | Description |
|---|---|---|
| Weather data | /app/weather.csv |
Daily weather observations (730 rows). Columns: date (YYYY-MM-DD), temp_max_f, temp_min_f, precipitation_in, humidity_pct, wind_speed_mph. Some cells may be missing. |
| Crime data | /app/crime.csv |
Individual crime incidents (~30k rows). Columns: incident_id, date (mixed formats: YYYY-MM-DD, MM/DD/YYYY, DD-Mon-YYYY), crime_type. |
/app/merged_daily.csvMerged daily-level dataset with one row per date. Required columns (exact names):
date — format YYYY-MM-DD, sorted ascendingcrime_count — integer, total number of crime incidents for that datetemp_max_f, temp_min_f, precipitation_in, humidity_pct, wind_speed_mph — from weather dataRows with any missing weather values after merging must be dropped. The file must contain only dates present in both datasets.
/app/correlation_matrix.csvPearson correlation matrix of the following columns from the merged dataset: crime_count, temp_max_f, temp_min_f, precipitation_in, humidity_pct, wind_speed_mph. The matrix must be a 6×6 CSV where the first column is the variable name (header: empty string or variable) and remaining columns are named after the variables. Values rounded to 4 decimal places.
/app/model_results.jsonJSON file containing regression model results. Train a linear regression model predicting crime_count from all five weather features. Use an 80/20 train/test split with random_state=42. The JSON must contain:
{
"model_type": "LinearRegression",
"features": ["temp_max_f", "temp_min_f", "precipitation_in", "humidity_pct", "wind_speed_mph"],
"target": "crime_count",
"train_size": <int>,
"test_size": <int>,
"r2_score": <float, rounded to 4 decimal places>,
"mae": <float, rounded to 4 decimal places>,
"rmse": <float, rounded to 4 decimal places>,
"coefficients": {
"temp_max_f": <float, rounded to 4>,
"temp_min_f": <float, rounded to 4>,
"precipitation_in": <float, rounded to 4>,
"humidity_pct": <float, rounded to 4>,
"wind_speed_mph": <float, rounded to 4>
},
"intercept": <float, rounded to 4>
}
/app/summary.txtA plain-text summary (at least 5 lines) for the city council containing: