---
id: 17296
lang: en
title: "A 30-Day Moving Average Beat LightGBM: It Catches 41% of Lima's Incidents in 5% of Cells"
published_at: "2026-11-21 02:07:08"
source_name: "Хабр: Машинное обучение"
source_url: "https://habr.com/ru/articles/1108000/?utm_campaign=1108000&utm_source=habrahabr&utm_medium=rss"
canonical_url: "https://news.hamidun.com/en/news/17296"
categories: ["research"]
publisher: "AI News by Jemal Hamidun (news.hamidun.com)"
---

# A 30-Day Moving Average Beat LightGBM: It Catches 41% of Lima's Incidents in 5% of Cells

> **Краткая суть (BLUF):** The best next-day forecast of incidents in Lima came from a 30-day moving average: the 5% of cells with the highest prediction contained 41.2% of cases, 8.25 times more than random selection (the PAI@5% metric). LightGBM with calendar features scored a PAI of 5.60–5.84, and with urban features, 5.36–5.51. Roads and buildings slightly worsened the ranking. So before reaching for a complex model, benchmark a simple baseline first: it may turn out to be the ceiling.  • The city is split into 2,120 H3 hexagonal cells, and the test ran for 37 days in autumn • The average beat boosting in all nine paired comparisons • Boosting that adjusts the average is unstable: PAI ranges from 0.007 to 5.87

Any team building a forecast on tabular data sooner or later adds more features to the model and reaches for a more powerful boosting method. A Habr write-up shows how that can end. The author took open data on criminal incidents in Lima and checked whether city characteristics (businesses, buildings, roads) help predict where incidents will be recorded tomorrow. The winner was a plain formula: a weighted average of incidents over the last few weeks. If you select the 5% of the city's cells with the highest forecast, they contain 41.2% of tomorrow's cases. That is 8.25 times better than random selection, and this number is called PAI@5%. LightGBM with calendar and urban features scored only 5.4–5.8.

## How the experiment was set up

The city is divided into 2,120 H3 hexagonal cells, each about 0.87 km². For each cell, the model estimates every day the probability that an incident will be recorded there. The input is the number of cases over the previous 28 days. The data comes from the public layer of Peru's Ministry of the Interior (SIDPOL): 117,050 cleaned records for 2026. After excluding domestic violence and points outside the grid, 71,715 incidents remained. Environmental features come from OpenStreetMap.

The metric is simple. Take the 106 cells, that is 5% of the grid, with the highest forecast, and calculate what share of the next day's incidents fell into them. Divide that share by 0.05, and you get PAI@5%. A value of 1 means random selection, and 8.25 means coverage 8.25 times higher. It does not mean "risk rose eightfold."

The task is hard. In 91.5% of cell-day pairs, there are no incidents. Yet 5% of cells account for 41% of all cases over a year. But the composition of the "hot" cells changes quickly: the overlap of the top 5% between adjacent days, based on actual data, is only 0.24 by the Jaccard index.

## What came out on top

The winner is EWM-30. For each cell, it sums daily incidents, with the weight of an observation halving every 30 days, so recent cases matter more than old ones. There is nothing to train here; the result is only calibrated into a probability. EWM-30 has a PAI of 8.25 with a 95% confidence interval of 8.00–8.50 and coverage of 41.2%. Next come a version with a 7-day half-life (8.02), a fixed map (7.99), the earlier LightGBM (7.52), and day-of-week averages (7.42). The advantage over the fixed map is small, +0.26, but the interval of 0.14–0.37 does not include zero.

Boosting with calendar features (day of the week, holidays, salary payment days) scored a PAI of 5.60–5.84. The version with businesses, buildings, and roads scored 5.36–5.51. Urban features did not help and slightly worsened the ranking. EWM-30 won in all nine paired comparisons: three boosting versions across three random seeds, with confidence intervals lying to the left of zero everywhere.

The third version performed worst: boosting meant only to adjust the logit of EWM-30. The best run scored 5.87, the worst 0.007. Probability accuracy by the Brier metric fell from 0.055 to 0.47–0.82. The practical lesson: if you take a strong base estimate and try to refine it without tight control, you can lose both the ranking and the calibration.

## Limitations

The author lists the weak points himself. The OSM snapshot is dated November 11, 2026, after the end of the test period (October 29), and the code does not check whether the urban features peek into the future. So the results for those features cannot be considered fully clean. Buildings and roads describe the environment but do not prove the causes of crime. OSM coverage of the city is uneven: an empty cell may be a park, a market, or simply an unmapped neighborhood.

The data also reflects crime, how often people contact the police, and recording practices. About 30% of reports have no coordinates. In addition, 511 cells have a hidden history, and for them the EWM-30 estimate cannot be recalculated.

The practical takeaway for developers and product managers: before investing in a complex model, benchmark a simple baseline on the same data and with the same metric. Compare against it using paired confidence intervals, not by eye. If the baseline is close to the ceiling of predictability, new features will only add the risk of data leakage and instability.

---
- **Первоисточник:** [Хабр: Машинное обучение](https://habr.com/ru/articles/1108000/?utm_campaign=1108000&utm_source=habrahabr&utm_medium=rss)
- **Каноническая ссылка:** https://news.hamidun.com/en/news/17296
- **Экосистема автора:** [Бесплатный интенсив по вайбкодингу — предзапись в Нике](https://t.me/vibecodeguidebot?start=agent_intensive_news_md) · [Nomad AI](https://nomadnet.ai) · [Telegram @jemal_hamidun](https://t.me/jemal_hamidun)
