# Research on Community Risk Prediction Model and Management Based on Deep Learning

Authors: Weida Yin
Journal: Wireless Communications and Mobile Computing
 (2022)

---

## Abstract

The influencing factors of community risk are complex. For the low accuracy of traditional prediction model, a multichannel convolutional neural network community risk prediction model is proposed by improving convolutional neural network of deep learning. First of all, in the community risk prediction model, the structure of multichannel input convolutional neural network is selected. Then, add it into the full connection layer. Subsequently, the DenseNet layer is added to establish connections between different network layers. Finally, the receptive field is improved, and the gradient disappearance is solved. Thus, the prediction accuracy of model is improved. Compared with the traditional model, the proposed multichannel convolutional neural network model has better prediction accuracy. In addition, it performs better on the three indicators, namely, correlation coefficientR, coefficient of determination R2, and mean square root error RMSE. Compared with the commonly used LSTM model and logic regression model, the proposed model also has certain advantages, which is more suitable for community risk prediction.


---

## Body

## 1. Introduction

Community is the basic unit of people’s life. Community risk is not only related to the safety of residents in the community but also related to the social public stability. The important measures to ensure the stability of social security are to strengthen the ability of community risk prevention and response and raise the safety consciousness of community residents. However, with the development of urbanization, the risks faced by the community in the process of development are becoming more and more complex. Therefore, the harm caused by community security risk is minimized by monitoring community security risk.Early social risk early warning mainly evaluates community security through Dempster-Shafer theory to realize community risk early warning. For example, Yin and Krzysztof et al. used Dempster-Shafer theory to study the safety risks of megacities community. A system of urban community safety evaluation indicators is constructed based on the static and dynamic factors. However, there are still problems for combining the static and dynamic factors to predict, such as insufficient content, insufficient index, and inaccurate model. Fortunately, the problems can be eliminated, which makes the evaluation of urban community safety more effective [1, 2]. Patel et al. described the association of social risk and exclusion factors with health outcomes for one of the largest populations in MENA [3]. At the same time, Patel et al. found that people with higher social risk factors reported poor health. It is beneficial to the screening and referral models of the social needs of the MENA sub-population in the United States. As can be seen, deep learning has been widely used to predict risk, which provides new ideas for community risk prediction. For example, Aditya et al. explored the details of cell phenotypes based on the advantages of deep learning in the recognition, analysis and prediction of visual phenotypes, which provides a reference for the application of the details of cell phenotypes in important biological problems [4]. Ozge and Zhang et al. realized high-resolution fuse classification based on recursive graph convolutional neural network [5, 6]. Dong et al. used handheld Raman spectrometers in public to collect hazardous chemicals data from public safety. At the same time, Dong et al. used the structure of convolutional neural network to determine hazardous chemicals in public safety [7]. Based on convolutional neural network, Frederic et al. realized the prediction of possible burning sites in wasteland through numerical simulation of the spread of wasteland fire. Therefore, a new application of short-term fire risk mapping is opened [8] .The above research shows that convolutional neural network has certain advantages in risk prediction in various fields, but there is still a problem of improving the prediction accuracy. Thus, based on convolutional neural network, and combined with community risk-related features, a multichannel convolutional neural network prediction model is proposed, where the single-channel input is improved to multichannel. In addition, DenseNet layer is added to establish connections to different network layers.


## 2. Basic Methods

### 2.1. Introduction to Convolutional Neural Networks

Convolutional neural network is a deep learning algorithm with deep structure. It is widely used in computer recognition and image recognition. Traditional convolutional neural network consists of five layers, namely, input layer, convolutional layer, pooling layer, fully connected layer, and output layer. The structure is as shown in Figure1. Among them, the convolution layer is responsible for extracting features through convolution operation. And in mathematical calculus, the specific calculation formula is as follows [9]:
(1)st=x∗wt=∫xawt−ada.Figure 1
Structure of convolutional neural network.In the formula,x means the input, and w represents the convolution kernel. In addition, a represents the integral, t represents the function displacement, and t represents the feature mapping. The discrete behavior of convolution is
(2)si,j=I∗Ki,j=∑m∑nIm,nKi−m,j−n.Since convolution is variable, the Formula (2) is expressed as [10]
(3)si,j=I∗Ki,j=∑m∑nIi−m,j−nKm,n.The pooling layer is responsible for downsampling the output feature mapping of the convolutional layer to further extract features and reduce weight parameters. There are average pooling and maximum pooling.The activation function is usually connected. There are three common activation functions, namely, Tanh function, RelU function, and Sigmoid function. Sigmoid function is shown in formula (4). Tanh function is shown in formula (5). And the simplified calculation is shown in formula (6). RelU function is shown in formula (7). Compared with Sigmoid function and Tanh function, RelU function has certain advantages in solving gradient disappearance [10, 11]. Therefore, RelU function is the activation function in this paper.
(4)σs=11+e−s,(5)tanh=ex−e−xex+e−x,(6)tanhx=2−+e−2x−1,(7)Relu=max0,x.To prevent cell inactivation, usually whenx<0, a non-0 slope is introduced into the RelU function, namely, [12]
(8)gx=max0,x+amin0,x.Whena=−1, namely, gx=x represents the absolute value correction method [13].The recognition and classification of information are realized through the interaction between different layers. This network has the characteristics of parameter sharing, feature invariability, and sparse connection [14]. However, it can only accurately predict a single input feature. The community risk of the research object in this paper has many influencing factors. Furthermore, the input network has many related feature factors. Therefore, a multichannel convolutional neural network model is proposed to predict community risk.


### 2.2. Introduction to Multichannel Convolutional Neural Networks

