Machine learning-based drug taking prediction method
By preprocessing blood test data of drug users and non-drug users and training random forest models, the problems of high cost and timeliness requirements for existing drug detection methods are solved, and drug use prediction with low cost and low timeliness requirements are achieved. High accuracy and good adaptability.
Patent Information
- Application Number
- CN202410695657.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-12-13
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing drug testing methods such as high cost of hair detection and high timeliness requirements for urine and blood tests, it is difficult to screen suspected drug users in a timely manner, and multiple drug testing is difficult to achieve.
Using machine learning-based drug use prediction methods, predicting drug use situations by preprocessing, correlation analysis and random forest model training of blood test data of drug users and non-drug users. Specific steps include outlier value processing, data discretization, missing value filling and random forest classification model training based on Gini impurity.
It realizes drug use judgments with low cost and low timeliness requirements, has high prediction accuracy, and can maintain good adaptability and anti-interference ability in practical applications.
Smart Images

Figure CN119128695A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of clinical diagnosis, and in particular to a drug abuse prediction method based on machine learning. Background Art
[0002] Drugs have gradually become one of the major social problems facing the world today. They not only cause serious health problems to users, but also greatly endanger social security and stability. At present, the detection of drug users is mainly through collecting their hair, urine or blood and analyzing the residual drugs or drug metabolites in them to determine whether there is drug use. However, hair testing is expensive, and most community hospitals do not have the corresponding instruments and equipment. At the same time, urine tests and blood tests are limited by the time that drugs and their metabolites stay in the body of users, and have high timeliness requirements, making it difficult to conduct drug testing on suspected users in a timely manner.
[0003] Therefore, it is necessary to find a method for drug use judgment that is not time-sensitive, relatively low-cost, and easy to obtain test samples, so as to achieve preliminary screening of suspected drug users and narrow the scope of accurate detection. At the same time, this method is not limited to the detection of a single drug, and can maintain a high accuracy rate and good adaptability in practical applications. Summary of the invention
[0004] In view of the problems existing in the background technology, the purpose of the present invention is to provide a drug abuse prediction method based on machine learning.
[0005] In order to achieve the above object, the present invention adopts the following technical scheme:
[0006] Step 1: Conduct multiple blood test items on a group of drug users and non-drug users, and collect original sample data with a balanced number of positive and negative samples;
[0007] Step 2: Preprocess the original sample data, including outlier processing based on central tendency analysis, data discretization, and missing value processing based on mode filling;
[0008] Step 3: Conduct correlation analysis on the preprocessed sample data and drug use status, and after removing irrelevant blood test items, obtain sample data of blood test items with strong correlation, and create a data set;
[0009] Step 4: Use the random forest machine learning model based on Gini impurity to perform classification training and testing on the blood test item data set to obtain a trained random forest classification model;
[0010] Step 5: Use the random forest classification model to predict drug use status of the test samples;
[0011] Furthermore, the outlier processing based on central tendency analysis is used for the original sample data as follows: Let the original sample data be X∈R n x m ;
[0012]
[0013] Where, column vector λ is a single blood test item containing all samples, x ij is the value of the jth blood test item in the i-th sample, n is the total number of samples, and m is the total number of blood test items contained in a single sample; j Each sample value x in ij Sort from small to large; take the values at 25% and 75% as the first quartile point and the third quartile point, and calculate the upper limit UIF of each blood test item based on the first quartile point and the third quartile point j and lower limit LIF j , the calculation formula is as follows:
[0014] UIF j =Q j3 +1.5(Q j3 -Q j1 )
[0015] LIF j =Q j3 -1.5(Q j3 -Q j1 )
[0016] In the formula, Q j1 is the first quartile point, Q j3 is the third quartile point, j=1,2,3,…,m; then compare the value of each blood test item in each sample with the upper limit and lower limit of the corresponding blood test item. If there is a value higher than the upper limit or lower than the lower limit in the sample, it is necessary to judge and process the abnormal value in combination with the reference value type of the blood test item corresponding to the value, which is specifically divided into the following two cases: 1) If the reference value of the item corresponding to the value is a single value, it is determined to be a normal value and the value is retained; 2) If the reference value of the item corresponding to the value is a single interval range or multiple interval ranges, it is determined to be an abnormal value and the sample is deleted from the original sample data.
[0017] Furthermore, the discretization processing of data is specifically as follows: the sample data after outlier processing is processed according to the reference value type of each blood test item:
[0018] 1) For a blood test item with a single reference value, let the reference value be k and the actual value be r. If r = k, the blood test item is normal and its value is assigned 3; otherwise, the blood test item is abnormal and its value is assigned 5.
[0019] 2) For a blood test item with a single interval range as the reference value, let the reference interval be (k1, k2) and the actual value be r. If r ∈ [ak2, +∞), the blood test item is too high and its value is assigned 5; if r ∈ [k2, ak2), the blood test item is on the high side and its value is assigned 4; if r ∈ [k1, k2), the blood test item is normal and its value is assigned 3; if r ∈ [bk1, k1), the blood test item is on the low side and its value is assigned 2; if r ∈ [0, bk1), the blood test item is too low and its value is assigned 1; where a > 1, 0 < b < 1 and both a and b are constants.
[0020] 3) For a blood test item with multiple interval ranges as the reference value, including the normal range K, the low range K L , the high range K H , let the actual value be r. If r is higher than the high range K H , the blood test item is too high and its value is assigned 5; if r ∈ K H , the blood test item is on the high side and its value is assigned 4; if r ∈ K, the blood test item is normal and its value is assigned 3; if r ∈ K L , the blood test item is on the low side and its value is assigned 2; if r is lower than the low range K L , the blood test item is too low and its value is assigned 1.
[0021] Further, the missing value processing based on the mode filling is specifically as follows: Let the sample data after data discretization be X ∈ R g x m :
[0022]
[0023] In the formula, the column vector q is a single blood test item containing all discretized samples, m is the total number of blood test items in a single sample, the row vector p is a single discretized sample containing all blood test items, g is the total number of discretized samples, and x ij is the value of the jth blood test item in the ith sample;
[0024] Statistically count the number of missing values N i of each blood test item in each discretized sample data p i , delete the samples with N i > T, and then for each blood test item qj The assignment in is counted to obtain each blood test item q j The discrete number I used for the most assignments j , will I j Fill in q j All missing values in ; where T is the missing value number threshold, I j =1,2,3,4,5.
[0025] Furthermore, the correlation analysis and data set preparation are as follows: Let the preprocessed sample be X∈R h x m , h is the number of valid samples after preprocessing, and each data x ij As the independent variable, drug use as the dependent variable Y, Y is 1 or 0, calculate the Pearson correlation coefficient ρ j , and its calculation formula is as follows:
[0026] ρ j = Cov(q j ,Y) / σ qj σ y
[0027] In the formula, j = 1, 2, 3, ..., m, m is the total number of blood test items for a single sample, q j is the pre-processed sample data contained in the j-th blood test item, Cov(q j ,Y) is q j Covariance with Y, σ qj for q j The standard deviation, σ y is the standard deviation of Y;
[0028] Then |ρ j |≥ρ th The blood test items and drug abuse classification labels are made into a data set, and the samples in the data set are divided into a training set and a test set according to the proportion; where ρ th is the set correlation threshold.
[0029] Furthermore, the random forest machine learning model based on Gini impurity is specifically:
[0030] Step 41: Set the number of random forest decision trees to t, the minimum number of samples of decision tree leaf nodes to f, the maximum depth of the decision tree to d, and use {t, f, d} to form the random forest parameter space, and use Gini impurity as the splitting criterion for each node of the decision tree;
[0031] Step 42: Divide the blood test data set into k parts, randomly select one of them as the test set, and the remaining k-1 parts as the training set, and calculate the mean square error MSE1 of the model on the test set;
[0032] Step 43: Select one of the k data sets as the test set without duplication, and the remaining k-1 sets as the training set, and repeat step 42 to obtain the mean square error (MSE) of k experiments. i , i = 1, 2, ..., k, and the k-fold cross validation error CV is obtained by averaging according to the following formula;
[0033]
[0034] Step 44: Randomly select n sets of parameters {t j ,f j ,d j}, repeat step 43 and calculate the k-fold cross validation error CV for each group of parameters j , where j = 1, 2, ..., n;
[0035] Step 45: Use the random forest classification model and apply a set of parameters corresponding to the minimum k-fold cross-validation error to train the blood test item training set.
[0036] Furthermore, the splitting of each node of the decision tree is implemented according to the following steps:
[0037] Step 411: Calculate the Gini impurity Gini(A) before the A node is split;
[0038]
[0039] In the formula, c is the total number of categories, P i is the probability that the sample in node A belongs to the i-th class;
[0040] Step 412: Select each feature in turn for splitting and calculate the sum of the Gini impurities of the two child nodes after the split (Gini(A ∑ );
[0041]
[0042]
[0043] In the formula, Gini(A j ) is the Gini impurity of each child node in node A, A j is the left or right child node after the split of node A, P ij For node A j The probability that a sample belongs to the i-th class, w jis the proportion of the corresponding individuals or groups in the two child nodes in the total (node A);
[0044] Step 413: Select the Gini impurity reduction Gini (A Δ )The largest feature is used as the split feature of the node;
[0045] Gini(A) Δ =Gini(A)-Gini(A ∑ ).
[0046] The beneficial effects of the present invention are:
[0047] (1) The present invention uses a random forest machine learning model to judge the drug use status of the subject by learning the differences between some blood test items of drug addicts and normal people. This method has relatively low cost and low timeliness requirements, and has a high prediction accuracy.
[0048] (2) The present invention uses an outlier processing method based on central tendency analysis, which can realize outlier screening for different blood test items and eliminate the interference caused by outliers on model training; then, through data discretization operation based on blood test reference values, the reference values are used as a control benchmark to weaken the interference of other diseases on the blood of the subjects, making it easier for the model to learn the blood differences between drug addicts and normal people, which is beneficial to improving the accuracy of drug abuse prediction.
[0049] (3) The present invention uses a random forest machine learning algorithm, which can find the interaction between blood features through feature combination, so as to more comprehensively learn the differences between the blood of drug addicts and normal people and obtain a higher prediction accuracy; at the same time, the random forest parameters are tuned using K-fold cross validation, which can more comprehensively evaluate the generalization ability of the random forest model and reduce the risk of overfitting, so that the method has better anti-interference ability in practical applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 A flowchart of a drug abuse prediction method based on machine learning;
[0051] Figure 2 Visualization process for some outlier processing;
[0052] Figure 3 The results of the correlation analysis between some blood test items and drug use status;
[0053] Figure 4 Schematic diagram of node splitting in a random forest decision tree. DETAILED DESCRIPTION
[0054] In order to make the purpose, technical solution and advantages of the invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and do not limit the present invention.
[0055] The specific embodiments and implementation process of the method of the present invention are as follows:
[0056] Step 1: A group of drug users and non-drug users are examined for multiple blood test items, and original sample data with a balanced number of positive and negative samples are collected. In this embodiment, 281 drug users and 307 non-drug users are examined for 81 blood test items including retinol binding protein, alanine aminotransferase, immunoglobulin A, immunoglobulin G, immunoglobulin M, etc., and two-dimensional original sample data X with a balanced number of positive and negative samples is collected, X∈R n x m .
[0057]
[0058] Where, column vector λ is a single blood test item containing all samples, x ij is the value of the jth blood test item in the ith sample, n is the total number of samples, and m is the total number of blood test items included in a single sample. In this embodiment, n=588, m=81.
[0059] Step 2: Preprocess the original sample data X, mainly including outlier processing, data discretization and missing value processing, as follows:
[0060] Step 21: Convert each blood test item λ in the original sample data j Each sample value x in ij Sort from small to large. The values at 25% and 75% are used as the first quartile point and the third quartile point, and the upper limit UIF of each blood test item is calculated based on the first quartile point and the third quartile point. j and lower limit LIF j , the calculation formula is as follows:
[0061] UIF j =Q j3 +1.5(Q j3 -Q j1 )
[0062] LIF j =Q j3 -1.5(Q j3 -Q j1 )
[0063] In the formula, Qj1 is the first quartile point, Q j3 is the third quartile point, j = 1, 2, 3, …, m.
[0064] Then compare the value of each blood test item in each sample with the upper and lower limits of the corresponding blood test item. If there is a value higher than the upper limit or lower than the lower limit in the sample, the abnormal value is judged and processed in combination with the reference value type of the blood test item corresponding to the value: if the reference value of the item corresponding to the value is a single value, it is determined to be a normal value and the value is retained; if the reference value of the item corresponding to the value is a single interval range or multiple interval ranges, it is determined to be an abnormal value and the sample is deleted from the original sample data.
[0065] The visualization process of some outlier processing in this embodiment is as follows: Figure 2 As shown in the figure, in the two single interval reference range tests of retinol binding protein (RBP) and total cholesterol (CHOL), the values of five samples deviated from the upper and lower limits of the test and were abnormal values, so these five samples were eliminated. After completing the abnormal value judgment and processing of the remaining items, a total of 578 valid samples were obtained.
[0066] Step 22: After outlier processing, the sample data is discretized according to the reference value type of each blood test item, which is specifically divided into the following three cases:
[0067] 1) If the reference value of a blood test item is a single value, let the reference value be k and the actual value be r. If r=k, the blood test item is normal and its value is assigned to 3; otherwise, the blood test item is abnormal and its value is assigned to 5.
[0068] In this embodiment, taking the blood test item of the absolute value of nucleated red blood cells as an example, its reference value k=0. If the actual value of the sample is not 0, it is considered that the blood test item of the absolute value of nucleated red blood cells of the sample is abnormal, and its value is assigned to 5; if the actual value is 0, it is considered that the blood test item of the absolute value of nucleated red blood cells of the sample is normal, and its value is assigned to 3.
[0069] 2) For a blood test item with a reference value in a single interval range, let the reference interval be (k1, k2) and the actual value be r. If r ∈ [ak2, +∞), then the blood test item is too high and its value is assigned 5; if r ∈ [k2, ak2), then the blood test item is on the high side and its value is assigned 4; if r ∈ [k1, k2), then the blood test item is normal and its value is assigned 3; if r ∈ [bk1, k1), then the blood test item is on the low side and its value is assigned 2; if r ∈ [0, bk1), then the blood test item is too low and its value is assigned 1. Here, a > 1, 0 < b < 1 and both a and b are constants. In this embodiment, a = 1.2 and b = 0.8.
[0070] In this embodiment, taking the blood test item of immunoglobulin G as an example, its reference range is (7.0 - 17.0) g / L. Therefore, the ranges of too high, on the high side, normal, on the low side, and too low for this blood test item are: [20.4, +∞), [17, 20.4), [7, 17), [5.6, 7), [0, 5.6), respectively, and the assignment is carried out according to the above process.
[0071] 3) For a blood test item with a reference value in multiple interval ranges, including the normal range K, the low range K L , the high range K H , let the actual value be r. If r is higher than the high range K H , then the blood test item is too high and its value is assigned 5; if r ∈ K H , then the blood test item is on the high side and its value is assigned 4; if r ∈ K, then the blood test item is normal and its value is assigned 3; if r ∈ K L , then the blood test item is on the low side and its value is assigned 2; if r is lower than the low range K L , then the blood test item is too low and its value is assigned 1.
[0072] In this embodiment, taking the blood test item of homocysteine as an example, its normal range is (5 - 15) μmol / L, the high range is (15 - 30) μmol / L, and the low range is (0 - 5) μmol / L. Since the low range includes 0 μmol / L, there is no need to set a too low range. Therefore, the ranges of too high, on the high side, normal, and on the low side for this blood test item are: [30, +∞), [15, 30), [5, 15), [0, 5), respectively, and the assignment is carried out according to the above process.
[0073] Step 23: After data discretization, the discrete sample X ∈ R g x m :
[0074]
[0075] Wherein, column vector q is a single blood test item containing all discretized samples, m is the total number of blood test items contained in a single sample, row vector p is a single discretized sample containing all blood test items, g is the total number of discretized samples, and x is ij is the value of the jth blood test item in the i-th sample. In this embodiment, m=81, g=578.
[0076] For each discretized sample data p i The number of missing values N for each blood test item i Perform statistics and delete N i >T samples, and then each blood test item q j The assignment in is counted to obtain each blood test item q j The discrete number I used for the most assignments j , will I j Fill in q j All missing values in ; where T is the missing value number threshold, I j =1, 2, 3, 4, 5. In this embodiment, T=24, and the number of valid samples after missing value processing is 515.
[0077] Step 3: Perform correlation analysis on the preprocessed sample data and drug use. Suppose the preprocessed sample is X∈R h x m , h is the number of valid samples after preprocessing, which is 515 in total in this embodiment. ij As the independent variable, drug use is the dependent variable Y, Y is 1 or 0, 1 represents drug use, 0 represents non-drug use, calculate the Pearson correlation coefficient ρ j , and its calculation formula is as follows:
[0078] ρ j = Cov(q j ,Y) / σ qj σ y
[0079] In the formula, j = 1, 2, 3, ..., m, m is the total number of blood test items for a single sample, a total of 81 items, q j is the pre-processed sample data contained in the j-th blood test item, Cov(q j ,Y) is q j Covariance with Y, σ qj Q j The standard deviation, σ y is the standard deviation of Y;
[0080] In removing |ρj |≤ρ th After the blood test items are collected, the blood test items with strong correlation are obtained. In this embodiment, 15 blood test items such as retinol binding protein, folic acid, β-hydroxybutyric acid, serum cystatin C, etc. have strong correlations. They are made into a data set with the classification labels of drug abuse, and the samples in the data set are divided into a training set and a test set at a ratio of 8 to 2. Among them, ρ th is the set correlation threshold. In this embodiment, ρ th =0.25.
[0081] In this embodiment, the results of partial correlation analysis are as follows: Figure 3 As shown, it can be seen that the blood test items with absolute values of correlation coefficients greater than 0.25 include Cl (chloride), Folate (folic acid), RBP (retinol binding protein), eGFR (glomerular filtration rate), Na (sodium), HBA (β-hydroxybutyrate), NRBC (absolute value of nucleated red blood cells), NRBC% (percentage of nucleated red blood cells), ALB (albumin), VitB12 (vitamin B12), UA (uric acid), Zn (zinc), CYSC (serum cystatin C), CHOL (total cholesterol), and PLT (platelets).
[0082] Step 4: Use the random forest machine learning model based on Gini impurity to classify and train and test the blood test item data set. The specific steps are as follows:
[0083] Step 41: Set the number of random forest decision trees to t, the minimum number of samples of decision tree leaf nodes to f, the maximum depth of the decision tree to d, and use {t, f, d} to form the random forest parameter space. Use Gini impurity as the splitting criterion for each node of the decision tree.
[0084] like Figure 4 The figure shows a schematic diagram of the splitting of the nodes of a random forest decision tree. Since each node in the decision tree needs to perform binary splitting on the samples therein according to the optimal splitting feature of the node, and obtain two leaf nodes of drug abuse and non-drug abuse after multiple splits, the leaf node where the sample is located is the prediction result of the decision tree. Therefore, for the large-scale decision tree containing a large number of blood features in this embodiment, Gini impurity is used to perform split feature screening calculation to improve its efficiency.
[0085] Figure 4 In the example, let the Gini impurity of node A before splitting be Gini(A):
[0086]
[0087] Wherein, c is the total number of categories, which is 2 in this embodiment, and P iis the probability that the sample in node A belongs to the i-th category, that is, the probability of drug abuse or non-drug abuse;
[0088] Select each feature in turn to split the A node, and calculate the sum of the Gini impurities of the two child nodes A1 and A2 after the split (Gini(A ∑ ), and select the Gini impurity reduction Gini(A Δ )The largest feature is used as the split feature of the node.
[0089]
[0090]
[0091] Gini(A) Δ =Gini(A)-Gini(A ∑ )
[0092] In the formula, Gini(A j ) is the Gini impurity of each child node in node A, A j is the left or right child node after the split of node A, P ij For node A j The probability that a sample belongs to the i-th class, w j is the proportion of the corresponding samples in the two child nodes in node A.
[0093] Step 42: Use k-fold cross validation to tune the random forest parameters, specifically:
[0094] Step 421: Divide the blood test data set into k parts, randomly select one of them as a test set, and use the remaining k-1 parts as training sets, and calculate the mean square error MSE1 of the model on the test set;
[0095] Step 422: Select one of the k data sets as the test set without duplication, and the remaining k-1 sets as the training set, and repeat step 421 to obtain the mean square error (MSE) of k experiments. i , i = 1, 2, ..., k, and the k-fold cross validation error CV is obtained by averaging according to the following formula;
[0096]
[0097] Step 423: Randomly select n sets of parameters {t j ,f j ,d j}, j = 1, 2, ..., n, repeat step 422 and calculate the k-fold cross validation error CV of each group of parameters j , the smaller the k-fold cross-validation error is, the more suitable the set of parameters is for the blood dataset.
[0098] In this embodiment, k=10, n=16 are selected, and by comparing the k-fold cross-validation errors of each group of parameter experiments, t=500, f=5, d=4 are finally selected as the training parameters of the random forest machine learning algorithm.
[0099] Step 43: Use the random forest machine learning algorithm with optimized parameters to train on the blood test item training set to obtain the final prediction model.
[0100] Step 5: Use the trained random forest drug abuse prediction model to predict drug abuse status of suspected drug users. In this embodiment, the prediction accuracy rate reaches 86.88%.
[0101] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A drug abuse prediction method based on machine learning, characterized in that: Including the following steps: Step 1: Conduct examinations including multiple blood test items on a group of drug addicts and non-drug addicts respectively, and collect original sample data with balanced positive and negative sample quantities; Step 2: Preprocess the original sample data, including outlier processing based on central tendency analysis, data discretization processing, and missing value processing based on mode filling; Step 3: Conduct a correlation analysis between the preprocessed sample data and the drug use situation. After removing irrelevant blood test items, obtain blood test item sample data with strong correlation and create a data set; Step 4: Use a random forest machine learning model based on Gini impurity to classify and train the blood test item data set and conduct tests to obtain a trained random forest classification model; Step 5: Use the random forest classification model to predict the drug use situation of the sample to be tested; In step 2, the outlier processing based on central tendency analysis is specifically performed on the original sample data as follows: Assume that the original sample data is X∈R n x m ; Where, column vector λ is a single blood test item containing all samples, x ij is the value of the jth blood test item in the i-th sample, n is the total number of samples, and m is the total number of blood test items contained in a single sample; j Each sample value x in ij Sort from small to large; take the values at 25% and 75% as the first quartile point and the third quartile point, and calculate the upper limit UIF of each blood test item based on the first quartile point and the third quartile point j and lower limit LIF j , the calculation formula is as follows: UIF j =Q j3 +1.5(Q j3 -Q j1 ) LIF j =Q j3 -1.5(Q j3 -Q j1 ) In the formula, Q j1 is the first quartile point, Q j3 is the third quartile point, j=1,2,3,…,m; then compare the value of each blood test item in each sample with the upper limit and lower limit of the corresponding blood test item. If there is a value higher than the upper limit or lower than the lower limit in the sample, it is necessary to judge and process the abnormal value in combination with the reference value type of the blood test item corresponding to the value, which is specifically divided into the following two cases: 1) If the reference value of the item corresponding to the value is a single value, it is determined to be a normal value and the value is retained; 2) If the reference value of the item corresponding to the value is a single interval range or multiple interval ranges, it is determined to be an abnormal value and the sample is deleted from the original sample data.
2. The drug abuse prediction method based on machine learning according to claim 1, characterized in that: In the said Step 2, the data discretization processing is specifically as follows: Process the sample data after outlier processing according to the reference value types of each blood test item: 1) For a blood test item with a single reference value, let the reference value be k and the actual value be r. If r = k, then this blood test item is normal and its value is assigned 3; otherwise, this blood test item is abnormal and its value is assigned 5; 2) For a blood test item with a single interval range as the reference value, let the reference interval be (k1, k2) and the actual value be r; if r ∈ [ak2, +∞), then this blood test item is too high and its value is assigned 5; if r ∈ [k2, ak2), then this blood test item is on the high side and its value is assigned 4; if r ∈ [k1, k2), then this blood test item is normal and its value is assigned 3; If r ∈ [bk1, k1), then this blood test item is on the low side and its value is assigned 2; if r ∈ [0, bk1), then this blood test item is too low and its value is assigned 1; where a > 1, 0 < b < 1 and both a and b are constants; 3) The reference values of blood test items are in multiple intervals, including normal range K, low range K L , high range K H , assuming the actual value is r, if r is higher than the high range K H , then the blood test item is too high and its value is assigned to 5; if r∈K H , then the blood test item is high, and its value is assigned to 4; if r∈K, then the blood test item is normal, and its value is assigned to 3; if r∈K L , then the blood test item is low, and its value is assigned to 2; if r is lower than the low range K L , then the blood test item is too low and its value is assigned to 1.
3. The drug abuse prediction method based on machine learning according to claim 1, characterized in that: In step 2, the missing value processing based on mode filling is specifically as follows: let the sample data after data discretization be X∈R g x m : Wherein, column vector q is a single blood test item containing all discretized samples, m is the total number of blood test items contained in a single sample, row vector p is a single discretized sample containing all blood test items, g is the total number of discretized samples, and x ij is the value of the jth blood test item in the i-th sample; For each discretized sample data p i The number of missing values N for each blood test item i Perform statistics and delete N i >T samples, and then each blood test item q j The assignment in is counted to obtain each blood test item q j The discrete number I used for the most assignments j , will I j Fill in q j All missing values in ; where T is the missing value number threshold, I j =1,2,3,4,5.
4. The drug abuse prediction method based on machine learning according to claim 1, characterized in that: In step 3, the correlation analysis and data set preparation are specifically as follows: Let the preprocessed sample be X∈R hxm , h is the number of valid samples after preprocessing, and each data x ij As the independent variable, drug use as the dependent variable Y, Y is 1 or 0, calculate the Pearson correlation coefficient ρ j , and its calculation formula is as follows: r j =Cov(q j ,Y) / s qj s y In the formula, j = 1, 2, 3, ..., m, m is the total number of blood test items for a single sample, q j is the pre-processed sample data contained in the j-th blood test item, Cov(q j ,Y) is q j Covariance with Y, σ qj for q j The standard deviation, σ y is the standard deviation of Y; j |≥ρ th The blood test items and drug abuse classification labels are made into a data set, and the samples in the data set are divided into a training set and a test set according to the proportion; where ρ th is the set correlation threshold.
5. The drug abuse prediction method based on machine learning according to claim 1, characterized in that: In the said Step 4, the random forest machine learning model based on Gini impurity is specifically as follows: Step 41: Set the number of random forest decision trees as t, the minimum number of samples in the leaf nodes of the decision tree as f, and the maximum depth of the decision tree as d. Use {t, f, d} to form the random forest parameter space, and use Gini impurity as the splitting criterion for each node of the decision tree; Step 42: Divide the blood test data set into k equal parts, randomly take one part as the test set, and the remaining k - 1 parts as the training set, and calculate the mean squared error MSE1 of this model on the test set; Step 43: Select one of the k data sets as the test set without duplication, and the remaining k-1 sets as the training set, and repeat step 42 to obtain the mean square error (MSE) of k experiments. i , i = 1, 2, 3...k, and the k-fold cross validation error CV is obtained by averaging according to the following formula; Step 44: Randomly select n sets of parameters {t j ,f j ,d j }, repeat step 43 and calculate the k-fold cross validation error CV for each group of parameters j , where j = 1, 2, ..., n; Step 45: Use the random forest classification model and apply a set of parameters corresponding to the minimum k-fold cross-validation error to train the blood test item training set.
6. The drug abuse prediction method based on machine learning according to claim 5, characterized in that: In the said Step 41, the splitting of each node of the decision tree is implemented according to the following steps: Step 411: Calculate the Gini impurity Gini(A) before the split of node A; In the formula, c is the total number of categories, P i is the probability that the sample in node A belongs to the i-th class; Step 412: Select each feature in turn for splitting and calculate the sum of the Gini impurities of the two child nodes after the split (Gini(A ∑ ); In the formula, Gini(A j ) is the Gini impurity of each child node in node A, A j is the left or right child node after the split of node A, P ij For node A j The probability that a sample belongs to the i-th class, w j is the proportion of the corresponding individuals or groups in the two child nodes in the total (node A); Step 413: Select the Gini impurity reduction Gini (A Δ )The largest feature is used as the split feature of the node; Gini(A) Δ =Gini(A)-Gini(A ∑ )。
