Automobile brand recommendation method and system based on attention mechanism and LSTM
By combining an attention-based and LSTM-based car brand recommendation method with a user preference model and a random forest classifier, the problem of recommendation accuracy under sparse user review data is solved, and more accurate car brand recommendations are achieved.
Patent Information
- Application Number
- CN202510211894.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-25
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2045-02-25
AI Technical Summary
Existing personalized recommendation systems have low accuracy under sparse user review data conditions, making it difficult to provide accurate car brand recommendations.
We employ an attention-based and LSTM-based car brand recommendation method. By processing user review data through a sentiment analysis model, we identify key information and contextual relationships. Combining a user preference model and a random forest classifier, we quantify users' attention to and needs for car feature dimensions and establish the correlation between user preferences and car brands.
It improves the accuracy and personalization of recommendations, effectively solves the problem of sparsity in user review data, and can more accurately judge user sentiment and recommend matching car brands.
Smart Images

Figure CN120235672B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and more specifically, to a method and system for recommending car brands based on attention mechanisms and LSTM. Background Technology
[0002] Against the backdrop of rapid development in the digital economy and big data, users can comment, rate, and assign ratings to various online services and products, ushering in an era of information overload for the automotive market. Faced with a deluge of vehicle information and user reviews, consumers often struggle to make accurate and effective purchasing decisions when choosing a car.
[0003] The application areas of recommendation systems are expanding rapidly, encompassing online services, book recommendations, e-learning platforms, travel planning, movie and music selection, professional research resources, and television programs. Personalized recommendation systems require users' past consumption information to provide personalized car recommendations, thereby improving user experience and car-buying efficiency.
[0004] Existing personalized recommendation systems require collecting a large amount of past user comments to provide relatively accurate recommendations. However, in reality, the amount of user comments online is limited. Using sparse user comment data, existing personalized recommendation systems have low accuracy and are difficult to implement widely. Summary of the Invention
[0005] The problem this invention aims to solve is that existing personalized recommendation systems have low recommendation accuracy due to sparse user review data.
[0006] To address the aforementioned problems, in a first aspect, this invention provides a car brand recommendation method based on attention mechanisms and LSTM, comprising:
[0007] User comment data is input into the sentiment analysis model, and after being processed by the LSTM layer and attention layer in the sentiment analysis model, the predicted sentiment scores of users on multiple aspects are obtained.
[0008] The predicted sentiment score for each user in each aspect, the mean sentiment score for each user in each aspect, and the standard deviation of the sentiment scores for all users in the corresponding aspect are input into the user preference model to obtain the importance score for each aspect.
[0009] The average sentiment score of all users in each aspect, the predicted sentiment score of each user in each aspect, and the average sentiment score of each user in each aspect are input into the user sentiment needs model to obtain the sentiment needs score in each aspect.
[0010] Based on the importance score and the emotional need score, the user's preference level in each aspect is obtained;
[0011] Based on the predicted sentiment scores of multiple users in various aspects, the overall feature vector of the car is obtained;
[0012] Based on the user's stated preferences, the overall feature vector of the car, and a random forest classifier, a recommended car brand is obtained.
[0013] Optionally, the sentiment analysis model includes multiple input layers, multiple LSTM layers, an attention layer, and an output layer. The multiple input layers are connected one-to-one with the multiple LSTM layers, and the multiple LSTM layers are connected sequentially. The outputs of the multiple LSTM layers are fused with the output of the attention layer, and the fused result is input to the output layer to obtain the predicted sentiment score.
[0014] Optionally, the fusion result is:
[0015]
[0016] e t =h t ·H T
[0017] The LSTM layer outputs a hidden state matrix H = [h1, h2, ..., h T ] represents the feature vector at each time step; T represents the number of LSTM layers, h t Let α represent the hidden state at time step t. t e represents the attention weights corresponding to the feature vector at time step t. t Let represent the relevance score of the hidden state at time step t.
[0018] Optionally, the user preference model is:
[0019]
[0020] Among them, aspect-importance(u i ,t j ) represents the importance score of the i-th user to the j-th aspect, u i (t j ) represents the predicted sentiment score for the i-th user in the j-th aspect, μ(t) j σ(t) represents the mean emotional score for each user across all aspects. j ) represents the standard deviation of the sentiment scores of all users in the j-th aspect.
[0021] Optionally, the user emotional need model is:
[0022]
[0023] Among them, aspect-need(u i ,t j ) represents the score of the i-th user's emotional needs in the j-th aspect. Let u represent the mean sentiment score of all users for the j-th aspect. i (t j ) represents the predicted sentiment score of the i-th user for the j-th aspect, μ(t) j () represents the average emotional score of each user across all aspects.
[0024] Optionally, the user's preference in each aspect is:
[0025] U = aspect-importance(u i ,t j )×aspect-need(u i ,t j )
[0026] Among them, aspect-importance(u i ,t j ) represents the importance score of the i-th user to the j-th aspect, aspect-need(u i ,t j ) represents the score of the emotional needs of the i-th user for the j-th aspect.
[0027] Optionally, the overall feature vector of the vehicle is:
[0028]
[0029] in, Representation t j Average sentiment score, t1, t2, ..., t j These are the various aspects of a car, where j represents the total number of aspects, and p... tj,i Indicates the i-th user in aspect t j The predicted sentiment score is given by n, where n is the total number of users who participated in the comment.
[0030] Secondly, the present invention also provides a car brand recommendation system based on attention mechanisms and LSTM, comprising:
[0031] The model prediction module is used to input user comment data into the sentiment analysis model. After processing by the LSTM layer and attention layer in the sentiment analysis model, the predicted sentiment scores of users on multiple aspects are obtained.
[0032] The importance analysis module is used to input the predicted sentiment score of each user in each aspect, the mean sentiment score of each user in each aspect, and the standard deviation of the sentiment scores of all users in the corresponding aspect into the user preference model to obtain the importance score of each aspect.
[0033] The emotional needs analysis module is used to input the average emotional score of all users in each aspect, the predicted emotional score of each user in each aspect, and the average emotional score of each user in each aspect into the user emotional needs model to obtain the emotional needs score for each aspect.
[0034] The preference analysis module is used to obtain the user's preference in each aspect based on the importance score and the emotional need score;
[0035] The vehicle feature analysis module is used to obtain the overall feature vector of the vehicle based on the predicted sentiment scores of multiple users in various aspects.
[0036] The car recommendation module is used to obtain recommended car brands based on the user's preferences, the overall feature vector of the car, and a random forest classifier.
[0037] Thirdly, the present invention provides an electronic device, including a memory and a processor;
[0038] The memory is used to store computer programs;
[0039] The processor is configured to, when executing the computer program, implement the car brand recommendation method based on attention mechanism and LSTM as described in the first aspect.
[0040] Fourthly, the present invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the car brand recommendation method based on attention mechanism and LSTM as described in the first aspect.
[0041] This invention provides a method and system for recommending car brands based on attention mechanisms and LSTM. Compared with existing technologies, it has the following advantages:
[0042] The LSTM and attention layers in the sentiment analysis model process user review data, identifying key information and contextual relationships within the reviews. The attention mechanism dynamically focuses on the most relevant parts of the review, providing deeper text understanding, reducing the amount of user review data required, and more accurately determining user sentiment tendencies. It obtains predicted sentiment scores for multiple aspects, and based on this, combines importance scores and sentiment demand scores to determine user preferences in each aspect. This quantifies user attention and needs for car features, as well as the sentiment tendencies of all users towards different car brands. Based on user preferences, the overall feature vector of the car, and a random forest classifier, recommended car brands are derived. By identifying user preferences from sentiment scores and predicting their car brand preferences, the model establishes a correlation between individual user preferences and multiple feature dimensions of car brands, improving the relevance and personalization of recommendations. This effectively addresses the sparsity problem of user review data while also improving recommendation accuracy. Attached Figure Description
[0043] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0044] Figure 1 A flowchart illustrating a car brand recommendation method based on attention mechanism and LSTM provided in an embodiment of the present invention;
[0045] Figure 2 A schematic diagram of the structure of the sentiment analysis model provided in an embodiment of the present invention;
[0046] Figure 3 This is a schematic diagram of the structure of a car brand recommendation system based on attention mechanism and LSTM, provided for an embodiment of the present invention. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions in the embodiments of this application are described clearly and completely. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0048] This application provides a car brand recommendation method and system based on attention mechanism and LSTM, which solves the problem that existing personalized recommendation systems are unable to provide accurate recommendation results based on sparse user review data, thereby improving the accuracy of recommendations.
[0049] To better understand the above technical solutions, the following will provide a detailed explanation of the technical solutions in conjunction with the accompanying drawings and specific implementation methods.
[0050] like Figure 1 As shown in the embodiment of this application, a car brand recommendation method based on attention mechanism and LSTM is provided, including:
[0051] S1: Input user comment data into the sentiment analysis model. After processing by the LSTM layer and attention layer in the sentiment analysis model, the predicted sentiment scores of users on multiple aspects are obtained.
[0052] S2: Input the predicted sentiment score of each user in each aspect, the mean sentiment score of each user in each aspect, and the standard deviation of the sentiment scores of all users in the corresponding aspect into the user preference model to obtain the importance score of each aspect.
[0053] S3: Input the average sentiment score of all users in each aspect, the predicted sentiment score of each user in each aspect, and the average sentiment score of each user in each aspect into the user sentiment need model to obtain the sentiment need score for each aspect.
[0054] S4: Based on the importance score and the emotional need score, obtain the user's preference level in each aspect.
[0055] S5: Based on the predicted sentiment scores of multiple users in various aspects, obtain the overall feature vector of the car.
[0056] S6: Based on the user's preferences, the overall feature vector of the car, and the random forest classifier, obtain the recommended car brand.
[0057] In this embodiment, user comment data is input into a sentiment analysis model. After processing by the LSTM layer and attention layer within the model, key information and contextual relationships in the comments are identified. The attention mechanism dynamically focuses on the most relevant parts of the comments, providing a deeper level of text understanding, reducing the amount of user comment data required, and more accurately determining the user's sentiment tendency. Predicted sentiment scores for multiple aspects are obtained. Based on this, the predicted sentiment scores for each user in each aspect, the average sentiment scores for each user in each aspect, and the standard deviation of the sentiment scores for all users in the corresponding aspects are input into a user preference model to obtain an importance score for each aspect. The average sentiment scores for all users in each aspect, the predicted sentiment scores for each user in each aspect, and the average sentiment scores for each user in each aspect are input into a user sentiment demand model to obtain a sentiment demand score for each aspect. Combining the importance score and the sentiment demand score yields the user's preference for each aspect, quantifying the user's attention and demand for vehicle features such as space, driving experience, and range. Based on the predicted sentiment scores for multiple users in each aspect, an overall feature vector of the vehicle is obtained, quantifying the user's sentiment tendency towards different vehicle brands. Based on the user's stated preferences, the overall feature vector of the car, and a random forest classifier, recommended car brands are obtained. By identifying user preferences from their sentiment scores and predicting their preferences for car brands, the correlation between individual user preferences and multiple feature dimensions of car brands is established, improving the relevance and personalization of the recommendations, and increasing the accuracy of the recommendations. This effectively solves the problem of sparsity in user review data while also improving the accuracy of recommendations.
[0058] The following is a detailed description of each step.
[0059] S1: Input user comment data into the sentiment analysis model. After processing by the LSTM layer and attention layer in the sentiment analysis model, the predicted sentiment scores of users on multiple aspects are obtained.
[0060] Specifically, before inputting user comment data into the sentiment analysis model, the user comment data needs to be preprocessed. Preprocessing mainly involves loading the original user comment data and a stop word list, performing word segmentation on the text, removing stop words to generate cleaned text, then using a word segmenter to convert the text into a numerical sequence, and using sequence padding to standardize the sequence length. In addition, the data is divided into training and testing sets, and the comments for each dimension undergo pre-sentiment analysis text cleaning and serialization to ensure the data is suitable for input into the sentiment analysis model.
[0061] like Figure 2As shown, an LSTM model based on an attention mechanism is constructed to form a sentiment analysis model for text sentiment analysis. The sentiment analysis model includes multiple input layers, multiple LSTM layers, an attention layer, and an output layer. The multiple input layers are connected one-to-one with the multiple LSTM layers, and the multiple LSTM layers are connected sequentially. The outputs of the multiple LSTM layers are fused with the output of the attention layer, and the fused result is input to the output layer to obtain the predicted sentiment score.
[0062] Input layer: The input layer receives the preprocessed text data and converts it into word embedding vectors, which are then used as input to the LSTM layer.
[0063] LSTM Layer: Employing an LSTM neural network, the key component of which is the gating unit system, capable of effectively storing and processing historical information. The LSTM model can learn long-term dependencies and uses three gating units: an input gate, a forget gate, and an output gate. These selectively forget historical information or update the unit state with new information, managing the propagation and preservation of information.
[0064] Forget Gate:
[0065] f t =σ(W f ·[h t-1 x t ]+b f (1)
[0066] Input gate:
[0067] i t =σ(W i ·[h t-1 x t ]+b i (2)
[0068] Update cell state:
[0069]
[0070] Cell status update:
[0071]
[0072] Output gate:
[0073] o t =σ(W o ·[h t-1 x t ]+b o (5)
[0074] Hidden status update:
[0075] h t =o t *tanh(c t (6)
[0076] Among them, W f W i W c W o ,b o ,b f ,b i ,b c These are the learnable weights and bias parameters, σ is the sigmoid activation function, · represents matrix multiplication, and * represents element-level multiplication, i.e., multiplying corresponding elements.
[0077] The LSTM layer processes the text step by step, generating the hidden state for each time step (e.g., h1, h2...h). t The hidden state matrix output by the LSTM layer is H = [h1, h2, ..., h...]. T ], where h t This represents the hidden state at time step t. This matrix represents the feature vector at each time step.
[0078] Hidden Layer: The output of the LSTM layer is a series of hidden states, with the hidden state h at each time step. t These hidden states are passed to the hidden layers, and these hidden states contain contextual information about the text. Alternatively, the hidden layers can be set as part of an LSTM layer, rather than being set independently.
[0079] Attention Layer: Employing an attention mechanism inspired by human visual attention mechanisms. When viewing images, people tend to focus on key parts while ignoring less important ones. Introducing this concept into natural language processing, attention models can capture long-range dependencies, provide a wider receptive field and richer contextual information, and improve the network's representational capabilities by focusing on important features and suppressing unnecessary ones.
[0080] The attention layer calculates the correlation between time steps to obtain the attention weight α. t Weight α t It will use softmax regularization to make their sum equal to 1: Where e t =h t ·H T Represents the relevance score of the hidden state.
[0081] Feature fusion: In this stage, the output of the LSTM (hidden state) and the context vector generated by the attention layer are fused. This is done according to the weight α. t For hidden state h t Weighted summation yields the context vector (i.e., the fusion result): This context vector represents the set of features most important for sentiment classification in the sequence. The context vector C can also be concatenated with the original LSTM output H to obtain a richer feature representation. The LSTM layer outputs a hidden state matrix H = [h1, h2, ..., h...]. T ] represents the feature vector at each time step; T represents the number of LSTM layers, h t Let α represent the hidden state at time step t. t e represents the attention weights corresponding to the feature vector at time step t. t Let represent the relevance score of the hidden state at time step t.
[0082] Output layer: The concatenated vector is passed to the fully connected layer, which maps the features to a sentiment score. Typically, the sigmoid function outputs a value between 0 and 1, representing the sentiment tendency and intensity of the text.
[0083] S2: Input the predicted sentiment score of each user in each aspect, the mean sentiment score of each user in each aspect, and the standard deviation of the sentiment scores of all users in the corresponding aspect into the user preference model to obtain the importance score of each aspect.
[0084] Specifically, user preferences refer to the preferences or inclinations users exhibit towards specific products, services, or features when faced with multiple choices. Constructing user preferences involves two parts: the importance of aspects to the user and the needs of those aspects. The importance of aspects refers to the user's assessment of the importance of each aspect, indicating the extent to which the user perceives a particular aspect as important to them. The needs of those aspects reveal the different needs that different users may have for the same aspect.
[0085] The user preference model is as follows:
[0086]
[0087] Among them, aspect-importance(u i ,t j ) represents the importance score of the i-th user to the j-th aspect, u i (t j ) represents the predicted sentiment score for the i-th user in the j-th aspect, μ(t) j σ(t) represents the mean emotional score for each user across all aspects. j) represents the standard deviation of the sentiment scores of all users in the j-th aspect.
[0088] Standard deviation represents the difference between the raw score and the mean (aspect average), that is, the difference between a user's sentiment score for a certain aspect (space, driving experience, etc.) and the mean (aspect average). In the analysis of user reviews, by calculating the importance score of aspects, we can identify users' different preferences in specific aspects, which is very valuable for user preference identification and personalized recommendations.
[0089] S3: Input the average sentiment score of all users in each aspect, the predicted sentiment score of each user in each aspect, and the average sentiment score of each user in each aspect into the user sentiment need model to obtain the sentiment need score for each aspect.
[0090] Specifically, to quantify users' needs for specific aspects of a car, a standardized value is calculated as the difference between a user's emotional value and the mean emotional value. If a user's emotional value for a certain aspect is significantly higher than the average, it indicates that the user values that aspect highly and therefore has a stronger need for it. Conversely, if a user's emotional value for a certain aspect is lower than the average, it indicates that the user's need for that aspect is relatively weak.
[0091] The user emotional needs model is as follows:
[0092]
[0093] Among them, aspect-need(u i ,t j ) represents the score of the i-th user's emotional needs in the j-th aspect. Let u represent the mean sentiment score of all users for the j-th aspect. i (t j ) represents the predicted sentiment score of the i-th user for the j-th aspect, μ(t) j The numerator represents the average emotional score of each user across all aspects. The numerator is incremented by 1 to ensure that the emotional needs result is non-negative, meaning that the user's needs for a certain aspect are at least 0.
[0094] S4: Based on the importance score and the emotional need score, obtain the user's preference level in each aspect.
[0095] The user's preference in each aspect is as follows:
[0096] U = aspect-importance(u i ,t j )×aspect-need(u i ,t j (9)
[0097] Among them, aspect-importance(u i ,t j ) represents the importance score of the i-th user to the j-th aspect, aspect-need(u i ,t j ) represents the score of the emotional needs of the i-th user for the j-th aspect.
[0098] Based on formulas (7) and (8), the user's aspect importance score and aspect affective need score are calculated respectively, providing a more comprehensive inference of the user's preferences for each aspect. A composite preference formula (9) is defined, which calculates the user's comprehensive preference score for a certain aspect by multiplying aspect importance and aspect need. This score takes into account both the user's level of attention to this aspect and their personal needs, thus providing a more comprehensive measure of user preference.
[0099] S5: Based on the predicted sentiment scores of multiple users in various aspects, obtain the overall feature vector of the car.
[0100] Specifically, after purchasing and using a product, users evaluate its various features based on their feelings and satisfaction. A user's emotional value reflects their direct experience and feelings about the product; analyzing user emotional tendencies allows for a deeper understanding of product characteristics. Therefore, the characteristics of various aspects of a car can be represented as follows:
[0101]
[0102] The overall feature vector of a car is composed of multiple features. The overall feature vector of a car is:
[0103]
[0104] in, Representation t j Average sentiment score, t1, t2, ..., t j These are the various aspects of a car, where j represents the total number of aspects. Indicates the i-th user in aspect t j The predicted sentiment score is given by n, where n is the total number of users who participated in the comment.
[0105] Transforming users' emotional characteristics toward automotive products into a quantified feature vector helps to more accurately capture user preferences during the recommendation process and provides data support for product feature analysis.
[0106] S6: Based on the user's preferences, the overall feature vector of the car, and the random forest classifier, obtain the recommended car brand.
[0107] Specifically, the recommendation algorithm in this application uses a random forest classifier. Based on the random forest classification model, the algorithm learns the relationship between user preference features (such as sentiment scores for "space" and "driving experience") and car brands to recommend car brands. The random forest constructs multiple decision trees, combining feature randomness and data randomness to extract and classify features from user characteristics. The model fits the correspondence between features and car brand labels using training data (i.e., user preferences in each aspect and the overall feature vectors of different car brands), and uses majority voting to predict user car brand choices in the test data. Finally, the model performance is evaluated through precision, recall, and F1 score, and the most likely matching car brand is recommended based on the user's personalized preferences. For example, by analyzing user reviews and finding that users have high preferences for driving experience and appearance, the random forest classifier will select car brands with higher preferences for driving experience and appearance features based on the overall feature vectors of each car brand.
[0108] like Figure 3 As shown in the figure, an embodiment of this application provides a car brand recommendation system based on attention mechanism and LSTM, including:
[0109] The model prediction module 100 is used to input user comment data into the sentiment analysis model. After processing by the LSTM layer and attention layer in the sentiment analysis model, the predicted sentiment scores of users on multiple aspects are obtained.
[0110] The importance analysis module 200 is used to input the predicted sentiment score of each user in each aspect, the mean sentiment score of each user in each aspect, and the standard deviation of the sentiment scores of all users in the corresponding aspects into the user preference model to obtain the importance score of each aspect.
[0111] The Emotional Needs Analysis Module 300 is used to input the average emotional score of all users in each aspect, the predicted emotional score of each user in each aspect, and the average emotional score of each user in each aspect into the user emotional needs model to obtain the emotional needs score for each aspect.
[0112] The preference analysis module 400 is used to obtain the user's preference in each aspect based on the importance score and the emotional need score.
[0113] The vehicle feature analysis module 500 is used to obtain the overall feature vector of the vehicle based on the predicted sentiment scores of multiple users in various aspects.
[0114] The car recommendation module 600 is used to obtain recommended car brands based on the user's preferences, the overall feature vector of the car, and a random forest classifier.
[0115] In this embodiment, the beneficial effects of the car brand recommendation system based on attention mechanism and LSTM are similar to those of the car brand recommendation method based on attention mechanism and LSTM described above, and will not be repeated here.
[0116] An electronic device provided in this application includes a memory and a processor; the memory is used to store a computer program; the processor is used to implement the car brand recommendation method based on attention mechanism and LSTM as described above when the computer program is executed.
[0117] This application provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the car brand recommendation method based on attention mechanism and LSTM as described above.
[0118] In this embodiment, the beneficial effects of the electronic device and the computer-readable storage medium are similar to those of the aforementioned car brand recommendation method based on attention mechanism and LSTM, and will not be repeated here.
[0119] The above method was used for experimental testing and analysis, and the experimental analysis process is as follows.
[0120] (1) Data acquisition and preprocessing
[0121] Using web scraping technology, 215,736 online reviews were collected from 32,531 users on a car forum, covering eight car brands. The reviews covered multiple aspects of the vehicles, including nine dimensions: "space," "driving experience," "range," "exterior," "interior," "value for money," and "intelligent features."
[0122] To ensure data quality and analytical accuracy, the data underwent preprocessing. First, deduplication was performed to eliminate the interference of duplicate data on the analysis results. For users who reviewed two or more car brands, reviews with the most recent purchase date were retained, ultimately resulting in 32,279 users and 149,552 reviews. Second, the review text was cleaned using a stop word library and a custom list of automotive-related stop words, removing frequently occurring words that did not contribute significantly to the analysis. Sentiment analysis models and recommendation algorithms were applied to build an accurate car brand recommendation model. Finally, user preference vectors and car feature vectors were constructed. Sentiment analysis was used to analyze online user reviews across the dimensions of "space," "driving experience," "range," "exterior," "interior," "value for money," and "intelligent features," calculating sentiment scores (sentiment values). Based on these scores, the importance and needs of users for each aspect were defined as their sentiment preferences. Similarly, the car feature vectors were calculated from user sentiment scores.
[0123] Precision, recall, and F1 score are used as evaluation metrics to assess the performance of recommendation methods and systems. There is a trade-off between precision and recall; typically, improving one leads to a decrease in the other. The F1 score, as their harmonic mean, provides a comprehensive measure that considers both metrics. These three metrics are used to evaluate the deviation between predicted results and actual observations, measuring the model's predictive performance. The sentiment analysis model and random forest classifier are tuned and trained based on these three metrics until they reach the required values.
[0124] (2) Model Training
[0125] For sentiment analysis of Chinese online comments, an attention-based LSTM method is employed. Before applying this model, the text data is preprocessed, including Chinese word segmentation, stop word removal, and the conversion of the text sequence into embedding vectors. These embedding vectors are then fed into an LSTM layer containing multiple LSTM units, each responsible for processing one time step of the sequence data. Following the LSTM layer, a hidden layer (h1, h2, ..., h...) is applied. TThe hidden states are then captured to extract key information from the sequence data. Next, the attention layer weights these hidden states to highlight the features most important for sentiment analysis. The calculation of the attention weights considers the contribution of each hidden state to the final sentiment prediction, thereby enhancing the model's ability to capture key information in the comments. In the final stage of the model, sentiment prediction is performed using a fully connected layer and a sigmoid activation function to determine the sentiment tendency of the comments. The sentiment score is defined between 0 and 1, where 0 represents negative sentiment, 1 represents positive sentiment, and 0.5 represents neutral sentiment. For aspects not commented on by the user, a neutral sentiment value of 0.5 is assigned to maintain the integrity of the model evaluation.
[0126] An attention-based LSTM sentiment analysis model was used to perform sentiment calculations on various aspects of the car, and the results are summarized in Table 1, providing a data foundation for the construction of car feature vectors and user preference vectors.
[0127] Table 1 User Emotional Scores in Various Aspects
[0128]
[0129] Table 2 User Emotional Preferences
[0130]
[0131] After analyzing the sentiment scores, the importance scores and sentiment needs scores for each user across various dimensions are calculated. This is achieved by comprehensively considering the user's sentiment rating and their level of attention to different aspects of the car. This calculation method reveals the user's personalized preferences for car features, thereby providing more accurate recommendations.
[0132] The results of user preference calculations are summarized in Table 2. This data not only reflects users' emotional inclinations towards various aspects of automobiles but also demonstrates the degree of importance they place on different features. Through this information, the recommendation system can more accurately capture users' personalized needs and provide them with car brand recommendations that better match their preferences.
[0133] By evaluating all users' emotional scores regarding their chosen brands in areas such as "space," "driving experience," "range," "exterior," "interior," "value for money," and "intelligent features," and calculating the average of these scores, we can comprehensively reflect the market's overall emotional inclination towards each car brand across different characteristics, thus forming the car's feature vector. Table 3 details the average emotional scores for each car brand in the aforementioned areas, providing an intuitive display for the quantification of car characteristics. This data clearly demonstrates the performance of different brands in various characteristics, meeting market demands and user expectations.
[0134] Table 3 Characteristics of Car Brands
[0135]
[0136] The recommendation algorithm uses a random forest classifier. Based on the random forest classification model, it learns the relationship between user preference features (such as sentiment scores for "space" and "driving experience") and brands to achieve brand recommendations. Random forests construct multiple decision trees, combining feature randomness and data randomness to extract patterns from user features and perform classification. The model fits the correspondence between features and brand labels using training data and predicts user brand choices in the test data using majority voting. Finally, the model performance is evaluated using precision, recall, and F1 score, and the most likely matching brand is recommended based on the user's personalized preferences.
[0137] (3) Recommendation Results Analysis
[0138] In car recommendation systems, precision is the percentage of users predicted to belong to a particular brand who actually belong to that brand, while recall is the percentage of users who correctly predict a particular brand among all users who actually belong to that brand. The F1 score model strikes a balance between precision and recall, considering both the accuracy (high precision) and the comprehensiveness (high recall) of the system's ability to identify user interests. The personalized car recommendation system, based on a random forest classifier, analyzes the correlation between user preferences and brand characteristics, recommending car brands that match the preferences of users with different characteristics. As shown in Table 4, the overall precision of this recommendation system is 0.911, indicating good performance in brand prediction.
[0139] Table 4 Recommendation Results Indicators
[0140]
[0141] In the prediction of car brand 1, the model achieved a precision of 0.925, indicating that the model's accuracy in predicting car brand 1 was very high, and most users predicted to be car brand 1 actually did choose car brand 1. The model's recall was 0.995, meaning that among all users who actually purchased car brand 1, the model was able to identify almost all users, missing very few samples. The F1 score, which combines precision and recall, was also high at 0.959 for car brand 1, indicating that the model's prediction of car brand 1 users was very balanced, efficiently identifying car brand 1 users while maintaining high accuracy. For car brand 7, the model had high precision but relatively low recall, at only 0.222. This means that among all users who actually chose car brand 7, the model could only identify approximately 22.2% of users, indicating that the model missed many samples that truly belonged to car brand 7. For car brands 2, 3, 4, 5, 6, and 8, the model's precision is above 0.8 and the recall is around 0.6. This indicates that the overall performance of the model is acceptable, but there is still room for improvement, especially in terms of recall. The model's recognition ability should be improved without sacrificing accuracy.
[0142] In the task of classifying car brands, precision, recall, and F1 score are important metrics for evaluating model performance. Through the above experimental analysis, the random forest classifier performs excellently in all three metrics, indicating its greater potential for practical application in car brand recommendation.
[0143] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0144] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A car brand recommendation method based on attention mechanism and LSTM, characterized in that, include: User comment data is input into the sentiment analysis model, and after being processed by the LSTM layer and attention layer in the sentiment analysis model, the predicted sentiment scores of users on multiple aspects are obtained. The predicted sentiment score for each user in each aspect, the mean sentiment score for each user in each aspect, and the standard deviation of the sentiment scores for all users in the corresponding aspect are input into the user preference model to obtain the importance score for each aspect. The average sentiment score of all users in each aspect, the predicted sentiment score of each user in each aspect, and the average sentiment score of each user in each aspect are input into the user sentiment needs model to obtain the sentiment needs score in each aspect. Based on the importance score and the emotional need score, the user's preference level in each aspect is obtained; Based on the predicted sentiment scores of multiple users in various aspects, the overall feature vector of the car is obtained; Based on the user's stated preferences, the overall feature vector of the car, and a random forest classifier, a recommended car brand is obtained.
2. The car brand recommendation method based on attention mechanism and LSTM as described in claim 1, characterized in that, The sentiment analysis model includes multiple input layers, multiple LSTM layers, an attention layer, and an output layer. The multiple input layers are connected one-to-one with the multiple LSTM layers, and the multiple LSTM layers are connected sequentially. The outputs of the multiple LSTM layers are fused with the output of the attention layer, and the fused result is input to the output layer to obtain the predicted sentiment score.
3. The car brand recommendation method based on attention mechanism and LSTM as described in claim 2, characterized in that, The fusion result is as follows: e t =h t ·H T The LSTM layer outputs a hidden state matrix H = [h1, h2, ..., h T ] represents the feature vector at each time step; T represents the number of LSTM layers, h t Let α represent the hidden state at time step t. t e represents the attention weights corresponding to the feature vector at time step t. t Let represent the relevance score of the hidden state at time step t.
4. The car brand recommendation method based on attention mechanism and LSTM as described in claim 1, characterized in that, The user preference model is as follows: Among them, aspect-importance(u i ,t j ) represents the importance score of the i-th user to the j-th aspect, u i (t j ) represents the predicted sentiment score for the i-th user in the j-th aspect, μ(t) j σ(t) represents the mean emotional score for each user across all aspects. j ) represents the standard deviation of the sentiment scores of all users in the j-th aspect.
5. The car brand recommendation method based on attention mechanism and LSTM as described in claim 1, characterized in that, The user emotional needs model is as follows: Among them, aspect-need(u i ,t j ) represents the score of the i-th user's emotional needs in the j-th aspect. Let u represent the mean sentiment score of all users for the j-th aspect. i (t j ) represents the predicted sentiment score of the i-th user for the j-th aspect, μ(t) j () represents the average emotional score of each user across all aspects.
6. The car brand recommendation method based on attention mechanism and LSTM as described in claim 1, characterized in that, The user's preference in each aspect is as follows: U=aspect-importance(u i ,t j )×aspect-need(u i ,t j ) Among them, aspect-importance(u i ,t j ) represents the importance score of the i-th user to the j-th aspect, aspect-need(u i ,t j ) represents the score of the emotional needs of the i-th user for the j-th aspect.
7. The car brand recommendation method based on attention mechanism and LSTM as described in any one of claims 1-6, characterized in that, The overall feature vector of the vehicle is: in, Representation t j Average sentiment score, t1, t2, ..., t j These are the various aspects of a car, where j represents the total number of aspects. Indicates the i-th user in aspect t j The predicted sentiment score is given by n, where n is the total number of users who participated in the comment.
8. A car brand recommendation system based on attention mechanism and LSTM, characterized in that, include: The model prediction module is used to input user comment data into the sentiment analysis model. After processing by the LSTM layer and attention layer in the sentiment analysis model, the predicted sentiment scores of users on multiple aspects are obtained. The importance analysis module is used to input the predicted sentiment score of each user in each aspect, the mean sentiment score of each user in each aspect, and the standard deviation of the sentiment scores of all users in the corresponding aspect into the user preference model to obtain the importance score of each aspect. The emotional needs analysis module is used to input the average emotional score of all users in each aspect, the predicted emotional score of each user in each aspect, and the average emotional score of each user in each aspect into the user emotional needs model to obtain the emotional needs score for each aspect. The preference analysis module is used to obtain the user's preference in each aspect based on the importance score and the emotional need score; The vehicle feature analysis module is used to obtain the overall feature vector of the vehicle based on the predicted sentiment scores of multiple users in various aspects. The car recommendation module is used to obtain recommended car brands based on the user's preferences, the overall feature vector of the car, and a random forest classifier.
9. An electronic device, characterized in that, Including memory and processor; The memory is used to store computer programs; The processor is configured to, when executing the computer program, implement the car brand recommendation method based on attention mechanism and LSTM as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The storage medium stores a computer program that, when executed by a processor, implements the car brand recommendation method based on attention mechanism and LSTM as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Fine-grained text emotion conversion model based on semantic-emotion double attention
CN113051931A
User comment sentiment analysis method and device, equipment, storage medium and product
CN118733778A