In the convolutional neural network model, multichannel input is adopted, and DenseNet layer is added to establish connections between different network layers, as can be seen that the sensory field and prediction accuracy are improved. The structure is shown in Figure2, where the left part is the traditional convolutional neural network, and the right part is the improved multichannel convolutional neural network.Figure 2
Framework of multichannel convolutional neural network model.There are eight parts for the multichannel convolutional neural network, namely, input layer, convolutional layer, pooling layer, flatten layer, fully connected layer, DenseNet, dropout layer, and output layer. Input layer consists of four feature inputs. Each feature input is convoluted by two convolution layers, pooled by a maximum pooling layer, and flattened by a flatten layer. Then, it passes fully connected layer and DenseNet layer. Each component layer in the DenseNet layer uses the BN and RelU functions and then uses a four-channel output feature to conduct3×3 convolution and through the three-layer Denise block. Meanwhile, average pooling operation is performed, and a softmax classifier is added. Then, after passing through the dropout layer with a dropout value of 0.5, the final prediction result is output by the output layer.


## 2.1. Introduction to Convolutional Neural Networks

Convolutional neural network is a deep learning algorithm with deep structure. It is widely used in computer recognition and image recognition. Traditional convolutional neural network consists of five layers, namely, input layer, convolutional layer, pooling layer, fully connected layer, and output layer. The structure is as shown in Figure1. Among them, the convolution layer is responsible for extracting features through convolution operation. And in mathematical calculus, the specific calculation formula is as follows [9]:
(1)st=x∗wt=∫xawt−ada.Figure 1
Structure of convolutional neural network.In the formula,x means the input, and w represents the convolution kernel. In addition, a represents the integral, t represents the function displacement, and t represents the feature mapping. The discrete behavior of convolution is
(2)si,j=I∗Ki,j=∑m∑nIm,nKi−m,j−n.Since convolution is variable, the Formula (2) is expressed as [10]
(3)si,j=I∗Ki,j=∑m∑nIi−m,j−nKm,n.The pooling layer is responsible for downsampling the output feature mapping of the convolutional layer to further extract features and reduce weight parameters. There are average pooling and maximum pooling.The activation function is usually connected. There are three common activation functions, namely, Tanh function, RelU function, and Sigmoid function. Sigmoid function is shown in formula (4). Tanh function is shown in formula (5). And the simplified calculation is shown in formula (6). RelU function is shown in formula (7). Compared with Sigmoid function and Tanh function, RelU function has certain advantages in solving gradient disappearance [10, 11]. Therefore, RelU function is the activation function in this paper.
(4)σs=11+e−s,(5)tanh=ex−e−xex+e−x,(6)tanhx=2−+e−2x−1,(7)Relu=max0,x.To prevent cell inactivation, usually whenx<0, a non-0 slope is introduced into the RelU function, namely, [12]
(8)gx=max0,x+amin0,x.Whena=−1, namely, gx=x represents the absolute value correction method [13].The recognition and classification of information are realized through the interaction between different layers. This network has the characteristics of parameter sharing, feature invariability, and sparse connection [14]. However, it can only accurately predict a single input feature. The community risk of the research object in this paper has many influencing factors. Furthermore, the input network has many related feature factors. Therefore, a multichannel convolutional neural network model is proposed to predict community risk.


## 2.2. Introduction to Multichannel Convolutional Neural Networks

In the convolutional neural network model, multichannel input is adopted, and DenseNet layer is added to establish connections between different network layers, as can be seen that the sensory field and prediction accuracy are improved. The structure is shown in Figure2, where the left part is the traditional convolutional neural network, and the right part is the improved multichannel convolutional neural network.Figure 2
Framework of multichannel convolutional neural network model.There are eight parts for the multichannel convolutional neural network, namely, input layer, convolutional layer, pooling layer, flatten layer, fully connected layer, DenseNet, dropout layer, and output layer. Input layer consists of four feature inputs. Each feature input is convoluted by two convolution layers, pooled by a maximum pooling layer, and flattened by a flatten layer. Then, it passes fully connected layer and DenseNet layer. Each component layer in the DenseNet layer uses the BN and RelU functions and then uses a four-channel output feature to conduct3×3 convolution and through the three-layer Denise block. Meanwhile, average pooling operation is performed, and a softmax classifier is added. Then, after passing through the dropout layer with a dropout value of 0.5, the final prediction result is output by the output layer.


## 3. Community Risk Prediction Model Based on Multichannel Convolutional Neural Network

The community risk prediction model of multichannel convolutional neural network is constructed as follows:(1)
Data collection: collect and organize the factors affecting community risk and screen out the characteristic factors with strong correlation after preprocessing such as data cleaning and normalization(2)
Dataset division: the data is divide into training set and testing set in the ratio of 4 : 1(3)
Construction of multichannel convolutional neural network model: input layer: each input variable corresponds to an input layerLi, and one-dimensional convolution kernel is used to extract input variable features for each layer Li. The input layer is a vectorVi=D1,D2,D3,D4,D5,D6,D7 for a variable week, which represents a three-dimensional matrix with the shape of 1×7×1, and the single input shape is (1, 7, 1). Convolution layer: there are 32 convolution kernels in one-dimensional convolution layer, and the size is 3. RelU function is activation function. Pooling layer: the maximum pooling layer size is 2. Flatten layer: the flatten feature obtained by the flatten layer is Fi. Each Fi is spliced to obtain a complete flatten eigenvalue F=F1,F2,F3,F4. Fully connected layer: neurons in full connection layer D2 is 100, and the activation function is RelU function. Output layer: the number of euron is 1, which corresponds to the data value on the eighth day after one week(4)
Model training: use training dataset to train the model. Mean square error (MSE) is used as loss function, and Adam is used as optimizer. The number of iterations is 20, and batch-size is 4 [15]. When the model output value and the MSE of observation value do not change or reach the maximum number of iterations, save the model(5)
Based on the above saved model, testing dataset is used to predict and output prediction results. Comparing the output prediction results with the actual value, the accuracy of the model is calculated; that is, the prediction of community risk is completedThe above process can be illustrated in Figure3.Figure 3
Construction process of community risk prediction model.


