Next Article in Journal
Research on Spatial Spillover Effects of Comprehensive Carrying Capacity of Water and Soil Resources: Evidence from the Yellow River Basin, China
Previous Article in Journal
Establishment of Natural Products Development Laboratory: A Future-Proofing Intervention and DOrSU’s Commitment to UN-SDGs
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Analyzing the Relationship Between Built-Environment Factors and Safety Threat Reports in Cracow, Poland

1
School of Urban Arts, Tianjin Chengjian University, Tianjin 300392, China
2
School of Architecture, Tianjin University, Tianjin 300072, China
*
Author to whom correspondence should be addressed.
Sustainability 2025, 17(20), 9300; https://doi.org/10.3390/su17209300
Submission received: 3 September 2025 / Revised: 9 October 2025 / Accepted: 13 October 2025 / Published: 20 October 2025

Abstract

With the acceleration of urbanization, the coupling relationship between the built environment and urban safety hazards has become increasingly prominent. Irrational spatial structures and resource allocations may aggravate safety hazards and negatively affect residents’ quality of life, thus requiring urgent scientific evaluation and optimization. However, existing studies mostly focus on linear correlation analysis, which makes it difficult to reveal the complex nonlinear mechanisms among multidimensional environmental factors. Taking Cracow (Kraków), Poland as the study area, this research utilizes multi-source spatial data to quantify environmental features such as transportation, socioeconomic conditions, visual landscapes, and public services, in order to uncover their role in the formation of safety hazards. An XGBoost-based safety hazard prediction model is constructed, and SHAP interpretability analysis, together with two-dimensional partial dependence plots (2D PDPs), are introduced to systematically explore the synergistic gains, marginal effects, and resource allocation thresholds of key variables. The results indicate that variables such as average housing price, distance to the nearest police station, and average population density contribute significantly to hazard prediction, and that certain combinations of variables exhibit strong synergistic effects in reducing hazards within medium-range intervals. The study concludes that integrating machine learning with interpretability analysis can not only effectively identify the spatial features associated with high levels of safety hazards, but also provide quantifiable and actionable optimization pathways for urban planning and safety hazard governance. This research further underscores the role of managing urban safety hazards as a key pillar in the sustainable development of cities by linking safety hazard modeling with spatial governance strategies that promote inclusive, resilient, and livable urban environments.

1. Introduction

Against the backdrop of rapid global urbanization, urban public safety has become an increasingly core issue in urban planning, management, and governance. As population concentration and urban structural complexity rise, the frequent occurrence of safety incidents imposes higher demands on city systems. The United Nations’ 2030 Agenda for Sustainable Development lists “building safe, inclusive, and sustainable cities” as Sustainable Development Goal 11, underscoring the global strategic importance of urban safety [1]. Urban safety is not only about protecting residents’ lives and property, but also directly affects social stability, economic vitality, and the capacity for sustainable development [2]. In this context, constructing safe and livable cities is a key pathway to improving residents’ well-being [3]. Urban safety constitutes not only a core component of urban governance but also a fundamental prerequisite for sustainable development. Within the framework of sustainability—which encompasses the social, economic, and environmental dimensions—safety serves as a cross-cutting element. Socially, secure environments strengthen community cohesion, enhance public trust, and promote inclusiveness. Economically, improved safety conditions stimulate investment, enhance residents’ productivity, and reduce social and financial losses associated with urban risks. Environmentally, safety-oriented planning measures such as optimized lighting, transport organization, and green open spaces contribute to healthier and more livable urban ecosystems. According to the United Nations Sustainable Development Goal 11 (“Make cities inclusive, safe, resilient, and sustainable”), safety is not only an outcome but also a foundation of sustainability. Therefore, understanding and mitigating urban safety hazards are vital steps toward achieving inclusive, resilient, and sustainable cities. Consequently, it has become an urgent topic in urban studies and public policy to understand the multidimensional factors influencing urban safety and to explore spatial intervention strategies that can enhance it [4]. In this regard, explainable machine learning tools such as SHAP (SHapley Additive exPlanations) and two-dimensional Partial Dependence Plots (2D PDPs) provide new opportunities to uncover variable contributions, nonlinear interactions, and threshold effects, thereby supporting more transparent and evidence-based analyses of urban safety.
The built environment of cities not only shapes people’s daily behavioral patterns but also significantly affects the spatial distribution of safety hazards (including but not limited to crime-related incidents) and residents’ subjective sense of safety. Several classic theories in sociology and criminology provide a theoretical foundation for this understanding. For example, Routine Activity Theory posits that crime occurs when a motivated offender, a suitable target, and the absence of a capable guardian converge in time and space, with the built environment strongly influencing these three factors [5]. Similarly, Crime Pattern Theory emphasizes that urban structures and people’s mobility patterns jointly determine the spatial concentration of potential criminal behaviors [6]. Meanwhile, the Broken Windows Theory suggests that if a community shows signs of persistent disorder—such as graffiti, garbage accumulation, and building deterioration—it sends signals of neglect and lack of order, which may induce more serious crimes [7]. Such disorder not only reduces residents’ sense of security but also weakens the community’s ability to deter crime. From the perspective of spatial design, Defensible Space Theory highlights that rational organization and design of space can enhance residents’ sense of control over their environment, thereby suppressing crime [4]. This theory later evolved into the Crime Prevention Through Environmental Design (CPTED) strategy, which advocates enhancing lighting, improving visual permeability, strengthening natural surveillance, and creating a stronger sense of territoriality to deter potential unlawful behavior. While these theories were originally developed to explain crime, their spatial logic provides valuable insights for understanding broader urban safety hazards. In summary, the built environment is not only the physical carrier of urban functions but also an important determinant of urban safety, and its mechanisms and spatial differences warrant deeper exploration.
Crowdsourcing is a way of collecting data and identifying problems by engaging the public in specific tasks. With the development of geographic information technologies and the growing awareness of citizen participation, Volunteered Geographic Information (VGI) has become an important supplementary tool in urban research. Goodchild first proposed the concept of VGI and likened citizens to “human sensors,” emphasizing its unique role in reflecting urban spatial conditions in real time [8]. Compared to traditional official statistics, crowdsourced data has advantages such as timeliness, high spatial resolution, and the ability to reflect subjective perceptions, providing sharper and broader perspectives for urban safety research. For example, Shelton analyzed geographic data from social media to reveal spatial inequalities among urban social groups, showing that VGI helps identify structural problems in cities [9]. See compared the data quality contributed by experts and non-experts, finding that differences were limited in specific tasks, indicating the potential reliability of VGI under certain conditions [10]. Later, See systematically reviewed research on VGI and citizen science, pointing out their wide applications in urban planning, environmental management, and disaster response [11]. Haklay further proposed a classification model of VGI participation depth, from passive information receipt to active analytical engagement, highlighting how different forms of participation influence data quality and governance outcomes [12]. Poland’s launch of the National Safety Threat Map (NSTM, Krajowa Mapa Zagrożeń Bezpieczeństwa) (Table 1) in 2016 provides a paradigmatic case for the application of VGI in public safety. Overall, VGI enables broad social participation at a relatively low cost, compensating for the limitations of traditional crime statistics by providing broader coverage of both criminal and non-criminal safety hazards, and offers strong support for data-driven urban governance—especially in identifying safety hotspots and devising targeted interventions.
Current studies on the relationship between the built environment and urban safety have traditionally relied on official crime statistics or surveys. However, such data often fail to capture residents’ subjective perceptions of safety risks in daily life, making it difficult to reveal the true spatial patterns of urban safety hazards [6,13]. Moreover, some studies have found that official data may suffer from institutional bias, causing systemic overestimation of crime rates in certain areas and thereby undermining objectivity [14]. In recent years, the rise in crowdsourced platforms and VGI has offered new possibilities to complement traditional data [12], but systematic research on the coupling mechanisms between crowdsourced safety hazard data and built environment features remains scarce. Such gaps hinder the full exploration of their potential in urban safety assessment and spatial governance. Methodologically, traditional approaches often rely on linear or logistic regression, which can reveal correlations between certain variables and crime rates but struggle to handle high-dimensional multi-source data, complex variable interactions, and nonlinear relationships. They also lack interpretability in explaining how factors influence outcomes [15]. Recently, machine learning methods have been introduced into urban safety hazard research due to their strong fitting capacity and pattern recognition advantages [16]. Some studies have also employed crowdsourced data to capture residents’ perceptions of safety risks [17]. However, most of these works remain at the level of macro-correlation analysis and lack quantitative modeling and in-depth interpretation of the relationship between micro-level built environment features and perceived safety hazards. In particular, the interpretability of models remains underdeveloped. Thus, there is a pressing need to introduce models that combine high predictive accuracy with strong interpretability, integrating crowdsourced safety data to systematically reveal the complex mechanisms linking built environment features with safety hazards. Using machine learning together with interpretability techniques such as SHAP can enable fine-grained and visualized analyses of the “built environment–safety hazard” relationship, thereby providing scientific support for precise spatial governance and policymaking.
Building on this background, this study focuses on Cracow, Poland, to explore the spatial mechanisms linking built environment features with residents’ reported safety hazards. We integrate multi-source data, including street-level built environment elements (such as POI functional diversity, green space coverage, lighting, transportation node density, and housing prices) and crowdsourced safety hazard reports from the NSTM platform, to construct a spatial database and conduct machine learning modeling. To improve model interpretability and usability, we further employ SHAP (Shapley Additive Explanations) to explain the model results, clarify the extent and direction of each variable’s influence on urban safety hazards, and enhance transparency and operational value.
The NSTM dataset used in this study covers a wider range of urban safety hazards than conventional crime data. Unlike traditional crime-based analyses, the present research expands the scope to encompass both criminal and non-criminal risks—such as traffic accidents, environmental threats, and other public safety concerns.
Expected innovations and contributions: This study is the first to conduct high-resolution spatial coupling analysis between crowdsourced safety hazard data (NSTM) and street-level built environment features, thereby improving data granularity and local sensitivity in urban safety research. By introducing the SHAP interpretability approach, the study enhances readability and transparency while retaining machine learning’s predictive performance, overcoming the “black-box” bottleneck in urban research applications. The results provide quantitative support for city managers to design more targeted spatial optimization strategies, particularly useful for data-driven urban safety hazard governance and place-based interventions. Through this work, we aim to provide empirical evidence for how built environments affect residents’ perceived safety hazards and to offer a transferable paradigm for integrating crowdsourced data and interpretable AI in urban studies.

