A Comparative Study of Loss Functions for Short-Range Crime Forecasting: Enhancing Embedding Generation for Visualization Systems
Resumo
Criminal incidents have complex socio-economic impacts and reduce the population’s perceived security. Accurate short-term crime-rate forecasting enables more efficient allocation of policing resources and better strategic decisions to mitigate criminal activity. Transformer-based architectures are effective at capturing complex temporal dependencies in time series forecasting; however, model behaviour and the structure of learned representations are strongly influenced by the training loss. In this work, we present a comparative analysis of Transformer and recurrent architectures trained with two different losses, the Mean Squared Error (MSE) and the Soft Dynamic Time Warping (Soft-DTW), with focus on short-term forecasting of vehicle thefts in São Paulo. Our goal is to produce embeddings that are more representative of crime dynamics and thus more useful for downstream tasks such as visualization and pattern analysis. We evaluate Autoformer, ITransformer, and Informer alongside LSTM and GRU baselines, using three performance metrics: MSE, MAE and DTW. Overall, models trained with the DTW-based loss achieved performance similar to, or slightly worse than, those trained with MSE; an important exception is the Autoformer, which showed improved accuracy with Soft-DTW at the 14-day horizon. We discuss several factors that likely affected these results: (i) the short forecasting horizons studied, (ii) the formulation of the prediction task (forecasting the entire aggregated series may not be optimal), and (iii) aggregation to daily city-level counts, which discards spatial heterogeneity and may remove salient signal. These findings motivate further experiments (e.g., multi-scale and spatially resolved forecasting) to more comprehensively assess the comparative effectiveness of Soft-DTW and MSE for criminal time series prediction.Referências
A. S. R, D. Nidhi, D. S. C, and K. Sowjanya K, “Crime forecasting : A theoretical approach,” in 2022 IEEE 7th International Conference on Recent Advances and Innovations in Engineering (ICRAIE), vol. 7, 2022, pp. 37–41.
R. K. Srivastava, A. Gupta, and G. Sharma, “Forecasting crime rate using artificial intelligence applications,” in 2023 International Conference on Sustainable Communication Networks and Application (ICSCNA), 2023, pp. 1222–1226.
A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, L. Kaiser, and I. Polosukhin, “Attention is all you need,” 2023. [Online]. Available: [link]
F. Caffaro, L. Bongiovanni, and C. Rossi, Geo-temporal Crime Forecasting Using a Deep Learning Attention-Based Model. Cham: Springer Nature Switzerland, 2025, pp. 323–329. [Online]. DOI: 10.1007/978-3-031-62083-6_26
A. T. Nguyen Dai, T. T. Vo Thi, and T. B. Nguyen, “Applying itransformer for saigon river water level forecasting,” in 2024 International Conference on Advanced Technologies for Communications (ATC), 2024, pp. 556–560.
M. Cuturi and M. Blondel, “Soft-dtw: a differentiable loss function for time-series,” in Proceedings of the 34th International Conference on Machine Learning - Volume 70, ser. ICML’17. JMLR.org, 2017, p. 894–903.
S. Salvador and P. Chan, “Toward accurate dynamic time warping in linear time and space,” Intell. Data Anal., vol. 11, no. 5, p. 561–580, Oct. 2007.
J. Jiang, S. Lai, L. Jin, and Y. Zhu, “Dsdtw: Local representation learning with deep soft-dtw for dynamic signature verification,” IEEE Transactions on Information Forensics and Security, vol. 17, pp. 2198–2212, 2022.
K.-H. Ho, P.-S. Huang, I.-C. Wu, and F.-J. Wang, “Prediction of time series data based on transformer with soft dynamic time wrapping,” in 2020 IEEE International Conference on Consumer Electronics - Taiwan (ICCE-Taiwan), 2020, pp. 1–2.
W. Safat, S. Asghar, and S. A. Gillani, “Empirical analysis for crime prediction and forecasting using machine learning and deep learning techniques,” IEEE access, vol. 9, pp. 70 080–70 094, 2021.
E. G. İlgün and M. Dener, “Exploratory data analysis, time series analysis, crime type prediction, and trend forecasting in crime data using machine learning, deep learning, and statistical methods,” Neural Computing and Applications, vol. 37, no. 18, pp. 11 773–11 798, 2025.
G. Borowik, Z. M. Wawrzyniak, and P. Cichosz, “Time series analysis for crime forecasting,” in 2018 26th international conference on systems engineering (ICSEng). IEEE, 2018, pp. 1–10.
H. Silva, S. Rocha, and G. Gonçalves, “Técnicas para predição de crimes utilizando dados oficiais considerando tempo e espaço,” in Anais da XII Escola Regional de Computação do Ceará, Maranhão e Piauí. Porto Alegre, RS, Brasil: SBC, 2024, pp. 229–238. [Online]. Available: [link]
J. L. de Jesus Goulart, M. M. Provenza, V. L. Xavier, I. C. de Almeida Lima, P. H. C. Simões, and J. C. Siqueira, “Previsões de séries temporais para os crimes de letalidade violenta no rio de janeiro através dos modelos de estado e suavização exponencial, arima e redes neurais autorregressivas,” Caderno Pedagógico, vol. 21, no. 10, pp. e8626–e8626, 2024.
Y. Chen, W. Jia, and Q. Wu, “Fine-scale deep learning model for time series forecasting,” Applied Intelligence, 2024.
V. Le Guen and N. Thome, “Deep time series forecasting with shape and temporal criteria,” IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 45, no. 1, pp. 342–355, 2022.
Y. Chen, C. Obrecht, and F. Kuznik, “Enhancing peak prediction in residential load forecasting with soft dynamic time wrapping loss functions,” Integrated Computer-Aided Engineering, vol. 31, no. 3, pp. 327–340, 2024.
D. B. L. Silva, T. Vieira, E. de Barros Costa, A. Paiva, and L. G. Nonato, “A street corner-level methodology to analyze the influence of points of interest on urban crime,” Socio-Economic Planning Sciences, p. 102297, 2025. [Online]. Available: [link]
G. Garcia-Zanabria and L. Nonato, “Visual crime pattern analysis,” in Anais Estendidos da XXXV Conference on Graphics, Patterns and Images. Porto Alegre, RS, Brasil: SBC, 2022, pp. 55–61. [Online]. Available: [link]
T. P. Santos, J. M. S. Souza, T. Vieira, and L. G. Nonato, “Space-time urban explorer: A visual tool for exploring spatiotemporal crime and patrolling data,” in 2024 37th SIBGRAPI Conference on Graphics, Patterns and Images (SIBGRAPI), 2024, pp. 1–6.
SSP, “Portal da transparência da ssp-sp,” 2025. [Online]. Available: [link]
F. Pedregosa, G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Prettenhofer, R. Weiss, V. Dubourg, J. Vanderplas, A. Passos, D. Cournapeau, M. Brucher, M. Perrot, and E. Duchesnay, “Scikit-learn: Machine learning in Python,” Journal of Machine Learning Research, vol. 12, pp. 2825–2830, 2011.
H. Wu, J. Xu, J. Wang, and M. Long, “Autoformer: Decomposition transformers with auto-correlation for long-term series forecasting,” Advances in neural information processing systems, vol. 34, pp. 22 419–22 430, 2021.
Y. Liu, T. Hu, H. Zhang, H. Wu, S. Wang, L. Ma, and M. Long, “itransformer: Inverted transformers are effective for time series forecasting,” arXiv preprint arXiv:2310.06625, 2023.
H. Zhou, S. Zhang, J. Peng, S. Zhang, J. Li, H. Xiong, and W. Zhang, “Informer: Beyond efficient transformer for long sequence time-series forecasting,” in Proceedings of the AAAI conference on artificial intelligence, vol. 35, no. 12, 2021, pp. 11 106–11 115.
M. Müller, Information retrieval for music and motion. Springer, 2007.
R. K. Srivastava, A. Gupta, and G. Sharma, “Forecasting crime rate using artificial intelligence applications,” in 2023 International Conference on Sustainable Communication Networks and Application (ICSCNA), 2023, pp. 1222–1226.
A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, L. Kaiser, and I. Polosukhin, “Attention is all you need,” 2023. [Online]. Available: [link]
F. Caffaro, L. Bongiovanni, and C. Rossi, Geo-temporal Crime Forecasting Using a Deep Learning Attention-Based Model. Cham: Springer Nature Switzerland, 2025, pp. 323–329. [Online]. DOI: 10.1007/978-3-031-62083-6_26
A. T. Nguyen Dai, T. T. Vo Thi, and T. B. Nguyen, “Applying itransformer for saigon river water level forecasting,” in 2024 International Conference on Advanced Technologies for Communications (ATC), 2024, pp. 556–560.
M. Cuturi and M. Blondel, “Soft-dtw: a differentiable loss function for time-series,” in Proceedings of the 34th International Conference on Machine Learning - Volume 70, ser. ICML’17. JMLR.org, 2017, p. 894–903.
S. Salvador and P. Chan, “Toward accurate dynamic time warping in linear time and space,” Intell. Data Anal., vol. 11, no. 5, p. 561–580, Oct. 2007.
J. Jiang, S. Lai, L. Jin, and Y. Zhu, “Dsdtw: Local representation learning with deep soft-dtw for dynamic signature verification,” IEEE Transactions on Information Forensics and Security, vol. 17, pp. 2198–2212, 2022.
K.-H. Ho, P.-S. Huang, I.-C. Wu, and F.-J. Wang, “Prediction of time series data based on transformer with soft dynamic time wrapping,” in 2020 IEEE International Conference on Consumer Electronics - Taiwan (ICCE-Taiwan), 2020, pp. 1–2.
W. Safat, S. Asghar, and S. A. Gillani, “Empirical analysis for crime prediction and forecasting using machine learning and deep learning techniques,” IEEE access, vol. 9, pp. 70 080–70 094, 2021.
E. G. İlgün and M. Dener, “Exploratory data analysis, time series analysis, crime type prediction, and trend forecasting in crime data using machine learning, deep learning, and statistical methods,” Neural Computing and Applications, vol. 37, no. 18, pp. 11 773–11 798, 2025.
G. Borowik, Z. M. Wawrzyniak, and P. Cichosz, “Time series analysis for crime forecasting,” in 2018 26th international conference on systems engineering (ICSEng). IEEE, 2018, pp. 1–10.
H. Silva, S. Rocha, and G. Gonçalves, “Técnicas para predição de crimes utilizando dados oficiais considerando tempo e espaço,” in Anais da XII Escola Regional de Computação do Ceará, Maranhão e Piauí. Porto Alegre, RS, Brasil: SBC, 2024, pp. 229–238. [Online]. Available: [link]
J. L. de Jesus Goulart, M. M. Provenza, V. L. Xavier, I. C. de Almeida Lima, P. H. C. Simões, and J. C. Siqueira, “Previsões de séries temporais para os crimes de letalidade violenta no rio de janeiro através dos modelos de estado e suavização exponencial, arima e redes neurais autorregressivas,” Caderno Pedagógico, vol. 21, no. 10, pp. e8626–e8626, 2024.
Y. Chen, W. Jia, and Q. Wu, “Fine-scale deep learning model for time series forecasting,” Applied Intelligence, 2024.
V. Le Guen and N. Thome, “Deep time series forecasting with shape and temporal criteria,” IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 45, no. 1, pp. 342–355, 2022.
Y. Chen, C. Obrecht, and F. Kuznik, “Enhancing peak prediction in residential load forecasting with soft dynamic time wrapping loss functions,” Integrated Computer-Aided Engineering, vol. 31, no. 3, pp. 327–340, 2024.
D. B. L. Silva, T. Vieira, E. de Barros Costa, A. Paiva, and L. G. Nonato, “A street corner-level methodology to analyze the influence of points of interest on urban crime,” Socio-Economic Planning Sciences, p. 102297, 2025. [Online]. Available: [link]
G. Garcia-Zanabria and L. Nonato, “Visual crime pattern analysis,” in Anais Estendidos da XXXV Conference on Graphics, Patterns and Images. Porto Alegre, RS, Brasil: SBC, 2022, pp. 55–61. [Online]. Available: [link]
T. P. Santos, J. M. S. Souza, T. Vieira, and L. G. Nonato, “Space-time urban explorer: A visual tool for exploring spatiotemporal crime and patrolling data,” in 2024 37th SIBGRAPI Conference on Graphics, Patterns and Images (SIBGRAPI), 2024, pp. 1–6.
SSP, “Portal da transparência da ssp-sp,” 2025. [Online]. Available: [link]
F. Pedregosa, G. Varoquaux, A. Gramfort, V. Michel, B. Thirion, O. Grisel, M. Blondel, P. Prettenhofer, R. Weiss, V. Dubourg, J. Vanderplas, A. Passos, D. Cournapeau, M. Brucher, M. Perrot, and E. Duchesnay, “Scikit-learn: Machine learning in Python,” Journal of Machine Learning Research, vol. 12, pp. 2825–2830, 2011.
H. Wu, J. Xu, J. Wang, and M. Long, “Autoformer: Decomposition transformers with auto-correlation for long-term series forecasting,” Advances in neural information processing systems, vol. 34, pp. 22 419–22 430, 2021.
Y. Liu, T. Hu, H. Zhang, H. Wu, S. Wang, L. Ma, and M. Long, “itransformer: Inverted transformers are effective for time series forecasting,” arXiv preprint arXiv:2310.06625, 2023.
H. Zhou, S. Zhang, J. Peng, S. Zhang, J. Li, H. Xiong, and W. Zhang, “Informer: Beyond efficient transformer for long sequence time-series forecasting,” in Proceedings of the AAAI conference on artificial intelligence, vol. 35, no. 12, 2021, pp. 11 106–11 115.
M. Müller, Information retrieval for music and motion. Springer, 2007.
Publicado
30/09/2025
Como Citar
BELCHIOR, Aline Martins Nascimento; JANUARIO, Raissa Rosa dos Santos; CABRAL, Marvin Mendes; NONATO, Luis Gustavo.
A Comparative Study of Loss Functions for Short-Range Crime Forecasting: Enhancing Embedding Generation for Visualization Systems. In: WORKSHOP DE TRABALHOS EM ANDAMENTO - CONFERENCE ON GRAPHICS, PATTERNS AND IMAGES (SIBGRAPI), 38. , 2025, Salvador/BA.
Anais [...].
Porto Alegre: Sociedade Brasileira de Computação,
2025
.
p. 212-217.
DOI: https://doi.org/10.5753/sibgrapi.est.2025.38299.