## 4. Simulation Experiment

### 4.1. Data Sources and Preprocessing

#### 4.1.1. Data Sources

Community risk is related to its basic information, case information, climate information, community population information, and many other factors. Therefore, in order to realize community risk prediction and management, community risk data sources should be obtained from many aspects. In this simulation reference [16], the security cases, climate data and second-hand housing price data of a community in a third-tier city in China from January 2017 to December 2019 are selected as experimental data. Among them, the data of public security cases are provided by the public security bureau. Through desensitization of the data and screening according to the address of the case, a total of 12,000 data of community security cases data are obtained. Climate data are counted on a daily basis, and a total of 1095 pieces of data are obtained. In addition, the second-hand housing price and the number of community security cases are shown in Figure 4.Figure 4
Comparison between the average price of second-hand houses and the number of cases.


#### 4.1.2. Data Preprocessing

(1) Missing Value Processing. There may be missing values in the experimental data. Avoiding the influence of missing value on model prediction effect, the data, such as the small amount of data and the weather that is easy to be queried, is performed the artificial fill processing. For the community public security cases with no influence on the prediction results and the large amount of data, the early-warning data is deleted. For the missing data of the number of community security cases of important research objects, the moving window mean filling method is adopted for processing, and the mean value of the cases near the missing data is used as the missing data case loads, which can be expressed as the formula as [17]
(9)Xm=16Xm−3+Xm−2+Xm−1+Xm+1+Xm+2+Xm+3,whereXm−n stands for the number of cases near the missing value; Xm represents the missing value filling the number of cases.(2) Normalization. Considering the difference of experimental data magnitude, they are normalized, and the specific function is expressed as Formula (10) [18]:
(10)y=x−MinMax−Min.Here,x stands for the original data value, y is the normalized data value, Max represents the maximum value of data, and Min represents the minimum data value.In addition, considering that not all values can be mapped to the interval [0,1], for practical application, all target mapping interval is assumed toα,β, and the result of original data mapping to interval α,β is [19]
(11)Y=a+x−MinMax−Min×β−a.


### 4.2. Feature Extraction

#### 4.2.1. Feature Screening

Extracting features is the key to construct community risk prediction model. In order to screen out the feature factors most relevant to community risk prediction, Pearson correlation coefficient is improved for the influencing factors analysis. The original calculation formula of Pearson correlation coefficient is shown in formula (12) [20]:
(12)R=∑1nXi−X¯Yi−Y¯∑1nYi−Y¯2∑1nXi−X¯2.In the formula, there are two related variables, namely,X and Y. Xi is the community security cases, and Yi is the screened characteristic data. Moreover, the mean values of Xi and Yi areX¯ andY¯ respectively. And the correlation between X and Y is R.The number of moving average community security cases is adopted to obtain the smooth numberMi. Moreover, usingMi to replace X¯, the improved Pearson backbone coefficient could be obtained. The correlation smoothing coefficient Rm can be expressed as [21]
(13)Rm=∑1nXi−MiYi−Y¯∑1nYi−Y2∑1nXi−Mi2,where the value range ofRm is [-1, 1]. When the value is within [-1, 0), variables are negative correlated. When its value is within [0, 1], variables are positive correlated. The larger the value of Rmis, the higher the correlation degree is. When the correlation is less than 0.05, there is no significant correlation between variables [22].


#### 4.2.2. Correlation Analysis of Feature Factors

The proposed model is to predict the daily community security case number. When analyzing feature correlation, the data that never changes in a short time is ignored, such as residential population density. The public security cases, noise reduction cases, second-hand housing price, climate, and vacation data are selected to analyze the correlation. Pearson correlation is used to test each influencing factor, and the results are shown in Table1. There is a positive correlation between the second-hand housing price and the number of noise reduction security cases, with a correlation coefficient of 0.44678 and a great correlation. There is a negative correlation between climate, vacation, and noise reduction cases, with correlation coefficients of -0.1512 and -0.3027, respectively, showing a significant correlation. This shows that the second-hand housing price, climate, holidays, and the number of public security cases have an important impact on the community security risk. Therefore, this paper selects the above four types of feature data as input of the model.Table 1
Correlation test results of influencing factors.
CasesSecond-hand housing priceClimateHolidaysNoise reduction casesCases1.0000-0.1284-0.0650-0.39500.4468Second-hand housing price-0.12841.00000.0385-0.0049-0.1135Climate-0.06500.03851.0000-0.0001-0.1512Holidays-0.3950-0.0049-0.00011.0000-0.3027Noise reduction cases0.44678-0.1135-0.1512-0.30271.0000


### 4.3. Evaluation Indicators

Root mean square error (RMSE) is used to evaluate the prediction effect of the model, as shown in formula (14) [23]. The smaller RMSE value is, the smaller the deviation value is. And the prediction effect of the model is better. Furthermore, correlation coefficient (R) and determination coefficient (R2) are used to evaluate the robustness of the model prediction effect. The calculation methods are shown in formulas (15) and (16) [24]. The larger the value is, the closer the predicted value is to the actual value, and the better the robustness of the model is.
(14)RMSE=1n∑i−1nyi−y^i.Formula (14) shows that yi is the true value. y^i is the predicted value.
(15)rX,Y=CoυX,YVarXVarY,(16)R2=1‐SSresSStot=SSregSStot,(17)y¯=1n∑i=1nyi,(18)SStot=∑iyi−y¯2,(19)SSreg=∑ifi−y¯2SStot=∑iyi−y¯2,SSres=∑iyi−fi2=∑iei2SStot=∑iyi−y¯2.Formula (15) shows that CovX,Y represents the covariance of X and Y, which can be calculated by formula (20) [25]. VarX represents the variances of X, which can be calculated by formula (21).
(20)CovX,Y=EX−EXY−EY,(21)varX=∑i=1nXi−X¯Xi−X¯n−1.