2. Related Works

2.1. The Relationship Between Urban Safety and the Built Environment

Exploring how the built environment affects crime and broader urban safety hazards is crucial for understanding safety mechanisms. Within the CPTED framework, Cozens summarized five key strategies: natural surveillance, target hardening, territoriality, access control, and ongoing maintenance. They emphasized that good physical design can systematically reduce safety risks [18]. Recent empirical studies have increasingly validated these theories from the perspective of the built environment. For example, Kuo et al. found in their Chicago study that higher green space coverage in residential areas was associated with lower perceived rates of aggressive crime [19]. Shepley et al., in a systematic review, concluded that the presence of green space significantly correlates with reduced crime across multiple types, particularly in suburban and moderately dense areas [20]. Some studies have found that greening vacant lots reduced violence, crime, and fear through a citywide randomized controlled trial, highlighting the positive policing effect of micro-environmental interventions [21]. Mouratidis empirically demonstrated that higher tree coverage enhances residents’ perceived safety [22]. Jonescu et al., from an integrated environmental systems perspective, revealed how urban heat islands, tree canopy coverage, and population density jointly affect crime rates, emphasizing the combined role of green space and climatic suitability in public safety [23]. Hipp et al. further analyzed how micro-geographic built environment features affect crime rates, underscoring the critical role of micro-spatial characteristics [24]. Beyond green space, other environmental variables also exert a significant influence. Studies have shown that street lighting, environmental cleanliness, and spatial openness correlate strongly with violent crime, burglary, and nighttime safety perception [18]. Land-use structure is also important: One study found that different urban functional mixes significantly affect crime density, with mixed land-use enhancing safety [25]. Other researchers have studied public space renewal in disadvantaged communities and found that planning interventions effectively improved safety perception, further validating the social benefits of environmental design [26]. Additionally, CPTED principles have been applied to explain Fear of Crime (FoC). Based on photo evaluations and fear scales from 460 participants, researchers have found that insufficient natural surveillance and lack of territoriality exacerbate public-space FoC [27]. This research provides perceptual evidence for CPTED in micro-spatial governance. Furthermore, some studies have highlighted the “perception bias” between actual crime risk and residents’ subjective sense of safety, stressing the need to combine objective and subjective measures for multidimensional safety analysis [28]. Overall, the built environment shapes urban spatial forms and deeply influences residents’ behavior and safety perception, making it a crucial dimension in urban safety studies. While most previous studies relied primarily on crime data to examine urban safety mechanisms, this research takes a broader perspective by analyzing diverse urban safety hazards—including both criminal and non-criminal risks that influence residents’ daily well-being and perceived security.

2.2. Streetscape Images and Urban Safety Research

With the availability of streetscape image data and advances in computer vision, researchers have increasingly applied these methods to urban safety research, using automated recognition of visual features to analyze links with perceptions of safety and the spatial distribution of safety hazards (including crime-related incidents). Naik et al. proposed the “StreetScore” model, combining Google Street View imagery and crowdsourced surveys to predict subjective safety perception across 21 U.S. cities using support vector regression [29]. Research on urban perception has progressively expanded in scope. The dimensions of safety, aesthetics, and vibrancy were broadened through convolutional neural networks applied to Place Pulse 2.0 data, highlighting inter-city variations in visual cognition [30]. Gender-specific analyses further showed that women often experience stronger feelings of insecurity under certain road and lighting conditions [31]. Streetscape-based models of perceived safety have been introduced and refined, proving the feasibility of leveraging visual features and enhancing prediction accuracy through finer feature extraction [32,33]. Connections between mental health and urban environments have also been revealed, with perceived safety demonstrated to significantly affect well-being, suggesting that improving visual safety enhances quality of life [34]. Extensions of these approaches have shown that juvenile crime is shaped jointly by perceived safety and the physical environment [35]. A systematic “urban visual intelligence” framework has also been advanced to mine latent street-level features [36]. More recently, multimodal large language models have been integrated into safety perception frameworks [37]. Other work has emphasized the interaction of facilities and visual elements in influencing robbery distribution [38], the spatio-temporal coupling of visual environments and safety risks [39], and the use of image recognition to detect pickpocketing hotspots [40]. Comparative studies of streetscape features at drug dealing and robbery sites have further confirmed the precision of imagery-based urban safety analysis [41]. Collectively, these contributions illustrate how computer vision combined with streetscape imagery can capture safety-related spatial features and support risk prevention, public health, and urban planning.

2.3. Crowdsourcing Platforms and Urban Safety Data

With the rise of Volunteered Geographic Information (VGI) in governance, many studies have examined how crowdsourced data can identify and monitor community-level safety hazards and risks. Compared with traditional governance, VGI is more sensitive and timely in detecting micro-spatial risks, complementing official data gaps, improving transparency, and strengthening civic participation [42]. It has been suggested that integrating crowdsourced data with municipal service systems better captures residents’ daily risk perceptions and enables more precise spatial governance [43]. Efforts combining streetscape imagery with crowdsourced survey data have built gender-sensitive safety perception models, underscoring the differences across groups and supporting inclusive planning [44]. Reviews of VGI applications highlight that platforms provide accurate spatial positioning and rapid temporal response, while compensating for the limitations of traditional governance in micro-spatial sensing and responsiveness [45]. Other findings emphasize that integrating crowdsourced risk data with environmental imagery features such as greenery, lighting, and enclosure contributes to more holistic safety perception models [46]. In practice, Poland’s NSTM system exemplifies this integration, with public order risks in Cracow mapped through reports from the platform [47]. Comparable initiatives, such as the U.S. 311 hotline, provide residents with channels to report issues like illegal dumping, road damage, or noise, and analyses have shown that such data reveal micro-disorder and supplement urban governance [48]. Collectively, these crowdsourced platforms generate spatialized data that empirically link the built environment with residents’ perceptions, thereby forming a foundation for urban safety assessment. At the same time, it is recognized that crowdsourced data may contain reporting biases, uneven participation, or subjective misperceptions. To address these issues, this study employed data-cleaning procedures, spatial cross-validation, and consistency checks with official statistics where available, aiming to improve reliability and mitigate potential bias. Building on this, the present study leverages NSTM data combined with micro built environment features for spatial coupling analysis, further advancing multi-source data integration and interpretability in urban safety governance.

2.4. Machine Learning Models for Urban Spatial Analysis

While earlier applications largely focused on crime prediction, the present study extends these methods to model broader urban safety hazards. With advances in spatial big data and computation, machine learning has become vital in modeling the links between urban features and social phenomena [49], particularly in urban safety analysis. Compared to traditional regression models (e.g., SAR, SEM), machine learning better handles high-dimensional, nonlinear, and heterogeneous spatial data [50]. Recent reviews have examined crime prediction models such as Random Forest, XGBoost, SVM, and Graph Neural Networks (GNNs), identifying both their advantages and shortcomings while emphasizing future needs in data fusion, multi-scale modeling, and interpretability [51]. Supervised learning approaches, including RF, XGBoost, and SVM, remain widely applied in predicting high-risk areas. Self-exciting point processes have been introduced to enhance hotspot prediction accuracy [52]. Automated quantification of perceived safety was advanced through StreetScore, which applied convolutional neural networks to Google Street View imagery [29]. Further developments enabled automated feature extraction from images to connect environmental elements such as buildings, lighting, and greenery with crime occurrence [53]. Machine learning techniques have also been used to measure spatial features from GSV imagery and assess their influence on street-level crime distribution [26]. Deep graph neural networks, such as GCN, have demonstrated superior performance in predicting crime hotspots in Chicago compared to traditional methods [54]. Hybrid architectures combining ResNet, GCN, and LSTM with attention mechanisms have been validated in multi-district crime forecasting [55]. Semantic segmentation of imagery integrated with police geonarratives has been shown to effectively distinguish high- and low-crime areas, achieving accuracy rates above 95% in two U.S. cities [56]. The importance of interpretability has been reinforced through studies showing that coupling XGBoost with SHAP provides clear visualizations of feature contributions, enhancing transparency [57]. Reviews further note that deep learning is becoming dominant in AI-based crime prediction, with multi-source data integration identified as a key future direction [58]. Taken together, these contributions demonstrate that machine learning effectively captures complex spatial patterns beyond traditional methods and provide a solid foundation for the model design in this study.

2.5. Explainable Machine Learning in Urban Research

As machine learning grows more complex, “black-box” models pose challenges for interpretability [59]. Explainable AI (XAI) has thus become critical for urban governance studies. Shapley Additive Explanations (SHAP), based on Shapley values, quantifies the marginal contribution of each variable, thereby revealing internal model logic and enhancing interpretability and trust [60]. In the field of transportation safety, applications of XGBoost combined with SHAP have demonstrated that nighttime, adverse weather, and complex road structures are critical factors in highway accident prediction [61]. In disaster risk analysis, rainfall, impervious surface coverage, and drainage density were identified as dominant drivers of flood risk, providing evidence for sponge-city strategies [62]. For social inequality research, SHAP integrated with deep learning has been employed to analyze racial segregation in Las Vegas housing, uncovering nonlinear interactions among housing prices, income, and infrastructure [63]. Studies of the built environment have shown that greenery positively affects real estate values, while higher density exerts a suppressing effect, highlighting the economic implications of spatial form [64]. At micro-scales, theft patterns have been analyzed by linking visitation intensity and spatial usage with SHAP-based interpretation [65]. Comparative evaluations of explainable AI methods in micro-crime prediction further indicate that SHAP provides the strongest transparency and usability [66]. In mobility research, LightGBM with SHAP has been applied to elderly walking behavior, identifying built environment factors shaping mobility [67]. Overall, SHAP has been successfully applied across domains, including urban safety, disaster risk, segregation, housing, and mobility, proving effective in translating model outputs into actionable strategies. Building on this foundation, the present study applies SHAP to interpret safety hazard prediction, aiming to identify critical features and provide scientific support for governance and interventions.

