Decision tree model generation method and data recommendation method based on decision tree model

By calculating and correcting the information gain, the problem of equal information gain in the decision tree model is solved, ensuring the accuracy of feature attribute selection and improving the classification performance of the decision tree model.

CN114418035BActive Publication Date: 2026-07-17TENCENT TECHNOLOGY (SHENZHEN) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TENCENT TECHNOLOGY (SHENZHEN) CO LTD
Filing Date
2022-03-25
Publication Date
2026-07-17

AI Technical Summary

Technical Problem

When processing datasets, existing decision tree models cannot determine the optimal splitting features due to the similarity or small difference in feature information, resulting in equal information gain and poor classification performance.

Method used

By calculating the modified information gain to determine the feature attributes for dataset partitioning, the problem of feature attribute selection when the information gain is equal and maximum is solved, thus ensuring the accuracy of the decision tree model.

Benefits of technology

It improves the classification accuracy of decision tree models, ensuring optimal dataset partitioning under conditions of equal information gain, and generating more accurate decision tree models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114418035B_ABST
    Figure CN114418035B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a decision tree model generation method and a data recommendation method based on the decision tree model. The method comprises: obtaining a training data set formed by feature information of a plurality of training samples, the training samples having known category attributes; in a process of generating a decision tree model according to the training data set, iteratively calculating information gain of each feature attribute under each node, and dividing a data set contained by a current node according to a feature attribute corresponding to maximum information gain until a category attribute can be determined according to the data set contained by the node; if information gains of a plurality of feature attributes under the current node are equal and are maximum information gain, then calculating respective correction information gains of the plurality of feature attributes, and determining a feature attribute for dividing the data set contained by the current node according to the calculated correction information gains; and outputting the decision tree model formed according to the training data set. The decision tree model generated by the present application has more accurate classification effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of machine learning technology, specifically to a decision tree model generation method and a data recommendation method based on a decision tree model. Background Technology

[0002] Decision tree models are classic algorithm models in the field of machine learning. The decision tree algorithm is a method to approximate discrete function values. A decision tree is a tree structure that represents the classification of samples based on features. The classification process of a decision tree can be summarized as recursively selecting the optimal splitting feature from a given dataset according to the feature selection criteria, and then splitting the dataset according to the selected optimal splitting feature so that each subset has the best classification.

[0003] The feature selection criteria used in decision tree models include information gain. Information gain represents the difference in information entropy before and after splitting a dataset using a certain feature. Information entropy measures the uncertainty of a random variable, so information gain can be used to measure the effectiveness of using a particular feature for splitting a dataset. In practical applications, datasets often contain many features with the same value, making it difficult to determine the optimal splitting feature when using a decision tree model for classification. This results in the inability to split the dataset, leading to poor classification performance using the decision tree model. Summary of the Invention

[0004] To address the aforementioned technical problems, embodiments of this application provide a decision tree model generation method and apparatus, a data recommendation method and apparatus based on a decision tree model, an electronic device, a computer-readable storage medium, and a computer program product.

[0005] According to one aspect of the embodiments of this application, a decision tree model generation method is provided, comprising: acquiring a training dataset formed by feature information of multiple training samples, wherein each training sample has a known category attribute and the feature information of each training sample corresponds to different feature attributes; during the process of generating a decision tree model based on the training dataset, iteratively calculating the information gain of each feature attribute under each node, and dividing the dataset contained in the current node according to the feature attribute corresponding to the maximum information gain, so as to split into multiple child nodes based on the current node, until the category attribute can be determined based on the dataset contained in the node; if the information gains of multiple feature attributes under the current node are equal and are the maximum information gain, then calculating the corrected information gain corresponding to each of the multiple feature attributes, and determining the feature attribute used to divide the dataset contained in the current node according to the calculated corrected information gain; and outputting the decision tree model formed based on the training dataset.

[0006] According to one aspect of the embodiments of this application, a decision tree model generation apparatus is provided, comprising: a dataset acquisition module configured to acquire a training dataset formed by feature information of multiple training samples, wherein each training sample has a known category attribute and the feature information of each training sample corresponds to different feature attributes; a model generation module configured to, during the process of generating a decision tree model based on the training dataset, iteratively calculate the information gain of each feature attribute under each node, and divide the dataset contained in the current node according to the feature attribute corresponding to the maximum information gain, so as to split into multiple child nodes based on the current node, until the category attribute can be determined based on the dataset contained in the node; if the information gains of multiple feature attributes under the current node are equal and are the maximum information gain, then calculate the corrected information gain corresponding to each of the multiple feature attributes, and determine the feature attribute used to divide the dataset contained in the current node according to the calculated corrected information gain; and a model output module configured to output the decision tree model formed based on the training dataset.

[0007] According to one aspect of the embodiments of this application, a data recommendation method based on a decision tree model is provided, comprising: obtaining a set of candidate samples to be recommended, each candidate sample containing multiple feature information; predicting the probability that each candidate sample belongs to a specified category attribute according to a decision tree model obtained by a decision tree model generation method; sorting the candidate samples in the candidate sample set in descending order of probability, and selecting target candidate samples for recommendation according to the sorting result.

[0008] According to one aspect of the embodiments of this application, a data recommendation device based on a decision tree model is provided, comprising: a sample set acquisition module configured to acquire a set of candidate samples to be recommended, each candidate sample containing multiple feature information; a probability prediction module configured to predict the probability that each candidate sample belongs to a specified category attribute according to a decision tree model obtained by a decision tree model generation device; and a sample recommendation module configured to sort the candidate samples in the candidate sample set in descending order of probability, and select target candidate samples for recommendation based on the sorting result.

[0009] According to one aspect of the embodiments of this application, an electronic device is provided, including: one or more processors; and a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the electronic device enables the decision tree model generation method or the data recommendation method based on the decision tree model as described above.

[0010] According to one aspect of the embodiments of this application, a computer-readable storage medium is provided, on which computer-readable instructions are stored, which, when executed by a computer's processor, cause the computer to perform the decision tree model generation method or the data recommendation method based on the decision tree model as described above.

[0011] According to one aspect of the embodiments of this application, a computer program product is also provided, including a computer program that, when executed by a processor, implements the decision tree model generation method or the data recommendation method based on the decision tree model as described above.

[0012] In the technical solution provided in the embodiments of this application, for the process of generating a decision tree model, the prior art needs to iteratively calculate the information gain of each feature attribute under each node, and divide the dataset contained in the current node according to the feature attribute corresponding to the maximum information gain, so as to split into multiple child nodes based on the current node, until the category attribute can be determined according to the dataset contained in the node. If the information gains of multiple feature attributes under a certain node are equal and the maximum information gain is reached, the prior art cannot solve this problem, resulting in inaccurate classification of the obtained decision tree model. This application avoids the problem of being unable to divide the dataset contained in the current node when there are multiple features with equal information gains and the maximum information gain by correcting the information gain. Specifically, the feature attribute used to divide the dataset contained in the current node is determined according to the corrected information gain, thereby making the final generated decision tree model have a more accurate classification effect.

[0013] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0014] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.

[0015] Figure 1 This is a schematic diagram of an exemplary decision tree structure.

[0016] Figure 2 This is another exemplary schematic diagram of a decision tree structure.

[0017] Figure 3 This is a schematic diagram of a recommendation implementation process proposed in the existing technology to address the problem that the recommendation effect is affected by the presence of many features with the same value or small data differences for each song in the context of connected vehicle song recommendation.