### 4.4. Parameter Settings

The final prediction result of convolutional neural network will affect model parameters. To obtain best prediction results, control variable method is used to determine convolutional layers, convolutional kernels, activation function, optimizer, and pooling operation mode of pooling layer. The model is set for 20 iterations. And its loss function is the mean square error,epoch=20, batch−size=4, and dropout=0.5.


#### 4.4.1. Determination of the Number of Convolutional Layer

The proposed model is constructed with different convolutional layers. And the community risk security cases are predicted. The results are shown in Table2. When convolutional layers are 2, correlation coefficient and coefficient of determination are the largest, which are 0.9694 and 0.9389, respectively. And the root mean square error is the smallest, which is 0.8188. As can be seen that, when convolutional layers are 2, the prediction effect of model has a small error with the real value, and the prediction effect is better. Therefore, the number of convolutional layer is set to 2.Table 2
Comparison of model prediction results of different number of convolutional layer.
The number of convolutional layerRR2RMSE10.96350.93000.880020.96940.93890.818830.96850.93420.8455


#### 4.4.2. Determination of the Number of Convolution Kernels

Convolution kernels are responsible for feature extraction. The more the convolution kernels is, the more fully the model extracts features. However, too many convolution kernels will lead to overfitting, and the prediction accuracy of the model will be reduced. Therefore, it is necessary to determine the number of model convolution kernels. In addition, different numbers of convolution kernels are set up to build models and make predictions. The results are as shown in Table3. When convolution kernels are 32, the correlation coefficient and coefficient of determination are the largest, which are 0.9697 and 0.9389, respectively. Meanwhile, the root mean square error is the smallest, which is 0.8188. Thus, convolution kernels are 32 in this paper.Table 3
Comparison of model prediction results of different number of convolution kernel.
The number of convolution kernelRR2RMSE160.95390.91120.8390320.96970.93890.8188640.96230.92100.8466


#### 4.4.3. Determination of Activation Function

The common activation functions are Sigmoid, Tanh, and RelU functions. Different activation functions are selected to build models and make predictions. The results are shown in Table4. When RelU function is the activation function, the model performs better.Table 4
Comparison of model prediction results of different activation functions.
Activation functionRR2RMSESigmoid0.84560.82651.1002Tanh0.94700.89711.0688RelU0.96970.93890.8188


#### 4.4.4. Optimizer Determination

Common model parameter optimizers include Adam and RMSprop. Different optimizers are selected to optimize the model parameters, and the model prediction results are obtained as shown in Table5. When Adam is used as the parameter optimizer, the model performs better. Therefore, Adam is selected as the model parameter optimizer in this paper.Table 5
Comparison of model prediction results of different optimizer.
OptimizerRR2RMSERMSprop0.95890.92110.8790Adam0.96970.93890.8188


#### 4.4.5. Determination of Pooling Operation

Pooling layer is an important network layer to prevent model overfitting. And the selection of pooling operation is particularly important. Different pooling operations are used to construct the pooling layer and make predictions. The prediction results of the model are shown in Table6. Compared with average pooling operation, when maximum pooling operation is selected, the model performs better.Table 6
Comparison of model prediction results of different optimizers.
Pooling operationRR2RMSEAverage pooling0.96320.93770.8426Maximum pooling0.96970.93890.8188Through the above experiments, the parameters of the constructed multichannel convolutional neural network model are finally determined as follows: there are 2 convolutional layers, there are 32 convolution kernels, the activation function is RelU function, the optimizer is Adam, and the pooling operation is maximum pooling. The details are shown in Table7.Table 7
Model parameter settings.
Parameter nameValueConvolutional layer2Convolutional filter32Activation functionReLUOptimizerAdamPoolingMax poolingEpoch20Loss functionMSEBatch_size4Dropout0.5


### 4.5. Experimental Results

#### 4.5.1. Model Verification

The improved effect of the proposed model on the convolutional neural network needs to be verified. Based on the above optimal parameter settings, the prediction results of model before and after the improvement are compared. The results are shown in Table8. Compared with original model, the proposed model improves the prediction accuracy of model, and the structure of convolutional neural network model is improved. Moreover, the performance of proposed model is superior to the original model. Therefore, the improvement of convolutional neural network model is effective.Table 8
Comparison of model prediction results.
ModelRR2RMSEConvolutional neural network model0.96320.93770.8712Multichannel convolutional neural network model0.97630.95690.8571To verify the effectiveness of the model, a multichannel convolutional neural network prediction model is constructed under the optimal parameter setting. Furthermore, the prediction is made on the testing set. The comparison between the prediction result and actual observed value is shown in Figure5. The predicted value curve of the model fits well with the actual observed value curve. There are many positions almost coinciding with each other, and the overall change trend is the same, which indicates that prediction effect of the proposed model is good.Figure 5
Comparison between model prediction result and actual observed value.For the prediction effect analysis of the model, correlation coefficient, coefficient of determination ,and root mean square error are calculated on testing set. The results are shown in Table9. The R value is 87.77%, R2 is 77.13%, and root mean square error is 0.8571, which meets prediction accuracy requirement. It indicates that the proposed model has good predictive ability. What is more, the correlation between predicted value and actual value is good.Table 9
Comparison of model prediction results.
RR2RMSEMultichannel convolutional neural network model87.77%77.13%0.8571


#### 4.5.2. Model Comparison