3. Machine Learning Modeling and Interpretability Analysis of Built Environment and Safety Hazards

3.1. Safety Hazard Data in Cracow, Poland

The NSTM (National Safety Threat Map) platform, administered by the Polish National Police, allows citizens to anonymously mark safety hazards—such as traffic violations, noise disturbances, and suspicious behavior—thereby enabling real-time sensing and spatial representation of urban safety hazards. Residents are encouraged to proactively report a wide range of problems, including illegal parking, noise nuisances, and drug-related activities. The platform has become an important auxiliary tool for public security agencies to identify safety hazard hotspots and optimize police deployment [68].
To quantify the impact of built-environment factors on urban safety hazards and to identify the key spatial elements influencing residents’ propensity to report hazards, this study builds a machine-learning model using built-environment data for Cracow together with hazard locations reported via NSTM. During data preprocessing, the study area was partitioned into 800 m × 800 m fishnet grids as the spatial analysis unit (Figure 1). Thirteen built-environment indicators were overlaid onto each grid cell, and the number of NSTM reports within each cell was counted as the response variable to construct the dataset. The dataset was randomly split into a training set (80%) and a test set (20%) to ensure objectivity and generalizability in model performance evaluation.

3.2. Model Performance Comparison

In the study of the built environment and urban safety hazards, constructing predictive models that are both stable in performance and interpretable is the foundation for analyzing underlying variable mechanisms (Figure 2). However, traditional machine learning methods often rely on manually completing multiple steps, such as feature preprocessing, model selection, and hyperparameter optimization. This approach is not only labor-intensive but also limited in tuning efficiency and modeling accuracy when faced with heterogeneous multi-source data and complex variable structures. Particularly during model integration and cross-validation, each algorithm must be evaluated and compared individually, which greatly increases experimental time and computational cost.
To improve overall modeling efficiency and ensure the robustness and generalizability of the results, this study introduced AutoGluon (version 1.4.0, developed by Amazon Web Services, Washington, DC, USA), an automated machine learning (AutoML) framework. With its end-to-end training pipeline, AutoGluon automates processes ranging from data cleaning and feature engineering to parallel multi-model training and ensemble fusion. Within a specified time budget, the framework is able to automatically tune a variety of algorithms—including XGBoost, LightGBM, CatBoost, Random Forest, linear models, K-Nearest Neighbors (KNN), and neural networks—while further improving model performance through bagging and ensemble architectures. This strategy not only substantially reduces reliance on manual tuning experience but also provides a high-quality modeling foundation for subsequent feature-importance-based interpretability analysis, thereby ensuring both scientific rigor and practical value of the research findings.
In this study, AutoGluon was employed for multi-model comparison and hyperparameter tuning. During model integration and cross-validation, a training time budget of 7200 s (2 h) was allocated, with five-fold cross-validation enabled. Six baseline models were preliminarily evaluated: XGBoost, LightGBM, ExtraTrees, Random Forest, CatBoost, and KNeighbors. At the early stage of modeling, AutoGluon automatically executed preprocessing for both numerical and categorical features, including missing-value imputation, numerical normalization, and categorical encoding transformations. Throughout multiple rounds of cross-validation, the system efficiently searched and optimized the key hyperparameters of candidate models. Model performance was uniformly evaluated using the coefficient of determination (R2), with results recorded for each validation round. Ultimately, AutoGluon generated a performance leaderboard (see Table 2), showing the average R2 scores and corresponding training times of each algorithm on the validation set, thereby providing an intuitive comparison of model accuracy and efficiency.
According to the integrated evaluation results, the model with the best validation performance (i.e., the highest average R2 value) was selected as the candidate scheme and entered the next stage of fine-tuned training and parameter adjustment, aimed at further improving stability and generalization ability.
Figure 3 presents scatter plots of prediction performance for safety hazard scores on the test set under different base regressors using AutoGluon. Each subplot compares predicted values (y-axis) against true values (x-axis). The red dashed line (y = x) indicates ideal prediction performance, while the blue scatter points represent the distribution of predicted and actual values for each test sample. The coefficient of determination (R2) for each model is also annotated in the upper-left corner.
Among the models, XGBoost exhibited the closest clustering of scatter points around the diagonal, with the smallest deviation and the highest fitting quality (R2 = 0.904). Random Forest, LightGBM, and CatBoost performed slightly below XGBoost, but their predicted distributions remained concentrated near the diagonal, with relatively small errors and overall satisfactory fits. In contrast, ExtraTrees and KNeighbors achieved moderate accuracy, with more dispersed scatter distributions. Taken together, the performance across R2 values and the aggregation trend between predicted and true values suggest that XGBoost provides the best fitting ability and generalization performance in this study. Consequently, XGBoost was ultimately selected as the core regression model for subsequent feature interpretation and mechanism analysis.

3.3. Model Training

Based on the comparative results from the previous stage, this study concentrated the training time budget on the best-performing model—XGBoost—allocating 7200 s for retraining. Although preliminary hyperparameter optimization had already been conducted under the multi-model parallel framework, the time resources in that stage were distributed across multiple algorithms. In this phase, a more focused search space and computational resources were dedicated specifically to XGBoost, enabling deeper fine-tuning of its hyperparameters. With a longer single-model training duration, five-fold cross-validation was performed again to examine the robustness of the model and minimize the influence of random fluctuations on the final outcome.
Through this targeted retraining process, a regression model with improved accuracy and greater stability was obtained, providing a solid numerical foundation for subsequent feature-importance analysis and interpretability of influencing mechanisms. In the preliminary retraining, XGBoost achieved an R2 of 0.859, demonstrating notable gains over the baseline.
Finally, taking the R2 metric as the primary criterion, XGBoost was selected as the main model and underwent secondary fine-tuned training. After repeated five-fold cross-validation, the XGBoost model achieved the highest R2 value of 0.903 on the test set, with an RMSE of 1.785, outperforming all other candidate models. Its robustness and interpretability establish it as the fundamental framework for the subsequent SHAP-based explanatory analysis.

4. Evaluating the Impact of Public Space Environment on Urban Safety Hazards

4.1. Feature Importance and Correlation Analysis

The selection of built-environment features in this study was based on multiple dimensions, including three-dimensional urban morphology, road transportation, and socio-economic and demographic factors, leading to the construction of 13 indicators. After completing the training and validation of the XGBoost model, the relative contributions of these 13 built-environment indicators to urban safety hazards were assessed using permutation importance (measured by the change in ΔR2). As illustrated in Figure 4, average housing price, distance to the nearest police station, and average population density ranked at the top, thereby revealing critical patterns in how built-environment characteristics shape urban safety hazards.
Figure 4 presents the results of feature-importance evaluation for built-environment variables, derived from the XGBoost model (XGBoost_BAG_L1/T366). By applying the permutation importance method and using ΔR2 variation as the evaluation criterion, the impacts of 13 built-environment features on model performance were systematically compared.
The results indicate that “average housing price” is the most influential variable. Its permutation led to the sharpest decline in model performance (ΔR2 ≈ 0.7), suggesting that this variable plays a dominant role in explaining spatial disparities in residents’ perceptions of safety hazards. This finding reflects a strong correlation between urban economic value and residents’ perceived safety. The “distance to the nearest police station” ranked second, highlighting that accessibility to policing facilities significantly affects residents’ perceptions of environmental safety hazards. This result corroborates the core principle of Crime Prevention Through Environmental Design (CPTED) theory, which emphasizes the link between environmental monitoring and residents’ perceived safety, extending beyond crime to broader urban safety hazards. Additionally, “average population density” also showed notable explanatory power, suggesting that the degree of population aggregation may indirectly influence safety-hazard outcomes by shaping human behaviors and interaction patterns.
By contrast, factors such as road traffic density, number of intersections, and visual features extracted from street-view images (e.g., average number of colors, edge detection, scene depth, color contrast) had relatively lower marginal impacts on model performance. Nevertheless, as constitutive elements of the built environment, these factors still provide complementary explanatory value within the multi-source perception framework.
Overall, the model results highlight urban economic attributes, safety accessibility, and population density as the key variables shaping residents’ spatial safety-hazard experiences. Moreover, they validate the effectiveness of integrating multi-source spatial data with machine learning for urban safety-hazard modeling. These findings offer both data support and theoretical grounding for identifying and intervening in high-risk urban spaces.

4.2. Two-Dimensional Partial Dependence Analysis: Synergistic Mechanisms of Built Environment Features