[0018] Figure 4 This is a flowchart illustrating a decision tree generation method in an exemplary embodiment of this application.

[0019] Figure 5 This is a flowchart illustrating a decision tree generation method, which is another exemplary embodiment of this application.

[0020] Figure 6 This is a schematic diagram of an exemplary implementation environment.

[0021] Figure 7 This is a flowchart illustrating a data recommendation method based on a decision tree model, as shown in an exemplary embodiment of this application.

[0022] Figure 8 This is a schematic diagram illustrating the overall process of a decision tree model from generation to application.

[0023] Figure 9 This is a block diagram illustrating a decision tree model generation apparatus in an exemplary embodiment of this application.

[0024] Figure 10 This is a block diagram illustrating a decision tree-based data recommendation apparatus, as shown in an exemplary embodiment of this application.

[0025] Figure 11 This is an exemplary structural diagram of a computer system suitable for implementing an electronic device according to embodiments of this application. Detailed Implementation

[0026] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0027] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0028] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.

[0029] In this application, "multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.

[0030] First, it should be noted that this application relates to the field of artificial intelligence (AI). AI is the theory, methods, technology, and application systems that utilize digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science that attempts to understand the essence of intelligence and produce a new kind of intelligent machine that can react in a way similar to human intelligence. AI studies the design principles and implementation methods of various intelligent machines, enabling them to possess the functions of perception, reasoning, and decision-making.

[0031] Machine learning (ML) is a multidisciplinary field involving probability theory, statistics, approximation theory, convex analysis, and many other disciplines. It specifically studies how computers can simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to endow computers with intelligence; its applications span all areas of artificial intelligence. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, and inductive learning.

[0032] Decision tree models are classic algorithm models in the field of machine learning. The decision tree algorithm is a method to approximate discrete function values. A decision tree is a tree structure that represents the classification of samples based on features. The classification process of a decision tree can be summarized as recursively selecting the optimal splitting feature from a given dataset according to the feature selection criteria, and then splitting the dataset according to the selected optimal splitting feature so that each subset of data has the best classification.

[0033] The process of selecting the optimal splitting feature to segment the dataset can also be called feature grouping. Therefore, the process of using a decision tree model for data classification can also be summarized as iteratively selecting the optimal splitting feature from the current dataset to group the features contained in the current dataset.

[0034] Figure 1 This is a schematic diagram of an exemplary decision tree structure, used to predict whether a student is a good student. For example... Figure 1 As shown, a decision tree consists of several nodes connected by branches. Each node includes internal nodes and leaf nodes. Each internal node represents a classification test on a feature attribute, and each branch represents the output of that feature attribute over a certain value range. Each leaf node represents a class or class distribution, such as... Figure 1 The leaf nodes in the illustration represent the two categories of good students and not good students; the node at the top level of the tree structure is called the root node.

[0035] It should be understood that Figure 1 The decision tree structure shown is merely an example to facilitate understanding of decision tree structures. In practical applications, the decision tree should be generated according to the actual dataset and the set feature selection criteria, for example, in... Figure 2 In the structural diagram of the decision tree model shown, compared to Figure 1 The structure of the decision tree model shown has reduced the number of internal nodes corresponding to the feature attribute of score and added internal nodes corresponding to the feature attribute of assignment submission rate. No restrictions are placed on the specific structure of the decision tree model here.

[0036] The generation process of a decision tree is a supervised learning process. By providing several samples, each of which has a set of feature attributes and a classification result (i.e., the classification result is known), a decision tree model can be obtained by learning the classification results of these samples. This decision tree model can predict the correct classification of the feature attributes of new samples.

[0037] To facilitate understanding the generation process of decision trees, we will still use... Figure 1 The decision tree structure shown serves as an example to illustrate the process of generating a decision tree: given a set of feature information for each of several students (including student scores, attendance rates, number of questions answered, etc.) and corresponding classification results (good student or not a good student), the system learns to obtain a decision tree structure as follows: Figure 1The decision tree model shown predicts whether a student is a good student by sequentially judging whether the values ​​of each feature attribute meet specific conditions. Specifically, the root node of the decision tree model contains the initial dataset. Based on the value of the feature attribute "score" contained in the initial dataset, the initial dataset is divided into two subsets, for example, "feature set of students with scores greater than A" and "feature set of students with scores not greater than A". Each subset corresponds to a child node. If the category attribute can be determined based on the dataset contained in the child node, this child node is designated as a leaf node; if the category attribute cannot be determined based on the dataset contained in the child node, the dataset contained in this node is further divided, and this node splitting process is recursively executed until the node is split into two leaf nodes, thus obtaining the decision tree model. The specific feature attribute selected for splitting the dataset contained in the current node depends on the set feature selection criteria, as described below.

[0038] Specifically, the generation process of a decision tree is essentially a process of continuously dividing the dataset into optimal subsets using feature selection criteria. For each partition, the goal is to obtain the optimal subset, thereby ensuring the final decision tree structure is optimal. The feature selection criteria used in the decision tree generation process mainly include information gain and information entropy; that is, information gain and information entropy are used to measure whether each partition of the dataset is optimal. Information entropy is used to measure the uncertainty of random variables. For ease of understanding, let's assume the random variable... Possible values ​​are , , ..., For each possible value Its probability is expressed as , ( =1, 2, ..., ),random variable Information entropy is represented as follows:

[0039]

[0040] For dataset In general, random variables It refers to the sample category, i.e., assuming the samples share a common category. There are n categories, and the probability of each category is expressed as: ,in Indicates category The number of samples, Represents the dataset The total number of samples in the dataset Information entropy can be represented as follows:

[0041]

[0042] Information gain represents the difference in information entropy before and after partitioning a dataset using a certain feature attribute. For a dataset to be partitioned, if the information entropy before partitioning is denoted as entropy(before) and the information entropy after partitioning is denoted as entropy(after), then entropy(before) is usually fixed, while entropy(after) is variable. The smaller the entropy(after), the less uncertainty there is in the subset of data obtained by partitioning using the current feature attribute. In other words, the larger the difference between entropy(before) and entropy(after), the less uncertainty there is in partitioning the dataset using the current feature attribute. Therefore, the difference in information entropy before and after partitioning the dataset (i.e., information gain) can be used to measure the effectiveness of using the current feature attribute for partitioning the dataset.

[0043] In the construction of decision trees, the goal is always to achieve a dataset partition with less uncertainty as quickly as possible, thus improving the classification performance of the decision tree structure. Therefore, the feature with the highest information gain is usually chosen to partition the current dataset. However, in real-world applications, it's easy for samples in the dataset to have the same numerical value for their features. For example, in the context of connected car song recommendation, user clicks and plays are relatively inactive, resulting in many songs having the same numerical value for features such as click count, favorite count, and rating count, or many song features with small numerical differences. This can lead to situations where two or more feature attributes have the same information gain when using existing decision tree algorithms to learn the decision tree model, making it difficult to determine the optimal partitioning feature. This results in the inability to partition the dataset, leading to classification bias in the final learned decision tree model and poor classification performance.

[0044] Other application scenarios involving category recommendation may also encounter the above problems, such as product recommendation scenarios. If product samples have many features with the same value or small data differences due to poor circulation, such as the number of views, the number of favorites, and the number of purchases, etc., these application scenarios with the same problems will not be listed one by one here.