Experiment compares the prediction results of different models on the testing set, as shown in Table10. Compared with the commonly used prediction model, such as LSTM model and logistic regression model, the proposed multichannel convolutional neural network model has the largest determination error and the smallest root mean square error. Thus, the proposed model has certain advantages in community risk prediction, and its prediction performance is superior to LSTM model and logistics regression model.Table 10
Comparison of prediction results of different models.
ModelR-squaredRMSEMultichannel CNN prediction model0.770.86LSTM prediction model0.720.92Logistic regression prediction model0.591.10


## 4.1. Data Sources and Preprocessing

### 4.1.1. Data Sources

Community risk is related to its basic information, case information, climate information, community population information, and many other factors. Therefore, in order to realize community risk prediction and management, community risk data sources should be obtained from many aspects. In this simulation reference [16], the security cases, climate data and second-hand housing price data of a community in a third-tier city in China from January 2017 to December 2019 are selected as experimental data. Among them, the data of public security cases are provided by the public security bureau. Through desensitization of the data and screening according to the address of the case, a total of 12,000 data of community security cases data are obtained. Climate data are counted on a daily basis, and a total of 1095 pieces of data are obtained. In addition, the second-hand housing price and the number of community security cases are shown in Figure 4.Figure 4
Comparison between the average price of second-hand houses and the number of cases.


### 4.1.2. Data Preprocessing

(1) Missing Value Processing. There may be missing values in the experimental data. Avoiding the influence of missing value on model prediction effect, the data, such as the small amount of data and the weather that is easy to be queried, is performed the artificial fill processing. For the community public security cases with no influence on the prediction results and the large amount of data, the early-warning data is deleted. For the missing data of the number of community security cases of important research objects, the moving window mean filling method is adopted for processing, and the mean value of the cases near the missing data is used as the missing data case loads, which can be expressed as the formula as [17]
(9)Xm=16Xm−3+Xm−2+Xm−1+Xm+1+Xm+2+Xm+3,whereXm−n stands for the number of cases near the missing value; Xm represents the missing value filling the number of cases.(2) Normalization. Considering the difference of experimental data magnitude, they are normalized, and the specific function is expressed as Formula (10) [18]:
(10)y=x−MinMax−Min.Here,x stands for the original data value, y is the normalized data value, Max represents the maximum value of data, and Min represents the minimum data value.In addition, considering that not all values can be mapped to the interval [0,1], for practical application, all target mapping interval is assumed toα,β, and the result of original data mapping to interval α,β is [19]
(11)Y=a+x−MinMax−Min×β−a.


## 4.1.1. Data Sources

Community risk is related to its basic information, case information, climate information, community population information, and many other factors. Therefore, in order to realize community risk prediction and management, community risk data sources should be obtained from many aspects. In this simulation reference [16], the security cases, climate data and second-hand housing price data of a community in a third-tier city in China from January 2017 to December 2019 are selected as experimental data. Among them, the data of public security cases are provided by the public security bureau. Through desensitization of the data and screening according to the address of the case, a total of 12,000 data of community security cases data are obtained. Climate data are counted on a daily basis, and a total of 1095 pieces of data are obtained. In addition, the second-hand housing price and the number of community security cases are shown in Figure 4.Figure 4
Comparison between the average price of second-hand houses and the number of cases.


## 4.1.2. Data Preprocessing

(1) Missing Value Processing. There may be missing values in the experimental data. Avoiding the influence of missing value on model prediction effect, the data, such as the small amount of data and the weather that is easy to be queried, is performed the artificial fill processing. For the community public security cases with no influence on the prediction results and the large amount of data, the early-warning data is deleted. For the missing data of the number of community security cases of important research objects, the moving window mean filling method is adopted for processing, and the mean value of the cases near the missing data is used as the missing data case loads, which can be expressed as the formula as [17]
(9)Xm=16Xm−3+Xm−2+Xm−1+Xm+1+Xm+2+Xm+3,whereXm−n stands for the number of cases near the missing value; Xm represents the missing value filling the number of cases.(2) Normalization. Considering the difference of experimental data magnitude, they are normalized, and the specific function is expressed as Formula (10) [18]:
(10)y=x−MinMax−Min.Here,x stands for the original data value, y is the normalized data value, Max represents the maximum value of data, and Min represents the minimum data value.In addition, considering that not all values can be mapped to the interval [0,1], for practical application, all target mapping interval is assumed toα,β, and the result of original data mapping to interval α,β is [19]
(11)Y=a+x−MinMax−Min×β−a.


## 4.2. Feature Extraction

### 4.2.1. Feature Screening

Extracting features is the key to construct community risk prediction model. In order to screen out the feature factors most relevant to community risk prediction, Pearson correlation coefficient is improved for the influencing factors analysis. The original calculation formula of Pearson correlation coefficient is shown in formula (12) [20]:
(12)R=∑1nXi−X¯Yi−Y¯∑1nYi−Y¯2∑1nXi−X¯2.In the formula, there are two related variables, namely,X and Y. Xi is the community security cases, and Yi is the screened characteristic data. Moreover, the mean values of Xi and Yi areX¯ andY¯ respectively. And the correlation between X and Y is R.The number of moving average community security cases is adopted to obtain the smooth numberMi. Moreover, usingMi to replace X¯, the improved Pearson backbone coefficient could be obtained. The correlation smoothing coefficient Rm can be expressed as [21]
(13)Rm=∑1nXi−MiYi−Y¯∑1nYi−Y2∑1nXi−Mi2,where the value range ofRm is [-1, 1]. When the value is within [-1, 0), variables are negative correlated. When its value is within [0, 1], variables are positive correlated. The larger the value of Rmis, the higher the correlation degree is. When the correlation is less than 0.05, there is no significant correlation between variables [22].


### 4.2.2. Correlation Analysis of Feature Factors