To further reveal the nonlinear coupling relationships among different built-environment elements, this study selected the top seven core variables based on the feature-importance ranking (Figure 5). Following the principle of covering key urban dimensions such as transportation systems, socio-economic attributes, visual perception, and public services, six pairs of representative variables were constructed for a two-dimensional partial dependence plot (2D PDP) analysis. This allowed systematic exploration of synergistic gains, marginal effects, and resource-allocation thresholds of built-environment factors, with the aim of providing quantitative support for the prevention and optimization of urban safety hazards.
Road Traffic × Intersection Density.
Road traffic intensity reflects the transport load of an area, while intersection density measures the connectivity and diversion capacity of the road network. Their interaction illustrates a “mobility efficiency–pathway choice” mechanism: heavy traffic pressure requires high-density nodes for effective diversion; otherwise, congestion may occur, increasing safety-hazard risks. When road traffic exceeds 25 and intersection density falls below 50, the predicted safety-hazard score rises to about 0.015, indicating systemic safety-hazard risk from inadequate node support under high flow. By contrast, when intersection density increases to around 70–90 and traffic intensity remains moderate (10–15), the predicted safety-hazard score falls below 0.02, forming an optimized “medium flow + high node density” combination. Under extreme conditions (traffic > 25, node density > 90), the response curve flattens but remains slightly lower than in the high-flow, low-node scenario, reflecting diminishing marginal returns.
Average Housing Price × Distance to Nearest Police Station.
Average housing price serves as a proxy for socio-economic capital, while distance to the nearest police station represents the accessibility of safety resources. This pairing reflects the spatial coupling of “economic value–safety provision.” Results show that high-value areas lacking corresponding safety services are more prone to safety hazards. When police distance exceeds 12,000 m, even housing prices above 9000 yield predicted values around 0.02–0.03, suggesting that the absence of safety services weakens locational advantages. Conversely, when housing prices are between 8000 and 10,000 and police distance shortens to 5000–7000 m, predicted safety-hazard scores fall below 0.075, reflecting the synergistic “high value–high safety” effect. Once the distance to police stations drops below 3000 m, further reductions in safety-hazard scores plateau, revealing a rational threshold for safety-resource allocation, beyond which excessive density provides no additional benefit.
Average Population × Road Traffic.
Average population density represents baseline travel demand, while road traffic intensity reflects supply capacity. Their interaction evaluates the dynamic “population pressure–transport capacity” relationship, revealing how the supply–demand balance between infrastructure and aggregation shapes safety-hazard outcomes. When high population density (>12,000) combines with high traffic load (>25), predicted safety-hazard scores exceed 0.01, signaling systemic bottlenecks. The optimal balance occurs with a population of around 8000–10,000 and a traffic intensity of 10–15, reducing predicted values below 0.03. At low population levels (<5000), expansions in road capacity yield limited reduction in safety hazards, underscoring the importance of demand-side effects.
Average Color Count × Average Edge Detection.
Color count reflects visual richness, while edge-detection values capture spatial texture complexity. Their interaction reflects the relationship between “visual stimulus–cognitive load” and safety hazards: moderate complexity mitigates the insecurity caused by monotony, while excessive texture may generate distraction and risk. When the color count is <800 and edge values exceed 0.12, predicted safety-hazard scores rise above 0.02, indicating that mismatched monotony and high texture increase safety-hazard risk. With richer colors (>1200) and moderate edge values (0.08–0.10), the lowest safety-hazard responses approach 0.035, forming the optimal low-risk zone. Once edge values exceed 0.15, additional colors fail to reduce safety hazards further, indicating saturation in visual complexity.
Intersection Density × Average Color Count.
Intersections, as spatial nodes, influence pedestrian aggregation and interaction probabilities, while color diversity enhances visual appeal and may mitigate environmental safety hazards. Their interaction reflects a “node vitality–visual anchor” synergy. When intersection density exceeds 80 but color count remains below 1000, predicted safety-hazard scores remain around 0.015, showing that isolated nodes cannot generate sufficient attraction and may increase safety-hazard risks. At intermediate densities (60–80) with color counts of 1200–1400, safety-hazard scores drop below 0.025, verifying the combined effect of “nodes + visuals” in hazard reduction. Beyond 1500 colors, the improvement effect plateaus, with only slight further reductions, cautioning against visual overload.
Distance to Nearest Police Station × Average Population.
The distance to police stations reflects the accessibility of safety services, while population density determines demand intensity. This combination evaluates how “resource efficiency–service equity” influences safety-hazard prevention. When population exceeds 14,000 and police distance exceeds 10,000 m, predicted safety-hazard scores rise above 0.02, showing that inadequate safety coverage leads to elevated safety-hazard risks. The optimal zone occurs at population levels of 8000–12,000 with police distance of 4000–6000 m, where safety-hazard scores fall below 0.06. In low-density areas (<6000), variations in police distance have limited influence on safety-hazard levels, supporting prioritization of resource allocation based on population density.
Taken together, these six variable pairs—covering multiple dimensions and guided by both XGBoost importance rankings and urban planning theory—maximize the revelation of nonlinear interaction effects between key factors. The visualized results from 2D PDP analysis provide intuitive and interpretable quantitative evidence to inform urban design and decision-making.

4.3. SHAP-Based Global Interpretability

Figure 6 presents the SHAP global explanation results based on the XGBoost model, including the ranking of built-environment features in terms of their importance to urban safety-hazard predictions, as well as the distribution of their influence direction and intensity on the model outputs. The results are analyzed from two perspectives: feature importance and influence trends.
From the bar chart of mean absolute SHAP values (Figure 6), it is clear that average housing price has the highest mean SHAP value, indicating that the model is most sensitive to variations in residential cost with respect to residents’ perceived safety. Distance to the nearest police station ranks second, suggesting that accessibility of policing facilities also has a significant impact on safety-hazard evaluation. Other indicators of relatively high importance include average population density, road traffic features, and average color count, reflecting the combined influence of population distribution, transport accessibility, and the visual environment on residents’ perception of urban safety hazards. The importance of the remaining features decreases in sequence. While these features still provide auxiliary contributions to the overall model predictions, their relative effects are weaker. Collectively, the evaluation highlights residential cost and spatial distribution of policing facilities as the core determinants of urban safety hazards, followed by population density, transportation network elements (e.g., road traffic, number of intersections, bus stops), and visual attributes (e.g., average color count, edge detection, scene depth, color contrast); while factors such as functional land-use mix play relatively minor roles.
On the scatter plots of SHAP values (Figure 7), color gradients represent each feature’s contribution across its range of values: blue dots for low feature values and red dots for high feature values. For the average housing price, most red points fall on the positive side, suggesting that higher housing prices are generally associated with higher safety-hazard scores—that is, residents tend to link high-cost housing areas with better residential environments, stronger security management, and more stable social order. Conversely, blue points (low housing prices) are mostly associated with negative contributions, implying that low-price areas are more likely to correspond to lower safety-hazard scores in the model. For distance to the nearest police station, high values (i.e., longer distances) are mainly blue and skew negative, while low values (shorter distances) are red and positive. This indicates that closer proximity to policing facilities makes a significant positive contribution to perceived safety—districts with higher police coverage density are more likely to foster improved safety-hazard perception. For bus-stop density, high-density areas generally yield positive SHAP values, showing that more concentrated public transport nodes increase residents’ perceptions of accessibility, vitality, and potential safety hazards. By contrast, low-density (blue) regions reduce safety-hazard scores. Similarly, average color count and average scene depth tend to fall in the positive SHAP-value range at higher values, suggesting that visual diversity and spatial layering enhance street-scene attractiveness and strengthen perceived safety. For road traffic density, however, some high-value (red) points fall into the negative range, implying that excessive traffic pressure may reduce residents’ sense of safety. Streetlight count and road intersections exhibit slight positive contributions at higher values, suggesting that improved night lighting and greater accessibility through node distribution modestly enhance safety-hazard perception. Other features, such as POI functional diversity, alcohol-sales outlet density, color contrast, and average edge detection, show point clouds clustered near zero, indicating minimal or unstable effects on model outputs.
Figure 8 presents the feature-contribution heatmap based on SHAP values. From the figure, it can be observed that “average housing price” appears as deep red in most samples, indicating a significant positive contribution to safety-hazard evaluation and serving as the strongest driver of the overall model output. This suggests that higher housing prices are often associated with stronger perceived safety, possibly reflecting the role of better living environments and supporting facilities in enhancing residents’ sense of security. The “distance to the nearest police station” follows closely, exhibiting an alternating pattern of deep red and deep blue across many samples. This indicates a complex influence: greater distances from police facilities may weaken residents’ sense of perceived safety, while closer deployments may reinforce safety-hazard perception. Thus, this variable makes a substantial contribution to safety-hazard evaluation as well. The “average population” variable displays relatively darker shades in certain samples, suggesting that population density exerts a moderating effect on safety-hazard outcomes in specific areas. By contrast, transportation and lighting-related indicators such as “road traffic,” “number of intersections,” and “streetlight count” generally appear in lighter colors, implying weaker overall effects, though notable contributions can still be found in localized samples. Visual-related variables such as “average color count,” “average color contrast,” and “average scene depth” also show mostly light shading, reflecting limited explanatory power in the model. Nevertheless, they do produce certain positive or negative fluctuations in specific instances. Additionally, “POI functional diversity” and “number of alcohol outlets” appear relatively uniform and faint across the heatmap, suggesting only minor overall effects, though they may hold localized significance under particular conditions. In sum, the heatmap provides an intuitive representation of how different built-environment features influence safety-hazard predictions. It highlights both the dominant drivers and the more localized, context-dependent effects, offering valuable insights into the underlying logic of the model and the relationship between urban spatial features and safety-hazard outcomes.

4.4. Local Interpretability

To reveal the local driving factors behind the differences in predicted scores of urban spatial safety hazards across different neighborhoods, this study selected six representative grid cells and conducted local interpretation and analysis of each sample’s prediction results using SHAP values. Specifically, grid cells (No. 30, 195, 211, 499, 530, and 587) were selected, and force plots (Figure 9) were generated to display only the top eight features with the highest SHAP values for each sample, with feature values retained to three decimal places.
The results indicate that variables such as population density, road traffic intensity, and intersection density generally exert significant positive effects on safety-hazard scores, while factors such as average housing price and the distribution of police stations act as negative constraints in most samples. Moreover, certain visual perception features (e.g., average scene depth, color count, and edge detection) also exert differentiated impacts at the neighborhood level: when streetscapes appear enclosed or cluttered, safety-hazard tendencies are significantly amplified, whereas higher visual openness and environmental cleanliness help mitigate hazards. It is noteworthy that the direction and magnitude of variable effects vary spatially across grid cells. For instance, in densely populated areas, the combined effect of average population and traffic intensity markedly increases safety-hazard levels, whereas in areas with higher housing prices and adequate police coverage, the impact of these adverse factors is substantially diminished. Overall, the local interpretation results confirm the model’s comprehensive sensitivity to built environment and perception indicators, highlighting the dominant role of population, traffic, and physical environment in hazard formation, while also revealing the moderating value of economic level and public safety facilities in risk mitigation. This suggests that the spatial distribution of urban safety hazards is not driven by a single factor, but rather the outcome of interactions among multiple factors, thereby underscoring the importance of differentiated governance and targeted interventions at the micro-spatial scale.
Figure 10 illustrates the SHAP local explanation curves for six representative grid cells, while Figure 11 presents the SHAP value distribution for all 584 grid cells across the study area. By jointly examining the local and global perspectives, the comparison of feature contribution directions and magnitudes reveals the multiple driving pathways and regional heterogeneity of urban spatial safety hazards.
This analysis underscores the differentiated safety-hazard outcomes associated with built environment characteristics across various types of neighborhoods, thereby providing quantitative evidence to support hazard prevention and spatial governance at the grid-cell scale.