[0045] Furthermore, in the context of connected vehicle song recommendation, because each song has many features with similar or small differences that affect the recommendation effect, existing technologies generally use analysis of variance (ANOVA) to achieve song recommendation. Current technologies use user rating data for songs, iteratively grouping them by constructing the maximum between-group variance, and then finding the optimal group. For example... Figure 3As shown, the existing technology first determines the number of groups, then iteratively calculates the inter-group variance for each group to obtain a sequence of inter-group variance vectors for each number of groups. Next, it constructs an inter-group variance matrix based on the component variance sequences for all groups, selecting the group with the largest inter-group variance matrix and its corresponding group number as the optimal group data and optimal group. Finally, it constructs a CF (Collaborative Filtering-based) model for each group to recommend songs. However, the existing technology requires a very large amount of computation, resulting in low computational efficiency due to excessive consumption of computing and storage resources. Furthermore, this approach can only group the entire dataset each time, failing to provide model training and prediction capabilities, thus resulting in a lack of generalization ability in the model.

[0046] To address the aforementioned technical problems, embodiments of this application propose a decision tree model generation method and apparatus, a data recommendation method and apparatus based on a decision tree model, an electronic device, a computer-readable storage medium, and a computer program product, which will be described in detail below.

[0047] First see Figure 4 , Figure 4 This is a flowchart illustrating a decision tree generation method in an exemplary embodiment of this application. The method can be executed by a terminal device, such as a mobile phone, computer, smart home appliance, vehicle terminal, or aircraft; it can also be executed by a server, such as a standalone physical server, a server cluster or distributed system composed of multiple physical servers; or it can be a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. This embodiment does not limit this.

[0048] like Figure 4 As shown, in an exemplary embodiment, the decision tree model generation method includes steps S410 to S440, which are described in detail below.

[0049] Step S410: Obtain a training dataset formed by the feature information of multiple training samples. Each training sample has known category attributes, and the feature information of each training sample corresponds to different feature attributes.

[0050] As mentioned earlier, the generation of a decision tree model is to obtain a data model for classification by learning the relationship between the feature attributes of several samples and the classification results. The essential process is to continuously divide the dataset formed by the feature information of several features into optimal data subsets using the criteria that satisfy feature selection. Therefore, for the generation of a decision tree model, it is necessary to obtain a training dataset formed by the feature information of multiple training samples under different feature attributes, and to know the category attributes of each training sample. Subsequently, by continuously dividing the training dataset, the nodes and branches of the decision tree model are generated accordingly. That is, the nodes are continuously split until the attribute category can be determined based on the dataset contained in the child nodes obtained by the split, thus finally obtaining a decision tree model with data classification function.

[0051] It should be noted that feature information refers to specific feature values, while feature attributes are properties used to describe the same type of feature information. Let's continue with... Figure 1 As an example, scores, attendance rates, and the number of questions answered are feature attributes. Each student's feature value under the corresponding feature attribute is the specific feature information. For example, a student with a score of 90, an attendance rate of 99%, and 12 questions answered are the student's feature information under different feature attributes. It should be understood that the feature information of the training samples and the corresponding feature attributes should be determined based on the actual scenario. The example above does not represent a limitation on the feature information under different feature attributes.

[0052] In step S420, during the process of generating a decision tree model based on the training dataset, the information gain of each feature attribute under each node is iteratively calculated, and the dataset contained in the current node is divided according to the feature attribute corresponding to the maximum information gain, so as to form multiple child nodes based on the current node, until the category attribute can be determined based on the dataset contained in the node.

[0053] As mentioned earlier, in the process of generating decision tree models using existing technologies, it is necessary not only to construct the various nodes of the decision tree model, including internal nodes (the root node is located at the top of the tree structure) and leaf nodes, but also to construct branches for connecting the nodes.

[0054] Since internal nodes represent classification tests on a feature attribute, the process of generating a decision tree model from the training dataset requires iteratively calculating the information gain of each feature attribute under each node. The dataset contained in the current node is then divided based on the feature attribute corresponding to the maximum information gain, thus splitting the current node into multiple child nodes until the category attribute can be determined from the dataset contained in the node. The current node can be called the parent node of the child nodes obtained from the split, and the relationship between the parent node and the child nodes is called a branch, which is usually the output of the feature attribute represented by the parent node in a certain value range.

[0055] It should be noted that the detailed process of generating the decision tree model mentioned in step S420 corresponds to the content of the decision tree algorithm. For details, please refer to the aforementioned principle of decision tree generation, which will not be repeated here. Decision tree algorithms for generating decision tree models include, for example, ID3 (a decision tree algorithm based on information theory, using information entropy and information gain as metrics to achieve inductive classification of datasets), C4.5 (an extension of the ID3 algorithm, which, like ID3, uses the concept of information entropy and, like ID3, builds a decision tree model by learning from the dataset), CART (Classification and Regression Tree), etc. This embodiment does not limit this to these algorithms.

[0056] Step S430: If the information gain of multiple feature attributes under the current node is equal and is the maximum information gain, then calculate the corrected information gain corresponding to each of the multiple feature attributes, and determine the feature attributes used to divide the dataset contained in the current node based on the calculated corrected information gain.

[0057] In real-world applications, training datasets often contain training samples with identical numerical values ​​for their features. For example, in the context of connected vehicle song recommendation, user clicks and plays are relatively inactive, resulting in many songs having the same numerical values ​​for features such as click counts, favorite counts, and rating counts. Alternatively, there may be many song features with small numerical differences. This can lead to situations where, during the iterative calculation of the information gain of each feature attribute under each node in step S420, and the partitioning of the dataset contained in the current node based on the feature attribute with the maximum information gain to form multiple child nodes, multiple feature attributes under the current node may have equal and maximum information gains. This can affect the selection of the feature attribute used to partition the dataset contained in the current node based on the maximum information gain in step S420, resulting in poor classification performance of the generated decision tree model.

[0058] To address this issue, those skilled in the art might readily conceive of randomly selecting one feature attribute from among multiple feature attributes with equal and maximum information gain for the current dataset partitioning. However, this random selection method leads to weak classification prediction performance of the decision tree model. For example, if the value of one or more feature attributes of the predicted sample differs significantly from that of the training sample set, the classification logic corresponding to the decision tree model generated based on the training sample set will be unable to adapt to the feature distribution of the predicted sample, thus failing to accurately classify the predicted sample.

[0059] To address this issue, this embodiment calculates the corresponding corrected gain for each feature attribute with equal information gain and the maximum information gain for the current node. Then, based on the calculated corrected information gain, it determines the feature attribute used to partition the data contained in the current node. In other words, this embodiment addresses situations where the maximum information gain cannot be directly used to partition the current data. It further calculates the corrected information gain, correcting each maximum information gain that cannot be uniquely determined, and uses the obtained corrected information gain to determine which feature data to select for partitioning the current dataset to obtain the optimal data subset.

[0060] For a detailed description of the correction process, please refer to the subsequent embodiments. It will not be repeated here, but it should be noted that the calculation of the corrected information gain for each feature attribute in this embodiment considers the proportion of each feature attribute to the target category attribute. The target category attribute can be the category attribute corresponding to positive samples, such as the "good student" category attribute in the previous example, or it can be the category attribute corresponding to negative samples, such as the "not a good student" category attribute in the previous example. The former is usually chosen, but it can also be selected according to actual needs. That is, this embodiment corrects the corresponding information gain based on the degree of influence of each feature attribute on the target category attribute. The corrected information gain thus reflects whether using each feature attribute to partition the dataset contained in the current node can obtain the optimal data subset.