The proposed model is to predict the daily community security case number. When analyzing feature correlation, the data that never changes in a short time is ignored, such as residential population density. The public security cases, noise reduction cases, second-hand housing price, climate, and vacation data are selected to analyze the correlation. Pearson correlation is used to test each influencing factor, and the results are shown in Table1. There is a positive correlation between the second-hand housing price and the number of noise reduction security cases, with a correlation coefficient of 0.44678 and a great correlation. There is a negative correlation between climate, vacation, and noise reduction cases, with correlation coefficients of -0.1512 and -0.3027, respectively, showing a significant correlation. This shows that the second-hand housing price, climate, holidays, and the number of public security cases have an important impact on the community security risk. Therefore, this paper selects the above four types of feature data as input of the model.Table 1
Correlation test results of influencing factors.
CasesSecond-hand housing priceClimateHolidaysNoise reduction casesCases1.0000-0.1284-0.0650-0.39500.4468Second-hand housing price-0.12841.00000.0385-0.0049-0.1135Climate-0.06500.03851.0000-0.0001-0.1512Holidays-0.3950-0.0049-0.00011.0000-0.3027Noise reduction cases0.44678-0.1135-0.1512-0.30271.0000


## 4.2.1. Feature Screening

Extracting features is the key to construct community risk prediction model. In order to screen out the feature factors most relevant to community risk prediction, Pearson correlation coefficient is improved for the influencing factors analysis. The original calculation formula of Pearson correlation coefficient is shown in formula (12) [20]:
(12)R=∑1nXi−X¯Yi−Y¯∑1nYi−Y¯2∑1nXi−X¯2.In the formula, there are two related variables, namely,X and Y. Xi is the community security cases, and Yi is the screened characteristic data. Moreover, the mean values of Xi and Yi areX¯ andY¯ respectively. And the correlation between X and Y is R.The number of moving average community security cases is adopted to obtain the smooth numberMi. Moreover, usingMi to replace X¯, the improved Pearson backbone coefficient could be obtained. The correlation smoothing coefficient Rm can be expressed as [21]
(13)Rm=∑1nXi−MiYi−Y¯∑1nYi−Y2∑1nXi−Mi2,where the value range ofRm is [-1, 1]. When the value is within [-1, 0), variables are negative correlated. When its value is within [0, 1], variables are positive correlated. The larger the value of Rmis, the higher the correlation degree is. When the correlation is less than 0.05, there is no significant correlation between variables [22].


## 4.2.2. Correlation Analysis of Feature Factors

The proposed model is to predict the daily community security case number. When analyzing feature correlation, the data that never changes in a short time is ignored, such as residential population density. The public security cases, noise reduction cases, second-hand housing price, climate, and vacation data are selected to analyze the correlation. Pearson correlation is used to test each influencing factor, and the results are shown in Table1. There is a positive correlation between the second-hand housing price and the number of noise reduction security cases, with a correlation coefficient of 0.44678 and a great correlation. There is a negative correlation between climate, vacation, and noise reduction cases, with correlation coefficients of -0.1512 and -0.3027, respectively, showing a significant correlation. This shows that the second-hand housing price, climate, holidays, and the number of public security cases have an important impact on the community security risk. Therefore, this paper selects the above four types of feature data as input of the model.Table 1
Correlation test results of influencing factors.
CasesSecond-hand housing priceClimateHolidaysNoise reduction casesCases1.0000-0.1284-0.0650-0.39500.4468Second-hand housing price-0.12841.00000.0385-0.0049-0.1135Climate-0.06500.03851.0000-0.0001-0.1512Holidays-0.3950-0.0049-0.00011.0000-0.3027Noise reduction cases0.44678-0.1135-0.1512-0.30271.0000


## 4.3. Evaluation Indicators

Root mean square error (RMSE) is used to evaluate the prediction effect of the model, as shown in formula (14) [23]. The smaller RMSE value is, the smaller the deviation value is. And the prediction effect of the model is better. Furthermore, correlation coefficient (R) and determination coefficient (R2) are used to evaluate the robustness of the model prediction effect. The calculation methods are shown in formulas (15) and (16) [24]. The larger the value is, the closer the predicted value is to the actual value, and the better the robustness of the model is.
(14)RMSE=1n∑i−1nyi−y^i.Formula (14) shows that yi is the true value. y^i is the predicted value.
(15)rX,Y=CoυX,YVarXVarY,(16)R2=1‐SSresSStot=SSregSStot,(17)y¯=1n∑i=1nyi,(18)SStot=∑iyi−y¯2,(19)SSreg=∑ifi−y¯2SStot=∑iyi−y¯2,SSres=∑iyi−fi2=∑iei2SStot=∑iyi−y¯2.Formula (15) shows that CovX,Y represents the covariance of X and Y, which can be calculated by formula (20) [25]. VarX represents the variances of X, which can be calculated by formula (21).
(20)CovX,Y=EX−EXY−EY,(21)varX=∑i=1nXi−X¯Xi−X¯n−1.


## 4.4. Parameter Settings

The final prediction result of convolutional neural network will affect model parameters. To obtain best prediction results, control variable method is used to determine convolutional layers, convolutional kernels, activation function, optimizer, and pooling operation mode of pooling layer. The model is set for 20 iterations. And its loss function is the mean square error,epoch=20, batch−size=4, and dropout=0.5.


### 4.4.1. Determination of the Number of Convolutional Layer

The proposed model is constructed with different convolutional layers. And the community risk security cases are predicted. The results are shown in Table2. When convolutional layers are 2, correlation coefficient and coefficient of determination are the largest, which are 0.9694 and 0.9389, respectively. And the root mean square error is the smallest, which is 0.8188. As can be seen that, when convolutional layers are 2, the prediction effect of model has a small error with the real value, and the prediction effect is better. Therefore, the number of convolutional layer is set to 2.Table 2
Comparison of model prediction results of different number of convolutional layer.
The number of convolutional layerRR2RMSE10.96350.93000.880020.96940.93890.818830.96850.93420.8455


