Urban management method and system based on historical event data assistance
Through the method based on historical event data, the Apriori algorithm and logistic regression model are used to analyze the correlation and causes of urban governance problems, and the problem of insufficient data processing in the existing technology is solved, achieving accurate urban problems Forecasting and reason analysis have improved the efficiency of urban governance.
Patent Information
- Application Number
- CN202411404486.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2024-12-20
AI Technical Summary
The existing urban problem prediction method handles data in general and is not highly targeted, and fails to effectively analyze the causes of the incident problems.
Using a method based on historical event data, collect urban governance indicator data through big data technology, use the Apriori algorithm to perform correlation analysis, find out event factors with high correlation with specific problems, and establish a logistic regression model to predict whether the problem exists or not. Analyze the cause of the problem.
A multi-dimensional correlation analysis of urban specific problems has been achieved, and the potential problems can be discovered in a timely manner and the main causes can be determined, which has improved the efficiency and effectiveness of urban governance.
Smart Images

Figure CN119168832A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of big data mining, and in particular to a city management method assisted by historical event data, a city management system assisted by historical event data, an electronic device and a computer-readable storage medium. Background Art
[0002] With the rapid development and popularization of big data technology in recent years, people have begun to realize that historical event data contains rich information and laws, which can be used to help us predict future problems. Specifically, this method first needs to collect a large amount of historical event data. Then, these historical data are modeled and analyzed using statistical methods such as time series analysis and regression analysis or machine learning methods to mine the hidden patterns and trends in the data. For example, in the construction of smart cities, the city service center receives a large amount of data on urban problems reflected by residents every day, which provides a good research material for studying urban problems. Through data mining algorithms, the correlation of urban data information is mined, and the laws between data are effectively displayed through visualization to predict possible problems in the city and formulate solutions.
[0003] However, the existing data processing methods for predicting urban problems are relatively general, not very targeted at various specific problems, and the causes of the incidents are not analyzed. Summary of the invention
[0004] In order to at least solve the problem that the existing technology is not targeted enough and does not analyze the causes of event problems, the present disclosure provides a city management method assisted by historical event data, a city management system assisted by historical event data, an electronic device, and a computer-readable storage medium, which can find related problems in social governance, find factors related to the problem by revealing the connection between problem events, and analyze the causes of the problem while predicting whether there is a corresponding problem.
[0005] In a first aspect, the present disclosure provides a city management method assisted by historical event data, the method comprising:
[0006] Collect indicator data on urban governance through big data technology;
[0007] Clean and preprocess the collected data;
[0008] Use the Apriori algorithm to analyze the association of pre-processed data, find out the problem events that may be associated with the specific problem, and find out the event factors with a high degree of correlation with the specific problem;
[0009] A logistic regression model is established based on event factors with a high correlation with specific problems to predict whether a specific problem exists, and the causes of the specific problem are analyzed through the model results of the logistic regression.
[0010] Furthermore, the data cleaning and preprocessing of the collected data includes:
[0011] Clean and process the selected data to remove noise and incomplete information;
[0012] Unify data types and classify problem events according to location, time, and event type.
[0013] Furthermore, the Apriori algorithm is used to perform correlation analysis on the pre-processed data to find out the problem events that may be related to the specific problem, and to find out the event factors with a high correlation with the specific problem, including:
[0014] The Apriori algorithm is used to calculate frequent item sets based on the events that occur every day and at each location. Through the frequent item sets, the associated events related to the specific problem are screened, and the associated events are sorted by the degree of correlation to find out the event factors with a high degree of correlation with the specific problem.
[0015] Furthermore, the Apriori algorithm is used to calculate frequent item sets based on events occurring at each location every day, and to screen out related events related to specific issues, including:
[0016] Step S1: Determine the minimum support and minimum confidence;
[0017] Step S2: Calculate the support of each recorded event, and call the event set with support greater than or equal to the minimum support the first frequent item set, and record it as L1;
[0018] Step S3: concatenate the subsets in L1 into a new event set, recorded as the candidate set C2 of the second frequent item set;
[0019] Step S4: Calculate the event set in C2, and call the event set with support greater than or equal to the minimum support the second frequent item set, and record it as L2;
[0020] Step S5: Repeat the above steps S3 and S4 until no frequent item sets can be found;
[0021] Step S6: Calculate the confidence of the frequent item set with the largest number of items at the end, and select the associated events related to the specific problem according to the minimum confidence.
[0022] Furthermore, the logistic regression model is established based on the event factors with high correlation with the specific problem to predict whether there is a specific problem, and the cause of the specific problem is analyzed through the model results of the logistic regression, including:
[0023] Import the sample dataset;
[0024] Use the train_test_split function in Python to divide the sample data set into training set and test set;
[0025] Use the LogisticRegression function to build a Logistic regression model, take each event factor as an input variable, predict whether a specific problem will occur, and use the fit function to train the model;
[0026] Use the score function to check the prediction accuracy of the model in the training set and test set, and get the prediction model with the best accuracy;
[0027] Use classification_report to view the coefficients of each input variable in the prediction model with the best accuracy;
[0028] The influence of each event factor on a specific problem is determined based on the coefficient of each input variable.
[0029] Furthermore, the method further comprises:
[0030] Determine recommendations for improving specific issues based on the degree of impact of each event factor on the specific issue.
[0031] In a second aspect, the present disclosure provides a city management system assisted by historical event data, the system comprising:
[0032] A data collection module configured to collect indicator data on urban governance through big data technology;
[0033] A data processing module, which is configured to clean and pre-process the collected data;
[0034] The association analysis module is configured to use the Apriori algorithm to perform association analysis on the pre-processed data, find out the problem events that may be associated with the specific problem, and find out the event factors with a high degree of association with the specific problem;
[0035] The problem analysis module is configured to establish a logistic regression model based on event factors with a high correlation with the specific problem to predict whether there is a specific problem, and analyze the cause of the specific problem through the model results of the logistic regression.
[0036] Furthermore, the problem analysis module is specifically configured as follows:
[0037] Import the sample dataset;
[0038] Use the train_test_split function in Python to divide the sample data set into training set and test set;
[0039] Use the LogisticRegression function to build a Logistic regression model, take each event factor as an input variable, predict whether a specific problem will occur, and use the fit function to train the model;
[0040] Use the score function to check the prediction accuracy of the model in the training set and test set, and get the prediction model with the best accuracy;
[0041] Use classification_report to view the coefficients of each input variable in the prediction model with the best accuracy;
[0042] The influence of each event factor on a specific problem is determined based on the coefficient of each input variable.
[0043] In a third aspect, the present disclosure provides an electronic device comprising a memory and a processor, wherein the memory stores a computer program, and when the processor runs the computer program stored in the memory, the processor executes the urban management method based on the assistance of historical event data as described in any one of the first aspects.
[0044] In a fourth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the urban management method based on the assistance of historical event data as described in any one of the first aspects above is implemented.
[0045] Beneficial effects:
[0046] The city management method based on historical event data, the city management system based on historical event data, the electronic device and the storage medium provided by the present disclosure first use the Apriori algorithm to find the correlation between specific problem events. The algorithm is simple and easy to understand, and the calculated correlation events have good explanatory power. By identifying the correlation between social problems underlying big data, the algorithm can determine whether there is a significant relationship between two or more variables, which allows managers to understand the relevant issues comprehensively and multi-dimensionally. After finding events related to specific problems, logistic regression analysis is used to predict whether a specific problem has occurred at a certain location, and then analyze which factor has the greatest impact on the problem. Measures can be taken in a timely manner to intervene and solve problems to avoid the expansion and complication of problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 A flowchart of a city management method based on historical event data assistance provided in the first embodiment of the present disclosure;
[0048] Figure 2 A flowchart of a city management method based on historical event data assistance provided in the second embodiment of the present disclosure;
[0049] Figure 3 This is an architecture diagram of a city management system based on historical event data assistance provided in Embodiment 3 of the present disclosure;
[0050] Figure 4 This is an architecture diagram of an electronic device provided in Embodiment 4 of the present disclosure. DETAILED DESCRIPTION
[0051] In order to enable those skilled in the art to better understand the technical solution of the present disclosure, the present disclosure is further described in detail below in conjunction with the drawings and embodiments. It should be understood that the specific embodiments and drawings described herein are only used to explain the present invention, rather than to limit the present invention.
[0052] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence; and, in the absence of conflict, the embodiments in the present disclosure and the features in the embodiments can be arbitrarily combined with each other.
[0053] The terms used in the embodiments of the present disclosure are only for the purpose of describing specific embodiments and are not intended to limit the present disclosure. The singular forms of "a", "said" and "the" used in the embodiments of the present disclosure and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings.
[0054] In the subsequent description, the suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of the present disclosure, and have no specific meanings. Therefore, "module", "component" or "unit" can be used in a mixed manner.
[0055] The technical solution of the present invention and how the technical solution of the present invention solves the above-mentioned problems existing in the prior art are described in detail below with specific embodiments. It is understandable that in the embodiments of the present application, the execution subject can perform some or all of the steps in the embodiments of the present application, and these steps or operations are only examples. The embodiments of the present application can also perform other operations or deformations of various operations. In addition, each step can be performed in a different order presented in the embodiments of the present application, and it is possible not to perform all the operations in the embodiments of the present application. And, the following several specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.
[0056] Figure 1 A flowchart of a city management method based on historical event data assistance provided in the first embodiment of the present disclosure is shown in FIG. Figure 1 As shown, the method includes:
[0057] Step S101: Collecting indicator data on urban governance through big data technology;
[0058] Step S102: Cleaning and preprocessing the collected data;
[0059] Step S103: Use the Apriori algorithm to perform correlation analysis on the pre-processed data to find out the problem events that may be related to the specific problem, and find out the event factors with a high correlation with the specific problem;
[0060] Step S104: A logistic regression model is established based on event factors with a high correlation with the specific problem to predict whether there is a specific problem, and the cause of the specific problem is analyzed through the model result of the logistic regression.
[0061] The disclosed embodiments focus on the prediction and cause analysis of various specific urban problems, such as traffic congestion, disasters, environmental pollution, noise nuisance, water and power outages, etc. Based on the big data of urban governance, the Apriori algorithm in data mining technology is used to explore the trend of events hidden in the data, find out the correlation factors with the occurrence of specific problem events, and then use logistic regression to predict and analyze the problem, so as to timely discover potential abnormal situations in the city and analyze the causes of known problems, and give managers the direction and grasp to solve the problems.
[0062] First, the indicator data on urban governance are collected through big data technology; for example: the location, area, and time of road collapse, the location, decibel, and time of noise nuisance, the traffic volume during traffic congestion, the number of traffic accidents, weather, construction events, etc. The collected data is then cleaned and preprocessed, such as data cleaning, data unification, and corresponding event classification. Then, the Apriori algorithm is used to analyze the association relationship of the preprocessed data to find out the problem events that are highly likely to be associated with the specific problems to be analyzed (such as traffic congestion). Through these problem events, the corresponding event factors with high correlation can be obtained, such as whether the problem event occurs, the event status, etc.; then a logistic regression model is established, and the model is trained through the constructed sample data (including data with specific problems and data without specific problems); and the influence of each event factor is determined according to the prediction accuracy of the model during the training process, and the causes of the specific problems are analyzed, so as to obtain a model that accurately predicts whether a specific problem is sent, and analyzes the factors that need to be solved. Timely measures are taken to intervene and solve problems to avoid the expansion and complexity of problems and improve the efficiency and effectiveness of urban governance.
[0063] The disclosed embodiment uses the correlation algorithm in the statistical method to find related problems in social governance, and finds factors related to specific problems by revealing the connection between problem events. It also uses the logistic regression model to analyze the causes of the problems while predicting whether there are specific problems, and find out the most critical problems, so as to better deal with the problems and prevent them from occurring.
[0064] Furthermore, the data cleaning and preprocessing of the collected data includes:
[0065] Clean and process the selected data to remove noise and incomplete information;
[0066] Unify data types and classify problem events according to location, time, and event type.
[0067] The existing data cleaning methods can be used to remove abnormal and incomplete data from the collected data, and the problem events can be classified by unifying the data types. For example, the following events may be related to urban traffic, such as whether there is an accident, whether it is raining, traffic volume, road capacity, whether it is a weekday, road name, traffic congestion, etc., and can be divided into traffic-type events. The preprocessing of indicator data determines the presentation effect of related events later. The clearer the event is during preprocessing, the easier it is to explain the related events later.
[0068] Furthermore, the Apriori algorithm is used to perform correlation analysis on the pre-processed data to find out the problem events that may be related to the specific problem, and to find out the event factors with a high correlation with the specific problem, including:
[0069] The Apriori algorithm is used to calculate frequent item sets based on the events that occur every day and at each location. Through the frequent item sets, the associated events related to the specific problem are screened, and the associated events are sorted by the degree of correlation to find out the event factors with a high degree of correlation with the specific problem.
[0070] Faced with massive data on urban issues, we first use the Apriori algorithm to calculate frequent item sets based on events occurring every day and at each location. Through frequent item sets, we sort events related to specific issues (such as traffic congestion) by correlation and find out event factors related to specific issues. For example, for traffic congestion, we use various traffic-related events, such as the following data: vehicle volume, number of lanes on urban roads, status of traffic lights, traffic accidents, percentage of traffic participants violating traffic rules, whether there are multiple modes of transportation, whether there are special events such as going to and from school, climate and weather factors, etc. Through the Apriori algorithm, we can find out events with a high correlation with traffic congestion.
[0071] Furthermore, the Apriori algorithm is used to calculate frequent item sets based on events occurring at each location every day, and to screen out related events related to specific issues, including:
[0072] Step S1: Determine the minimum support and minimum confidence;
[0073] Step S2: Calculate the support of each recorded event, and call the event set with support greater than or equal to the minimum support the first frequent item set, and record it as L1;
[0074] Step S3: concatenate the subsets in L1 into a new event set, recorded as the candidate set C2 of the second frequent item set;
[0075] Step S4: Calculate the event set in C2, and call the event set with support greater than or equal to the minimum support the second frequent item set, and record it as L2;
[0076] Step S5: Repeat the above steps S3 and S4 until no frequent item sets can be found;
[0077] Step S6: Calculate the confidence of the frequent item set with the largest number of items at the end, and select the associated events related to the specific problem according to the minimum confidence.
[0078] The principle of the Apriori algorithm used is as follows:
[0079] Items and item sets:
[0080] Let I = {i1,i2,i3,…i n},i1,i2,i3,…i n is an item, and the set I is an item set. For example, in the big data of urban governance issues, a noise nuisance incident, a road collapse incident, and a large truck speeding incident occurred in a certain place on a certain day. Each problem event is an event item, and their collection is an item set.
[0081] Support:
[0082] The support of the association rule X→Y reflects the possibility of {X,Y} appearing in all event sets. The formula is as follows
[0083]
[0084] Where N represents the total number of events, and NUM(X∪Y) represents the number of times event X and event Y occur simultaneously.
[0085] Confidence:
[0086] The confidence of the association rule X→Y reflects the proportion of the event {X,Y} in the case of event X occurring alone. The formula is as follows
[0087]
[0088] Degree of action:
[0089] The degree of association rule X→Y reflects the ratio of the probability of event X to the probability of event X under the condition of event Y. The formula is as follows:
[0090]
[0091] Minimum support and minimum confidence:
[0092] According to actual needs, by calculating the support and confidence of the event and comparing them with the minimum support and minimum confidence, those events that do not meet the minimum values can be removed and pruning operations can be performed to ensure the minimum reliability of the event.
[0093] Frequent itemsets:
[0094] The set of events whose support is greater than the minimum support.
[0095] The basic idea of the Apriori algorithm is to obtain frequent item sets layer by layer in an iterative manner, and it has the following two properties:
[0096] 1. There are two item sets in the event database, X and Y, assuming that And Y is a frequent itemset, X is a non-empty set, then X is a frequent itemset.
[0097] 2. There are two item sets in the time database, X and Y, assuming that And when X is an infrequent itemset, then Y is also an infrequent itemset.
[0098] The idea of the Apriori algorithm is intuitive and simple, easy to understand and implement, and users can quickly understand and use the algorithm. In addition, the algorithm is widely applicable to various types of data sets and has strong scalability, and can be used on data sets containing a large number of events. The setting of the minimum support and minimum confidence determines how to filter the association relationship of events, and different thresholds determine different associated events.
[0099] The process of using the Apriori algorithm to analyze data. Specifically, the Apriori algorithm will first find frequent item sets. Taking traffic congestion as an example, it will find the factors that often appear in traffic congestion events. Then, it will find the association rules between these frequent item sets, that is, which factors are more likely to cause traffic congestion when combined. This step can be implemented through the mlxtend library in Python.
[0100] For example, the screening process of a traffic congestion-related event is as follows:
[0101] First, import the data set as shown in Table 1.
[0102] Table 1: Screened dataset of traffic congestion-related events
[0103]
[0104] Then the data needs to be one-hot encoded, that is, the occurrence is recorded as 1, and the absence is recorded as 0.
[0105] Use the apriori function in Python to find frequent item sets. At this time, set the parameter min_support to 0.5, that is, filter frequent item sets with support greater than 0.5.
[0106] Use the association_rules function in Python to calculate association rules in frequent item sets, set the parameter metric to lift and min_threshold to 1, that is, use the lift metric to find association rules with a lift greater than 1.
[0107] The rule found through the above steps is that traffic jams are closely related to whether there are accidents, heavy traffic, small road capacity, and rain.
[0108] Furthermore, the logistic regression model is established based on the event factors with high correlation with the specific problem to predict whether there is a specific problem, and the cause of the specific problem is analyzed through the model results of the logistic regression, including:
[0109] Import the sample dataset;
[0110] Use the train_test_split function in Python to divide the sample data set into training set and test set;
[0111] Use the LogisticRegression function to build a Logistic regression model, take each event factor as an input variable, predict whether a specific problem will occur, and use the fit function to train the model;
[0112] Use the score function to check the prediction accuracy of the model in the training set and test set, and get the prediction model with the best accuracy;
[0113] Use classification_report to view the coefficients of each input variable in the prediction model with the best accuracy;
[0114] The influence of each event factor on a specific problem is determined based on the coefficient of each input variable.
[0115] The principle of the logistic regression algorithm used is as follows:
[0116] The core of Logistic regression is the sigmoid function, also known as the logistic function, and its formula is as follows:
[0117] σ(z)=1 / (1+e -z )
[0118] Among them, z is a linear combination of the input samples, that is:
[0119] z=w0+w1x1+w2x2+...+w n x n
[0120] where w0,w1,…w n are the parameters of the model, x1,x2,…,x n is the characteristic value of the input sample. The sigmoid function maps z to a value between [0, 1], indicating the probability that the sample belongs to the positive class.
[0121] Logistic regression parameter learning usually uses the maximum likelihood estimation method. Given training samples ((x1,y1),(x2,y2),...,(x m ,y m)), where x i is the sample feature vector, y i is the class label (0 or 1). The parameters of the model can be learned by maximizing the likelihood function, that is:
[0122]
[0123] The commonly used loss function for Logistic regression is the cross entropy loss function, which has the following formula:
[0124]
[0125] In one implementation, a logistic regression model is established for traffic congestion and the model training process is as follows:
[0126] First, import the sample data set as shown in Table 2.
[0127] Table 2: Traffic congestion sample dataset
[0128]
[0129] Use the train_test_split function in Python to divide the dataset into training and test sets, and set test_size to 0.3, that is, 30% of the total data is used as the test set.
[0130] Then use the LogisticRegression function to build a Logistic regression model, which takes traffic flow, road capacity, whether it rains, and whether a traffic accident occurs as input variables to predict whether traffic congestion will occur, and then use the fit function to train the model.
[0131] The score function can be used to view the prediction accuracy of the model in the training set and test set to illustrate the prediction effect of the model.
[0132] Use classification_report to view the coefficients of each input variable in the model. Assuming the model has the best prediction accuracy, the coefficients of each factor are: traffic volume is 0.591, road capacity is -0.247, whether it rains is 1.726, and whether a traffic accident occurs is 1.041.
[0133] It can be seen that according to the results of the Logistic regression model, the coefficients of traffic volume, whether it rains and whether there are traffic accidents are positive, indicating that the greater the traffic volume, the greater the rain and the traffic accidents are, the greater the probability of traffic congestion, while the road capacity coefficient is negative, indicating that the smaller the road capacity, the smaller the probability of traffic congestion. From the coefficient size, the factor with the largest coefficient is whether it rains, indicating that the rain factor has the greatest impact on traffic congestion, indicating that rain is the main cause of traffic congestion, and other reasons also need to be taken seriously.
[0134] By establishing a logistic regression model, factors related to traffic congestion are used as input to predict whether there is a traffic congestion problem in a certain place. According to the size of the model coefficient, the main causes of traffic congestion can be analyzed. The larger the factor coefficient, the higher the degree of impact on traffic congestion. City managers need to focus on solving these factors with large coefficients when solving traffic congestion problems.
[0135] Furthermore, the method further comprises:
[0136] Determine recommendations for improving specific issues based on the degree of impact of each event factor on the specific issue.
[0137] According to the final results of the corresponding regression model, the impact of each highly correlated event factor on the problem can be determined, so as to put forward targeted improvement suggestions and provide urban management with the direction and means to solve the problem.
[0138] For example, the Logistic regression model analysis shows that rain is one of the most important reasons for traffic jams, which needs to be improved, for example: through the intelligent transportation system to collect and analyze the dynamic traffic operation data of the road network, to monitor the operation status of the road network, and to issue severe weather warnings to reduce the impact of severe weather on road traffic. For other influencing factors, the following suggestions for improvement can be put forward, for example: 1. In response to the problem of large traffic volume and small road capacity, roads can be widened or newly built, road planning can be optimized, and traffic diversion can be strengthened. 2. In response to traffic accidents, safe driving publicity can be strengthened to improve drivers' legal awareness and cultivate good driving habits.
[0139] The disclosed embodiment uses the Apriori algorithm to find the correlation between specific problem events. The algorithm is simple and easy to understand, and the calculated correlation events are well interpretable. By identifying the correlation between social problems underlying big data, the algorithm can determine whether there is a significant relationship between two or more variables, which allows managers to understand related issues comprehensively and multi-dimensionally. After finding events related to specific problems, logistic regression analysis is used to predict whether a specific problem has occurred in a certain location, and the model is used to analyze which factor has the greatest impact on the problem. Measures can be taken in a timely manner to intervene and solve problems to avoid the expansion and complexity of the problem.
[0140] like Figure 2 As shown, the second embodiment of the present disclosure also provides a city management method based on historical event data, which specifically explores the causes of traffic congestion in a city and proposes improvement suggestions. Figure 2 As shown, the steps include:
[0141] 1. Data Collection
[0142] Collect traffic data in the city, including traffic flow, road capacity, traffic light status, weather conditions, whether there is traffic jam, traffic jam location, whether there are major events, whether traffic signs and markings are clear, whether there are traffic violations, whether there are traffic accidents, the number of branch roads and other information.
[0143] 2. Data preprocessing
[0144] The selected data are cleaned and processed to remove noise and incomplete information.
[0145] 3. Use Apriori algorithm
[0146] The Apriori algorithm is used to analyze this data. Specifically, the Apriori algorithm first finds frequent item sets, that is, factors that often appear in traffic jams. Then, it finds the association rules between these frequent item sets, that is, which factors are more likely to cause traffic jams when combined. This step can be achieved through the mlxtend library in Python. First, import the data set as shown in Table 1.
[0147] Table 1: Screened dataset of traffic congestion-related events
[0148]
[0149]
[0150] Then the data needs to be one-hot encoded, that is, the occurrence is recorded as 1, and the absence is recorded as 0.
[0151] Use the apriori function in Python to find frequent item sets. At this time, set the parameter min_support to 0.5, that is, filter frequent item sets with support greater than 0.5.
[0152] Use the association_rules function in Python to calculate association rules in frequent item sets, set the parameter metric to lift and min_threshold to 1, that is, use the lift metric to find association rules with a lift greater than 1.
[0153] The rule found through the above steps is that traffic jams are closely related to whether there are accidents, heavy traffic, small road capacity, and rain.
[0154] 4. Build a Logistic Regression Model
[0155] First, import the sample data set as shown in Table 2.
[0156] Table 2: Traffic congestion sample dataset
[0157]
[0158] Use the train_test_split function in Python to divide the dataset into training and test sets, and set test_size to 0.3, that is, 30% of the total data is used as the test set.
[0159] Then use the LogisticRegression function to build a Logistic regression model, which takes traffic flow, road capacity, whether it rains, and whether a traffic accident occurs as input variables to predict whether traffic congestion will occur, and then use the fit function to train the model.
[0160] The score function can be used to view the prediction accuracy of the model in the training set and test set to illustrate the prediction effect of the model.
[0161] Use classification_report to view the coefficients of each input variable in the model, assuming that the traffic volume is 0.591, the road capacity is -0.247, whether it rains is 1.726, and whether there is a traffic accident is 1.041.
[0162] 5. Analyze the causes of traffic jams
[0163] According to the results of the Logistic regression model, the coefficients of traffic volume, whether it rains and whether there are traffic accidents are positive, indicating that the greater the traffic volume, the greater the rain and the traffic accidents are, the greater the probability of traffic congestion, while the road capacity coefficient is negative, indicating that the smaller the road capacity, the smaller the probability of traffic congestion. From the coefficient size, the factor with the largest coefficient is whether it rains, indicating that the rain factor has the greatest impact on traffic congestion, indicating that rain is the main cause of traffic congestion, and other reasons also need to be taken seriously.
[0164] 6. Propose suggestions for improvement
[0165] Logistic regression model analysis shows that rain is one of the most important reasons for traffic jams, which needs to be improved, for example: through the intelligent transportation system to collect and analyze the dynamic traffic operation data of the road network, to monitor the operation status of the road network, and to issue severe weather warnings to reduce the impact of severe weather on road traffic. For other influencing factors, the following suggestions for improvement can be put forward, for example: 1. In response to the problem of large traffic volume and small road capacity, roads can be widened or newly built, road planning can be optimized, and traffic diversion can be strengthened. 2. In response to traffic accidents, safe driving publicity can be strengthened to improve drivers' legal awareness and cultivate good driving habits.
[0166] The third embodiment of the present disclosure also provides a city management system based on historical event data. Figure 3 As shown, the system comprises:
[0167] A data collection module 11, which is configured to collect indicator data on urban governance through big data technology;
[0168] A data processing module 12, which is configured to clean and pre-process the collected data;
[0169] The correlation analysis module 13 is configured to use the Apriori algorithm to perform correlation analysis on the pre-processed data, find out the problem events that may be related to the specific problem, and find out the event factors with a high correlation with the specific problem;
[0170] The problem analysis module 14 is configured to establish a logistic regression model based on event factors with a high correlation with the specific problem to predict whether there is a specific problem, and analyze the cause of the specific problem through the model result of the logistic regression.
[0171] Furthermore, the data processing module 12 is specifically configured as follows:
[0172] Clean and process the selected data to remove noise and incomplete information;
[0173] Unify data types and classify problem events according to location, time, and event type.
[0174] Furthermore, the association analysis module 13 is specifically configured as follows:
[0175] The Apriori algorithm is used to calculate frequent item sets based on the events that occur every day and at each location. Through the frequent item sets, the associated events related to the specific problem are screened, and the associated events are sorted by the degree of correlation to find out the event factors with a high degree of correlation with the specific problem.
[0176] Furthermore, the Apriori algorithm is used to calculate frequent item sets based on events occurring at each location every day, and to screen out related events related to specific issues, including:
[0177] Step S1: Determine the minimum support and minimum confidence;
[0178] Step S2: Calculate the support of each recorded event, and call the event set with support greater than or equal to the minimum support the first frequent item set, and record it as L1;
[0179] Step S3: concatenate the subsets in L1 into a new event set, recorded as the candidate set C2 of the second frequent item set;
[0180] Step S4: Calculate the event set in C2, and call the event set with support greater than or equal to the minimum support the second frequent item set, and record it as L2;
[0181] Step S5: Repeat the above steps S3 and S4 until no frequent item sets can be found;
[0182] Step S6: Calculate the confidence of the frequent item set with the largest number of items at the end, and select the associated events related to the specific problem according to the minimum confidence.
[0183] Furthermore, the problem analysis module 14 is specifically configured as follows:
[0184] Import the sample dataset;
[0185] Use the train_test_split function in Python to divide the sample data set into training set and test set;
[0186] Use the LogisticRegression function to build a Logistic regression model, take each event factor as an input variable, predict whether a specific problem will occur, and use the fit function to train the model;
[0187] Use the score function to check the prediction accuracy of the model in the training set and test set, and get the prediction model with the best accuracy;
[0188] Use classification_report to view the coefficients of each input variable in the prediction model with the best accuracy;
[0189] The influence of each event factor on a specific problem is determined based on the coefficient of each input variable.
[0190] Furthermore, the system also includes a suggestion module 15;
[0191] The suggestion module 15 is configured to determine suggestions for improving a specific problem based on the degree of influence of various event factors on the specific problem.
[0192] The city management system assisted by historical event data in the embodiment of the present disclosure is used to implement the city management method assisted by historical event data in method embodiment 1 and embodiment 2, so the description is relatively simple. For details, please refer to the relevant description in the previous method embodiment, which will not be repeated here.
[0193] In addition, if Figure 4 As shown, the fourth embodiment of the present disclosure further provides an electronic device, including a memory 100 and a processor 200, wherein the memory 100 stores a computer program, and when the processor 200 runs the computer program stored in the memory 100, the processor 200 executes the above-mentioned various possible methods.
[0194] The memory 100 is connected to the processor 200. The memory 100 may be a flash memory, a read-only memory or other memory, and the processor 200 may be a central processing unit or a single-chip microcomputer.
[0195] In addition, an embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to perform the above-mentioned various possible methods.
[0196] The computer-readable storage medium includes volatile or non-volatile, removable or non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, computer program modules or other data). Computer-readable storage media include, but are not limited to, RAM (Random Access Memory), ROM (Read-Only Memory), EEPROM (Electrically Erasable Programmable read only memory), flash memory or other memory technology, CD-ROM (Compact Disc Read-Only Memory), Digital Video Disc (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer.
[0197] It is to be understood that the above embodiments are merely exemplary embodiments used to illustrate the principles of the present disclosure, but the present disclosure is not limited thereto. For those of ordinary skill in the art, various modifications and improvements can be made without departing from the spirit and substance of the present disclosure, and these modifications and improvements are also considered to be within the scope of protection of the present disclosure.
Claims
1. A city management method based on historical event data, characterized in that: The method comprises: Collect indicator data on urban governance through big data technology; Clean and preprocess the collected data; Use the association rule mining algorithm Apriori algorithm to analyze the association relationship of the pre-processed data, find out the problem events that may be related to the specific problem, and find out the event factors with a high degree of correlation with the specific problem; A logistic regression model is established based on event factors with a high correlation with specific problems to predict whether a specific problem exists, and the causes of the specific problem are analyzed through the model results of the logistic regression.
2. The method according to claim 1, characterized in that The data cleaning and preprocessing of the collected data includes: Clean and process the selected data to remove noise and incomplete information; Unify data types and classify problem events according to location, time, and event type.
3. The method according to claim 1, characterized in that The Apriori algorithm is used to perform correlation analysis on the pre-processed data to find out the problem events that may be related to the specific problem, and to find out the event factors with a high correlation with the specific problem, including: The Apriori algorithm is used to calculate frequent item sets based on the events that occur every day and at each location. Through the frequent item sets, the associated events related to the specific problem are screened, and the associated events are sorted by the degree of correlation to find out the event factors with a high degree of correlation with the specific problem.
4. The method according to claim 3, characterized in that The Apriori algorithm is used to calculate frequent item sets based on events that occur every day and at each location, and to screen out related events related to specific issues, including: Step S1: Determine the minimum support and minimum confidence; Step S2: Calculate the support of each recorded event, and call the event set with support greater than or equal to the minimum support the first frequent item set, and record it as L1; Step S3: concatenate the subsets in L1 into a new event set, recorded as the candidate set C2 of the second frequent item set; Step S4: Calculate the event set in C2, and call the event set with support greater than or equal to the minimum support the second frequent item set, and record it as L2; Step S5: Repeat the above steps S3 and S4 until no frequent item sets can be found; Step S6: Calculate the confidence of the frequent item set with the largest number of items at the end, and select the associated events related to the specific problem according to the minimum confidence.
5. The method according to claim 1 or 3, characterized in that: The logistic regression model is established based on event factors with a high correlation with the specific problem to predict whether there is a specific problem, and the cause of the specific problem is analyzed through the logistic regression model result, including: Import the sample dataset; Use the train_test_split function in Python to divide the sample data set into training set and test set; Use the LogisticRegression function to build a Logistic regression model, take each event factor as an input variable, predict whether a specific problem will occur, and use the fit function to train the model; Use the score function to check the prediction accuracy of the model in the training set and test set, and get the prediction model with the best accuracy; Use classification_report to view the coefficients of each input variable in the prediction model with the best accuracy; The influence of each event factor on a specific problem is determined based on the coefficient of each input variable.
6. The method according to claim 5, characterized in that The method further comprises: Determine recommendations for improving specific issues based on the degree of impact of each event factor on the specific issue.
7. A city management system based on historical event data, characterized in that: The system comprises: A data collection module configured to collect indicator data on urban governance through big data technology; A data processing module, which is configured to clean and pre-process the collected data; The association analysis module is configured to use the Apriori algorithm to perform association analysis on the pre-processed data, find out the problem events that may be associated with the specific problem, and find out the event factors with a high degree of association with the specific problem; The problem analysis module is configured to establish a logistic regression model based on event factors with a high correlation with the specific problem to predict whether there is a specific problem, and analyze the cause of the specific problem through the model results of the logistic regression.
8. The system according to claim 7, characterized in that The problem analysis module is specifically configured as follows: Import the sample dataset; Use the train_test_split function in Python to divide the sample data set into training set and test set; Use the LogisticRegression function to build a Logistic regression model, take each event factor as an input variable, predict whether a specific problem will occur, and use the fit function to train the model; Use the score function to check the prediction accuracy of the model in the training set and test set, and get the prediction model with the best accuracy; Use classification_report to view the coefficients of each input variable in the prediction model with the best accuracy; The influence of each event factor on a specific problem is determined based on the coefficient of each input variable.
9. An electronic device, characterized in that: It comprises a memory and a processor, wherein the memory stores a computer program, and when the processor runs the computer program stored in the memory, the processor executes the city management method based on the assistance of historical event data as described in any one of claims 1-6.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the city management method based on the assistance of historical event data as described in any one of claims 1 to 6 is implemented.