[0061] For the corrected information gains corresponding to the multiple calculated feature attributes, first determine whether these corrected information gains contain equal corrected information gains. If the values ​​of these corrected information gains are not equal, select the feature attribute corresponding to the largest corrected information gain as the feature attribute used to partition the dataset contained in the current node. As mentioned earlier, the influence of the feature attribute corresponding to the largest corrected information gain on the target category attribute should be greater than that of other feature attributes with corrected information gains. Therefore, selecting the feature attribute corresponding to the largest corrected information gain to partition the current dataset can obtain the optimal data subset. If we assume that the corrected information gain of feature attribute a1 is greater than that of feature attribute a2, and feature attribute a1 in the dataset contained in the current node has 3 values, then feature attribute a1 can be selected to partition the dataset contained in the current node. Specifically, the dataset is divided into 3 data subsets based on the 3 values ​​of feature attribute a1, thus forming 3 corresponding child nodes.

[0062] If these corrected information gains contain equal corrected information gains, then it is further determined whether the equal corrected information gains are the maximum corrected information gains. If so, it means that the influence of the corresponding feature attributes on the target category attribute cannot be distinguished, or that the influence of the corresponding feature attributes on the target category attribute is consistent. In this case, the feature attributes corresponding to these equal corrected information gains are merged to obtain merged feature attributes. Then, this merged feature attribute is determined as the feature attribute used to partition the dataset contained in the current node. For example, if feature attribute a1 has 3 feature values, it can be divided into 3 child nodes, and feature attribute a2 has 2 feature values, it can be divided into 2 child nodes. Based on the merged feature attribute formed by feature attributes a1 and a2, it can be divided into 3*2=6 child nodes.

[0063] If it is determined that the equal corrected information gain is not the maximum corrected information gain, that is, the calculated corrected information gain contains a unique maximum corrected information gain, then the feature attribute corresponding to the maximum corrected information gain can be directly selected as the feature attribute used to divide the dataset contained in the current node.

[0064] The feature attribute determination process described above ensures that the feature attributes determined for each node to divide the dataset contained in the current node are optimal, thereby ensuring that the generated decision tree model has the best classification performance.

[0065] Step S440: Output the decision tree model formed based on the training dataset.

[0066] The steps above illustrate the process of supervised learning based on the training dataset. By learning the classification results of the training samples contained in the training dataset through the above process, a decision tree model formed based on the training dataset can be obtained. This decision tree model can predict the correct attribute category for the feature attributes of new samples.

[0067] As can be seen from the above, this embodiment improves the accuracy of dataset partitioning by calculating the corrected information gain and comparing the magnitude of the corrected information gain to determine the final feature attribute used to partition the current dataset. Even when the corrected information gain cannot uniquely determine the feature attribute used to partition the dataset, this embodiment partitions the dataset using the merged feature attribute. This is equivalent to comprehensively considering the optimal data subset partitioning when partitioning the dataset. Therefore, it can effectively solve the dataset partitioning problem in existing decision tree algorithms when the information gain of multiple feature attributes is equal, and also makes the decision tree model learned in this embodiment have more accurate classification performance.

[0068] The following example uses two feature attributes with the largest and equal information gain under a node to illustrate the process of calculating the corrected information gain in step S230. It should be understood that if there are more than two feature attributes with the largest and equal information gain under a node, the corrected information gain for each feature attribute can be calculated similarly. For example, this can be achieved by dividing the two or more feature attributes into multiple pairwise groups and then calculating the corresponding corrected information gain according to the process shown in the example below. The case of more than two features will not be elaborated upon here.

[0069] The corrected information gain for each feature attribute under a node is the product of the corresponding information gain and the correction factor. For example, the two feature attributes with the largest and equal information gains under a node are the first and second information attributes in the dataset contained in the current node. Each feature attribute (which can be represented as) ) and the Each feature attribute (which can be represented as) For the data set contained in the node, the first... If there are several feature attributes, and the information gain corresponding to these feature attributes is expressed as... The correction factor corresponding to this feature attribute is expressed as The corrected information gain corresponding to this feature attribute is then expressed as follows: .

[0070] No. The correction factor corresponding to the i-th feature attribute is determined by the i-th feature attribute. The percentage of samples corresponding to the target category attribute in the dataset contained in the current node under each feature attribute and the percentage of samples corresponding to the target category attribute under each feature attribute. The proportion of samples corresponding to the target category attribute in the dataset contained in the current node under each feature attribute is used to determine the feature attribute. For example, the proportion of samples corresponding to the target category attribute in the dataset contained in the node is used to determine the feature attribute. Correction factor corresponding to each feature attribute It can be calculated using the following formula:

[0071]

[0072] in, Indicates the first The percentage of samples in the dataset containing each feature attribute that correspond to the target category attribute under each feature attribute. Indicates the first The percentage of samples in the dataset containing the current node that correspond to the target category attribute under each feature attribute.

[0073] No. The proportion of samples corresponding to the target category attribute in the dataset contained in the current node under the feature attribute is determined by the feature attribute. The number of samples corresponding to the target category attribute in the dataset contained in the current node under each feature is determined by the total number of samples contained in the training dataset. For example, the first... Under each feature attribute, the proportion of samples in the dataset containing the current node corresponding to the target category attribute. It can be calculated using the following formula:

[0074]

[0075] in Indicates the first The number of samples in the dataset containing the current node that correspond to the target category attribute under each feature. This represents the total number of samples in the training dataset. The [number]th [sample]... The percentage of samples in the dataset corresponding to the target category attribute under each feature attribute in the current node. It can be calculated in the same way, and will not be repeated here.

[0076] Accordingly, the first node in the dataset contained in the node can be obtained. Correction factor corresponding to each feature attribute It is calculated using the following formula:

[0077]

[0078] It can be seen that if Greater than , The value is greater than 1. The value is less than 1, the first The corrected information gain corresponding to the first feature attribute is greater than that of the second. The corrected information gain corresponding to the first feature attribute is selected. Each feature attribute is used to partition the dataset contained in the current node. If Less than , The value is less than 1. The value is greater than 1, the first The corrected information gain corresponding to the first feature attribute is greater than that of the second. The corrected information gain corresponding to the first feature attribute is selected. Each feature attribute is used to partition the dataset contained in the current node. If equal , The value is equal to 1. The value is also equal to 1, the first The corrected information gain corresponding to the i-th feature attribute is also equal to the i-th feature attribute. The corrected information gain corresponding to the nth feature attribute, therefore the nth feature attribute will be... The first feature attribute and the first The merged feature attribute, obtained by merging the feature attributes, is used to partition the dataset contained in the current node.

[0079] Therefore, it can be seen that the calculation of the corrected information gain corresponding to each feature attribute in this embodiment takes into account the proportion of each feature attribute to the target category attribute, and finally selects the feature attribute with a greater influence to divide the current dataset, thereby obtaining the optimal data subset and improving the classification accuracy of the generated decision tree model.

[0080] The information gain corresponding to the feature attribute is calculated using the following formula:

[0081]

[0082] In the formula above, Represents the training dataset. This indicates the first node in the dataset contained in the current node. Each feature attribute Indicates the first Information gain under each feature attribute The information entropy of the root node in a decision tree model is represented by its value. Indicates the first The first feature attribute The number of samples contained in the data subset divided by each child node. This represents the total number of samples in the training dataset. Indicates the first The first feature attribute Information entropy of each child node Indicates the first The total number of child nodes under each feature attribute. This is typically the total number of values ​​for that feature attribute in the dataset contained in the current node.