### 4.4.2. Determination of the Number of Convolution Kernels

Convolution kernels are responsible for feature extraction. The more the convolution kernels is, the more fully the model extracts features. However, too many convolution kernels will lead to overfitting, and the prediction accuracy of the model will be reduced. Therefore, it is necessary to determine the number of model convolution kernels. In addition, different numbers of convolution kernels are set up to build models and make predictions. The results are as shown in Table3. When convolution kernels are 32, the correlation coefficient and coefficient of determination are the largest, which are 0.9697 and 0.9389, respectively. Meanwhile, the root mean square error is the smallest, which is 0.8188. Thus, convolution kernels are 32 in this paper.Table 3
Comparison of model prediction results of different number of convolution kernel.
The number of convolution kernelRR2RMSE160.95390.91120.8390320.96970.93890.8188640.96230.92100.8466


### 4.4.3. Determination of Activation Function

The common activation functions are Sigmoid, Tanh, and RelU functions. Different activation functions are selected to build models and make predictions. The results are shown in Table4. When RelU function is the activation function, the model performs better.Table 4
Comparison of model prediction results of different activation functions.
Activation functionRR2RMSESigmoid0.84560.82651.1002Tanh0.94700.89711.0688RelU0.96970.93890.8188


### 4.4.4. Optimizer Determination

Common model parameter optimizers include Adam and RMSprop. Different optimizers are selected to optimize the model parameters, and the model prediction results are obtained as shown in Table5. When Adam is used as the parameter optimizer, the model performs better. Therefore, Adam is selected as the model parameter optimizer in this paper.Table 5
Comparison of model prediction results of different optimizer.
OptimizerRR2RMSERMSprop0.95890.92110.8790Adam0.96970.93890.8188


### 4.4.5. Determination of Pooling Operation

Pooling layer is an important network layer to prevent model overfitting. And the selection of pooling operation is particularly important. Different pooling operations are used to construct the pooling layer and make predictions. The prediction results of the model are shown in Table6. Compared with average pooling operation, when maximum pooling operation is selected, the model performs better.Table 6
Comparison of model prediction results of different optimizers.
Pooling operationRR2RMSEAverage pooling0.96320.93770.8426Maximum pooling0.96970.93890.8188Through the above experiments, the parameters of the constructed multichannel convolutional neural network model are finally determined as follows: there are 2 convolutional layers, there are 32 convolution kernels, the activation function is RelU function, the optimizer is Adam, and the pooling operation is maximum pooling. The details are shown in Table7.Table 7
Model parameter settings.
Parameter nameValueConvolutional layer2Convolutional filter32Activation functionReLUOptimizerAdamPoolingMax poolingEpoch20Loss functionMSEBatch_size4Dropout0.5


## 4.4.1. Determination of the Number of Convolutional Layer

The proposed model is constructed with different convolutional layers. And the community risk security cases are predicted. The results are shown in Table2. When convolutional layers are 2, correlation coefficient and coefficient of determination are the largest, which are 0.9694 and 0.9389, respectively. And the root mean square error is the smallest, which is 0.8188. As can be seen that, when convolutional layers are 2, the prediction effect of model has a small error with the real value, and the prediction effect is better. Therefore, the number of convolutional layer is set to 2.Table 2
Comparison of model prediction results of different number of convolutional layer.
The number of convolutional layerRR2RMSE10.96350.93000.880020.96940.93890.818830.96850.93420.8455


## 4.4.2. Determination of the Number of Convolution Kernels

Convolution kernels are responsible for feature extraction. The more the convolution kernels is, the more fully the model extracts features. However, too many convolution kernels will lead to overfitting, and the prediction accuracy of the model will be reduced. Therefore, it is necessary to determine the number of model convolution kernels. In addition, different numbers of convolution kernels are set up to build models and make predictions. The results are as shown in Table3. When convolution kernels are 32, the correlation coefficient and coefficient of determination are the largest, which are 0.9697 and 0.9389, respectively. Meanwhile, the root mean square error is the smallest, which is 0.8188. Thus, convolution kernels are 32 in this paper.Table 3
Comparison of model prediction results of different number of convolution kernel.
The number of convolution kernelRR2RMSE160.95390.91120.8390320.96970.93890.8188640.96230.92100.8466


## 4.4.3. Determination of Activation Function

The common activation functions are Sigmoid, Tanh, and RelU functions. Different activation functions are selected to build models and make predictions. The results are shown in Table4. When RelU function is the activation function, the model performs better.Table 4
Comparison of model prediction results of different activation functions.
Activation functionRR2RMSESigmoid0.84560.82651.1002Tanh0.94700.89711.0688RelU0.96970.93890.8188


## 4.4.4. Optimizer Determination

Common model parameter optimizers include Adam and RMSprop. Different optimizers are selected to optimize the model parameters, and the model prediction results are obtained as shown in Table5. When Adam is used as the parameter optimizer, the model performs better. Therefore, Adam is selected as the model parameter optimizer in this paper.Table 5
Comparison of model prediction results of different optimizer.
OptimizerRR2RMSERMSprop0.95890.92110.8790Adam0.96970.93890.8188


## 4.4.5. Determination of Pooling Operation