4.5. Interaction Effects Analysis

To further enhance the intuitiveness of the interaction effects analysis, Figure 12 and Figure 13 present case-based demonstrations of typical 800 m × 800 m grid cells. Figure 12 illustrates the spatial distribution of seven core factors identified in the interaction analysis, together with representative street view images of corresponding grid cells. These examples highlight the heterogeneity of built environment features across different urban areas. By visually inspecting the street-level imagery, one can directly observe how elements such as road traffic intensity, intersection density, population density, and average housing price are manifested in spatial patterns, thereby providing perceptual support for the subsequent SHAP-based quantitative interaction analysis.
Figure 13 further deconstructs the representative grid cells through semantic segmentation of street view imagery, illustrating how visual complexity features such as “average color count” and “average edge density” are reflected in real street environments. The results show that differences in the proportions of vegetation, buildings, and roads among grids directly shape the structure of visual information, which in turn produces distinct nonlinear interaction effects in predicting safety hazards. This case-based illustration not only supplements the numerical findings but also helps elucidate the mechanisms by which visual environmental features interact with spatial structural factors.
On this basis, Figure 14 presents SHAP dependence plots for pairwise combinations of key built environment features, visually revealing how synergistic effects and mutual constraints jointly shape safety-hazard predictions at the grid-cell level. Through in-depth analysis of six representative variable interactions, this study identifies a series of characteristic nonlinear coupling patterns.
For the interaction between average housing price and distance to the nearest police station, we find that when housing prices fall within 6000–8000 PLN/m2 and the nearest police station is located within 12 km, SHAP values increase significantly. This indicates that moderately high residential costs, combined with favorable accessibility to policing facilities, jointly enhance residents’ perceived safety in the built environment. Conversely, when housing prices are below 7000 PLN/m2 and policing facilities are far away, SHAP values shift negative, reflecting a marked decline in safety perception.
The interaction between distance to the nearest police station and average population density reveals a collaborative mechanism between spatial accessibility and population concentration. As police-station distance gradually increases within 0–10 km, SHAP values also rise, particularly in areas with a population density greater than 4000 residents, underscoring the importance of policing facilities in densely populated zones. However, when police-station distance exceeds 10 km and population density drops below 4000, SHAP values sharply decline, suggesting that sparsely populated areas rely more heavily on policing service radii.
The third analysis examines average population and road traffic intensity. Within the range of 2000–15,000 residents, SHAP values exhibit an overall positive trend regardless of traffic intensity, peaking at around 4000 residents before gradually leveling off or declining. When population density surpasses 15,000 and traffic intensity falls between 15 and 25, SHAP values decrease to approximately −3 to −4, indicating that the combination of high population density and strong traffic load may exacerbate safety hazards.
For road traffic intensity and intersection density, their synergistic relationship appears as follows: when road traffic does not exceed 10 and the number of intersections is fewer than 20, SHAP values are slightly positive, but the overall impact remains negative. As traffic intensity rises above 15 and intersections reach 20–30, SHAP values approach neutrality. Beyond these thresholds, with further increases in both variables, SHAP values continue to rise, suggesting that a denser traffic network, once a certain threshold is crossed, positively contributes to perceived safety—possibly due to improved traffic order and stronger spatial control.
The interaction between intersection density and average color count shows that when intersections equal zero, an increase in color richness elevates SHAP values slowly from about −0.2 to 0. As intersection density increases simultaneously, when color counts range between 1250 and 1750, SHAP values shift firmly into positive territory, indicating that rich visual landscapes in traffic-node-dense areas help enhance urban safety perception.
The interaction between average color count and average edge-detection value reveals the nonlinear impact of urban visual complexity. When the color count is near zero, edge-detection values exert a slightly positive SHAP contribution. Within the color count range of 1000–1500, edge-detection values clustering around 0.08–0.16 significantly boost SHAP values in a positive direction. However, as the color count exceeds 1500, SHAP values gradually turn negative, suggesting that overly complex or visually overloaded streetscapes may induce discomfort, thereby weakening residents’ sense of safety.
In sum, the SHAP dependence plots systematically uncover the nonlinear structural effects of the built environment on safety-hazard predictions. Housing costs, policing accessibility, and population density collectively form the foundational core of safety perception, while traffic density, street intersections, and visual features exhibit strong enhancing or suppressing effects under different thresholds. These interaction patterns not only reflect the dynamic coupling and nonlinear characteristics of urban variables but also emphasize that the “intermediate ranges” of feature values are often the critical nodes where synergistic benefits emerge.
This implies that reducing urban safety hazards should not rely solely on maximizing a single dimension, but rather on achieving organic coordination and structural balance across multiple built-environment factors. The findings provide a data-driven, scientific basis for urban governance and spatial design, supporting the implementation of fine-grained and multi-scalar strategies for optimizing urban safety.
This chapter, through feature-importance evaluation, two-dimensional partial dependence analysis, global and local SHAP interpretability, and interaction-effect analysis, systematically reveals the multidimensional mechanisms by which built-environment factors influence the prediction of urban safety-hazard predictions. The results demonstrate that average housing price, distance to the nearest police station, and average population density serve as the core driving factors of safety hazards; meanwhile, transportation structures and visual landscapes also exert important synergistic effects under specific conditions, with particularly notable benefits emerging within intermediate threshold ranges. These findings not only enrich the understanding of the spatial mechanisms underlying safety-hazard distribution but also provide valuable data support for policy formulation and planning interventions.

5. Discussion

5.1. Summary of Findings

This study demonstrates that urban safety hazards are not determined by a single factor but by the joint influence of multiple dimensions, including economic attributes, security accessibility, population density, transportation structures, and visual environments. Among these, average housing price, distance to the nearest police station, and average population density emerged as the most critical variables.
PDP and SHAP interaction analyses revealed that optimal safety perception often occurs within moderate thresholds. For example, “moderate traffic flow + high intersection density,” “medium-to-high housing price + moderate police coverage,” and “rich color + moderate texture complexity” produced strong positive effects. Extreme conditions, by contrast—such as high flow with low connectivity, high housing cost with distant policing, or high density with congestion—reduced safety perception and showed diminishing or negative marginal effects.
Although visual perception variables ranked lower in global importance, they contributed synergistic gains in specific ranges, reflecting the multidimensional and nonlinear nature of urban safety mechanisms.
Despite variations in the causes and outcomes of the analyzed safety hazards, the findings hold clear practical significance. By identifying shared spatial patterns and threshold effects—such as the impacts of population density, policing accessibility, and traffic intensity—this study demonstrates that diverse urban risks are shaped by a limited set of built-environment determinants. These results provide policymakers with generalizable, evidence-based principles to formulate integrated strategies that can simultaneously mitigate multiple safety hazards, thereby enhancing urban resilience and sustainability.

5.2. Policy Implications for Urban Development

While each category of safety hazard has distinct characteristics, their spatial distributions are governed by common environmental mechanisms. Policymakers therefore need not treat each hazard type in isolation; instead, they can regulate shared structural conditions—for example, improving police accessibility in high-density zones or optimizing traffic management in congested areas—to simultaneously reduce diverse safety risks.
Unlike earlier studies that focused on isolated variables, our results highlight the importance of dynamic coupling and nonlinear interactions across dimensions. For policymakers, this implies that extreme one-dimensional interventions may not always be effective. Instead, balanced, coordinated, and threshold-oriented strategies are required. For instance, prioritizing police deployment in high-population areas is more impactful than in low-density zones; increasing intersection density is effective in moderate-to-high traffic contexts but less so in extreme conditions. Streetscape design should aim for richness without visual overload, ensuring a sense of comfort and order.
Moreover, SHAP enhances model transparency and interpretability, enabling both experts and non-experts to understand variable contributions to safety-hazard evaluation and facilitating data-driven, evidence-based policy design.
Finally, these insights underscore that urban safety serves as a cornerstone of sustainable development. Improving perceived safety reinforces the social, economic, and environmental pillars of sustainability—strengthening community cohesion, attracting investment, and promoting environmentally sound design. Thus, effective safety-hazard governance contributes directly to the triple bottom line of sustainability and should be embedded in broader urban development strategies.

5.3. Methodological Contributions

This study contributes methodologically in several ways:
  • By integrating economic, demographic, transportation, and visual features, it breaks away from single-source data limitations in safety-hazard evaluation.
  • By combining XGBoost with SHAP, it achieves both predictive accuracy and interpretability, capturing nonlinear interactions while clarifying variable effects on urban safety risks.
  • By applying 2D PDP and SHAP interaction plots, it identifies cooperative mechanisms and threshold effects, offering quantifiable references for spatial governance of safety hazards.
These methods provide scalable tools not only for macro-level planning but also for micro-level safety-hazard governance.

5.4. Limitations and Future Work

Several limitations remain. First, NSTM crowdsourced data may suffer from reporting bias, as perceived safety depends on individual cognition and digital access. Second, safety-hazard measurement relies on model-based predictions rather than large-scale resident surveys, suggesting a need for cross-validation with subjective data sources such as questionnaires or social media. Third, while our feature set covers economic, demographic, transport, and visual dimensions, it omits certain socio-demographic and cultural variables that may also play an important role in shaping safety perceptions, such as the share of migrants, religiosity, residents’ income levels, and the average age of the population. The absence of these variables is primarily due to current data limitations, but we are in communication with Statistics Poland to obtain access for future integration. Finally, though XGBoost with SHAP provides strong interpretability, different algorithms may yield variations. Future work could explore interpretable deep learning models or causal inference approaches. Overall, this study lays a methodological foundation for modeling urban safety hazards, while highlighting the need for more dynamic, integrated, and multi-method approaches to enhance policy relevance and to support sustainable urban development.

5.5. Ethical Considerations

