Mapping crime risk with machine learning
Risk terrain modeling asks which kinds of places go with crime nearby. This demo project holds only data: crimes reported in Durham, NC, and places from OpenStreetMap, such as bars, gas stations, and bus stops. You describe the model, and the assistant builds it in a notebook, runs it on this computer, and reports what it found.
Follow along: download risk-terrain.zip (1.0 MB) and unzip it, then add the folder as a project.
1. Let the assistant run Python
Open the project and press Sandbox locked. Turn on Assistant-run Python, so it can run what it writes, and Accept assistant edits automatically, so its notebook is saved as it goes.
Expand2. Ask for the model
Say what to build, from which data, and how to test it. Here: "Build a risk terrain model of violent crime in Durham with machine learning, in a notebook, and run it. The crimes and the places are in data/. Predict each 500 ft cell's violent crime for the next six months, test it on July to December 2024 against last six months' hot spots, use Shapley values to show which places drive the risk, and map the riskiest cells on an interactive map." The crime analysis skill gives it the method.
Expand3. Read what it found
It writes a notebook, runs it, fixes what fails, and sums up the results: how much of the next six months' violent crime fell in its riskiest cells, against last six months' hot spots, and which places mattered most.
Expand4. Check the test
Open the notebook it made. Each cell keeps its output, so the test is there to read: the share of crime in the top cells and the PAI for each method.
Expand5. See what drives it
Shapley values split each cell's prediction among the factors, so the chart shows which places, and recent crime, raise the risk most.
Expand6. The riskiest cells
The map shows the cells it rates riskiest. Ask for changes from here: another crime type, another cell size, or a model of places alone.
ExpandGood to know
- Each run is a little different: the assistant writes its own code each time, so the numbers and charts on your screen will differ from these.
- Everything runs on this computer, in the app's sandbox. The data never leaves it; the model reads only what it is shown of the outputs.
- Shapley values describe the model, not causes. A bus stop that raises a cell's risk says where crime tends to be, not that the stop causes it.
- OpenStreetMap is uneven: Durham's bus stops are well mapped, its bars and laundromats are not. An agency's business license list would be better.
- The crimes come from the City of Durham's open data portal, and the places are © OpenStreetMap contributors (ODbL).