Pooling layer is an important network layer to prevent model overfitting. And the selection of pooling operation is particularly important. Different pooling operations are used to construct the pooling layer and make predictions. The prediction results of the model are shown in Table6. Compared with average pooling operation, when maximum pooling operation is selected, the model performs better.Table 6
Comparison of model prediction results of different optimizers.
Pooling operationRR2RMSEAverage pooling0.96320.93770.8426Maximum pooling0.96970.93890.8188Through the above experiments, the parameters of the constructed multichannel convolutional neural network model are finally determined as follows: there are 2 convolutional layers, there are 32 convolution kernels, the activation function is RelU function, the optimizer is Adam, and the pooling operation is maximum pooling. The details are shown in Table7.Table 7
Model parameter settings.
Parameter nameValueConvolutional layer2Convolutional filter32Activation functionReLUOptimizerAdamPoolingMax poolingEpoch20Loss functionMSEBatch_size4Dropout0.5


## 4.5. Experimental Results

### 4.5.1. Model Verification

The improved effect of the proposed model on the convolutional neural network needs to be verified. Based on the above optimal parameter settings, the prediction results of model before and after the improvement are compared. The results are shown in Table8. Compared with original model, the proposed model improves the prediction accuracy of model, and the structure of convolutional neural network model is improved. Moreover, the performance of proposed model is superior to the original model. Therefore, the improvement of convolutional neural network model is effective.Table 8
Comparison of model prediction results.
ModelRR2RMSEConvolutional neural network model0.96320.93770.8712Multichannel convolutional neural network model0.97630.95690.8571To verify the effectiveness of the model, a multichannel convolutional neural network prediction model is constructed under the optimal parameter setting. Furthermore, the prediction is made on the testing set. The comparison between the prediction result and actual observed value is shown in Figure5. The predicted value curve of the model fits well with the actual observed value curve. There are many positions almost coinciding with each other, and the overall change trend is the same, which indicates that prediction effect of the proposed model is good.Figure 5
Comparison between model prediction result and actual observed value.For the prediction effect analysis of the model, correlation coefficient, coefficient of determination ,and root mean square error are calculated on testing set. The results are shown in Table9. The R value is 87.77%, R2 is 77.13%, and root mean square error is 0.8571, which meets prediction accuracy requirement. It indicates that the proposed model has good predictive ability. What is more, the correlation between predicted value and actual value is good.Table 9
Comparison of model prediction results.
RR2RMSEMultichannel convolutional neural network model87.77%77.13%0.8571


### 4.5.2. Model Comparison

Experiment compares the prediction results of different models on the testing set, as shown in Table10. Compared with the commonly used prediction model, such as LSTM model and logistic regression model, the proposed multichannel convolutional neural network model has the largest determination error and the smallest root mean square error. Thus, the proposed model has certain advantages in community risk prediction, and its prediction performance is superior to LSTM model and logistics regression model.Table 10
Comparison of prediction results of different models.
ModelR-squaredRMSEMultichannel CNN prediction model0.770.86LSTM prediction model0.720.92Logistic regression prediction model0.591.10


## 4.5.1. Model Verification

The improved effect of the proposed model on the convolutional neural network needs to be verified. Based on the above optimal parameter settings, the prediction results of model before and after the improvement are compared. The results are shown in Table8. Compared with original model, the proposed model improves the prediction accuracy of model, and the structure of convolutional neural network model is improved. Moreover, the performance of proposed model is superior to the original model. Therefore, the improvement of convolutional neural network model is effective.Table 8
Comparison of model prediction results.
ModelRR2RMSEConvolutional neural network model0.96320.93770.8712Multichannel convolutional neural network model0.97630.95690.8571To verify the effectiveness of the model, a multichannel convolutional neural network prediction model is constructed under the optimal parameter setting. Furthermore, the prediction is made on the testing set. The comparison between the prediction result and actual observed value is shown in Figure5. The predicted value curve of the model fits well with the actual observed value curve. There are many positions almost coinciding with each other, and the overall change trend is the same, which indicates that prediction effect of the proposed model is good.Figure 5
Comparison between model prediction result and actual observed value.For the prediction effect analysis of the model, correlation coefficient, coefficient of determination ,and root mean square error are calculated on testing set. The results are shown in Table9. The R value is 87.77%, R2 is 77.13%, and root mean square error is 0.8571, which meets prediction accuracy requirement. It indicates that the proposed model has good predictive ability. What is more, the correlation between predicted value and actual value is good.Table 9
Comparison of model prediction results.
RR2RMSEMultichannel convolutional neural network model87.77%77.13%0.8571


## 4.5.2. Model Comparison

Experiment compares the prediction results of different models on the testing set, as shown in Table10. Compared with the commonly used prediction model, such as LSTM model and logistic regression model, the proposed multichannel convolutional neural network model has the largest determination error and the smallest root mean square error. Thus, the proposed model has certain advantages in community risk prediction, and its prediction performance is superior to LSTM model and logistics regression model.Table 10
Comparison of prediction results of different models.
ModelR-squaredRMSEMultichannel CNN prediction model0.770.86LSTM prediction model0.720.92Logistic regression prediction model0.591.10


## 5. Conclusion

To sum up, the proposed community risk prediction model improves the input of convolutional neural network. DenseNet layer is added to make the multichannel convolutional neural network model built. And the receptive field is improved. In addition, the connection between different network layers solves gradient disappearance problem, and the accuracy of model prediction is improved. Compared with the traditional model, namely, LSTM model and logistic regression model, the proposed multichannel convolutional neural network prediction model performs better on the RMSE index. It has certain advantages and is more suitable for community risk prediction. Meanwhile, it provides decision support for community security risk prevention. Although some research results have been obtained, there are still many shortcomings to be improved in the community risk prediction. The further research should be carried out from the following aspects: In the construction of multichannel convolutional neural network model, this paper mainly considers the model related to time series. However, the spatial factors in practical application also have a greater impact on community risk. Therefore, in the following study, the community spatial data should be incorporated into the analysis of community risk factors, so as to improve the practicality and generalization of the model.



---

*Source: 2373284-2022-03-11.xml*