The use of crowdsourced data and machine learning in urban safety-hazard research raises important ethical concerns. First, privacy and data protection must be safeguarded, as georeferenced reports may inadvertently reveal sensitive information about individuals or communities. Anonymization, data aggregation, and strict compliance with data protection regulations (e.g., GDPR in the European context) are essential to mitigate these risks. Second, crowdsourced data often reflect uneven participation, with disadvantaged groups potentially underrepresented due to limited digital access. This raises concerns of algorithmic bias, whereby safety-hazard governance strategies could unintentionally privilege certain populations while neglecting others. Third, the interpretability of machine learning models, while advanced by SHAP, must be communicated responsibly to non-expert stakeholders to avoid misinterpretation or overreliance on safety-hazard predictions. Addressing these ethical challenges requires transparency in data use, inclusivity in data collection, and accountability in applying predictive models for policy decisions.

6. Conclusions

Based on multi-source built environment data, this study constructed and validated an urban safety hazard evaluation model integrating XGBoost and SHAP interpretability analysis. From dimensions of economic attributes, policing accessibility, population density, transportation structures, and visual landscapes, it systematically identified the key drivers of safety hazards and their nonlinear interactions.
The results show that average housing price, distance to the nearest police station, and average population density are the core determinants of safety-hazard variation. Importantly, many variables exhibited cooperative effects within mid-range thresholds—such as moderate traffic with high intersection density or high housing value with sufficient police coverage—indicating that hazards can be reduced most effectively through balanced interventions rather than extreme one-dimensional policies.
This research demonstrates that combining machine learning with interpretability analysis enables fine-grained, transparent assessment of the built environment–safety relationship. The findings not only enrich theoretical understanding of urban safety mechanisms but also provide quantitative, actionable guidance for governance and spatial planning.
In practice, the proposed approach offers feasible pathways for policymakers to design targeted interventions and optimize resource allocation under limited budgets. Beyond safety-hazard governance, the framework also highlights the potential of integrating crowdsourced data with explainable AI in broader urban research fields. Taken together, the study underscores that urban safety is a core dimension of sustainable urban development, directly linking the findings to the mission of Sustainability and contributing to data-driven, people-centered urban governance.
Despite the diversity of safety hazards examined, the integrative analytical framework proposed in this study captures their underlying commonalities, providing a transferable and generalizable tool for evidence-based urban safety-hazard management.
Viewed through the lens of sustainability, urban safety emerges as a cornerstone of sustainable urban development—enhancing social trust, improving residents’ well-being, and strengthening urban resilience. By embedding explainable machine learning within the sustainable city framework, the study contributes to the broader vision of creating inclusive, resilient, and sustainable urban environments, as outlined in the United Nations Sustainable Development Goal 11.

Author Contributions

Conceptualization, Z.W. and C.W.; Methodology, Z.W.; Validation, L.W.; Formal analysis, Z.W. and C.W.; Investigation, L.W.; Data curation, Z.W.; Writing—original draft, Z.W. and L.W.; Writing—review & editing, Z.W. and L.W.; Supervision, C.W. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Institutional Review Board Statement

Not applicable.

Informed Consent Statement

Not applicable.

Data Availability Statement

The data presented in this study are available on request from the corresponding author.

Conflicts of Interest

The authors declare no conflict of interest.

Nomenclature

DNPSDistance to Nearest Police StationAPAverage Population
PMPOI Functional MixNSNumber of Streetlights
ASPAlcohol Sales PointAEDAverage Edge Detection
AHPAverage Housing PriceASDAverage Scene Depth
RTIRoad Traffic IntensityACCAverage Color Contrast
INDIntersection DensityANCAverage Number of Colors
BSBus Stop

