Urban park resource optimal configuration method based on random forest model
Through the random forest model, the social media comment text was analyzed, the weight of environmental factors was extracted, and the user satisfaction score was calculated, which solved the problem of insufficient data utilization in urban park resource allocation, and achieved scientific optimization of park resources and accurate reflection of user needs.
Patent Information
- Application Number
- CN202411871744.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-04-15
AI Technical Summary
In the planning and management of existing urban parks, there is a lack of utilization of network big data, resulting in a single and poor real-time evaluation method for park satisfaction, which cannot fully reflect the multi-dimensional needs of users. The traditional evaluation system is difficult to meet the diversified needs of urban users.
Using a random forest model method, we obtain social media comment texts from network big data, conduct sentiment analysis and topic extraction, calculate the importance weight of environmental factors, generate user satisfaction scores, and then carry out targeted resource optimization configuration.
It realizes the scientificity and reliability of park resource allocation, accurately quantifies users' multi-dimensional demand for park services, improves the efficiency and efficiency of park resource allocation, and ensures the accuracy of park management strategies and resource investment.
Smart Images

Figure CN119831225A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of smart cities and urban and rural planning, and in particular to a method for optimizing the allocation of urban park resources based on a random forest model. Background Art
[0002] As an important part of urban functions, urban parks play an indispensable role in improving the quality of life of users, promoting physical and mental health, and enhancing the urban ecological environment. The spatial layout and service functions of urban parks have gradually become an important part of urban planning and public service facilities construction. Scientific and reasonable park planning and service optimization are one of the important links in urban ecological resource regulation, social equity maintenance, and improving public service levels. Scientifically evaluating user needs for parks in urban planning and rationally allocating park resources and service levels can effectively ensure the maximization of urban users' leisure experience and ecological service functions.
[0003] However, in the process of urbanization, the planning and layout of urban parks and their satisfaction are driven and restricted by a variety of factors. These factors are intertwined and together constitute a comprehensive mechanism that affects park satisfaction. The current development of urban parks generally faces the following problems: on the one hand, high-quality park resources within the city are concentrated in the central urban area, and the number of parks in suburban areas and grassroots communities is insufficient and single-function, which cannot meet the needs of users for diversified outdoor activities; on the other hand, although some parks have complete facilities, their service quality is not high and maintenance is insufficient, resulting in poor user experience. In addition, due to the lack of a scientific evaluation system, the measurement of park satisfaction usually relies only on offline questionnaires or expert evaluations, with small sample coverage and slow data updates, making it difficult to fully reflect the real needs of users and the dynamic changes of park services. At the same time, with the changes in the urban population structure and the diversification of user needs, the service pressure of urban parks has become increasingly prominent: including the increased demand for barrier-free facilities brought about by the aging population, the increased demand for fitness venues for users with chronic diseases, and the preference of young people for characteristic and park activities. These changes have made it difficult for traditional park planning and service management models to meet the needs of contemporary urban users.
[0004] With the accelerated development of digitalization, networking, and intelligence, the deep integration of the Internet and urban public services has provided a new solution for urban park planning and management. With the popularization of network infrastructure and smart terminals, massive amounts of user data have been generated on mobile application platforms such as social media, online reviews, and entertainment interactions. These data include users' direct feedback and implicit needs for parks. Analysis based on network big data can obtain information on the service status and user satisfaction of urban parks on a larger scale and more refined scale, providing a scientific basis for park planning, design, and optimization.
[0005] However, the current park service satisfaction evaluation methods still rely on traditional offline methods and lack the use of network big data. The limitations of this traditional method are mainly reflected in the following aspects: 1) Single data source: mainly based on questionnaire surveys or qualitative research, it is difficult to cover the real feelings of a large number of users. 2) Lack of real-time dynamics: It cannot reflect the dynamic characteristics of user experience changing with time, space and demand. 3) Insufficient indicator system: It ignores the multi-dimensional needs of users for service experience and does not make full use of data mining technology to reveal the key factors affecting satisfaction.
[0006] The satisfaction evaluation method based on network big data breaks through the limitations of traditional evaluation. It can not only integrate online and offline feedback information, but also dynamically track user needs and park service conditions, providing accurate decision-making support for optimizing resource allocation and service quality. Therefore, how to build a comprehensive evaluation system for urban park satisfaction based on network big data, scientifically quantify the relationship between park services and user satisfaction, and propose targeted optimization strategies are key technical issues that need to be urgently solved in the current field of urban planning and management. Summary of the invention
[0007] In view of the deficiencies of the above-mentioned prior art, the technical problem to be solved by the present invention is: how to provide a method for optimizing the allocation of urban park resources based on a random forest model. The method first fully mines the direct feedback and implicit needs of users for urban parks in network big data; secondly, extracts and calculates the user scores of environmental factors related to user satisfaction to consider the multi-dimensional needs of users for service experience; then, the importance weights of each environmental factor are generated through a random forest model, and the user satisfaction score for urban parks is weightedly calculated. This method can scientifically quantify the relationship between park services and user satisfaction through multi-dimensional indicators. Finally, based on the user satisfaction scores of urban parks and the importance of environmental factors, targeted optimization of urban park resources is carried out, thereby improving the comprehensiveness and reliability of the optimization of urban park resources.
[0008] In order to solve the above technical problems, the present invention adopts the following technical solutions:
[0009] A method for optimizing the allocation of urban park resources based on a random forest model, comprising:
[0010] S1: Obtain social media comment texts related to urban parks in the target area from the Internet big data;
[0011] S2: Perform sentiment analysis on social media comment texts to obtain the sentiment intensity score of each social media comment text;
[0012] S3: Extract topics about environmental factors from each social media comment text and assign corresponding distribution weights to each extracted environmental factor;
[0013] S4: Calculate the user score of each environmental factor based on the sentiment intensity score of each social media comment text, the extracted environmental factors, and the distribution weights assigned to the environmental factors;
[0014] S5: Determine the importance of environmental factors to user satisfaction through the random forest model and generate the importance weight of each environmental factor;
[0015] S6: Calculate the user satisfaction score of each city park based on the average user score of each environmental factor in the social media comment text of each city park and the importance weight of the environmental factor
[0016] S7: Compare the user satisfaction scores of various urban parks and the importance of environmental factors of each urban park to optimize resource allocation for urban parks in the target area.
[0017] Preferably, in step S1, the obtained social media comment text needs to be preprocessed;
[0018] Preprocessing includes:
[0019] 1) Delete irrelevant comments: Delete social media comments that are irrelevant to the actual experience of each city park;
[0020] 2) Standardization: unify the time format and location field naming format of social media comment text;
[0021] 3) Text data cleaning: including Chinese word segmentation, removal of stop words, removal of special characters and emoticons, language identification and translation, spelling correction and word standardization or processing of missing data and outliers.
[0022] Preferably, in step S2, sentiment analysis is performed on the social media comment text using a BERT pre-trained model;
[0023] The specific steps of sentiment scoring are as follows:
[0024] S201: Encode the input social media comment text through the Tokenizer of the BERT pre-trained model; convert the encoded social media comment text into a series of input vectors;
[0025] S202: extracting features from the input vector using the encoder of the BERT pre-trained model to obtain text features;
[0026] S203: Generate a value between -1 and 1 as the sentiment intensity score of the social media comment text based on the text features through the regression layer of the BERT pre-trained model.
[0027] Preferably, in step S203, when the sentiment intensity score of the social media comment text is between 1 and 0, the corresponding sentiment category is positive; when the sentiment intensity score of the social media comment text is 0, the corresponding sentiment category is neutral; when the sentiment intensity score of the social media comment text is between 0 and -1, the corresponding sentiment category is negative.
[0028] Preferably, in step S3, topics about environmental factors are extracted from social media comment texts using an LDA model;
[0029] The specific steps of topic extraction are as follows:
[0030] S301: Obtain social media comment text for LDA model training and perform preprocessing;
[0031] S302: converting all preprocessed social media comment texts into a bag-of-words model, so that each social media comment text is represented as a word frequency vector on a vocabulary;
[0032] S303: setting the number of environmental factors, i.e., topics, and using the LDA algorithm to train the bag-of-words model to output the topic distribution of each social media comment text and the keyword distribution of each topic; wherein each topic represents an environmental factor;
[0033] S304: assigning one or more environmental factors to each social media comment text according to the topic distribution;
[0034] S305: Determine the distribution weight of each environmental factor in the social media comment text according to the probability distribution of the environmental factor in each social media comment text.
[0035] Preferably, in step S4, the user score of each environmental factor in the social media comment text is obtained by multiplying the sentiment score of each social media comment text by the distribution weight of each environmental factor.
[0036] Preferably, in step S5, the specific steps of determining the importance weight of the environmental factor are as follows:
[0037] S501: construct a data set and divide it into a training set and a test set; wherein each sample in the data set includes an environmental factor as feature data and a user score as a target variable;
[0038] S502: Train the random forest model using the training set:
[0039] S5021: Randomly extract subsamples from the training set using Bootstrap sampling;
[0040] S5022: For each sub-sample set, a decision tree is constructed using the CART algorithm;
[0041] S5023: Each decision tree continues to split until it reaches the specified tree depth, minimum number of samples or other stopping conditions;
[0042] S5024: Repeat steps S5021 to S5023 until the number of decision trees reaches a preset value or the model converges;
[0043] S503: Test the random forest model using the test set;
[0044] S504: After the random forest model training is completed, the importance of each feature is evaluated by analyzing the contribution of each feature to the result; the importance of the feature is the importance of the environmental factor;
[0045] S505: Generate an importance weight for each environmental factor based on the importance of each feature.
[0046] Preferably, in step S504, the importance weight of each environmental factor is generated by the following steps:
[0047] S5041: For each decision tree in the random forest, traverse all its nodes;
[0048] S5042: For each node, find a feature for splitting;
[0049] S5043: Calculate the impurity change of the node before and after the feature is split, that is, the reduction of the Gini index; add up the impurity changes of the feature on all nodes to obtain the importance score of the feature on the current decision tree;
[0050] The calculation formula of the Gini index is expressed as:
[0051]
[0052] Where: Gini(D) represents the Gini index; p(i) represents the probability of environmental factor i in the sample; m represents the total number of categories of environmental factors;
[0053] S5044: Repeat steps S5041 to S5043 to calculate the importance score of each feature in each decision tree;
[0054] S5045: Calculate the average value of the importance score of each feature on all decision trees; normalize the average value of the importance score of each feature to generate the importance weight of the corresponding environmental factor.
[0055] Preferably, in step S6, the user satisfaction score of each city park is calculated by the following steps:
[0056] S601: Calculate the average score of each environmental factor in all social media comment texts of each city park as the original score;
[0057] S602: Construct an environmental factor matrix containing the original scores of each urban park on different environmental factors; the elements x in the environmental factor matrix ij represents the original score of urban park i on environmental factor j;
[0058] S603: For each environmental factor j, the original score x of city park i on environmental factor j is ij Normalize to get the relative score r ij ;
[0059] The normalized formula is expressed as:
[0060]
[0061] Where: n represents the number of urban parks;
[0062] S604: Determine the positive ideal solution A for each environmental factor j + and negative ideal solution A - ;
[0063] The formula is:
[0064]
[0065]
[0066] S605: Calculate city park i to positive ideal solution A + The forward distance and to the negative ideal solution A - Negative distance
[0067] The formula is:
[0068]
[0069] Where: w j represents the importance weight of environmental factor j;
[0070] S606: Based on forward distance and negative distance Calculate the user satisfaction score of city park i relative to other city parks;
[0071] The formula is:
[0072]
[0073] Where: C i Indicates that the user satisfaction score of city park i is equivalent to that of other city parks.
[0074] Preferably, in step S7, the strategy for optimizing resource configuration includes:
[0075] 1) Identify one or more urban parks with the lowest user satisfaction scores and make targeted resource allocation and improvements;
[0076] 2) Based on the importance of environmental factors generated by the random forest model, determine one or more environmental factors that have the greatest impact on the satisfaction score, and make targeted resource allocation and improvements.
[0077] Compared with the prior art, the urban park resource optimization configuration method based on the random forest model in the present invention has the following beneficial effects:
[0078] The present invention can accurately capture users' positive, neutral or negative comments on city parks by obtaining social media comment texts related to city parks from network big data and performing sentiment analysis on social media comment texts, thereby fully tapping users' direct feedback and implicit needs for parks. Different from traditional sentiment analysis methods, the present invention adopts the BERT pre-training model, which has accumulated rich language knowledge and context understanding capabilities through pre-training on a large-scale corpus, and can better identify complex emotional expressions and implicit emotions, ensuring the generalization ability of the model in social media comment texts of different fields and styles, thereby improving the accuracy and reliability of sentiment scoring.
[0079] Based on calculating the sentiment intensity score of social media comment text, the present invention further extracts environmental factors related to user satisfaction through the LDA model and assigns distribution weights to each environmental factor. The LDA model can automatically identify potential environmental factors from large-scale social media comment texts through unsupervised learning, and assign weights to them according to the frequency of occurrence and importance, ensuring a comprehensive consideration of the impact on user satisfaction. In this way, it is possible to accurately identify park environmental factors that users are concerned about (such as safety, facility management, environmental quality, green space coverage, etc.), and provide targeted improvement directions for park resource optimization.
[0080] The present invention evaluates the importance of environmental factors through a random forest model. By integrating the results of multiple decision trees, the random forest can objectively evaluate the role of each environmental factor in affecting user satisfaction, avoiding the subjectivity and uncertainty of human judgment. At the same time, the random forest reduces the risk of overfitting and improves the stability and reliability of the evaluation results by introducing randomness, such as randomly selecting features and sample division. Based on this model, the present invention can provide a scientific and reasonable decision-making basis for the optimal allocation of resources in urban parks, and prioritize the allocation of resources to improve the environmental factors that have the greatest impact on user satisfaction.
[0081] The present invention calculates the mean of the user scores of each environmental factor and combines the importance weights of the environmental factors to obtain the user satisfaction score of the urban park, thereby realizing the scientific optimization of park resources. Through this method, it is possible to accurately quantify the multi-dimensional needs of users for park services, truly reflect the overall performance of different urban parks in the minds of users, and thus provide a clear direction and goal for the optimal allocation of park resources. In addition, by comparing the satisfaction scores of different parks, it is possible to scientifically guide the rational allocation of resources among urban parks, ensure that park management strategies and resource investment are more accurate, and thus improve the benefits and efficiency of urban park resource allocation. BRIEF DESCRIPTION OF THE DRAWINGS
[0082] In order to make the purpose, technical solution and advantages of the invention more clear, the present invention will be further described in detail below with reference to the accompanying drawings, in which:
[0083] Figure 1 An optimal allocation method for urban park resources based on random forest model.
[0084] Figure 2 and Figure 3 An example of data collection. DETAILED DESCRIPTION
[0085] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. The components of the embodiments of the present invention generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but only represents selected embodiments of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work belong to the scope of protection of the present invention.
[0086] The following is a further detailed description through specific implementation methods:
[0087] Example:
[0088] This embodiment discloses a method for optimizing the allocation of urban park resources based on a random forest model.
[0089] like Figure 1 As shown in the figure, the urban park resource optimization configuration method based on the random forest model includes:
[0090] S1: Obtain social media comment texts related to urban parks in the target area from the Internet big data;
[0091] S2: Perform sentiment analysis on social media comment texts to obtain the sentiment intensity score of each social media comment text;
[0092] S3: Extract topics about environmental factors from each social media comment text and assign corresponding distribution weights to each extracted environmental factor;
[0093] S4: Calculate the user score of each environmental factor based on the sentiment intensity score of each social media comment text, the extracted environmental factors, and the distribution weights assigned to the environmental factors;
[0094] S5: Determine the importance of environmental factors to user satisfaction through the random forest model and generate the importance weight of each environmental factor;
[0095] S6: Calculate the user satisfaction score of each city park based on the average user score of each environmental factor in the social media comment text of each city park and the importance weight of the environmental factor
[0096] S7: Compare the user satisfaction scores of various urban parks and the importance of environmental factors of each urban park to optimize resource allocation for urban parks in the target area.
[0097] The present invention can accurately capture users' positive, neutral or negative comments on city parks by obtaining social media comment texts related to city parks from network big data and performing sentiment analysis on social media comment texts, thereby fully tapping users' direct feedback and implicit needs for parks. Different from traditional sentiment analysis methods, the present invention adopts the BERT pre-training model, which has accumulated rich language knowledge and context understanding capabilities through pre-training on a large-scale corpus, and can better identify complex emotional expressions and implicit emotions, ensuring the generalization ability of the model in social media comment texts of different fields and styles, thereby improving the accuracy and reliability of sentiment scoring.
[0098] Based on calculating the sentiment intensity score of social media comment text, the present invention further extracts environmental factors related to user satisfaction through the LDA model and assigns distribution weights to each environmental factor. The LDA model can automatically identify potential environmental factors from large-scale social media comment texts through unsupervised learning, and assign weights to them according to the frequency of occurrence and importance, ensuring a comprehensive consideration of the impact on user satisfaction. In this way, it is possible to accurately identify park environmental factors that users are concerned about (such as safety, facility management, environmental quality, green space coverage, etc.), and provide targeted improvement directions for park resource optimization.
[0099] The present invention evaluates the importance of environmental factors through a random forest model. By integrating the results of multiple decision trees, the random forest can objectively evaluate the role of each environmental factor in affecting user satisfaction, avoiding the subjectivity and uncertainty of human judgment. At the same time, the random forest reduces the risk of overfitting and improves the stability and reliability of the evaluation results by introducing randomness, such as randomly selecting features and sample division. Based on this model, the present invention can provide a scientific and reasonable decision-making basis for the optimal allocation of resources in urban parks, and prioritize the allocation of resources to improve the environmental factors that have the greatest impact on user satisfaction.
[0100] The present invention calculates the mean of the user scores of each environmental factor and combines the importance weights of the environmental factors to obtain the user satisfaction score of the urban park, thereby realizing the scientific optimization of park resources. Through this method, it is possible to accurately quantify the multi-dimensional needs of users for park services, truly reflect the overall performance of different urban parks in the minds of users, and thus provide a clear direction and goal for the optimal allocation of park resources. In addition, by comparing the satisfaction scores of different parks, it is possible to scientifically guide the rational allocation of resources among urban parks, ensure that park management strategies and resource investment are more accurate, and thus improve the benefits and efficiency of urban park resource allocation.
[0101] In order to better introduce the technical solution of the present invention, this embodiment is described through the following parts.
[0102] 1. Data Collection and Preprocessing
[0103] In this embodiment, the required information is obtained through network media data and social network data, and legal and compliant web crawler technology is used to ensure that the data acquisition process complies with the terms of service and privacy policy of the relevant websites. The selected Internet platforms include but are not limited to Dianping, Ctrip and Weibo. The evaluation data provided by these platforms contains a variety of event attributes, including but not limited to the following fields: event geography, user information, score, event comment and time attribute. Through these data, the social media evaluation text data of urban parks in the target area can be effectively obtained to provide support for subsequent analysis. Examples of data collection include Figure 2 and Figure 3 shown.
[0104] In order to ensure the effectiveness of subsequent analysis and model training, the collected urban park review data must be scientifically preprocessed. Data preprocessing not only helps to remove noise data, but also improves the consistency, usability and accuracy of text data. Preprocessing includes:
[0105] 1) Remove irrelevant comments: Remove social media comment texts that are not related to the actual experience of each city park, including advertisements, invalid information, or spam comments;
[0106] In this embodiment, irrelevant comments usually do not involve the actual experience of the park, and may be automatically generated or contain advertisement links and promotional content. Removing irrelevant comments helps ensure that the dataset only contains real and valuable user feedback, thereby reducing the interference of noise on the analysis results.
[0107] 2) Standardization: Unify the time format of social media comment texts and the naming format of location fields;
[0108] In this embodiment, the time fields in the data may come from different sources and have inconsistent formats. It is necessary to unify the time format, for example, convert all timestamps to a unified date and time format (such as ISO 8601 format). Similarly, location fields (such as park names, cities, regions, etc.) may have different writing styles or spelling mistakes, and it is necessary to standardize the geographical location information to ensure unified naming. The standardized time and location fields will make the data more consistent and easier to process in subsequent analysis.
[0109] 3) Text data cleaning: Include Chinese word segmentation, stop word removal, special character and emoji removal, language recognition and translation, spelling correction and word standardization, or handling missing data and outliers.
[0110] Specifically:
[0111] Chinese word segmentation: Chinese text does not have obvious word delimiters like English, so Chinese word segmentation is the first step in processing Chinese text data. The purpose of word segmentation is to break down a continuous sequence of characters into meaningful lexical units for subsequent analysis and modeling.
[0112] Stop word removal: Stop words refer to those words that appear frequently in the text but do not carry important meanings, such as "de", "le", "he", etc. These words have little impact on the analysis, and removing them helps improve the efficiency and accuracy of text analysis. Stop word removal usually uses existing stop word dictionaries (such as the Harbin Institute of Technology stop word dictionary), and can be extended or customized according to the actual situation.
[0113] Removal of special characters and emojis: Social media comments often contain special characters (such as "#" or "@"), emojis, etc. These symbols have little impact on the analysis results and may even introduce noise. Therefore, these irrelevant characters and symbols need to be removed from the comment text.
[0114] Language identification and translation: Since the user groups of social media platforms may use different languages, comments may contain multiple languages (such as Chinese, English, etc.). In order to ensure that comments in different languages can be analyzed uniformly, language identification is required and non-target languages (such as English) need to be translated. Using existing language identification tools (such as Langid or Google Translate API), the language of the comments can be automatically identified and non-Chinese comments can be translated to ensure language consistency during the analysis process.
[0115] Spelling correction and word standardization: Spelling errors, abbreviations, or irregular words in social media comments may affect the analysis results. Spelling correction tools such as TextBlob can be used to detect and correct spelling errors. In addition, common abbreviations or local colloquialisms (such as "park + promenade" or "park + trail") can be standardized to ensure that words with the same meaning do not distract from the processing results.
[0116] Handling missing data and outliers: Missing key information in reviews (such as ratings, review content, etc.) needs to be filled or deleted. Missing data can be filled by interpolation, mean filling, etc., or by directly deleting reviews with serious missing data. Outliers in ratings or review content (such as abnormal data with too high or too low ratings, and reviews that obviously do not conform to the actual situation of the park) need to be marked and removed to ensure the quality of the analysis data.
[0117] 2. Sentiment Rating
[0118] In this embodiment, sentiment analysis is performed on social media comment texts using a BERT pre-trained model based on natural language processing (NLP) technology;
[0119] The specific steps of sentiment scoring are as follows:
[0120] S201: Encode the input social media comment text through the Tokenizer of the BERT pre-trained model and convert it into a vector form that the model can understand; convert the encoded social media comment text into a series of input vectors;
[0121] In this embodiment, the Tokenizer will perform word segmentation, add special tags (such as <cls>and <sep>), padding, and truncation. The input vector includes word embedding, position embedding, and segment embedding, which together constitute the input representation of the BERT model.
[0122] S202: extracting features from the input vector using the encoder of the BERT pre-trained model to obtain text features;
[0123] In this embodiment, the encoder of BERT is composed of multiple stacked Transformer layers, each of which contains a self-attention mechanism and a feedforward neural network. In the self-attention mechanism, the vector of each word interacts with other words in the input sequence and generates a new representation, so that the model can capture the contextual information in the text. After processing multiple Transformer layers, the BERT model can extract high-level features of the text (i.e., text features), which contain rich semantic information and contextual relationships.
[0124] S203: Generate a value between -1 and 1 as the sentiment intensity score of the social media comment text based on the text features through the regression layer of the BERT pre-trained model.
[0125] In this embodiment, the sentiment intensity score and the sentiment category are mapped, and the sentiment intensity score of 1 is mapped to positive, the sentiment intensity score of 0 is mapped to neutral, and the sentiment intensity score of -1 is mapped to negative. When the sentiment intensity score of the social media comment text is between 1 and 0, the corresponding sentiment category is positive; when the sentiment intensity score of the social media comment text is 0, the corresponding sentiment category is neutral; when the sentiment intensity score of the social media comment text is between 0 and -1, the corresponding sentiment category is negative.
[0126] 3. Topic Extraction and Weight Assignment
[0127] In this embodiment, the topic extraction about environmental factors is performed on social media comment texts through the LDA (Latent Dirichlet Allocation) model;
[0128] The specific steps of topic extraction are as follows:
[0129] S301: Obtain social media comment text for LDA model training and perform preprocessing;
[0130] In this embodiment, the preprocessing includes removing stop words and punctuation marks, performing stem extraction, etc.
[0131] S302: converting all preprocessed social media comment texts into a bag-of-words model, so that each social media comment text is represented as a word frequency vector on a vocabulary;
[0132] In this embodiment, by converting the review text into a word frequency matrix, the LDA model can establish a document-word matrix (ie, a word frequency matrix) through a bag-of-words model to represent the frequency of occurrence of each word in the text in the document.
[0133] S303: setting the number of environmental factors, i.e., topics, and using the LDA algorithm to train the bag-of-words model to output the topic distribution of each social media comment text and the keyword distribution of each topic; wherein each topic represents an environmental factor;
[0134] In this embodiment, the LDA model is used for training based on all social media comment texts. The LDA model automatically learns and generates a predetermined number of topics based on the word frequency matrix (for example, assuming that we set it to 3 topics: environmental quality, safety, and facility management). Each topic will have a probability distribution of words, for example: "lawn", "greenery", and "air" may be related to the "environmental quality" topic.
[0135] Once the model is trained, the LDA model will generate a topic distribution based on the vocabulary distribution of each review. Each review will get a probability distribution about different topics, indicating the weight of the review under each topic. For example, if the review involves words such as "green space", "air", and "environment", the LDA model may think that this review is highly relevant to the topic of "environmental quality" and generate a higher weight.
[0136] S304: assigning one or more environmental factors to each social media comment text according to the topic distribution;
[0137] S305: Determine the distribution weight of each environmental factor in the social media comment text according to the probability distribution of the environmental factor in each social media comment text.
[0138] Specifically, for each social media comment text, the user score of each environmental factor in the social media comment text is obtained by multiplying its sentiment score by the distribution weight of each environmental factor.
[0139] Examples of user scores for environmental factors are shown in Table 1.
[0140] Table 1
[0141]
[0142]
[0143] Assume that three topics, namely environmental factors (environmental quality, safety, and facility management), are selected and the following distribution results are obtained through LDA training (this is a simplified example):
[0144] 1. For comment 1: "Botanical garden, large area, green and lively, suitable for relaxation", the topic weights of the LDA model may be:
[0145] Environmental quality: 0.85; safety: 0.05; facility management: 0.10.
[0146] 2. For comment 2: "Large parking lot, many children, far toilet, sunbathing", the topic weights of the LDA model may be:
[0147] Environmental quality: 0.45; Safety: 0.30; Facility management: 0.25.
[0148] These weights reflect the importance of each comment under different topics.
[0149] Suppose a review has a sentiment score of 0.8, which means that the review is generally positive.
[0150] For this review, suppose that the LDA model analysis shows that the weight of Topic 1 (Environmental Quality) is 0.85; the weight of Topic 2 (Facility Management) is 0.65; and the weight of Topic 3 (Safety) is 0.25. Then, the sentiment intensity score of each topic can be calculated as follows:
[0151] The sentiment intensity score of topic 1 = sentiment intensity score * topic 1 weight = 0.8 * 0.85 = 0.68
[0152] The emotional intensity score of topic 2 = emotional intensity score * topic 2 weight = 0.8 * 0.65 = 0.52
[0153] The emotional intensity score of topic 3 = emotional intensity score * topic 3 weight = 0.8 * 0.25 = 0.20
[0154] Finally, the sentiment intensity score of each topic is calculated in this way, and the scores of all topics are combined to form a comprehensive topic sentiment analysis result. Based on the topic weight and sentiment intensity score of the comment, the vector representation of each comment we finally generate will be:
[0155] Comment sentiment intensity score = 0.8;
[0156] Topic weight: [0.85, 0.65, 0.25];
[0157] Sentiment intensity score for each topic: [0.68, 0.52, 0.20];
[0158] Comprehensive vectorization results: [0.8, 0.68, 0.52, 0.20].
[0159] 4. Random Forest Model
[0160] In this embodiment, the specific steps of determining the importance weight of environmental factors are as follows:
[0161] S501: Construct a data set and divide it into a training set and a test set, with the training set accounting for 75% and the test set accounting for 25%. Each sample in the data set includes environmental factors as feature data and user scores as target variables; user scores may also include actual user ratings, such as the score (1-5 stars) in each comment.
[0162] In this embodiment, the environmental factors need to be preprocessed, including missing value processing and standardization. Missing value processing: For missing environmental factor scores or behavior data, the mean filling missing value record method can be used for processing. Standardization: Since the ranges of different feature values vary greatly, it may be necessary to standardize the data (Z-score standardization) so that the scales of different features are consistent.
[0163] S502: Train the random forest model using the training set:
[0164] S5021: Randomly select a subsample set from the training set through Bootstrap sampling (with replacement sampling);
[0165] In this embodiment, each sub-sample set will be used to train an independent decision tree. During the training process of each tree, a feature subset is randomly selected, which can ensure that the training process of each tree is independent and reduce the risk of overfitting.
[0166] S5022: For each sub-sample set, a decision tree is constructed using the CART algorithm (Classification and Regression Trees);
[0167] In this embodiment, the construction of the decision tree depends on selecting the optimal segmentation feature and its corresponding segmentation point. Here, the Gini Impurity metric is used to select the optimal segmentation point.
[0168] S5023: Each decision tree continues to split until it reaches the specified tree depth, minimum number of samples or other stopping conditions;
[0169] S5024: Repeat steps S5021 to S5023 until the number of decision trees reaches a preset value or the model converges;
[0170] S503: Test the random forest model using the test set;
[0171] S504: After the random forest model training is completed, the importance of each feature is evaluated by analyzing the contribution of each feature to the result; the importance of the feature is the importance of the environmental factor;
[0172] S505: Determine the influence of the corresponding environmental factor on the user satisfaction based on the importance of each feature, and generate the importance weight of each environmental factor.
[0173] Specifically, the importance weight of each environmental factor is generated through the following steps:
[0174] S5041: For each decision tree in the random forest, traverse all its nodes;
[0175] S5042: For each node, find a feature for splitting;
[0176] S5043: Calculate the impurity change of the node before and after the feature is split, that is, the reduction of the Gini index; add up the impurity changes of the feature on all nodes to obtain the importance score of the feature on the current decision tree;
[0177] The calculation formula of the Gini index is expressed as:
[0178]
[0179] Where: Gini(D) represents the Gini index; p(i) represents the probability of environmental factor i in the sample; m represents the total number of categories of environmental factors;
[0180] S5044: Repeat steps S5041 to S5043 to calculate the importance score of each feature in each decision tree;
[0181] S5045: Calculate the average value of the importance score of each feature on all decision trees (as the importance of the feature in the random forest model); normalize the average value of the importance score of each feature to generate the importance weight of the corresponding environmental factor.
[0182] In this embodiment, the average value of each feature importance score is normalized by dividing the average value of each feature importance score by the sum of the average values of all feature importance scores, so that the sum of the importance values of all features is 1. The normalized importance value is used as the importance weight of the environmental factor.
[0183] The formula is:
[0184]
[0185] Where: i, j represent the i-th and j-th environmental factors (features) respectively; n represents the number of environmental factors (features).
[0186] 5. User Satisfaction Calculation (TOPSIS)
[0187] In this embodiment, the user satisfaction score of each city park is calculated through the following steps:
[0188] S601: Calculate the average score of each environmental factor in all social media comment texts of each city park as the original score; the original scores of the environmental factors of the city parks are shown in Table 2.
[0189] Table 2
[0190]
[0191] S602: Construct an environmental factor matrix containing the original scores of each urban park on different environmental factors; the elements x in the environmental factor matrix ij represents the original score of urban park i on environmental factor j;
[0192] In this embodiment, environmental factors include safety, facility management, environmental quality and green space coverage.
[0193] S603: For each environmental factor j, the original score x of city park i on environmental factor j is ij Normalize to get the relative score r ij ;
[0194] The normalized formula is expressed as:
[0195]
[0196] Where: n represents the number of urban parks;
[0197] S604: Determine the positive ideal solution A for each environmental factor j + and negative ideal solution A - ; Positive ideal solution (A + ) refers to the optimal value of each indicator, usually the maximum value of each column of standardized values; negative ideal solution (A - ) refers to the worst value of each metric, usually the minimum of the standardized values in each column.
[0198] The formula is:
[0199]
[0200] S605: Calculate city park i to positive ideal solution A + The forward distance (the smaller the better) and to the negative ideal solution A - Negative distance (Bigger is better);
[0201] The formula is:
[0202]
[0203] Where: w j represents the importance weight of environmental factor j;
[0204] S606: Based on forward distance and negative distance Calculate the user satisfaction score of city park i relative to other city parks;
[0205] The formula is:
[0206]
[0207] Where: C i Indicates the user satisfaction score of city park i equal to that of other city parks. i The closer it is to 1, the higher the overall satisfaction with the urban park.
[0208] 6. Optimized resource allocation
[0209] In this embodiment, the strategies for optimizing resource configuration include:
[0210] 1) Identify one or more urban parks with the lowest user satisfaction scores and make targeted resource allocations and improvements.
[0211] In this embodiment, the parks with poor performance are identified by evaluating the comprehensive satisfaction of different parks, and corresponding improvement measures are formulated according to the shortcomings of these parks.
[0212] Strategy implementation direction: Differentiated improvement: Carry out personalized optimization according to the characteristics of different parks. For example, if some parks have low scores in "facility management", we can concentrate resources on facility repair and renewal; while in parks with low green coverage, we can increase greening to improve satisfaction. Concentrated resource investment: According to the comprehensive satisfaction score, focus on the transformation of parks with low scores and provide more financial and management support.
[0213] 2) Based on the importance of environmental factors generated by the random forest model, determine one or more environmental factors that have the greatest impact on the satisfaction score, and make targeted resource allocation and improvements.
[0214] In this embodiment, priority is given to improving those environmental factors that contribute most to user satisfaction. For example, if security, facility management, or green coverage is a key factor affecting satisfaction, key investments and improvements can be made in these areas. Security: Strengthen the park's lighting, monitoring equipment, increase security patrols, and other measures to ensure visitors' sense of security. Facility management: Regularly inspect and maintain facilities in the park (such as seats, toilets, fitness equipment, etc.) to ensure the integrity and ease of use of the facilities. Green coverage: Increase the green area, plant more trees and plants, provide more shaded areas, and improve the comfort and aesthetics of the park.
[0215] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit the technical solution. Those skilled in the art should understand that those modifications or equivalent substitutions of the technical solution of the present invention that do not depart from the purpose and scope of the technical solution should be included in the scope of the claims of the present invention.< / sep> < / cls>
Claims
1. A method for optimizing the allocation of urban park resources based on a random forest model, characterized in that: include: S1: Obtain social media comment texts related to urban parks in the target area from the Internet big data; S2: Perform sentiment analysis on social media comment texts to obtain the sentiment intensity score of each social media comment text; S3: Extract topics about environmental factors from each social media comment text and assign corresponding distribution weights to each extracted environmental factor; S4: Calculate the user score of each environmental factor based on the sentiment intensity score of each social media comment text, the extracted environmental factors, and the distribution weights assigned to the environmental factors; S5: Determine the importance of environmental factors to user satisfaction through the random forest model and generate the importance weight of each environmental factor; S6: Calculate the user satisfaction score of each city park based on the average user score of each environmental factor in the social media comment text of each city park and the importance weight of the environmental factor S7: Compare the user satisfaction scores of various urban parks and the importance of environmental factors of each urban park to optimize resource allocation for urban parks in the target area.
2. The method for optimizing the allocation of urban park resources based on the random forest model according to claim 1, characterized in that: In step S1, the obtained social media comment text needs to be preprocessed; Preprocessing includes: 1) Delete irrelevant comments: Delete social media comments that are irrelevant to the actual experience of each city park; 2) Standardization: unify the time format and location field naming format of social media comment text; 3) Text data cleaning: including Chinese word segmentation, removal of stop words, removal of special characters and emoticons, language identification and translation, spelling correction and word standardization or processing of missing data and outliers.
3. The method for optimizing the allocation of urban park resources based on the random forest model according to claim 1, characterized in that: In step S2, sentiment analysis is performed on social media comment texts using the BERT pre-trained model; The specific steps of sentiment scoring are as follows: S201: Encode the input social media comment text through the Tokenizer of the BERT pre-trained model; convert the encoded social media comment text into a series of input vectors; S202: extracting features from the input vector using the encoder of the BERT pre-trained model to obtain text features; S203: Generate a value between -1 and 1 as the sentiment intensity score of the social media comment text based on the text features through the regression layer of the BERT pre-trained model.
4. The method for optimizing the allocation of urban park resources based on the random forest model as claimed in claim 3, characterized in that: In step S203, when the sentiment intensity score of the social media comment text is between 1 and 0, the corresponding sentiment category is positive; when the sentiment intensity score of the social media comment text is 0, the corresponding sentiment category is neutral; when the sentiment intensity score of the social media comment text is between 0 and -1, the corresponding sentiment category is negative.
5. The method for optimizing the allocation of urban park resources based on the random forest model according to claim 1, characterized in that: In step S3, the topic extraction about environmental factors is performed on the social media comment text through the LDA model; The specific steps of topic extraction are as follows: S301: Obtain social media comment text for LDA model training and perform preprocessing; S302: converting all preprocessed social media comment texts into a bag-of-words model, so that each social media comment text is represented as a word frequency vector on a vocabulary; S303: setting the number of environmental factors, i.e., topics, and using the LDA algorithm to train the bag-of-words model to output the topic distribution of each social media comment text and the keyword distribution of each topic; wherein each topic represents an environmental factor; S304: assigning one or more environmental factors to each social media comment text according to the topic distribution; S305: Determine the distribution weight of each environmental factor in the social media comment text according to the probability distribution of the environmental factor in each social media comment text.
6. The method for optimizing the allocation of urban park resources based on the random forest model according to claim 1, characterized in that: In step S4, the user score of each environmental factor in the social media comment text is obtained by multiplying the sentiment score of each social media comment text by the distribution weight of each environmental factor.
7. The method for optimizing the allocation of urban park resources based on the random forest model according to claim 1, characterized in that: In step S5, the specific steps of determining the importance weight of the environmental factor are as follows: S501: construct a data set and divide it into a training set and a test set; wherein each sample in the data set includes an environmental factor as feature data and a user score as a target variable; S502: Train the random forest model using the training set: S5021: Randomly extract subsamples from the training set using Bootstrap sampling; S5022: For each sub-sample set, a decision tree is constructed using the CART algorithm; S5023: Each decision tree continues to split until it reaches the specified tree depth, minimum number of samples or other stopping conditions; S5024: Repeat steps S5021 to S5023 until the number of decision trees reaches a preset value or the model converges; S503: Test the random forest model using the test set; S504: After the random forest model training is completed, the importance of each feature is evaluated by analyzing the contribution of each feature to the result; The importance of the feature is the importance of the environmental factor; S505: Generate an importance weight for each environmental factor based on the importance of each feature.
8. The method for optimizing the allocation of urban park resources based on the random forest model according to claim 6, characterized in that: In step S504, the importance weight of each environmental factor is generated through the following steps: S5041: For each decision tree in the random forest, traverse all its nodes; S5042: For each node, find a feature for splitting; S5043: Calculate the impurity change of the node before and after the feature is split, that is, the reduction of the Gini index; add up the impurity changes of the feature on all nodes to obtain the importance score of the feature on the current decision tree; The calculation formula of the Gini index is expressed as: Where: Gini(D) represents the Gini index; p(i) represents the probability of environmental factor i in the sample; m represents the total number of categories of environmental factors; S5044: Repeat steps S5041 to S5043 to calculate the importance score of each feature in each decision tree; S5045: Calculate the average value of the importance score of each feature on all decision trees; normalize the average value of the importance score of each feature to generate the importance weight of the corresponding environmental factor.
9. The method for optimizing the allocation of urban park resources based on the random forest model according to claim 1, characterized in that: In step S6, the user satisfaction score of each city park is calculated by the following steps: S601: Calculate the average score of each environmental factor in all social media comment texts of each city park as the original score; S602: Construct an environmental factor matrix containing the original scores of each urban park on different environmental factors; the elements x in the environmental factor matrix ij represents the original score of urban park i on environmental factor j; S603: For each environmental factor j, the original score x of city park i on environmental factor j is ij Normalize to get the relative score r ij ; The normalized formula is expressed as: Where: n represents the number of urban parks; S604: Determine the positive ideal solution A for each environmental factor j + and negative ideal solution A - ; The formula is: S605: Calculate city park i to positive ideal solution A + The forward distance and to the negative ideal solution A - Negative distance The formula is: Where: w j represents the importance weight of environmental factor j; S606: Based on forward distance and negative distance Calculate the user satisfaction score of city park i relative to other city parks; The formula is: Where: C i Indicates that the user satisfaction score of city park i is equivalent to that of other city parks.
10. The method for optimizing the allocation of urban park resources based on the random forest model according to claim 1, characterized in that: In step S7, the strategy for optimizing resource configuration includes: 1) Identify one or more urban parks with the lowest user satisfaction scores and make targeted resource allocation and improvements; 2) Based on the importance of environmental factors generated by the random forest model, determine one or more environmental factors that have the greatest impact on the satisfaction score, and make targeted resource allocation and improvements.
Citation Information
Patent Citations
Network-purchased product estimation method based on user comments and historical scores
CN106296282A
Movie comment viewpoint emotion tendency analysis method
CN110825876A
Park text comment emotion scoring method based on machine learning
CN111159342A
Historical and cultural block walking comfort evaluation method based on semantic segmentation
CN118230142A
Cited By
Urban park perception value evaluation method based on multi-modal data fusion
CN121545160A