[0083] As can be seen from the above, the information gain corresponding to a feature attribute represents the difference in information entropy before and after splitting the dataset according to that feature attribute, and represents the information entropy of the root node of the decision tree model. It is usually certain that the information entropy after the dataset is divided is fixed. The smaller the value, the greater the information gain of the feature attribute, and the better the effect of using the feature attribute to partition the dataset.

[0084] Information entropy of the root node in a decision tree model It is calculated using the following formula:

[0085]

[0086] in This indicates that the category attribute in the training dataset is the first... The sample percentage of each category is specified, and the total number of categories for the category attributes is 2. Of course, in practical applications, the total number of category attributes can be greater than 2, depending on the actual needs of the classification. This embodiment does not impose this limitation.

[0087] Combining the above calculation process for corrected information gain, we can obtain a comprehensive formula for calculating corrected information gain, as shown below:

[0088]

[0089] In the formula above, it is assumed that the two feature attributes with the largest and equal information gain under a node are respectively the first and second features in the dataset contained in the current node. Each feature attribute and the Each feature attribute , Representing feature attributes The corresponding corrected information gain, Representing feature attributes The corresponding information gain, Representing feature attributes The corresponding information gain. It can be seen that when the feature attribute... Information gain is not equal to feature attribute When calculating information gain, the feature attribute corresponding to the largest information gain is directly selected for partitioning the current dataset under a node. Therefore, it is calculated according to the second formula shown above (my formula below), and specifically, the information gain is calculated, not the modified information gain. When the feature attribute... Information gain equals feature attribute When considering the information gain (and the information gain of these two feature attributes is the maximum information gain under the current node), it is not possible to directly select the feature attribute corresponding to the maximum information gain when partitioning the dataset under the node. Therefore, the corrected information gain is calculated according to the first formula shown above (the formula above).

[0090] The above embodiments clearly describe the detailed process of generating a decision tree model. However, the final acquisition of a decision tree model usually includes a testing phase for the decision tree model obtained in the training and generation phase, in addition to the training and generation phase described above. Only after the generated decision tree model has been tested and verified to meet the requirements can it be used for actual classification prediction.

[0091] like Figure 5 As shown, in an exemplary embodiment, the decision tree model generation method in Figure 4The illustrated embodiment includes steps S410 to S440, and further includes steps S450 to S470. That is, in... Figure 5 The decision tree model generation method shown includes a process of testing the decision tree model after outputting the decision tree model formed based on the training dataset. The testing process of the decision tree model will be described in detail below. As for how to output the corresponding decision tree model based on the training dataset, please refer to the description in the foregoing embodiments, which will not be repeated here.

[0092] It should also be noted that, Figure 5 The specific entity responsible for implementing the decision tree model generation method shown is also related to... Figure 4 The embodiments shown are the same and can be terminal devices such as mobile phones, computers, smart home appliances, vehicle terminals, and aircraft, or independent physical servers, or server clusters or distributed systems composed of multiple physical servers, or cloud servers that provide basic cloud computing services. This embodiment does not limit these.

[0093] like Figure 5 As shown, in an exemplary embodiment, the process of testing the decision tree model after outputting the decision tree model formed based on the training dataset includes steps S450 to S470, which are described in detail below.

[0094] Step S450: The output decision tree model is used as the model to be tested and input into the test dataset for testing to obtain the classification results predicted by the model to be tested for multiple test samples.

[0095] To more accurately verify the effectiveness of the decision tree model generated during the training phase, the test dataset used to test the decision tree model should have a similar feature distribution to the training data. Typically, the training and test datasets share the same data source. For example, a large number of samples in a sample set can be randomly divided into training and test samples according to a certain ratio. The training dataset consists of the feature set of the training samples, and the test dataset consists of the feature set of the test samples. This ensures that the training and test datasets have similar feature distributions and can be used to test the decision tree model learned from the training dataset.

[0096] The output decision tree model is used as the test model and input into the test dataset for testing. This yields the classification results predicted by the test model for multiple test samples. The attribute category of each test sample is also known. Therefore, based on the classification results output by the test model for each test sample, it can be determined whether the test model outputs the correct classification result. Subsequently, by statistically analyzing the judgment results, it can be determined whether the model performance meets the expected requirements.

[0097] Step S460: Calculate the performance evaluation index of the model to be tested based on the obtained classification results. The performance evaluation index includes at least one of accuracy, precision, and recall.

[0098] In this embodiment, accuracy refers to the ratio of correctly classified test sample data to the total number of test samples, which can be calculated using the following formula:

[0099]

[0100] in Indicates accuracy rate. This represents the test sample that was correctly classified as a positive sample. This represents the test samples that were correctly classified as negative samples. This represents all test samples. It should be noted that positive samples refer to test samples that belong to a certain category attribute (usually the category attribute being sought), while negative samples refer to test samples that do not belong to this category attribute.

[0101] Precision is the ratio of the number of test samples correctly classified as positive to the total number of test samples classified as positive, and it is calculated using the following formula:

[0102]

[0103] in Indicates precision. This indicates a test sample that is classified as a positive sample but is actually a negative sample.

[0104] Recall rate is the ratio of correctly classified positive samples to the number of test samples that should have been correctly classified, and it is calculated using the following formula:

[0105]

[0106] in Represents recall. This represents a test sample that is classified as a positive sample but is actually a positive sample.

[0107] Any of the performance evaluation metrics shown above can be used to evaluate the performance of the model under test, but they each have different focuses or concerns. For example, accuracy can be used to measure the overall predictive performance, precision focuses more on the performance of the model under test in correctly classifying positive samples, and recall focuses more on the performance of the model under test in correctly classifying all positive samples. Therefore, in different application scenarios, at least one performance evaluation metric can be selected to evaluate the performance of the model under test based on the actual performance concerns.

[0108] Step S470: If the performance evaluation index indicates that the model performance of the model to be tested meets the standard, then the model to be tested is taken as the optimal decision tree model.

[0109] The performance evaluation index indicates that the model under test has met the standard. For example, the value of the performance evaluation index is greater than the preset threshold. The preset threshold is usually determined based on experience. Alternatively, if there are multiple performance evaluation indices, and the number of performance evaluation indices that meet the standard is greater than the preset value, the performance evaluation index can also be used to indicate that the model under test has met the standard. These are not listed one by one and can be set according to the actual application requirements.

[0110] If the performance evaluation index indicates that the model under test meets the standard, then the model under test can be used as the optimal decision tree model for practical applications, that is, the optimal decision tree model can be used to predict the class attributes of real samples.

[0111] For example, embodiments of this application also provide a data recommendation method based on a decision tree model, wherein the decision tree model used in the method can be... Figure 4 The decision tree model obtained in the illustrated embodiment can also be Figure 5 The optimal decision tree model obtained in the illustrated embodiment is not limited here. Furthermore, the execution subject of this method can be a terminal device such as a mobile phone, computer, smart home appliance, vehicle terminal, or aircraft; it can also be an independent physical server; it can be a server cluster or distributed system composed of multiple physical servers; or it can be a cloud server providing basic cloud computing services. This embodiment also does not limit this.

[0112] For example in Figure 6 In the exemplary implementation environment shown, server 610 is used to execute a data recommendation method based on a decision tree model to determine target candidate samples from a set of candidate samples and transmit these target candidate samples to terminal device 620. The communication connection established between server 610 and terminal device 620 can be wired or wireless; this implementation environment does not impose any limitations on this.