References

  1. United Nations. Transforming Our World the 2030 Agenda for Sustainable Development. 2015. Available online: https://sdgs.un.org/2030agenda (accessed on 15 August 2025).
  2. Coaffee, J. Urban Resilience, Planning, Environment, Cities, 1st ed.; Bloomsbury Publishing: London, UK, 2017; ISBN 978-1-137-28882-0. [Google Scholar]
  3. United Nations. Human Settlements Programme World Cities Report 2016: Urbanization and Development—Emerging Futures. 2016. Available online: https://unhabitat.org/world-cities-report-2016 (accessed on 15 August 2025).
  4. Ellis, W.R.; Newman, O. Defensible Space: Crime Prevention through Urban Design. J. Archit. Educ. 1973, 27, 11. [Google Scholar] [CrossRef]
  5. Cohen, L.E.; Felson, M. Social Change and Crime Rate Trends: A Routine Activity Approach. Am. Sociol. Rev. 1979, 44, 588. [Google Scholar] [CrossRef]
  6. Brantingham, P.L.; Brantingham, P.J. Environment, Routine, and Situation: Toward a Pattern Theory of Crime; Routledge: Abingdon, UK, 1993. [Google Scholar]
  7. Wilson, J.Q.; Kelling, G.L. Broken Windows: The Police and Neighborhood Safety. Atl. Mon. 1982, 249, 29–36. [Google Scholar]
  8. Goodchild, M.F. Citizens as Sensors: The World of Volunteered Geography. GeoJournal 2007, 69, 211–221. [Google Scholar] [CrossRef]
  9. Shelton, T.; Poorthuis, A.; Zook, M. Social Media and the City: Rethinking Urban Socio-Spatial Inequality Using User-Generated Geographic Information. Landsc. Urban Plan. 2015, 142, 198–211. [Google Scholar] [CrossRef]
  10. See, L.; Comber, A.; Salk, C.; Fritz, S.; Van Der Velde, M.; Perger, C.; Schill, C.; McCallum, I.; Kraxner, F.; Obersteiner, M. Comparing the Quality of Crowdsourced Data Contributed by Expert and Non-Experts. PLoS ONE 2013, 8, e69958. [Google Scholar] [CrossRef]
  11. See, L.; Mooney, P.; Foody, G.; Bastin, L.; Comber, A.; Estima, J.; Fritz, S.; Kerle, N.; Jiang, B.; Laakso, M.; et al. Crowdsourcing, Citizen Science or Volunteered Geographic Information? The Current State of Crowdsourced Geographic Information. IJGI 2016, 5, 55. [Google Scholar] [CrossRef]
  12. Haklay, M. Citizen Science and Volunteered Geographic Information: Overview and Typology of Participation. In Crowdsourcing Geographic Knowledge; Sui, D., Elwood, S., Goodchild, M., Eds.; Springer Netherlands: Dordrecht, The Netherlands, 2013; pp. 105–122. ISBN 978-94-007-4586-5. [Google Scholar]
  13. Sampson, R.J.; Raudenbush, S.W. Systematic Social Observation of Public Spaces: A New Look at Disorder in Urban Neighborhoods. Am. J. Sociol. 1999, 105, 603–651. [Google Scholar] [CrossRef]
  14. Brayne, S. Predict and Surveil: Data, Discretion, and the Future of Policing; Oxford University Press: New York, NY, USA, 2021; ISBN 978-0-19-068409-9. [Google Scholar]
  15. Groff, E.R.; Lockwood, B. Criminogenic Facilities and Crime across Street Segments in Philadelphia: Uncovering Evidence about the Spatial Extent of Facility Influence. J. Res. Crime Delinq. 2014, 51, 277–314. [Google Scholar] [CrossRef]
  16. Mandalapu, V.; Elluri, L.; Vyas, P.; Roy, N. Crime Prediction Using Machine Learning and Deep Learning: A Systematic Review and Future Directions. IEEE Access 2023, 11, 60153–60170. [Google Scholar] [CrossRef]
  17. Solymosi, R.; Bowers, K.J.; Fujiyama, T. Crowdsourcing Subjective Perceptions of Neighbourhood Disorder: Interpreting Bias in Open Data. Br. J. Criminol. 2018, 58, 944–967. [Google Scholar] [CrossRef]
  18. Cozens, P.; Love, T. A Review and Current Status of Crime Prevention through Environmental Design (CPTED). J. Plan. Lit. 2015, 30, 393–412. [Google Scholar] [CrossRef]
  19. Kuo, F.E.; Sullivan, W.C. Environment and Crime in the Inner City: Does Vegetation Reduce Crime? Environ. Behav. 2001, 33, 343–367. [Google Scholar] [CrossRef]
  20. Shepley, M.M.; Sachs, N.A.; Sadatsafavi, H.; Fournier, C.; Peditto, K. The Impact of Green Space on Violent Crime in Urban Environments: An Evidence Synthesis. Int. J. Environ. Res. Public Health 2019, 16, 5119. [Google Scholar] [CrossRef]
  21. Branas, C.C.; South, E.; Kondo, M.C.; Hohl, B.C.; Bourgois, P.; Wiebe, D.J.; MacDonald, J.M. Citywide Cluster Randomized Trial to Restore Blighted Vacant Land and Its Effects on Violence, Crime, and Fear. Proc. Natl. Acad. Sci. USA 2018, 115, 2946–2951. [Google Scholar] [CrossRef]
  22. Mouratidis, K. The Impact of Urban Tree Cover on Perceived Safety. Urban For. Urban Green. 2019, 44, 126434. [Google Scholar] [CrossRef]
  23. Jonescu, E.E.; Ramanayaka, C.E.; Olatunji, O.A.; Uylaki, T.J. Understanding the Impact of Urban Heat Islands on Crime: Insights from Temperature, Population Density, and Green Canopy Cover. Crime Sci. 2024, 13, 15. [Google Scholar] [CrossRef]
  24. Hipp, J.R.; Lee, S.; Ki, D.; Kim, J.H. Measuring the Built Environment with Google Street View and Machine Learning: Consequences for Crime on Street Segments. J. Quant. Criminol. 2022, 38, 537–565. [Google Scholar] [CrossRef]
  25. Sypion-Dutkowska, N.; Leitner, M. Land Use Influencing the Spatial Distribution of Urban Crime: A Case Study of Szczecin, Poland. IJGI 2017, 6, 74. [Google Scholar] [CrossRef]
  26. Navarrete-Hernandez, P.; Luneke, A.; Truffello, R.; Fuentes, L. Planning for Fear of Crime Reduction: Assessing the Impact of Public Space Regeneration on Safety Perceptions in Deprived Neighborhoods. Landsc. Urban Plan. 2023, 237, 104809. [Google Scholar] [CrossRef]
  27. Senna, I.; Iglesias, F.; Matsunaga, L.H. Measuring the Effects of Crime Prevention through Environmental Design (CPTED) on Fear of Crime in Public Spaces. Crime Prev. Community Saf. 2025, 27, 1–17. [Google Scholar] [CrossRef]
  28. Zhang, F. “Perception Bias”: Deciphering a Mismatch between Urban Crime and Perception of Safety. Landsc. Urban Plan. 2021, 14, 104003. [Google Scholar] [CrossRef]
  29. Naik, N.; Philipoom, J.; Raskar, R.; Hidalgo, C. Streetscore—Predicting the Perceived Safety of One Million Streetscapes. In Proceedings of the 2014 IEEE Conference on Computer Vision and Pattern Recognition Workshops, Columbus, OH, USA, 23–28 June 2014; pp. 793–799. [Google Scholar]
  30. Dubey, A.; Naik, N.; Parikh, D.; Raskar, R.; Hidalgo, C.A. Deep Learning the City: Quantifying Urban Perception at a Global Scale. In Proceedings of the European Conference on Computer Vision, Amsterdam, The Netherlands, 11–14 October 2016; pp. 196–212. [Google Scholar]
  31. Cui, Q.; Zhang, Y.; Yang, G.; Huang, Y.; Chen, Y. Analysing Gender Differences in the Perceived Safety from Street View Imagery. Int. J. Appl. Earth Obs. Geoinf. 2023, 124, 103537. [Google Scholar] [CrossRef]
  32. Acosta, S.F.; Camargo, J.E. Predicting City Safety Perception Based on Visual Image Content. In Progress in Pattern Recognition, Image Analysis, Computer Vision, and Applications; Vera-Rodriguez, R., Fierrez, J., Morales, A., Eds.; Lecture Notes in Computer Science; Springer International Publishing: Cham, Switzerland, 2019; Volume 11401, pp. 177–185. ISBN 978-3-030-13468-6. [Google Scholar]
  33. Acosta, S.F.; Camargo, J.E. City Safety Perception Model Based on Visual Content of Street Images. In Proceedings of the 2018 IEEE International Smart Cities Conference (ISC2), Kansas City, MO, USA, 16–19 September 2018; pp. 1–8. [Google Scholar]
  34. Wang, R.; Yuan, Y.; Liu, Y.; Zhang, J.; Liu, P.; Lu, Y.; Yao, Y. Using Street View Data and Machine Learning to Assess How Perception of Neighborhood Safety Influences Urban Residents’ Mental Health. Health Place 2019, 59, 102186. [Google Scholar] [CrossRef]
  35. Li, B.; Li, G.; Lan, L.; Jin, A.; Lin, Z.; Wang, Y.; Chen, X. The Influence Mechanism of Urban Street Environment on Juvenile Delinquency Based on Multi-Source Data Fusion: A Case Study of Manhattan, New York. Comput. Urban Sci. 2024, 4, 26. [Google Scholar] [CrossRef]
  36. Fan, Z.; Zhang, F.; Loo, B.P.Y.; Ratti, C. Urban Visual Intelligence: Uncovering Hidden City Profiles with Street View Images. Proc. Natl. Acad. Sci. USA 2023, 120, e2220417120. [Google Scholar] [CrossRef] [PubMed]
  37. Zhang, J.; Li, Y.; Fukuda, T.; Wang, B. Urban Safety Perception Assessments via Integrating Multimodal Large Language Models with Street View Images. Cities 2025, 165, 106122. [Google Scholar] [CrossRef]
  38. He, Z.; Gu, Y.; Gong, Y.; Wu, L.; Zhou, M. Analyzing the Joint Influence of Urban Facilities and Street Perception Characteristics on Street Robbery. J. Geovisualization Spat. Anal. 2025, 9, 22. [Google Scholar] [CrossRef]
  39. Qi, Z.; Luo, H.; Chi, C. Eyes on the Streets: Leveraging Street-Level Imaging to Model Urban Crime Dynamics. arXiv 2024, arXiv:2404.10147. [Google Scholar] [CrossRef]
  40. Yao, Y.; Dong, A.; Liu, Z.; Jiang, Y.; Guo, Z.; Cheng, J.; Guan, Q.; Luo, P. Extracting the Pickpocketing Information Implied in the Built Environment by Treating It as the Anomalies. Cities 2023, 143, 104575. [Google Scholar] [CrossRef]
  41. Zhou, H.; Liu, L.; Lan, M.; Zhu, W.; Song, G.; Jing, F.; Zhong, Y.; Su, Z.; Gu, X. Using Google Street View Imagery to Capture Micro Built Environment Characteristics in Drug Places, Compared with Street Robbery. Comput. Environ. Urban Syst. 2021, 88, 101631. [Google Scholar] [CrossRef]
  42. Evans, J.; Karvonen, A. ‘Give Me a Laboratory and I Will Lower Your Carbon Footprint!’—Urban Laboratories and the Governance of Low-carbon Futures. Int. J. Urban Reg. Res. 2013, 38, 413–430. [Google Scholar] [CrossRef]
  43. Wheeler, A.P. The Effect of 311 Calls for Service on Crime in D.C. at Microplaces. Crime Delinq. 2018, 64, 1882–1903. [Google Scholar] [CrossRef]
  44. Zhou, H.; Wang, J.; Wilson, K.; Widener, M.; Wu, D.Y.; Xu, E. Using Street View Imagery and Localized Crowdsourcing Survey to Model Perceived Safety of the Visual Built Environment by Gender. Int. J. Appl. Earth Obs. Geoinf. 2025, 139, 104421. [Google Scholar] [CrossRef]
  45. Chaves, R.; Schneider, D.; Correia, A.; Motta, C.L.R.; Borges, M.R.S. Crowdsourcing as a Tool for Urban Emergency Management: Lessons from the Literature and Typology. Sensors 2019, 19, 5235. [Google Scholar] [CrossRef]
  46. Biljecki, F.; Ito, K. Street View Imagery in Urban Analytics and GIS: A Review. Landsc. Urban Plan. 2021, 215, 104217. [Google Scholar] [CrossRef]
  47. Polończyk, A.; Leśniak, A. Mapping Public Order Offenses: A Study of the Spatial Distribution of Perceived Risk Intensity in the City of Krakow, Poland. Cartogr. Geogr. Inf. Sci. 2020, 47, 171–191. [Google Scholar] [CrossRef]
  48. Kontokosta, C.; Hong, B.; Korsberg, K. Equity in 311 Reporting: Understanding Socio-Spatial Differentials in the Propensity to Complain. arXiv 2017, arXiv:1710.02452. [Google Scholar] [CrossRef]
  49. Tang, F.; Zeng, P.; Wang, L.; Zhang, L.; Xu, W. Urban Perception Evaluation and Street Refinement Governance Supported by Street View Visual Elements Analysis. Remote Sens. 2024, 16, 3661. [Google Scholar] [CrossRef]
  50. Anselin, L.; Syabri, I.; Kho, Y. GeoDa: An Introduction to Spatial Data Analysis. Geogr. Anal. 2006, 38, 5–22. [Google Scholar] [CrossRef]
  51. Jenga, K.; Catal, C.; Kar, G. Machine Learning in Crime Prediction. J. Ambient Intell. Human Comput. 2023, 14, 2887–2913. [Google Scholar] [CrossRef]
  52. Mohler, G.O.; Short, M.B.; Brantingham, P.J.; Schoenberg, F.P.; Tita, G.E. Self-Exciting Point Process Modeling of Crime. J. Am. Stat. Assoc. 2011, 106, 100–108. [Google Scholar] [CrossRef]
  53. Dakin, K.; Xie, W.; Parkinson, S.; Khan, S.; Monchuk, L.; Pease, K. Built Environment Attributes and Crime: An Automated Machine Learning Approach. Crime Sci. 2020, 9, 12. [Google Scholar] [CrossRef]
  54. Zubair, T.; Fatima, S.K.; Ahmed, N.; Khan, A. Crime Hotspot Prediction Using Deep Graph Convolutional Networks. arXiv 2025, arXiv:2506.13116. [Google Scholar] [CrossRef]
  55. Hou, M.; Hu, X.; Cai, J.; Han, X.; Yuan, S. An Integrated Graph Model for Spatial–Temporal Urban Crime Prediction Based on Attention Mechanism. IJGI 2022, 11, 294. [Google Scholar] [CrossRef]
  56. Amiruzzaman, M.; Curtis, A.; Zhao, Y.; Jamonnak, S.; Ye, X. Classifying Crime Places by Neighborhood Visual Appearance and Police Geonarratives: A Machine Learning Approach. J. Comput. Soc. Sci. 2021, 4, 813–837. [Google Scholar] [CrossRef]
  57. Zhang, X.; Liu, L.; Lan, M.; Song, G.; Xiao, L.; Chen, J. Interpretable Machine Learning Models for Crime Prediction. Comput. Environ. Urban Syst. 2022, 94, 101789. [Google Scholar] [CrossRef]
  58. Iqbal, N.; Hassan, A.; Waheed, T. AI-Driven Crime Prediction: A Systematic Literature Review. J. Comput. Soc. Sci. 2025, 8, 53. [Google Scholar] [CrossRef]
  59. Dakalbab, F.; Abu Talib, M.; Abu Waraga, O.; Bou Nassif, A.; Abbas, S.; Nasir, Q. Artificial Intelligence & Crime Prediction: A Systematic Literature Review. Soc. Sci. Humanit. Open 2022, 6, 100342. [Google Scholar] [CrossRef]
  60. Lundberg, S.M.; Lee, S.-I. A Unified Approach to Interpreting Model Predictions. arXiv 2017, arXiv:1705.07874. [Google Scholar] [CrossRef]
  61. Parsa, A.B.; Movahedi, A.; Taghipour, H.; Derrible, S.; Mohammadian, A.K. Toward Safer Highways, Application of XGBoost and SHAP for Real-Time Accident Detection and Feature Analysis. Accid. Anal. Prev. 2020, 136, 105405. [Google Scholar] [CrossRef] [PubMed]
  62. Fu, X.; Wang, M.; Zhang, D.; Chen, F.; Peng, X.; Wang, L.; Tan, S.K. An XGBoost-SHAP Framework for Identifying Key Drivers of Urban Flooding and Developing Targeted Mitigation Strategies. Ecol. Indic. 2025, 175, 113579. [Google Scholar] [CrossRef]
  63. Liu, J.; Cai, Y.; Shen, X. Integrating Machine Learning, SHAP Interpretability, and Deep Learning Approaches in the Study of Environmental and Economic Factors: A Case Study of Residential Segregation in Las Vegas. Land 2025, 14, 957. [Google Scholar] [CrossRef]
  64. Han, J.; Woo, A.; Lee, S. Effects of Neighborhood Streetscape on the Single-Family Housing Price: Focusing on Nonlinear and Interaction Effects Using Interpretable Machine Learning. PLoS ONE 2025, 20, e0323495. [Google Scholar] [CrossRef]
  65. Chen, T.; Bowers, K.; Cheng, T. The Impacts of Specific Place Visitations on Theft Patterns: A Case Study in Greater London, UK. Comput. Urban Sci. 2025, 5, 30. [Google Scholar] [CrossRef]
  66. Khalfa, R.; Theinert, N.; Hardyns, W. Comparing XAI Techniques for Interpreting Short-Term Burglary Predictions at Micro-Places. Comput. Urban Sci. 2025, 5, 27. [Google Scholar] [CrossRef]
  67. Yang, L.; Yang, H.; Cui, J.; Zhao, Y.; Gao, F. Non-Linear and Synergistic Effects of Built Environment Factors on Older Adults’ Walking Behavior: An Analysis Integrating LightGBM and SHAP. Trans. Urban Data Sci. Technol. 2024, 3, 46–60. [Google Scholar] [CrossRef]
  68. Polko, P.; Kimic, K. National Map of Security Threats as a Citizen Involvement Tool for Planning Safer Urban Public Spaces. Urban Plan. 2024, 9, 7156. [Google Scholar] [CrossRef]
