User scoring method and device, storage medium and electronic device
By using quantum computing methods to encode feature vectors and calculate similarity for user data, the problem of low efficiency in processing high-dimensional user data is solved, and fast and accurate user rating is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- BENYUAN TIANGONG (ZHENGZHOU) QUANTUM TECH CO LTD
- Filing Date
- 2023-11-14
- Publication Date
- 2026-04-17
AI Technical Summary
Existing user rating algorithms require processing massive amounts of high-dimensional and highly complex user data, leading to challenges in classical computing power and low computational efficiency.
The method employs quantum computing to encode user data of users to be rated into feature vectors. The similarity between feature vectors is calculated using a target quantum circuit, and the ratings of the k feature vectors with the highest similarity are obtained and weighted and summed. The superposition and entanglement properties of quantum states and the parallel properties are used for fast comparison.
It effectively reduces the complexity of classic classification algorithms, improves the computational efficiency and accuracy of user ratings, and is suitable for rating large-scale, multi-dimensional user data.
Smart Images

Figure CN121883100A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of quantum computing technology, and in particular to a user rating method, apparatus, storage medium and electronic device. Background Technology
[0002] Currently, user rating is widely used in all aspects of life. For example, application developers can rate users' usage habits and frequency, electronic device manufacturers can rate users' brand loyalty, and credit institutions can rate users' spending power. Furthermore, with the development of information technology, the amount of user data available is becoming increasingly vast, and the richness and reliability of this data are gradually improving. Consequently, data processing technologies for user rating based on user data have also developed significantly.
[0003] In existing technologies, most user scoring algorithms utilize general logistic regression models to centrally process user data, and the final calculated result is the user score. For example, before issuing a credit card to a target user, it is necessary to first obtain the user's credit data, and then combine this data with various dimensions of user data such as personal information, debt repayment ability, and historical credit history to score the target user. Ultimately, only users whose scores exceed a preset threshold can apply for and receive a credit card. It is evident that current user scoring methods require processing massive amounts of high-dimensional and highly complex user data, which poses a significant challenge to the computing power of classical computers.
[0004] Quantum computers are physical devices that perform high-speed mathematical and logical operations, store and process quantum information according to the laws of quantum mechanics, and have a more efficient ability to process mathematical problems than classical computers. Therefore, it is necessary to design a user rating method based on quantum computing to further improve the computational efficiency of user ratings. Summary of the Invention
[0005] The purpose of this invention is to provide a user rating method, apparatus, storage medium, and electronic device, aiming to further improve the computational efficiency of user rating algorithms.
[0006] One embodiment of the present invention provides a user rating method, the method comprising:
[0007] The user data of the user to be rated is encoded to obtain a first feature vector, and each target data is encoded to obtain a corresponding second feature vector; wherein, the target data is user data with known ratings;
[0008] Using the target quantum circuit, the similarity between each second feature vector and the first feature vector is calculated.
[0009] Obtain the scores corresponding to the k second feature vectors that have the highest similarity to the first feature vector, and perform a weighted summation of the k scores to obtain the score of the user to be scored.
[0010] Optionally, the target quantum circuit includes a feature encoding circuit and a similarity calculation circuit, wherein:
[0011] The feature encoding circuit operates on the first qubit and the second qubit to perform feature encoding based on the first feature vector, storing the encoded first target quantum state in the first qubit; and to perform feature encoding based on the second feature vector, storing the encoded second target quantum state in the second qubit.
[0012] The similarity calculation circuit is used to perform entanglement evolution on the first target quantum state and the second target quantum state, and measure the similarity between the second feature vector and the first feature vector after the evolution of the quantum state.
[0013] Optionally, the feature encoding circuit includes a first encoding circuit acting on the first qubit and a second encoding circuit acting on the second qubit. The first feature vector and the second feature vector both have a dimension of n. Both the first encoding circuit and the second encoding circuit contain n levels of angle encoding sub-circuits. Each level of angle encoding sub-circuit is used to encode feature data of the corresponding dimension in the feature vector.
[0014] Optionally, each level of angle-encoded sub-circuit includes a set of RY gates and RX gates, wherein the rotation angle θ of the RY gates and the rotation angle of the RX gates are... Determined based on the following formulas:
[0015] θ ξ =arctanγ ξ
[0016]
[0017] Where, γ ξ ξ represents the feature data of the corresponding dimension in the first or second feature vector after normalization, where ξ is the corresponding dimension in the first or second feature vector, and ξ∈{1,n}.
[0018] Optionally, the similarity calculation circuit sequentially includes a first H gate acting on the auxiliary bit, a controlled SWAP gate with the auxiliary bit as the control bit, and a second H gate acting on the auxiliary bit, wherein the target bit of the controlled SWAP gate is the first qubit and the second qubit;
[0019] The measurement of the evolved quantum state yields the similarity between the second eigenvector and the first eigenvector, including:
[0020] After executing the second H gate on the auxiliary bit, the probability P(|0>) that the quantum state of the auxiliary bit is |0> is obtained by measuring through a preset number of times;
[0021] The similarity between the first feature vector and the second feature vector is obtained using the following formula:
[0022] | <x|y i >| 2 =2P(|0>)-1
[0023] Where <x|y i > represents the first target quantum state |x> and a second target quantum state |y>. i The inner product of >.
[0024] Optionally, before encoding the user data of the user to be rated to obtain the first feature vector, the method further includes:
[0025] A user dataset is constructed using user data of rated users and actual ratings, and the user dataset is divided into a test dataset and a training dataset.
[0026] The distance between test data in the test dataset and training data in the training dataset is calculated using the k-nearest neighbor algorithm, and the prediction accuracy is calculated using the predicted score and the actual score of each test data; wherein the predicted score is determined based on the distance.
[0027] The training dataset is adjusted based on the prediction accuracy, and the training data in the adjusted training dataset is used as the target data.
[0028] Optionally, adjusting the training dataset based on the prediction accuracy and using the training data in the adjusted training dataset as the target data includes:
[0029] Repeatedly modify the training data in the training dataset, and / or adjust the amount of data included in the training dataset; wherein both the test dataset and the training dataset contain at least one user data point for each rating category;
[0030] After each adjustment, the prediction accuracy is calculated, and the training data in the training dataset with the highest prediction accuracy is used as the target data.
[0031] Another embodiment of the present invention provides a user rating device, the device comprising:
[0032] The encoding module is used to encode the user data of the user to be rated to obtain a first feature vector, and to encode each target data to obtain a corresponding second feature vector; wherein, the target data is user data with known ratings;
[0033] A quantum computing module is used to calculate the similarity between each second feature vector and the first feature vector using a target quantum circuit.
[0034] The weighted scoring module is used to obtain the scores corresponding to the k second feature vectors with the highest similarity to the first feature vector, and to perform a weighted summation of the k scores to obtain the score of the user to be scored.
[0035] Another embodiment of the present invention provides a storage medium storing a computer program, wherein the computer program is configured to execute the method described in any of the preceding claims when running.
[0036] Another embodiment of the present invention provides an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the method described in any of the preceding claims.
[0037] Compared with the prior art, the present invention provides a user rating method, apparatus, storage medium and electronic device. The method includes: encoding user data of the user to be rated to obtain a first feature vector; encoding each target data to obtain a corresponding second feature vector; wherein the target data is user data with known ratings; using a target quantum circuit, calculating the similarity between each second feature vector and the first feature vector; obtaining the ratings corresponding to the k second feature vectors with the highest similarity to the first feature vector, and performing a weighted summation of the k ratings to obtain the rating of the user to be rated.
[0038] Even when the user data and target data for the user to be rated are extremely large, including multi-dimensional feature information, the scheme provided in this invention can normalize and encode them into feature vectors. Then, through quantum computing, the similarity comparison between feature vectors is transformed into a similarity comparison between corresponding quantum states. Furthermore, utilizing the superposition and entanglement properties of quantum states and the parallel nature of quantum computing, all feature data in the feature vectors are compared, thereby quickly and accurately determining the rating that best matches the user to be rated. This scheme effectively reduces the complexity of classical classification algorithms and further improves the computational efficiency of user rating. Attached Figure Description
[0039] Figure 1 A network diagram of a user rating system provided in an embodiment of the present invention;
[0040] Figure 2 A flowchart illustrating a user rating method provided in an embodiment of the present invention;
[0041] Figure 3 This is a schematic diagram of a process for acquiring target data provided in an embodiment of the present invention;
[0042] Figure 4 This is a schematic diagram of the structure of a target quantum circuit provided in an embodiment of the present invention;
[0043] Figure 5 This is a schematic diagram of the structure of an angle-encoding sub-circuit provided in an embodiment of the present invention;
[0044] Figure 6 This is a schematic diagram of the structure of a user rating device provided in an embodiment of the present invention;
[0045] Figure 7 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present invention. Detailed Implementation
[0046] The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0047] Figure 1 This is a network block diagram of a user rating system provided in an embodiment of the present invention. The user rating system may include a network 110, a server 120, a wireless device 130, a client 140, storage 150, a classical computing unit 160, a quantum computing unit 170, and may also include additional memory, a classical processor, a quantum processor, and other devices not shown.
[0048] Network 110 is a medium used to provide communication links between various devices and computers connected together within a user rating system, including but not limited to the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. The connection method can be wired, wireless communication links, or fiber optic cables.
[0049] Server 120, wireless device 130, and client 140 are conventional data processing systems that may contain data and application programs or software tools that perform conventional computational processes. Client 140 may be a personal computer or a network computer, so the data may also be provided by server 120. Wireless device 130 may be a smartphone, tablet, laptop, smart wearable device, etc. Storage unit 150 may include database 151, which can be configured to store data such as qubit parameters, quantum logic gate parameters, quantum circuits, and quantum programs.
[0050] The classical computing unit 160 (quantum computing unit 170) may include a classical processor 161 (quantum processor 171) for processing classical data (quantum data) and a memory 162 (memory 172) for storing classical data (quantum data). The classical data (quantum data) may be a boot file, an operating system image, and an application program 163 (application program 173). The application program 163 (application program 173) may be used to implement a quantum algorithm compiled according to the user rating method provided in the embodiments of the present invention.
[0051] Any data or information stored or generated in the classical computing unit 160 (quantum computing unit 170) can also be configured to be stored or generated in another classical (quantum) processing system in a similar manner, and any application executed therein can also be configured to be executed in another classical (quantum) processing system in a similar manner.
[0052] It should be noted that a true quantum computer has a hybrid structure, which includes at least... Figure 1 The system consists of two main parts: the classical computing unit 160, which is responsible for performing classical calculations and control; and the quantum computing unit 170, which is responsible for running quantum programs to achieve quantum computing.
[0053] The aforementioned classical computing unit 160 and quantum computing unit 170 can be integrated into a single device or distributed across two different devices. For example, a first device including the classical computing unit 160 runs a classical computer operating system, providing quantum application development tools and services, as well as the storage and network services required for quantum applications. Users develop quantum programs using the quantum application development tools and services on the second device, and send these quantum programs to a second device including the quantum computing unit 170 via the network services. The second device runs a quantum computer operating system, which parses and compiles the quantum program's code into instructions that the quantum processor 170 can recognize and execute. The quantum processor 170 then implements the quantum algorithm corresponding to the quantum program based on these instructions.
[0054] The computing units of the classic processor 161 within the classic computing unit 160 are based on CMOS transistors on a silicon chip. These computing units are not limited by time or coherence; that is, they are available at any time without time constraints. Furthermore, the number of such computing units in a silicon chip is sufficient; currently, a single classic processor 161 contains tens of thousands of computing units. Given this sufficient number and the fixed selectable computing logic of the CMOS transistors (e.g., AND logic), computational performance is achieved by combining a large number of CMOS transistors with a limited set of logic functions during operation.
[0055] In the quantum computing unit 170, the basic computing unit of the quantum processor 171 is the qubit. The input of a qubit is limited by coherence and coherence time; that is, a qubit is limited by its available usage time and is not always readily available. Making full use of qubits within their available usage time is a key challenge in quantum computing. Furthermore, the number of qubits in a quantum computer is one of the representative indicators of its performance. Each qubit performs computational functions through on-demand configured logical functions. Given the limited number of qubits and the diverse logical functions available in quantum computing, such as Hadamard gates (H gates), Pauli-X gates (X gates), Pauli-Y gates (Y gates), Pauli-Z gates (Z gates), X gates, RY gates, RZ gates, CNOT gates, CR gates, iSWAP gates, Tofoli gates, etc., quantum computing requires combining a limited number of qubits with diverse logical function combinations to achieve computational effects.
[0056] Based on these differences, the design of classical logic functions applied to CMOS transistors and the design of quantum logic functions applied to qubits are significantly and fundamentally different. The design of classical logic functions applied to CMOS transistors does not need to consider the individuality of CMOS transistors. For example, the representation of a CMOS transistor in a silicon chip is its individual identifier, location, and usable time of each CMOS transistor. Therefore, classical algorithms composed of classical logic functions only express the operational relationship of the algorithm, not the algorithm's dependence on individual CMOS transistors.
[0057] Quantum logic functions applied to qubits need to consider the individuality of each qubit, such as its position within the quantum chip, its relationship with surrounding qubits, and the duration of its usable time. Therefore, quantum algorithms composed of quantum logic functions not only express the computational relationships within the algorithm but also its dependence on the individual qubits.
[0058] A quantum chip can include qubits and channels for controlling them. Quantum logic gates are implemented using analog signals. Different combinations of analog signals are applied to the qubits through these channels, thereby creating quantum circuits with different functions to process data. Therefore, the design of quantum logic functions in the qubits (including the design of whether qubits are used and the design of the efficiency of each qubit) is crucial for improving the computational performance of quantum computers and requires special design. This is the unique characteristic of quantum algorithms based on quantum logic functions, and it is fundamentally and significantly different from classical algorithms based on classical logic functions. The aforementioned design considerations for qubits are technical problems that ordinary computing devices do not need to consider or address.
[0059] Therefore, to further improve the calculation efficiency of user ratings, this invention proposes a user rating method and related apparatus. See also Figure 2 , Figure 2 A user rating method provided in this embodiment of the invention includes the following steps:
[0060] Step 201: Encode the user data of the user to be rated to obtain a first feature vector, and encode each target data to obtain a corresponding second feature vector; wherein, the target data is user data with known ratings;
[0061] Step 202: Using the target quantum circuit, calculate the similarity between each second feature vector and the first feature vector;
[0062] Step 203: Obtain the scores corresponding to the k second feature vectors with the highest similarity to the first feature vector, and perform a weighted summation of the k scores to obtain the score of the user to be scored.
[0063] Specifically, in this embodiment, to rate the user to be rated, it is first necessary to obtain the user data of the user to be rated; and to obtain the data of users with known ratings as target data. In one implementation, a user rating model can be pre-constructed, which can score each user based on the feature information of each user in various dimensions; thus, after scoring multiple users, the multiple user data and corresponding rating information can be saved, and a user rating dataset can be constructed, where each user data in the user rating dataset can be used as the target data. Since the above rating is determined based on the feature information of users in various dimensions, if the similarity between the feature information of the user to be rated and the feature information of known rated users can be quantitatively represented by mathematical calculations, the rated users most similar to the feature information of the user to be rated in various dimensions can be determined, and the rating of the user to be rated should be relatively close to the rating of such rated users.
[0064] Furthermore, in this embodiment, the user data of the user to be rated can be encoded to obtain a first feature vector, and each target data can be encoded to obtain a corresponding second feature vector. The aforementioned feature vectors are multi-dimensional vectors obtained through normalized encoding. Normalized encoding converts feature information into a unified data format and unit, thereby ensuring the accuracy and standardization of feature information and the consistency between multiple dimensions of feature information, which is beneficial to improving the reliability of subsequent similarity calculation results. In one implementation, to further improve the accuracy of the similarity calculation results, the user data of the user to be rated can be preprocessed before encoding, such as variable filtering and missing value handling, so that the encoded first feature vector and the second feature vector corresponding to the target data have the same dimension.
[0065] Furthermore, the similarity between the second eigenvector and the first eigenvector can be calculated using a target quantum circuit. This target quantum circuit can encode the corresponding quantum state based on the first and second eigenvectors, and utilize the superposition and entanglement properties of quantum states and the parallel nature of quantum computing to quickly compare all feature data in the eigenvectors, thereby obtaining the similarity between the second and first eigenvectors. Since the user corresponding to each second eigenvector has already been pre-rated, after determining the similarity between each second eigenvector and the first eigenvector through quantum computing, the ratings corresponding to the k second eigenvectors with the highest similarity to that first eigenvector can be obtained. The above process can be represented by the following formula:
[0066]
[0067] Where u represents the first feature vector, v j Let m be the j-th second eigenvector in the set {v}, and m be the total number of vectors in the set {v}. This means taking the second feature vector with the smallest distance from the first k. The preset number k can be set based on factors such as the amount of target data and the required scoring accuracy, and is not specifically limited here.
[0068] The score of the user to be rated can then be calculated using the aforementioned scores. In one implementation, the score can be calculated by weighted summation of the k scores. For example, if k=4, the weight of each of the four scores can be set to 0.25 on average, or, based on the similarity ranking from high to low, the scores of each ranking can be weighted to 0.4, 0.3, 0.2, and 0.1 respectively. The scores can then be weighted and summed based on these preset weights to obtain the score of the user to be rated. Specifically, the score of the user to be rated can be used in multiple fields. For example, in the financial field, banks and financial institutions can use the user's credit score to decide whether to issue credit cards, loans, etc.; another example is that internet companies can use the user's interest scores in different fields to recommend diverse information, products, video streams, etc. to the user. These are all feasible and will not be elaborated further here.
[0069] As can be seen, in the solution provided by this invention, when the user data and target data of the user to be rated are extremely large in scale, including multi-dimensional feature information, they can be normalized and encoded into feature vectors. Then, through quantum computing, the similarity comparison between feature vectors is transformed into a similarity comparison between corresponding quantum states. Furthermore, utilizing the superposition and entanglement properties of quantum states and the parallel nature of quantum computing, all feature data in the feature vectors are compared, thereby quickly and accurately determining the rating that best matches the user to be rated. This solution effectively reduces the complexity of classical classification algorithms and further improves the computational efficiency and accuracy of user ratings.
[0070] As one embodiment of the present invention, such as Figure 3 As shown, before encoding the user data of the user to be rated to obtain the first feature vector, the above method may further include the following steps:
[0071] Step 301: Construct a user dataset using the user data of rated users and the actual ratings, and divide the user dataset into a test dataset and a training dataset.
[0072] Specifically, classic machine learning is a computer programming science and art that learns from data. If a program, while using existing experience to perform a certain type of task, demonstrates the ability to continuously improve its performance by leveraging that existing experience, then the program can be considered "capable of learning." For example, a spam filter is a machine learning program that learns to label other spam emails by learning from examples of spam and regular non-spam emails labeled by users. The example data provided to the program for learning in the system is called the training dataset.
[0073] As can be understood, in the example above, the task (T) is to label new emails as spam, and the experience (E) is the training dataset including examples of spam and regular non-spam emails labeled by the user. If a performance metric (P) needs to be defined for this program, after the program labels the newly received emails, P can be defined as the proportion of correctly classified emails among all newly received emails. This specific performance metric is called accuracy. The machine learning algorithm described above is a supervised learning method, commonly used for classification tasks, where the newly received emails serve as the test dataset.
[0074] In this embodiment, a classic computer can be used to acquire user data and corresponding real ratings of rated users, constructing a user dataset. This user dataset is then divided into a test dataset and a training dataset. The user data and corresponding real ratings in the training dataset serve as existing experience and are used to train the classic classification model. The real ratings of the user data in the test dataset are hidden during the training phase and are used to test the trained classic classification model based on the user data with these hidden ratings, thus measuring its classification performance. The aim is to improve the reliability and accuracy of the user data in the training dataset by optimizing the user data in the training dataset.
[0075] Step 302: Calculate the distance between the test data in the test dataset and the training data in the training dataset using the k-nearest neighbor algorithm, and calculate the prediction accuracy using the predicted score and the actual score of each test data; wherein the predicted score is determined based on the distance.
[0076] In supervised learning, the program learns from labeled data and, after understanding the data, determines which label to assign to the new data by associating patterns from the labeled data with unlabeled new data. Supervised learning methods can be divided into classification algorithms and regression algorithms. Among classification algorithms, a commonly used algorithm is the k-Nearest Neighbors (KNN) algorithm. The idea behind KNN is very simple: for any n-dimensional input vector, each corresponding to a point in the feature space, the output is the category label or predicted value corresponding to that feature vector. Its working principle is to partition the feature vector space using training data and use the partitioning result as the final algorithm model. Therefore, KNN is a very special machine learning algorithm, lacking a typical learning process.
[0077] In the KNN model, there exists a set of training data, called the training dataset, and each data point in the training dataset has a label representing a user rating. In other words, a pre-established correspondence between each user data point and its rating is created. When test data without ratings is input, the program compares each feature of this unrated training data point with the corresponding feature of each training data point in the training dataset, and then extracts the classification label (i.e., the predicted rating) of the training data point with the closest feature (i.e., the nearest neighbor).
[0078] The following example illustrates the above process using a specific business scenario of credit card issuance in the financial sector. Due to the impact of economic globalization and the emergence of innovative financial derivatives, it is becoming increasingly difficult for banks to identify and prevent customer credit risk. How to improve the accuracy of commercial bank risk management, especially credit risk management, has become a key issue of concern for all banks. For example, in order to reduce the risk of overdue repayments caused by issuing credit cards to high-risk customers, banks and financial institutions usually establish user credit scoring models to predict whether a credit card applicant will have overdue repayments in the future based on the applicant's past behavior and attribute information, thereby deciding whether to issue a credit card to the applicant.
[0079] In credit scoring models, user credit scores typically use logistic regression to solve binary classification problems, determining whether a credit card applicant will default in the future. Therefore, the similarity between the applicant's data and that of existing credit card applicants can be calculated, outputting a classification label from the most similar user data, which serves as the label for the applicant's data. Banks and financial institutions can then use this label to predict the applicant's default risk.
[0080] The data required for building a user credit scoring model is high-dimensional and highly complex. For example, data used to assess customer credit includes various types, such as basic user attributes, repayment ability, credit history, and asset status. Specifically, in this embodiment, the selected data type can be similar to the dataset used for building credit scoring models publicly available on the Lending Club website (a US online financial platform). The data content includes applicant information, such as the applicant's age, gender, marital status, education, loan amount, and asset status, serving as data category features. Loan performance can also be included as a target category feature. Furthermore, the constructed dataset can be preprocessed. Preprocessing can include dependent variable mapping, missing value handling, WOE (Weight of Evidence) encoding, and variable filtering to convert the data into a uniform format and units, eliminating data inconsistencies, ensuring data accuracy and standardization, and thus improving the accuracy and reliability of the algorithm.
[0081] The preprocessed dataset can then be used as the user dataset. A portion of this dataset can be used as the test dataset, and the remaining data as the training dataset. After training the KNN classification model using the training dataset, the prediction accuracy is calculated using the test data from the test dataset. The KNN classification model calculates the similarity distance (e.g., Euclidean distance, Hamming distance) between the test data and the training data in the training dataset, and outputs the k nearest classification labels. For example, in the field of user credit scoring, the classification labels can be timely repayment, late repayment, etc.; or they can be scores used to quantify user credit, such as 90, 80, 70, 60, etc. The predicted score for each test data point can then be obtained through direct output or weighted summation. By comparing the predicted score with the actual score of that user data, the number of accurately predicted user data points and the number of inaccurately predicted user data points can be obtained, thus calculating the model's prediction accuracy.
[0082] Step 303: Adjust the training dataset based on the prediction accuracy, and use the training data in the adjusted training dataset as the target data.
[0083] Preferably, adjusting the training dataset based on the prediction accuracy and using the training data in the adjusted training dataset as the target data may include the following steps:
[0084] Repeatedly modify the training data in the training dataset, and / or adjust the amount of data included in the training dataset; wherein both the test dataset and the training dataset contain at least one user data point for each rating category;
[0085] After each adjustment, the prediction accuracy is calculated, and the training data in the training dataset with the highest prediction accuracy is used as the target data.
[0086] Specifically, for the training dataset, the amount of data included in the dataset can be increased or decreased, or the training data included can be replaced with test data from the test dataset. Of course, these increases, decreases, and replacements can also be performed simultaneously. In one implementation, inaccurate user data such as those with missing dimensions or statistical errors can be removed from the user dataset. It is important to note that each adjustment must ensure that both the test and training datasets contain at least one user data point for each rating category, and the model's prediction accuracy needs to be recalculated after each adjustment. By continuously adjusting the user data included in the test and training datasets, the model's prediction accuracy is continuously improved until the highest prediction accuracy is achieved, at which point the training data in the training dataset can be used as the target data.
[0087] In one implementation, a target matrix can be constructed based on the data in the training dataset. Then, a second feature vector can be encoded from the user data in each row of the target matrix. The target data in the training dataset can be shown in the table below:
[0088] Data Number Feature 1 Feature 2 Feature 3 Feature 4 rating categories 1 …… …… …… …… 1 2 …… …… …… …… 0 …… …… …… …… …… ……
[0089] Accordingly, the above preprocessing operations can be performed on the various types of data of the user to be rated, so that the user data of the user to be rated is as shown in the table below:
[0090] Feature 1 Feature 2 Feature 3 Feature 4 …… …… …… ……
[0091] The user data of the user to be rated contains the same number of features in the same dimensions as the target data in the training dataset, and the feature types of each dimension also correspond to each other.
[0092] As one embodiment of the present invention, such as Figure 4 As shown, the target quantum circuit may include a feature encoding circuit and a similarity calculation circuit, wherein:
[0093] The feature encoding circuit operates on the first qubit and the second qubit to perform feature encoding based on the first feature vector, storing the encoded first target quantum state in the first qubit; and to perform feature encoding based on the second feature vector, storing the encoded second target quantum state in the second qubit.
[0094] The similarity calculation circuit is used to perform entanglement evolution on the first target quantum state and the second target quantum state, and measure the similarity between the second feature vector and the first feature vector after the evolution of the quantum state.
[0095] In this embodiment, the feature encoding circuit may include a first encoding circuit acting on the first qubit and a second encoding circuit acting on the second qubit. The first feature vector and the second feature vector both have a dimension of n. Both the first encoding circuit and the second encoding circuit contain n levels of angle encoding sub-circuits. Each level of angle encoding sub-circuit is used to encode feature data of the corresponding dimension in the feature vector.
[0096] Specifically, in this embodiment, the user data of the users to be rated can be normalized and encoded into a first feature vector, and the target data can be normalized and encoded into a second feature vector, resulting in a second feature vector set. Each of the first and second feature vectors has a dimension of n, containing feature information in n dimensions. So firstly... Figure 4The feature encoding circuit U can traverse the second feature vector set, take any second feature vector and the first feature vector, encode them respectively, prepare them into quantum states, store the prepared first target quantum state on the first quantum bit, and store the prepared second target quantum state on the second quantum bit.
[0097] Then use Figure 4 The similarity calculation circuit in the system includes two H-gates and a Controlled-SWAP circuit to entangle the first and second target quantum states, calculate the distance between the first and second eigenvectors, and then store this distance on a third qubit using a phase estimation algorithm. The smaller the distance between the first and second eigenvectors, the higher the similarity. By weighted summing the k smallest similarity estimates among all calculated distances and the corresponding scores for the second eigenvectors, the rating of the user to be rated can be predicted.
[0098] The aforementioned feature coding circuit U may include the following coding quantum circuits: ground state coding quantum circuit, amplitude coding quantum circuit, and angle coding quantum circuit.
[0099] Specifically, the ground state relative to any quantum state is analogous to the basis vector relative to any vector. For example, for a quantum state... Where |0> and |1> are ground states, for the quantum state |ψ>=c|00>+d|01>+e|10>+f|11>, where |00>, |01>, |10>, and |11> are ground states. Ground-state encoded quantum circuits are used to encode input data into the ground state of the quantum bit. For example, for input data 5, its binary code is 101, which can then be encoded into the ground state |101> of the quantum bit.
[0100] Specifically, for quantum states Where a and b are amplitudes; for the quantum state |ψ>=c|00>+d|01>+e|10>+f|11>, where c, d, e, and f are amplitudes. For example, for the input data [1,3], after normalization, 1 corresponds to 0.25, 3 corresponds to 0.75, and thus the quantum state can be... The amplitude of To encode it.
[0101] Specifically, the angle-encoded quantum circuit includes parametric quantum logic gates, such as any one or more of the RX, RY, and RZ rotary gates. An inverse trigonometric function transformation is performed on the input data, and the resulting angle is used as the rotation angle parameter of the rotary gate, thereby encoding the input data.
[0102] Preferably, both the first and second encoding lines can contain n levels of angular encoding sub-lines, each level of angular encoding sub-line being used to encode feature data of the corresponding dimension in the feature vector. For example... Figure 5 As shown, each level of angle encoding sub-circuit includes a set of RY gates and RX gates, wherein the rotation angle θ of the RY gates and the rotation angle of the RX gates are... It can be determined based on the following formulas:
[0103] θ ξ =arctanγ ξ
[0104]
[0105] Where, γ ξ ξ represents the feature data of the corresponding dimension in the first or second feature vector after normalization, where ξ is the corresponding dimension in the first or second feature vector, and ξ∈{1,n}.
[0106] In this embodiment, to encode user data of different feature lengths, i.e., feature vectors containing feature data with multiple dimensions, a variable-depth feature encoding circuit U is designed. Feature encoding circuit U includes a first encoding circuit and a second encoding circuit. Both the first and second encoding circuits contain n levels of angular encoding sub-circuits. Each level of angular encoding sub-circuit includes a set of RY gates and RX gates for encoding feature data of corresponding dimensions in the feature vector. The initial state of the first and second qubits is |0>, the first target quantum state encoded by feature encoding circuit U is represented as |x>, and each encoded second target quantum state is represented as |y>. i The first-level angle encoding process can then be represented by the following formula:
[0107]
[0108]
[0109] Where, θ 11 This represents the rotation parameter of the first RX gate acting on the first qubit. θ represents the rotation parameter of the first RY gate acting on the first qubit. 21 This represents the rotation parameter of the first RX gate acting on the second qubit. This represents the rotation parameter of the first RY gate acting on the second qubit. Similarly, the first target quantum state, denoted as |x>, and each second target quantum state, denoted as |y>, can be encoded. i > Wherein, the rotation parameters of each revolving door are respectively expressed by the above formula θξ =arctanγ ξ and formula The calculations are complete and will not be elaborated upon here.
[0110] As can be seen, in this embodiment, by establishing a multi-level angle encoding sub-circuit, the feature vector of feature data containing multiple dimensions is encoded. By changing the level of the angle encoding sub-circuit, a quantum state similarity estimation circuit with variable depth is constructed, thereby making the user rating method in the technical solution of this invention applicable to user data with different feature categories and numbers.
[0111] As one embodiment of the present invention, such as Figure 4 As shown, the similarity calculation circuit sequentially includes a first H gate acting on the auxiliary bit, a controlled SWAP gate whose control bit is the auxiliary bit, and a second H gate acting on the auxiliary bit. The target bits of the controlled SWAP gate are the first qubit and the second qubit.
[0112] The measurement of the evolved quantum state to obtain the similarity between the second eigenvector and the first eigenvector may include the following steps:
[0113] After executing the second H gate on the auxiliary bit, the probability P(|0>) that the quantum state of the auxiliary bit is |0> is obtained by measuring through a preset number of times;
[0114] The similarity between the first feature vector and the second feature vector is obtained using the following formula:
[0115] | <x|y i >| 2 =2P(|0>)-1
[0116] in, <x|y i > represents the first target quantum state |x> and a second target quantum state |y>. i The inner product of >.
[0117] Specifically, the initial state of the auxiliary bit is |0>, and the first H gate converts the quantum state of the auxiliary bit from |0> to a superposition state. When the quantum state of the control bit (i.e., the auxiliary bit) of the controlled SWAP gate is |1>, the controlled SWAP gate is related to the quantum state |x> of the first quantum bit and the quantum state |y> of the second quantum bit. i After performing a swap operation and passing through the second H gate, a quantum state can be obtained:
[0118]
[0119] By measuring the aforementioned auxiliary bit a predetermined number of times, the probability that its quantum state is |0> can be obtained as follows:
[0120]
[0121] The number of measurements can be set according to the accuracy requirements of quantum state similarity estimation, and no specific limit is made here.
[0122] The similarity between the first eigenvector and a second eigenvector can then be expressed as:
[0123] | <x|y i >| 2 =2P(|0>)-1
[0124] In one implementation, the similarity between the first target quantum state and the second target quantum state can also be defined as:
[0125]
[0126] in, <x|y i > represents the first target quantum state |x> and a second target quantum state |y>. i The inner product of >. Therefore, when the probability of measuring the quantum state |0> is 1 / 2, it indicates that | <x|y i >| 2 =0, that is, |x> and |y> i >No fidelity, meaning dissimilar; when P(|0>)=1, it indicates that |x> and |y> are dissimilar. i It has the highest fidelity, that is, the most similar.
[0127] Compared to the classic KNN algorithm, the QKNN algorithm used in this embodiment reduces the complexity of calculating the similarity between feature vectors. The similarity calculation formula of the classic KNN algorithm is as follows:
[0128]
[0129] Here, n is the feature dimension. For m target data, the classic KNN algorithm requires calculating the similarity between the first feature vector and each feature data of the m second feature vectors, with an algorithm complexity of O(mn). The QKNN algorithm provided in this embodiment can encode all feature data of each second feature vector into quantum states using quantum circuits to calculate quantum state similarity, with an algorithm complexity of O(log(mn)). Therefore, compared with the classic KNN algorithm, it effectively reduces the algorithm complexity, improves computational efficiency, and has extremely high classification efficiency for large-scale datasets. Furthermore, by converting the similarity comparison between user data into a quantum state similarity comparison, the parallel characteristics of quantum computing and the superposition and entanglement characteristics of quantum states can be utilized to improve computational efficiency, accuracy, and sensitivity.
[0130] See Figure 6 , Figure 6 A user rating device provided in an embodiment of the present invention may include:
[0131] The encoding module 601 is used to encode the user data of the user to be rated to obtain a first feature vector, and to encode each target data to obtain a corresponding second feature vector; wherein, the target data is user data with known ratings;
[0132] Quantum computing module 602 is used to calculate the similarity between each second feature vector and the first feature vector using the target quantum circuit.
[0133] The weighted scoring module 603 is used to obtain the scores corresponding to the k second feature vectors that have the highest similarity to the first feature vector, and to perform a weighted summation of the k scores to obtain the score of the user to be scored.
[0134] The specific functions and effects of the user rating device can be explained by referring to other embodiments in this specification, and will not be repeated here. Each module in the user rating device can be implemented entirely or partially through software, hardware, or a combination thereof. Each module can be embedded in or independent of the processor in the computer device in hardware form, or it can be stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0135] Please see Figure 7 This specification also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor, when executing the computer program, implements the method for preparing normally distributed quantum states in any of the above embodiments. Please refer to... Figure 7 The computer device can be a classical computer or a quantum computer.
[0136] This specification also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a computer, causes the computer to perform the normal distribution quantum state preparation method in any of the above embodiments.
[0137] This specification also provides a computer program product containing instructions that, when executed by a computer, cause the computer to perform the normal distribution quantum state preparation method in any of the above embodiments.
[0138] It is understood that the specific examples in this specification are only intended to help those skilled in the art better understand the implementation methods described herein, and are not intended to limit the scope of the invention.
[0139] It is understood that in the various embodiments of this specification, the sequence number of each process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not limit the implementation process of the embodiments of this specification in any way.
[0140] It is understood that the various implementation methods described in this specification can be implemented individually or in combination, and the implementation methods in this specification are not limited in this respect.
[0141] Unless otherwise stated, all technical and scientific terms used in the embodiments of this specification have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of this specification. The term "and / or" as used in this specification includes any and all combinations of one or more of the associated listed items. The singular forms "a," "the," and "the" as used in the embodiments of this specification and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.
[0142] It is understood that the processor in the embodiments of this specification can be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method embodiments can be completed by integrated logic circuits in the processor's hardware or by instructions in software form. The processor can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this specification. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this specification can be directly implemented by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software modules can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory; the processor reads information from the memory and, in conjunction with its hardware, completes the steps of the above methods.
[0143] It is understood that the memory in the embodiments of this specification may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. Non-volatile memory may be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may be random access memory (RAM). It should be noted that the memory in the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0144] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this specification.
[0145] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the aforementioned method implementations, and will not be repeated here.
[0146] In the several embodiments provided in this specification, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0147] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0148] In addition, the functional units in the various embodiments of this specification can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0149] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of this specification, in essence, or the parts that contribute to the prior art, or parts of the technical solutions, can be embodied in the form of software products. These computer software products are stored in a storage medium and include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this specification. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0150] The above description is merely a specific embodiment of this specification, but the scope of protection of this invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this specification should be included within the scope of protection of this specification. Therefore, the scope of protection of this invention should be determined by the scope of the claims.
Claims
1. A user rating method, characterized in that, The method includes: The user data of the user to be rated is encoded to obtain a first feature vector, and each target data is encoded to obtain a corresponding second feature vector; wherein, the target data is user data with known ratings; Using the target quantum circuit, the similarity between each second feature vector and the first feature vector is calculated. Obtain the scores corresponding to the k second feature vectors that have the highest similarity to the first feature vector, and perform a weighted summation of the k scores to obtain the score of the user to be scored.
2. The method as described in claim 1, characterized in that, The target quantum circuit includes a feature encoding circuit and a similarity calculation circuit, wherein: The feature encoding circuit operates on the first qubit and the second qubit to perform feature encoding based on the first feature vector, storing the encoded first target quantum state in the first qubit; and to perform feature encoding based on the second feature vector, storing the encoded second target quantum state in the second qubit. The similarity calculation circuit is used to perform entanglement evolution on the first target quantum state and the second target quantum state, and measure the similarity between the second feature vector and the first feature vector after the evolution of the quantum state.
3. The method as described in claim 2, characterized in that, The feature encoding circuit includes a first encoding circuit acting on the first qubit and a second encoding circuit acting on the second qubit. The first feature vector and the second feature vector both have a dimension of n. Both the first encoding circuit and the second encoding circuit contain n levels of angle encoding sub-circuits. Each level of angle encoding sub-circuit is used to encode feature data of the corresponding dimension in the feature vector.
4. The method as described in claim 3, characterized in that, Each level of angle encoding sub-circuit includes a set of RY gates and RX gates, wherein the rotation angle θ of the RY gates and the rotation angle of the RX gates are... Determined based on the following formulas: θ ξ =arctanγ ξ Where, γ ξ ξ represents the feature data of the corresponding dimension in the first or second feature vector after normalization, where ξ is the corresponding dimension in the first or second feature vector, and ξ∈{1,n}.
5. The method as described in claim 2, characterized in that, The similarity calculation circuit sequentially includes a first H gate acting on the auxiliary bit, a controlled SWAP gate whose control bit is the auxiliary bit, and a second H gate acting on the auxiliary bit. The target bits of the controlled SWAP gate are the first qubit and the second qubit. The measurement of the evolved quantum state yields the similarity between the second eigenvector and the first eigenvector, including: After executing the second H gate on the auxiliary bit, the probability P(|0>) that the quantum state of the auxiliary bit is |0> is obtained by measuring through a preset number of times; The similarity between the first feature vector and the second feature vector is obtained using the following formula: | <x|y i >* 2 = 2P(|0>)-1 in, <x|y i > represents the first target quantum state |x> and a second target quantum state |y>. i The inner product of >.
6. The method according to any one of claims 1-5, characterized in that, Before encoding the user data of the user to be rated to obtain the first feature vector, the method further includes: A user dataset is constructed using user data of rated users and actual ratings, and the user dataset is divided into a test dataset and a training dataset. The distance between test data in the test dataset and training data in the training dataset is calculated using the k-nearest neighbor algorithm, and the prediction accuracy is calculated using the predicted score and the actual score of each test data; wherein the predicted score is determined based on the distance. The training dataset is adjusted based on the prediction accuracy, and the training data in the adjusted training dataset is used as the target data.
7. The method as described in claim 6, characterized in that, The step of adjusting the training dataset based on the prediction accuracy and using the training data in the adjusted training dataset as the target data includes: Repeatedly modify the training data in the training dataset, and / or adjust the amount of data included in the training dataset; wherein both the test dataset and the training dataset contain at least one user data point for each rating category; After each adjustment, the prediction accuracy is calculated, and the training data in the training dataset with the highest prediction accuracy is used as the target data.
8. A user rating device, characterized in that, The device includes: The encoding module is used to encode the user data of the user to be rated to obtain a first feature vector, and to encode each target data to obtain a corresponding second feature vector; wherein, the target data is user data with known ratings; A quantum computing module is used to calculate the similarity between each second feature vector and the first feature vector using a target quantum circuit. The weighted scoring module is used to obtain the scores corresponding to the k second feature vectors with the highest similarity to the first feature vector, and to perform a weighted summation of the k scores to obtain the score of the user to be scored.
9. A storage medium, characterized in that, The storage medium stores a computer program, wherein the computer program is configured to execute the method described in any one of claims 1 to 7 when it is run.
10. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to perform the method as described in any one of claims 1 to 7.