[0113] The flowchart for this decision tree-based data recommendation method is as follows: Figure 7 As shown, steps S710 to S730 are detailed below.

[0114] Step S710: Obtain a set of candidate samples to be recommended, where each candidate sample contains multiple feature information.

[0115] In this embodiment, the candidate sample set consists of multiple candidate samples to be recommended. The multiple feature information contained in each candidate sample can be determined according to the actual application scenario. For example, in the aforementioned vehicle-to-everything (V2X) song recommendation scenario, the feature information contained in the candidate sample may include the number of clicks, the number of favorites, and the number of reviews. In another example, in the product recommendation scenario, the feature information contained in the candidate sample may include the number of views, the number of favorites, and the number of purchases.

[0116] Step S720: Predict the probability of each candidate sample belonging to a specified category attribute based on the decision tree model.

[0117] Typically, decision tree models perform classification predictions for each candidate sample to obtain the probability of each candidate sample belonging to a predefined category attribute. For example, in a binary classification scenario, the predictions obtain the probability that each candidate sample belongs to the first category attribute and the probability that it belongs to the second category attribute.

[0118] Specifying a category attribute refers to the desired category attribute. For example, in the aforementioned car-connected song recommendation scenario, the category attributes include "positive user reviews" and "negative user reviews." Selecting "positive user reviews" as the category attribute ensures that the car-connected song recommendations are based on user satisfaction levels. Similarly, in the aforementioned product recommendation scenario, the category attributes include "buy" and "won't buy." Selecting "buy" as the category attribute ensures that product recommendations are based on the likelihood of a user making a purchase. Therefore, it can be seen that specifying a category attribute is more beneficial for recommending candidate samples.

[0119] Step S730: Sort the candidate samples in the candidate sample set in descending order of probability, and select the target candidate sample for recommendation based on the sorting result.

[0120] This embodiment sorts the candidate samples in the candidate sample set in descending order of probability, and selects target candidate samples for recommendation based on the sorting results. This allows for the recommendation of candidate samples that are more easily accepted or recognized, thereby achieving more accurate recommendations.

[0121] It should be noted that, in addition to the aforementioned vehicle-to-everything (V2X) song recommendation and product recommendation scenarios, the data recommendation method based on the decision tree model proposed in this embodiment is applicable to more classification recommendation scenarios, such as video or information recommendations based on user preferences, which will not be listed here. However, it should be noted that regardless of the application scenario, the decision tree model used should be learned from a training dataset collected within the same application scenario. This ensures that the decision tree model is suitable for classification prediction in this application scenario, improving the accuracy of classifying candidate samples and thus improving the accuracy of recommending them. Furthermore, it should be noted that the application scenarios applicable to the method proposed in this embodiment typically involve candidate samples containing features with identical values ​​or feature value differences less than a preset threshold. In such scenarios, the decision tree model generated by existing decision tree algorithms cannot handle the situation where the maximum information gain is equal during node splitting. This results in the decision tree model generated by existing decision tree algorithms failing to accurately classify the candidate samples; that is, the probability that a candidate sample belongs to a specified category attribute is inaccurate, thus affecting the accuracy of recommending the candidate samples.

[0122] Figure 8 This is a schematic diagram illustrating the overall process of a decision tree model from generation to application. For example... Figure 8 As shown, in the input data stage, a large amount of sample feature data needs to be obtained. For example, each car-related song can be considered as a sample. Sample feature data includes user ratings of the songs, the number of clicks, favorites, and reviews for each song, the type of review (positive or negative), whether playback was canceled, playback time, number of plays, payment amount for each song, number of payments, song style, language, and other feature data. These samples can be from different periods, such as samples from period T-1 and period T. Period T refers to the actual prediction time period, generally understood as the current period, while period T-1 is understood as the historical period.

[0123] During the sample construction phase, the samples from period T-1 are randomly divided into training samples and test samples according to a certain ratio, for example, the ratio of training samples to test samples is 8:2. This results in a training dataset formed by the feature data of the training samples and a test sample set formed by the feature data of the test samples. The samples from period T are used as prediction samples. The category attribute of the prediction samples is unknown and to be predicted, that is, the prediction samples do not contain the feature information of the user's rating type for the song.

[0124] In the decision tree model generation stage based on the training dataset, the information gain of different feature attributes under each node is iteratively calculated. If there are two feature attributes with equal information gains under a node, and this is the maximum information gain under the current node (it should be understood that this embodiment uses the example of two feature attributes with equal information gains and the maximum information gain under a node to illustrate the overall process), then a modified information gain is constructed and calculated. For details, please refer to the description in the aforementioned embodiment. Then, the maximum modified information gain is selected to partition the current dataset. If there is no feature attribute with equal and maximum information gain under a node, then the feature attribute corresponding to the maximum information gain is selected to partition the current dataset.

[0125] During the partitioning of the current dataset using the maximum modified information gain, if the two calculated modified information gains are still equal, the corresponding two feature attributes are merged and used to partition the current dataset; if the two modified information gains are not equal, the feature attribute corresponding to the maximum modified information gain is directly selected to partition the current dataset.

[0126] Based on the decision tree model generation process described above, a decision tree model learned from the training dataset can be obtained. This model is then used as the test model, and its prediction performance is tested using a test dataset. If the test model is determined to be the optimal decision tree model, the final decision tree model is obtained. If it is determined not to be the optimal model, the decision tree model is regenerated based on the training dataset until it passes the test.

[0127] The final decision tree model will be applied to the prediction classification of the predicted sample. That is, the final decision tree model will be used to predict the probability that the predicted sample belongs to a specified category attribute. Subsequently, recommendations for the predicted sample will be made based on the obtained classification results. It should be noted that the detailed process of the training, testing and prediction phases of the decision tree model can be found in the aforementioned embodiments, and will not be repeated here.

[0128] Figure 9This is a block diagram illustrating a decision tree model generation apparatus according to an exemplary embodiment of this application. The apparatus can be configured on a terminal device, such as a mobile phone, computer, smart home appliance, vehicle terminal, or aircraft, or on a server. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. This embodiment does not limit this.

[0129] like Figure 9 As shown, the decision tree model generation device 900 includes: a dataset acquisition module 910, configured to acquire a training dataset formed by feature information of multiple training samples, each training sample having a known category attribute, and each training sample's feature information corresponding to different feature attributes; a model generation module 920, configured to iteratively calculate the information gain of each feature attribute under each node during the process of generating a decision tree model based on the training dataset, and divide the dataset contained in the current node according to the feature attribute corresponding to the maximum information gain, so as to split into multiple child nodes based on the current node, until the category attribute can be determined based on the dataset contained in the node; if the information gains of multiple feature attributes under the current node are equal and are the maximum information gain, then calculate the corrected information gain corresponding to each of the multiple feature attributes, and determine the feature attribute used to divide the dataset contained in the current node based on the calculated corrected information gain; and a model output module 930, configured to output the decision tree model formed based on the training data.

[0130] In another exemplary embodiment, the model generation module 920 is further configured to: determine whether the calculated corrected information gain contains equal corrected information gains; if the corrected information gains corresponding to multiple feature attributes are not equal, select the feature attribute corresponding to the largest corrected information gain as the feature attribute used to divide the dataset contained in the current node.