Figure 1. Fishnet Data (1) Fishnet grids of 800 m × 800 m covering the Cracow area. (2) Visualization of safety hazard data overlaid on the fishnet grids. (3) Visualization of road traffic density data overlaid on the fishnet grids. (4) Visualization of POl functional mixture data overlaid on the fishnet grids.
Figure 1. Fishnet Data (1) Fishnet grids of 800 m × 800 m covering the Cracow area. (2) Visualization of safety hazard data overlaid on the fishnet grids. (3) Visualization of road traffic density data overlaid on the fishnet grids. (4) Visualization of POl functional mixture data overlaid on the fishnet grids.
Sustainability 17 09300 g001
Figure 2. Research framework of the study.
Figure 2. Research framework of the study.
Sustainability 17 09300 g002
Figure 3. Predicted scatter plot. This figure shows scatter plots of predicted safety hazard scores on the test set using different base regressors in AutoGluon. The red dashed line (y = x) indicates ideal predictions, while the blue points show predicted versus actual values for each sample. The coefficient of determination (R2) is annotated in the upper-left corner to evaluate model fit.
Figure 3. Predicted scatter plot. This figure shows scatter plots of predicted safety hazard scores on the test set using different base regressors in AutoGluon. The red dashed line (y = x) indicates ideal predictions, while the blue points show predicted versus actual values for each sample. The coefficient of determination (R2) is annotated in the upper-left corner to evaluate model fit.
Sustainability 17 09300 g003
Figure 4. Feature importance.
Figure 4. Feature importance.
Sustainability 17 09300 g004
Figure 5. 2D PDP.
Figure 5. 2D PDP.
Sustainability 17 09300 g005
Figure 6. Bee swarm. The figure presents the global SHAP explanation derived from the XGBoost model, highlighting both the relative importance ranking of built-environment features for predicting urban safety hazards and the distribution of their directional and magnitude effects on the model’s outputs.
Figure 6. Bee swarm. The figure presents the global SHAP explanation derived from the XGBoost model, highlighting both the relative importance ranking of built-environment features for predicting urban safety hazards and the distribution of their directional and magnitude effects on the model’s outputs.
Sustainability 17 09300 g006
Figure 7. Mean absolute SHAP value. In the scatter plots of SHAP values shown in this figure, the color gradient illustrates the effect of each feature across its value spectrum, with blue indicating lower feature values and red indicating higher feature values.
Figure 7. Mean absolute SHAP value. In the scatter plots of SHAP values shown in this figure, the color gradient illustrates the effect of each feature across its value spectrum, with blue indicating lower feature values and red indicating higher feature values.
Sustainability 17 09300 g007
Figure 8. Heatmap. In the heatmap, each column represents a sample instance, each row corresponds to a built-environment variable influencing safety hazards, and the color indicates the direction and magnitude of its effect on the model output: red denotes a positive contribution, blue a negative one, and darker shades indicate stronger effects.
Figure 8. Heatmap. In the heatmap, each column represents a sample instance, each row corresponds to a built-environment variable influencing safety hazards, and the color indicates the direction and magnitude of its effect on the model output: red denotes a positive contribution, blue a negative one, and darker shades indicate stronger effects.
Sustainability 17 09300 g008
Figure 9. Force plot. This figure presents SHAP force plots for six representative grid cells, highlighting the top eight features contributing to each sample’s predicted safety hazard score. The results show that population density, road traffic intensity, and intersection density generally increase hazard levels, whereas average housing price and police station distribution often act as mitigating factors. Feature interactions vary across cells: in densely populated and high-traffic areas, the combined effects of population and traffic significantly elevate safety risks, while in high-value neighborhoods with sufficient policing, economic and public safety factors jointly reduce hazards, emphasizing the importance of differentiated governance at the micro-spatial scale.
Figure 9. Force plot. This figure presents SHAP force plots for six representative grid cells, highlighting the top eight features contributing to each sample’s predicted safety hazard score. The results show that population density, road traffic intensity, and intersection density generally increase hazard levels, whereas average housing price and police station distribution often act as mitigating factors. Feature interactions vary across cells: in densely populated and high-traffic areas, the combined effects of population and traffic significantly elevate safety risks, while in high-value neighborhoods with sufficient policing, economic and public safety factors jointly reduce hazards, emphasizing the importance of differentiated governance at the micro-spatial scale.
Sustainability 17 09300 g009aSustainability 17 09300 g009b
Figure 10. Local model-predicted urban perception score. This figure shows the SHAP local explanation curves for six representative grid cells, revealing how interactions among built-environment features jointly influence safety risk predictions, with variables such as population density, traffic intensity, and intersection density playing key roles at the local level.
Figure 10. Local model-predicted urban perception score. This figure shows the SHAP local explanation curves for six representative grid cells, revealing how interactions among built-environment features jointly influence safety risk predictions, with variables such as population density, traffic intensity, and intersection density playing key roles at the local level.
Sustainability 17 09300 g010
Figure 11. Global model-predicted urban perception score. This figure presents the SHAP value distribution for all 584 grid cells across the study area, showing the variation in direction and magnitude of feature contributions from a global perspective, and reflecting the spatial heterogeneity and multiple driving pathways of urban safety hazards.
Figure 11. Global model-predicted urban perception score. This figure presents the SHAP value distribution for all 584 grid cells across the study area, showing the variation in direction and magnitude of feature contributions from a global perspective, and reflecting the spatial heterogeneity and multiple driving pathways of urban safety hazards.
Sustainability 17 09300 g011
Figure 12. Examples of interaction effects in representative grid cells.
Figure 12. Examples of interaction effects in representative grid cells.
Sustainability 17 09300 g012
Figure 13. Semantic segmentation examples of interaction effects in representative grid cells.
Figure 13. Semantic segmentation examples of interaction effects in representative grid cells.
Sustainability 17 09300 g013
Figure 14. Dependence.
Figure 14. Dependence.
Sustainability 17 09300 g014
Table 1. Categorization of safety hazards on the National Safety Threat Map (NSTM).
Table 1. Categorization of safety hazards on the National Safety Threat Map (NSTM).
Category (EN)Category (EN)
Acts of vandalismDestruction of greenery
Unauthorized swimming areasHomeless person requiring assistance
Illegal dumping sitesDriving ATVs in forest areas
Gathering of minors at risk of demoralizationSpeeding
PoachingDrinking in prohibited areas
Dangerous areas in water zonesDrowning
Dangerous entertainment activity locationsDrug use
Illegal tree fellingStray dogs
Illegal car racingGrass burning
Improper parkingTraffic accidents involving wildlife
Unprotected railway crossingAnimal abuse
Unattended railway crossingPoor traffic organization
Inappropriate road infrastructureBegging
Table 2. Comparison of model performance.
Table 2. Comparison of model performance.
ModelValidation Score (R2)Validation Score (MSE)Validation Score (RMSE)Validation Score (MAE)Fitting Time
(Seconds)
RandomForest0.8813.9181.9791.4230.521
XGBoost0.9043.1851.7851.3367.467
CatBoost0.8764.0452.0111.58060.408
LightGBM0.8833.8541.9631.46220.672
ExtraTrees0.7787.3372.7092.0270.521
KNeighbors0.62812.3063.5082.6570.033
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Wu, Z.; Wu, C.; Wang, L. Analyzing the Relationship Between Built-Environment Factors and Safety Threat Reports in Cracow, Poland. Sustainability 2025, 17, 9300. https://doi.org/10.3390/su17209300

AMA Style

Wu Z, Wu C, Wang L. Analyzing the Relationship Between Built-Environment Factors and Safety Threat Reports in Cracow, Poland. Sustainability. 2025; 17(20):9300. https://doi.org/10.3390/su17209300

Chicago/Turabian Style

Wu, Zixian, Chen Wu, and Lei Wang. 2025. "Analyzing the Relationship Between Built-Environment Factors and Safety Threat Reports in Cracow, Poland" Sustainability 17, no. 20: 9300. https://doi.org/10.3390/su17209300

APA Style

Wu, Z., Wu, C., & Wang, L. (2025). Analyzing the Relationship Between Built-Environment Factors and Safety Threat Reports in Cracow, Poland. Sustainability, 17(20), 9300. https://doi.org/10.3390/su17209300

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop