Decision tree generation method and device based on quantum fidelity, medium and equipment
Through the decision tree generation method based on quantum fidelity, the problems of traditional decision tree slow speed and imbalance in tree structure are solved, and faster and more balanced data classification is achieved, which is suitable for multiple data sets.
Patent Information
- Application Number
- CN202411488144.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-24
- Publication Date
- 2025-02-07
AI Technical Summary
How to achieve faster and balanced data classification through quantum decision trees to solve the problem of slow speed and imbalanced tree structure in the data classification process.
Using the decision tree generation method based on quantum fidelity, by obtaining the attribute set and classification label of the current node of the decision tree, the joint probability distribution of attributes and classification labels are encoded into quantum states, and the fidelity between each attribute and classification label is calculated. and select the attribute with the highest fidelity to divide the current node of the decision tree, and iteratively execute the classification processing of all nodes to generate the final decision tree.
The decision tree generation process is accelerated through quantum computing, and the generated decision tree is more balanced and fast, and is suitable for a variety of data sets, such as financial, medical, e-commerce and social media data sets.
Smart Images

Figure CN119397411A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of quantum computing technology, and in particular to a decision tree generation method, device, medium and equipment based on quantum fidelity. Background Art
[0002] A quantum computer is a device that follows the laws of quantum mechanics to perform high-speed mathematical and logical operations, store and process quantum information. Quantum computing is a computing technology based on the principles of quantum mechanics. It uses the superposition and entanglement of quantum bits to quickly process large amounts of data and solve some problems that are difficult to solve with classical computing. The characteristics of quantum computing include fast operation speed, strong information processing capabilities, and a wide range of applications. Compared with classical computing, quantum computing is more suitable for processing large-scale and complex data, and can more efficiently solve some key problems, such as prime factorization and discrete logarithms.
[0003] New machine learning combined with the characteristics of quantum computing can accelerate traditional algorithms, and this type of achievement has attracted widespread attention and research. The goal of quantum machine learning is to use the advantages of quantum computing, such as quantum parallelism and quantum entanglement, to accelerate the training and reasoning process of machine learning, while also providing better application scenarios and higher application value for quantum computing. Supervised quantum classification algorithm is an algorithm based on quantum computing for classification problems. Common supervised quantum classification algorithms include quantum K-nearest neighbor algorithm (KNN), quantum support vector machine (SVM), quantum neural network, quantum decision tree, etc.
[0004] In traditional machine learning, computers can automatically discover laws and patterns in data by analyzing and learning training data, and make predictions and decisions based on these laws and patterns. Decision tree machine learning algorithms draw conclusions based on existing information by simulating human behavior. The root node in the decision tree includes all data sets, and each internal node (including the root node) divides the data set into different sub-nodes according to specific attributes, thereby constructing an inverted tree structure, in which the leaf nodes are the final classification results. Traditional decision tree machine learning classification methods usually use information gain or Gini coefficient as the division criteria, and the decision tree algorithm is essentially a greedy algorithm, which results in a tendency to construct an unbalanced tree structure.
[0005] Therefore, how to achieve faster and more balanced data classification through quantum decision tree classification becomes a technical problem that needs to be solved. Summary of the invention
[0006] The object of the present invention is to provide a decision tree generation method, device, medium and equipment based on quantum fidelity, which is used to perform category division through a classification standard based on quantum fidelity and achieve faster and more balanced data classification through a quantum decision tree method.
[0007] According to one aspect of the present invention, a decision tree generation method based on quantum fidelity is provided, comprising: obtaining an attribute set X and a classification label Y of a data set of a current node of a decision tree; encoding the joint probability distribution of each attribute and the classification label into a quantum state respectively; calculating the fidelity between each attribute and the classification label according to the quantum state; selecting the attribute with the highest fidelity to divide the current node of the decision tree; iteratively performing classification processing of all nodes, and generating a final decision tree according to the classification attributes selected for each node.
[0008] According to one embodiment of the present invention, encoding the joint probability distribution of each attribute and classification label into a quantum state includes: obtaining the joint probability distribution of each attribute and classification label respectively, and normalizing and representing it as a quantum state; converting the quantum state into a density matrix representation; and obtaining a reduced density operator of the attribute subsystem and a reduced density operator of the classification label subsystem based on the joint probability distribution density matrix obtained by the conversion.
[0009] According to one embodiment of the present invention, the calculation of the fidelity between each attribute and the classification label based on the quantum state includes: obtaining the quantum fidelity based on the reduced density operator of the attribute subsystem and the reduced density operator of the classification label subsystem.
[0010] According to one embodiment of the present invention, the quantum fidelity is expressed as: ,in, is the reduced density operator of the attribute subsystem, is the reduced density operator of the classification label subsystem, tr() means finding the trace of the matrix, that is, obtaining the sum of the diagonal elements of the matrix, 0≤ ≤1.
[0011] According to an embodiment of the present invention, the iterative termination condition of the iterative execution of the classification process of all nodes includes that there is no attribute in the attribute set that can be used as a classification standard, or all sample classification labels of the current node are the same.
[0012] According to one embodiment of the present invention, the data set is a supervised learning data set, including a financial industry data set, or a medical data set, or an e-commerce data set, or a social media data set, or a text data set.
[0013] According to one embodiment of the present invention, the attribute values of the attribute set are binary or multi-classified. For the binary attribute values, they are encoded with 0 or 1 respectively; for the multi-classified attribute values, one-hot encoding is used to discretize them into multiple 0 or 1 features; or, if the attribute values of the attribute set are continuous values, binning is used to discretize them.
[0014] According to another aspect of the present invention, a decision tree generation device based on quantum fidelity is provided, comprising: A data acquisition unit is configured to acquire an attribute set X and a classification label Y of a current node data set of the decision tree; A quantum encoding unit is configured to encode the joint probability distribution of each attribute and the classification label into a quantum state; A fidelity measurement unit, configured to calculate the fidelity between each attribute and the classification label according to the quantum state; The node classifier is configured to select the attribute with the highest fidelity to partition the current node of the decision tree; The classification iterator is configured to iteratively perform classification processing on all nodes and generate a final decision tree based on the classification attributes selected by each node.
[0015] According to another aspect of the present invention, a computer-readable storage medium storing a computer program is provided. When the computer program is executed by a processor, the decision tree generation method based on quantum fidelity as described above is implemented.
[0016] According to another aspect of the present invention, a computer device is provided, the computer device comprising: a processor; a memory storing a computer program, and when the computer program is executed by the processor, the decision tree generation method based on quantum fidelity as described above is implemented.
[0017] Compared with the prior art, the present invention has the following beneficial effects: (1) Use quantum computing to replace the data set partitioning criteria of the classical decision tree, accelerate the calculation process, and construct a complete balanced quantum decision tree.
[0018] (2) Wide range of applications. The quantum decision tree generation method can be used for a variety of data. For example, the data sets used for quantum decision tree classification include financial industry data sets, medical data sets, e-commerce data sets, social media data sets, and text data sets.
[0019] (3) Data conversion is convenient. The attribute values of the attribute set X are binary or multi-classified. For binary attribute values, they are encoded with 0 / 1 respectively; for multi-classified attribute values, they are discretized into multiple 0 / 1 features using one-hot encoding; or, if the attribute values of the attribute set X are continuous values, they are discretized using binning. The converted encoded data is easy to convert to quantum states.
[0020] (4) The generated decision tree is more balanced. Since the joint distribution probability between attributes and labels is taken into account, the resulting classification tree structure is more balanced. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The above objects and features of the present invention will become more apparent from the following description in conjunction with the accompanying drawings.
[0022] Figure 1 Shown is a flow chart of a decision tree generation method based on quantum fidelity according to an exemplary embodiment of the present invention.
[0023] Figure 2 Shown is a schematic diagram of a decision tree generation device based on quantum fidelity according to an exemplary embodiment of the present invention.
[0024] Figure 3 FIG. 1 is a schematic diagram of performing node partitioning based on a selected attribute of quantum fidelity according to an exemplary embodiment of the present invention.
[0025] Figure 4 Shown is a schematic diagram of a balanced quantum decision tree constructed according to an exemplary embodiment of the present invention.
[0026] Figure 5 It is a schematic diagram showing node division of the iris data set based on the selected attributes of quantum fidelity according to an exemplary embodiment of the present invention. DETAILED DESCRIPTION
[0027] The idea of the present invention is to provide a decision tree generation method based on quantum fidelity, which uses quantum fidelity to replace the data set division standard of the classical decision tree, and is more inclined to generate a relatively balanced tree while accelerating the calculation process. In the decision tree generation process, classification and division processing will be performed based on fidelity at multiple nodes. The root node of the tree includes all the data of the data set, and each internal node (including the root node) divides the data set into child nodes according to specific attributes to construct an inverted tree structure. The leaf node is the final classification result. In the classification process, the data set is gradually divided into several data subsets.
[0028] Hereinafter, embodiments of the present invention will be described in detail with reference to the accompanying drawings, particularly the steps from classical data encoding to quantum state, data set partitioning criterion selection, and decision tree construction.
[0029] Each piece of data in the supervised learning data set D has an attribute set X and a label Y, and D can be expressed as {X, Y}. In the classical decision tree algorithm, all node partitioning methods are based on the probability distribution of the data set. In the quantum decision tree, general amplitude coding is only for the attribute set. In the quantum decision tree of the embodiment of the present invention, amplitude coding is selected to encode the data into a quantum state. Specifically, the joint probability distribution of the attribute and the corresponding classification label is selected to encode the quantum state, and the encoded quantum state is expressed as follows:
[0030] Among them, k is the selected attribute, i is the possible value corresponding to attribute k, and j corresponds to the possible classification label. The kth attribute is X i And the classification label is Y j The joint probability distribution of .
[0031] In order to describe any quantum state, the density matrix is used instead of the wave function to describe the system state. The specific representation is as follows: , The system is based on probability p i In quantum state |ψ i >, the combined system is in a mixed state { p i, |ψ i >}, ρ is the density operator. Therefore, the density matrix of the joint probability distribution is expressed as follows: .
[0032] For the dataset D {X, Y}, Reduced density operator for subsystems ρ X , ρ Y , corresponding to the fidelity F(ρ X , ρ Y ) It is expressed as follows: , in, is the reduced density operator of the attribute subsystem, is the reduced density operator of the classification label subsystem, and tr() represents the trace of the matrix, that is, the sum of the diagonal elements of the matrix. F(ρ X , ρ Y) Satisfy constraints 0<=F (ρ X , ρ Y )<=1。 When the fidelity is 0, it means that the quantum state distance of the subsystem is the farthest, which also means that the correlation between the attribute and the classification label is the lowest; on the contrary, when the fidelity is 1, the quantum state of the subsystem overlaps. Therefore, for the classification and division of nodes, the fidelity is calculated for each attribute respectively, and the attribute with the largest fidelity is selected as the node division standard.
[0033] like Figure 1 As shown, a flow chart of a decision tree generation method based on quantum fidelity is given, and the method includes: Step S101: Obtain the attribute set X and classification label Y of the current node data set of the decision tree; Step S102: respectively encode the joint probability distribution of each attribute and classification label into a quantum state; Step S103: Calculate the fidelity between each attribute and the classification label according to the quantum state; Step S104: Select the current node of the attribute partitioning decision tree with the highest fidelity; Step S105: Iteratively perform classification processing on all nodes, and generate a final decision tree according to the classification attributes selected by each node.
[0034] In the process of generating the decision tree, the quantum fidelity of all optional attributes on the current node is obtained according to the quantum state, the classification attribute as the classification standard of the current node is selected according to the quantum fidelity, and the classification processing of the current node is performed according to the classification attribute; the classification division of all nodes is completed through iterative processing to obtain the required decision tree.
[0035] like Figure 2 As shown, a schematic diagram of a decision tree generation device based on quantum fidelity is given, and the device includes: The data acquisition unit 201 is configured to acquire the attribute set X and the classification label Y of the current node data set of the decision tree; The quantum encoding unit 202 is configured to encode the joint probability distribution of each attribute and the classification label into a quantum state; A fidelity measurement unit 203, configured to calculate the fidelity between each attribute and the classification label according to the quantum state; A node classifier 204 is configured to select a current node of the attribute partitioning decision tree with the highest fidelity; The classification iterator 205 is configured to iteratively perform classification processing on all nodes and generate a final decision tree according to the classification attributes selected by each node.
[0036] The decision tree classification method can process discrete data, can process data with relevant characteristics, and can easily construct easy-to-understand classification rules. Classification rules are usually easy to explain and understand. In order to realize quantum decision tree classification, it is first necessary to determine the data set for decision tree classification. The data sets used for quantum decision tree classification include financial industry data sets, medical data sets, e-commerce data sets, social media data sets, and text data sets. Based on the above various types of data sets, decision trees can be used in the financial industry for credit assessment, fraud detection, investment decision-making and other application scenarios; decision trees can be used in the medical industry for disease diagnosis, drug efficacy prediction, medical risk assessment and other application scenarios; decision trees can be used in the e-commerce industry for product recommendations, sales forecasts, user behavior analysis and other application scenarios; decision trees can be used in the social media field for sentiment analysis, event prediction, user behavior analysis and other application scenarios.
[0037] Assume that from the above data sets, a general supervised learning data set D is selected, and the data in data set D has the attribute set and label sets , then the data set D is represented as D { , In the classical decision tree classification method, all node divisions are based on the probability distribution of the data set. In quantum decision tree classification, the data needs to be encoded into a quantum state through amplitude coding. The general amplitude coding is only for the attribute set. In this application, the joint probability distribution of the attribute and the corresponding classification label is encoded into the quantum state. The encoded quantum state is expressed as:
[0038] in, Is the attribute value Under the premise of meeting certain conditions, the classification label is Conditional probability distribution. In order to describe any quantum state, the density matrix is used instead of the wave function to describe the state of the quantum system, which is specifically expressed as follows: in, is the density operator, and the quantum system is expressed in terms of probability In quantum state , therefore, the system formed by the combination is in a mixed state { }. The density matrix of the joint probability distribution is expressed as:
[0039] For the dataset D { , }, set the attribute and the classification label set are regarded as two subsystems respectively, then the reduced density operators of the two subsystems are and According to the attribute set The reduced density operator , classification label set The reduced density operator , we can get the quantum fidelity It is expressed as: ) Among them, quantum fidelity Satisfy the constraints: 0≤ ≤1. When the quantum fidelity When it is 0, it means that the quantum state distance of the subsystem is the farthest, and it also means that the correlation between the attribute and the classification label is the lowest; when the quantum fidelity When is 1, it indicates that the quantum states of the subsystems overlap. Therefore, it can be determined that in the quantum decision tree classification process, quantum fidelity is selected as the node classification standard. Specifically, at each node, the quantum fidelity corresponding to each attribute can be calculated for each available attribute. , from the calculated quantum fidelity, select the attribute with the largest quantum fidelity as the node division criterion. After determining the node division criterion as quantum fidelity, the process of constructing the entire quantum decision tree is similar to that of the traditional decision tree.
[0040] The process of building a quantum decision tree includes the following steps: First, a node is generated for the data set. At the current node, if the data sets belong to the same category, the node is marked as a leaf node of the category. If the attribute set is empty or all nodes have the same value on the attribute set, the node is marked as a leaf node, and the classification label is the category with the largest number in the category.
[0041] The dataset is divided into subsets based on the properties selected by quantum fidelity as the node division criteria: For each subset, if the subset is empty, the branch node is marked as a leaf node, and the classification label is the class with the most samples in the parent set. If the subset is not empty, the decision tree construction method of this embodiment is recursively called for the non-empty subset. Finally, quantum fidelity is selected as the node classification standard to realize the decision tree generation process for the data set.
[0042] Embodiment 1 First, determine a data set D with attribute set and label sets , as shown in Table 1: Table 1: Data table of supervised dataset D
[0043] The dataset D shown in Table 1 is a binary classification dataset. Includes attributes X1, X2, X3 and label set The value of is 0 or 1. The dataset D may be a financial industry dataset, a medical dataset, an e-commerce dataset, a social media dataset, or a text dataset.
[0044] In order to demonstrate the quantum decision tree classification process based on quantum fidelity, a quantum decision tree will be constructed based on the data set D. Select appropriate attributes to divide the data set. For each attribute X1, X2, and X3 of the attribute set X, calculate their respective conditional probabilities and encode them into the quantum state together with the classification label. After normalization, the following quantum state is obtained:
[0045] First, obtain the density matrix of the hybrid system ρ XY : .
[0046] Then, the reduced density matrix is determined and .
[0047] Finally, according to the reduced density matrix and , and the quantum fidelity of the three attributes X1, X2, and X3 are calculated respectively: .
[0048] The quantum fidelity results are shown in Table 2: Table 2: List of quantum fidelity determined by classification of each attribute
[0049] According to Table 2, the attributes X1 and X2 of the data set D can both obtain the maximum quantum fidelity of 1. Therefore, X1 is randomly selected from the attributes X1 and X2 as the partitioning criterion to partition the data set D, such as Figure 3 As shown, a schematic diagram of the quantum decision tree divided according to attribute X1 is given.
[0050] Based on the above method of partitioning the quantum decision tree according to the quantum fidelity selection attribute, it can be extended to all nodes in the decision tree generation process and the decision tree can be constructed iteratively, such as Figure 4 The figure shows the final schematic diagram of the quantum decision tree structure. Figure 4In the quantum decision tree generation process shown in the figure, for the data set D, it is divided according to the attribute X1 to obtain two branch nodes 1 and 0; for the branch node 1, it is further classified according to the attribute X2 to obtain two leaf nodes 11 and 10; for the branch node 0, it is further classified according to the attribute X2 to obtain two leaf nodes 00 and 01.
[0051] Example 2: Quantum decision tree classification of the iris data set.
[0052] In order to demonstrate the fidelity-based quantum decision tree generation process, a quantum decision tree is constructed based on the iris dataset commonly used in classical machine learning.
[0053] The iris data set contains a total of 150 samples (divided into 3 different subgenera: setosa, versicolor and virginica, each with 50 samples), and each sample contains 4 features, namely sepal length X1, sepal width X2, petal length X3, and petal width X4. The first 100 samples (setosa and versicolor) are selected, and the 4 features are binarized. For each attribute, the conditional probability is calculated and encoded into the quantum state together with the classification label, and normalized to obtain the following results:
[0054] First calculate the density matrix of the hybrid system ρ XY , and then calculate the reduced density matrix of the subsystem ρ X , ρ Y, Finally, the fidelity of the four attributes is calculated as shown in Table 3.
[0055] Table 3: Fidelity calculated by attributes for the iris dataset
[0056] Attributes X3 and X4 can both obtain the maximum fidelity, and the fidelity is 1, indicating that both attributes can completely classify the data set. The final decision tree of the quantum decision tree divided by X3 is as follows: Figure 5 shown.
[0057] Example 3: The decision tree generation process of this solution is gradually implemented from classical data encoding to quantum state, data set partitioning standard selection, decision tree construction and other steps. For real cases, feature engineering is first required, including data preprocessing and feature conversion, etc., selecting appropriate attributes, discretizing and converting them into input attributes and labels similar to Table 1, and then using amplitude encoding to convert to quantum state.
[0058] For example, for the classic watermelon classification, the attributes and their possible values are: Color {green, black, light white}; Root {curled, slightly curled, stiff}; knocking sound {dull, dull, crisp}; Texture {clear, slightly blurry, fuzzy}; Umbilicus {depressed, slightly concave, flat}; Touch {hard and slippery, soft and sticky}.
[0059] The classification labels are {good melon, bad melon}.
[0060] Among them, attribute values include binary classification and multi-classification. For example, touch is a binary classification, which can be encoded with 0 / 1 respectively; the other attributes are multi-classification, which can be discretized into multiple 0 / 1 features using one-hot encoding; if the attribute is a continuous value, it can be discretized using binning. Finally, the attribute and label data shown in Table 1 are obtained, and the final decision tree is generated according to the decision tree generation method described above.
[0061] In addition, a computer-readable storage medium storing a computer program may also be provided according to an exemplary embodiment of the present invention. The computer-readable storage medium stores a computer program that, when executed by a processor, causes the processor to perform a decision tree generation method based on quantum fidelity according to an exemplary embodiment of the present invention. The computer-readable recording medium is any data storage device that can store data read out by a computer system. Examples of computer-readable recording media include: read-only memory, random access memory, read-only optical disk, magnetic tape, floppy disk, optical data storage device, and carrier wave (such as data transmission over the Internet via a wired or wireless transmission path).
[0062] In addition, a computing device may be provided according to an exemplary embodiment of the present invention. The computing device includes a processor and a memory. The memory is used to store a computer program. The computer program is executed by the processor so that the processor executes the computer program of the decision tree generation method based on quantum fidelity according to an exemplary embodiment of the present invention.
[0063] It should be noted that the first, second, third, fourth, etc. in the above description are to distinguish features with the same name in the same or different embodiments, and are not quantitatively limited. And the present invention is not limited to the specific configurations and processes described above or shown in the figures. The above is only a specific embodiment of the present invention. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the described system, device, module or unit can refer to the corresponding process in the method embodiment without further description. It should be understood that the scope of protection of the present invention is not limited to this. Any technician familiar with the technical field can think of various equivalent modifications or substitutions within the technical scope disclosed by the present invention, and these modifications or substitutions should be covered within the scope of protection of the present invention.
Claims
1. A decision tree generation method based on quantum fidelity, characterized in that: include: Get the attribute set X and classification label Y of the current node data set of the decision tree; Encode the joint probability distribution of each attribute and classification label into quantum states respectively; Calculate the fidelity between each attribute and the classification label based on the quantum state; Select the attribute with the highest fidelity to partition the current node of the decision tree; The classification process of all nodes is iterated and the final decision tree is generated according to the classification attributes selected by each node.
2. The method according to claim 1, characterized in that The method of encoding the joint probability distribution of each attribute and the classification label into a quantum state includes: Get the joint probability distribution of each attribute and classification label respectively, and normalize them into quantum states; Convert the quantum state into a density matrix representation; According to the joint probability distribution density matrix obtained by transformation, a reduced density operator of the attribute subsystem and a reduced density operator of the classification label subsystem are obtained.
3. The method according to claim 2, characterized in that The fidelity between each attribute and the classification label is calculated according to the quantum state, including: The quantum fidelity is obtained according to the reduced density operator of the attribute subsystem and the reduced density operator of the classification label subsystem.
4. The method according to claim 2, characterized in that: The quantum fidelity is expressed as: ,in, is the reduced density operator of the attribute subsystem, is the reduced density operator of the classification label subsystem, tr() means finding the trace of the matrix, that is, obtaining the sum of the diagonal elements of the matrix, 0≤ ≤1.
5. The method according to claim 1, characterized in that The iterative termination conditions of the iterative execution of the classification process of all nodes include that there is no attribute that can be used as a classification standard in the attribute set, or all sample classification labels of the current node are the same.
6. The method according to claim 1, characterized in that The data set is a supervised learning data set, including a financial industry data set, a medical data set, an e-commerce data set, a social media data set, or a text data set.
7. The method according to claim 1, characterized in that The attribute value of the attribute set is binary or multi-classified. For binary attribute values, they are encoded with 0 or 1 respectively; for multi-classified attribute values, one-hot encoding is used to discretize them into multiple 0 or 1 features; Alternatively, if the attribute value of the attribute set is a continuous value, it is discretized by using binning.
8. A decision tree generation device based on quantum fidelity, characterized in that: include: A data acquisition unit is configured to acquire an attribute set X and a classification label Y of a current node data set of the decision tree; A quantum encoding unit is configured to encode the joint probability distribution of each attribute and the classification label into a quantum state; A fidelity measurement unit, configured to calculate the fidelity between each attribute and the classification label according to the quantum state; The node classifier is configured to select the attribute with the highest fidelity to partition the current node of the decision tree; The classification iterator is configured to iteratively perform classification processing on all nodes and generate a final decision tree based on the classification attributes selected by each node.
9. A computer-readable storage medium storing a computer program, wherein: When the computer program is executed by a processor, the decision tree generation method based on quantum fidelity described in any one of claims 1 to 7 is implemented.
10. A computing device comprising: processor; A memory storing a computer program, which, when executed by a processor, implements the decision tree generation method based on quantum fidelity described in any one of claims 1 to 7.