[0131] In another exemplary embodiment, the model generation module 920 is further configured to: if the calculated modified information gain contains equal modified information gains, determine whether the equal modified information gains are the maximum modified information gain; if it is determined to be yes, merge the feature attributes corresponding to the equal modified information gains to obtain merged feature attributes, and determine the merged feature attributes as feature attributes used to partition the dataset contained in the current node; if it is determined to be no, select the feature attribute corresponding to the maximum modified information gain as the feature attribute used to partition the dataset contained in the current node.

[0132] In another exemplary embodiment, the number of feature attributes with the largest and equal information gain under a node includes two, namely the first and second features in the dataset contained in the current node. The first feature attribute and the first There are 1 feature attribute; in the model generation module 920, the corrected information gain corresponding to each feature attribute is the product of the corresponding information gain and the correction factor, and the 1st feature attribute is the product of the 2nd feature attribute and the correction factor. The correction factor corresponding to the i-th feature attribute is determined by the i-th feature attribute. The percentage of samples corresponding to the target category attribute in the dataset contained in the current node under each feature attribute and the percentage of samples corresponding to the target category attribute under each feature attribute. The proportion of samples corresponding to the target category attribute in the dataset contained in the current node under each feature attribute is used to determine the feature attribute.

[0133] In another exemplary embodiment, the first The proportion of samples corresponding to the target category attribute in the dataset contained in the current node under the feature attribute is determined by the feature attribute. The number of samples corresponding to the target category attribute in the dataset contained in the current node under each feature is determined by the total number of samples contained in the training dataset.

[0134] In another exemplary embodiment, the information gain corresponding to each feature attribute is calculated using the following formula:

[0135]

[0136] in, Represents the training dataset. This indicates the first node in the dataset contained in the current node. Each feature attribute Indicates the first Information gain under each feature attribute The information entropy of the root node in a decision tree model is represented by its value. Indicates the first The first feature attribute The number of samples contained in the data subset divided by each child node. This indicates the total number of samples contained in the training dataset. Indicates the first The first feature attribute Information entropy of each child node Indicates the first The total number of child nodes under each feature attribute.

[0137] In another exemplary embodiment, the information entropy of the root node of the decision tree model It is calculated using the following formula:

[0138]

[0139] in, This indicates that the category attribute in the training dataset is the first... The sample percentage of each category, and the total number of categories for the category attribute is 2.

[0140] In another exemplary embodiment, the first The first feature Information entropy of each child node It is calculated using the following formula:

[0141]

[0142] in, Indicates the first The first feature attribute The percentage of samples contained in the data subset divided by each child node.

[0143] In another exemplary embodiment, the decision tree model generation apparatus further includes:

[0144] The test data input module is configured to use the output decision tree model as the model to be tested, input the test dataset for testing, and obtain the classification results predicted by the model to be tested for multiple test samples; the evaluation index calculation module is configured to calculate the performance evaluation index of the model to be tested based on the obtained classification results. The performance evaluation index includes at least one of accuracy, precision, and recall; if the performance evaluation index indicates that the model performance of the model to be tested meets the standard, then the model to be tested is regarded as the optimal decision tree model.

[0145] Figure 10 This is a block diagram illustrating a decision tree-based data recommendation device in an exemplary embodiment of this application. The device can be configured on a terminal device, such as a mobile phone, computer, smart home appliance, vehicle terminal, or aircraft, or on a server. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. This embodiment does not limit this to any particular type of cloud computing.

[0146] like Figure 10 As shown, the data recommendation device 1000 based on the decision tree model includes:

[0147] The candidate sample acquisition module 1010 is configured to acquire a set of candidate samples to be recommended, each candidate sample containing multiple feature information; the prediction classification module 1020 is configured to predict the probability of each candidate sample belonging to a specified category attribute based on the decision tree model obtained by the decision tree model generation device; the ranking recommendation module 1030 is configured to sort the candidate samples in the candidate sample set in descending order of probability, and select target candidate samples for recommendation based on the ranking results.

[0148] In one exemplary embodiment, the candidate sample set includes a sample set formed by multiple songs, each song containing feature information with the same feature value or a feature value difference less than a preset threshold.

[0149] It should be noted that the apparatus and method provided in the above embodiments belong to the same concept, and the specific ways in which each module and unit performs operations have been described in detail in the method embodiments, and will not be repeated here. In practical applications, the apparatus provided in the above embodiments can be assigned to different functional modules as needed, that is, the internal structure of the apparatus can be divided into different functional modules to complete all or part of the functions described above, and this is not a limitation.

[0150] Embodiments of this application also provide an electronic device, including: one or more processors; and a storage device for storing one or more programs, which, when executed by the one or more processors, cause the electronic device to implement the decision tree model generation method or the data classification method based on the decision tree model provided in the above embodiments.

[0151] Figure 11 A schematic diagram of a computer system suitable for implementing the embodiments of this application is shown. It should be noted that... Figure 11 The computer system of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0152] like Figure 11As shown, the computer system includes a Central Processing Unit (CPU) 1101, which can perform various appropriate actions and processes based on programs stored in Read-Only Memory (ROM) 1102 or programs loaded from storage portion 1108 into Random Access Memory (RAM) 1103, such as performing the methods described in the above embodiments. Various programs and data required for system operation are also stored in RAM 1103. The CPU 1101, ROM 1102, and RAM 1103 are interconnected via bus 1104. An Input / Output (I / O) interface 1105 is also connected to bus 1104.

[0153] The following components are connected to I / O interface 1105: an input section 1106 including a keyboard, mouse, etc.; an output section 1107 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 1108 including a hard disk, etc.; and a communication section 1109 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 1109 performs communication processing via a network such as the Internet. A drive 1110 is also connected to I / O interface 1105 as needed. Removable media 1111, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 1110 as needed so that computer programs read from them can be installed into storage section 1108 as needed.

[0154] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program including a computer program for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 1109, and / or installed from removable medium 1111. When the computer program is executed by central processing unit (CPU) 1101, it performs various functions defined in the system of this application.

[0155] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying a computer-readable computer program. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. Computer-readable signal media can also be any computer-readable medium other than computer-readable storage media, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The computer program contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.

[0156] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. Each block in a flowchart or block diagram may represent a module, segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0157] The units described in the embodiments of this application can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the specific unit itself.

[0158] Another aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the decision tree model generation method or the data classification method based on the decision tree model as described above. This computer-readable storage medium may be included in the electronic device described in the above embodiments, or it may exist independently and not assembled into the electronic device.

[0159] Another aspect of this application provides a computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the decision tree model generation method or the data classification method based on the decision tree model provided in the various embodiments above.

[0160] The above description is merely a preferred exemplary embodiment of this application and is not intended to limit the implementation of this application. Those skilled in the art can easily make corresponding modifications or alterations based on the main concept and spirit of this application. Therefore, the scope of protection of this application should be determined by the scope of protection claimed in the claims.

Claims

1. A data recommendation method based on a decision tree model, characterized in that, The method includes: Obtain a candidate sample set to be recommended. The candidate sample set includes a sample set formed by multiple connected vehicle songs. The connected vehicle songs contain feature information with the same feature value or a feature value difference less than a preset threshold. The decision tree model predicts the probability of each connected vehicle song belonging to a specified category attribute. The decision tree model is generated through the following steps: First, a training dataset is obtained, consisting of feature information from multiple training samples. These training samples are connected vehicle songs collected from the same application scenario based on the candidate sample set. Each training sample contains feature information with identical or significantly different feature values. Each training sample has a known category attribute, and the feature information of each training sample corresponds to a different feature attribute. During the generation of the decision tree model from the training dataset, the information gain of each feature attribute under each node is iteratively calculated. The dataset contained in the current node is divided according to the feature attribute corresponding to the maximum information gain, thus splitting the current node into multiple child nodes until the category attribute can be determined based on the dataset contained in the node. If the information gains of multiple feature attributes under the current node are equal and constitute the maximum information gain, the corrected information gain corresponding to each feature attribute is calculated based on the proportion of each feature attribute to the specified category attribute. The calculated corrected information gain is used to determine the feature attribute used to divide the dataset contained in the current node. Finally, the decision tree model formed based on the training dataset is output. The connected vehicle songs in the candidate sample set are sorted in descending order of probability, and target connected vehicle songs are selected for recommendation based on the sorting results. The vehicle-connected songs include at least one of the following features: user rating of the song, number of clicks, number of favorites, number of comments, comment type, whether playback was canceled, playback time, number of plays, payment amount for each song, number of payments, song style, and language. The number of feature attributes with the largest and equal information gain under a node includes two types: the number of features with the largest and greatest information gain in the dataset contained in the current node, and the number of features with the largest and greatest information gain. The first feature attribute and the first There are 1 feature attributes; the corrected information gain corresponding to each feature attribute is the product of the corresponding information gain and the correction factor, and the 1st feature attribute is the 2nd feature attribute. The correction factor corresponding to the i-th feature attribute is determined by the i-th feature attribute. The percentage of samples corresponding to the target category attribute in the dataset contained in the current node under each feature attribute and the percentage of samples corresponding to the target category attribute under each feature attribute. The proportion of samples corresponding to the target category attribute in the dataset contained in the current node under each feature attribute is used to determine the feature attribute.

2. The method according to claim 1, characterized in that, The step of calculating the corrected information gain corresponding to each of the multiple feature attributes based on the proportion of each feature attribute to the specified category attribute, and determining the feature attributes used to partition the dataset contained in the current node based on the calculated corrected information gain, includes: Determine whether the calculated corrected information gain contains an equal corrected information gain; If the corrected information gains corresponding to the multiple feature attributes are not equal, the feature attribute corresponding to the largest corrected information gain is selected as the feature attribute used to divide the dataset contained in the current node.

3. The method according to claim 2, characterized in that, The process of generating the decision tree model also includes the following steps: If the calculated corrected information gain contains equal corrected information gains, determine whether the equal corrected information gains are the maximum corrected information gain; If it is determined to be so, the feature attributes corresponding to the equal modified information gain are merged to obtain the merged feature attribute, and the merged feature attribute is determined as the feature attribute used to divide the dataset contained in the current node. If the result is negative, the feature attribute corresponding to the maximum corrected information gain is selected as the feature attribute used to partition the dataset contained in the current node.

4. The method according to claim 3, characterized in that, The first The proportion of samples corresponding to the target category attribute in the dataset contained in the current node under the feature attribute is determined by the feature attribute. The number of samples corresponding to the target category attribute in the dataset contained in the current node under each feature is determined by the total number of samples contained in the training dataset.

5. The method according to claim 1, characterized in that, The information gain for each feature attribute at each node is calculated using the following formula: in, Represents the training dataset. This indicates the first node in the dataset contained in the current node. Each feature attribute Indicates the first Information gain under each feature attribute The information entropy of the root node in a decision tree model is represented by its value. Indicates the first The first feature attribute The number of samples contained in the data subset divided by each child node. This represents the total number of samples contained in the training dataset. Indicates the first The first feature attribute Information entropy of each child node Indicates the first The total number of child nodes under each feature attribute.

6. The method according to claim 5, characterized in that, The information entropy of the root node of the decision tree model It is calculated using the following formula: in, This indicates that the category attribute in the training dataset is the first... The sample percentage of each category, and the total number of categories for the category attribute is 2.

7. The method according to claim 5, characterized in that, The first The first feature attribute Information entropy of each child node It is calculated using the following formula: in, Indicates the first The first feature attribute The percentage of samples contained in the data subset divided by each child node.

8. The method according to any one of claims 1-3, characterized in that, After outputting the decision tree model formed based on the training dataset, the process of generating the decision tree model further includes the following steps: The output decision tree model is used as the model to be tested and input into the test dataset for testing. The classification results predicted by the model to be tested for multiple test samples are obtained. Based on the obtained classification results, calculate the performance evaluation index of the model to be tested, which includes at least one of accuracy, precision, and recall. If the performance evaluation index indicates that the model under test meets the performance target, then the model under test is selected as the optimal decision tree model.

9. A data recommendation device based on a decision tree model, characterized in that, The device includes: The sample set acquisition module is configured to acquire a candidate sample set to be recommended. The candidate sample set includes a sample set formed by multiple connected vehicle songs. Each connected vehicle song contains feature information with the same feature value or a feature value difference less than a preset threshold. The probability prediction module is configured to predict the probability of each connected vehicle song belonging to a specified category attribute based on a decision tree model. The decision tree model is generated through the following steps: First, a training dataset is obtained, consisting of feature information from multiple training samples. These training samples are connected vehicle songs collected from the same application scenario based on the candidate sample set. Each training sample contains feature information with identical or significantly different feature values. Each training sample has a known category attribute, and the feature information of each training sample corresponds to a different feature attribute. During the generation of the decision tree model based on the training dataset, the information gain of each feature attribute under each node is iteratively calculated. The dataset contained in the current node is then divided according to the feature attribute corresponding to the maximum information gain, forming multiple child nodes based on the current node, until the category attribute can be determined from the dataset contained in the node. If the information gains of multiple feature attributes under the current node are equal and constitute the maximum information gain, the corrected information gain corresponding to each feature attribute is calculated based on the proportion of each feature attribute to the specified category attribute. The calculated corrected information gain is used to determine the feature attribute used to divide the dataset contained in the current node. Finally, the decision tree model formed based on the training dataset is output. The sample recommendation module is configured to sort the connected vehicle songs in the candidate sample set in descending order of probability, and select target connected vehicle songs for recommendation based on the sorting results. The vehicle-connected songs include at least one of the following features: user rating of the song, number of clicks, number of favorites, number of comments, comment type, whether playback was canceled, playback time, number of plays, payment amount for each song, number of payments, song style, and language. The number of feature attributes with the largest and equal information gain under a node includes two types: the number of features with the largest and greatest information gain in the dataset contained in the current node, and the number of features with the largest and greatest information gain. The first feature attribute and the first There are 1 feature attributes; the corrected information gain corresponding to each feature attribute is the product of the corresponding information gain and the correction factor, and the 1st feature attribute is the 2nd feature attribute. The correction factor corresponding to the i-th feature attribute is determined by the i-th feature attribute. The percentage of samples corresponding to the target category attribute in the dataset contained in the current node under each feature attribute and the percentage of samples corresponding to the target category attribute under each feature attribute. The proportion of samples corresponding to the target category attribute in the dataset contained in the current node under each feature attribute is used to determine the feature attribute.

10. An electronic device, characterized in that, include: One or more processors; A storage device for storing one or more programs, which, when executed by one or more processors, cause the electronic device to perform the method as described in any one of claims 1-8.

11. A computer-readable storage medium, characterized in that, It stores computer-readable instructions that, when executed by the computer's processor, cause the computer to perform the method of any one of claims 1-8.

12. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1-8.