Insomnia typing device
By using a two-stage classification model, combined with data preprocessing and feature selection, the problem of low accuracy in traditional insomnia classification methods is solved, achieving higher classification accuracy and model stability.
Patent Information
- Application Number
- CN202511699110.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-19
- Publication Date
- 2026-02-17
AI Technical Summary
Traditional methods of classifying insomnia rely on human experience and subjective judgment, resulting in low accuracy.
A two-stage classification model was adopted. First, it was determined whether the patient had primary insomnia. Then, non-primary insomnia was further subdivided. The classification model was constructed using XGBoost, and the accuracy of the model was improved through data preprocessing and feature selection.
It improved the accuracy of insomnia classification, reduced model complexity and misclassification rate, and enhanced generalization ability.
Smart Images

Figure CN121545768A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, in particular to an insomnia typing device. BACKGROUND
[0002] Insomnia is a subjective experience, which is manifested as dissatisfaction with sleep time and / or sleep quality in the presence of appropriate sleep opportunities and sleep environment, and this state of dissatisfaction has affected daytime social function. Common types of insomnia include primary insomnia, depressive insomnia, anxiety insomnia, and insomnia related to somatic diseases, etc.
[0003] However, the traditional insomnia typing method mainly relies on artificial experience and subjective judgment to determine the specific type of insomnia. This method has obvious limitations, because the standards followed by different personnel in judgment may not be consistent, resulting in low accuracy of typing. SUMMARY
[0004] Therefore, the purpose of the present application is to provide an insomnia typing device, which can be divided into two stages to improve the accuracy of typing.
[0005] In a first aspect, the embodiments of the present application provide an insomnia typing device, which comprises a processor, a storage medium and a bus, the storage medium stores machine readable instructions executable by the processor, and when the device is running, the processor and the storage medium communicate through the bus, and the processor is used to execute the following steps: Obtain insomnia feature data of a target patient in each first insomnia feature dimension; Input the insomnia feature data into a first insomnia typing module in a two-stage classification model to obtain an initial typing result of the target patient; the first insomnia typing module is used to determine whether the target patient is primary insomnia; If the initial typing result is non-primary insomnia, input the insomnia feature data into a second insomnia typing module in the two-stage classification model to obtain a target typing result of the target patient; the second insomnia typing module is used to determine the insomnia type to which the target patient belongs from other insomnia types except primary insomnia.
[0006] In a possible implementation, the processor is used to train the two-stage classification model by the following steps: Obtain patient sample data in each second insomnia feature dimension and the insomnia type corresponding to the patient sample data; Use the patient sample data as samples and the insomnia type as labels to train the two-stage classification model.
[0007] In one possible implementation, when the processor performs the acquisition of patient sample data under each of the second insomnia feature dimensions, it performs the following steps: Acquire initial patient sample data under multiple second insomnia feature dimensions, and the insomnia type corresponding to the initial patient sample data; Noisy and boundary samples are removed from the initial patient sample data to obtain intermediate patient sample data; The number of samples for each type of insomnia in the intermediate patient sample data is balanced to obtain the final patient sample data.
[0008] In one possible implementation, when the processor performs the process of deleting noisy and boundary samples from the initial patient sample data to obtain intermediate patient sample data, it performs the following steps: Calculate the distance between every two initial patient sample data; For each initial patient sample data, the nearest neighbor initial patient sample data whose distance from the initial patient sample data is less than a preset distance threshold is determined according to a preset number; Count the number of the first samples of the nearest neighbor initial patient sample data that have a different insomnia type from the initial patient sample data; If the number of the first samples is greater than a preset sample number threshold, the initial patient sample data will be deleted.
[0009] In one possible implementation, when the processor performs the process of balancing the number of samples for each type of insomnia in the intermediate patient sample data to obtain the final patient sample data, it performs the following steps: The number of second samples for each type of insomnia was counted from the intermediate patient sample data; For insomnia types where the number of second samples is less than the maximum number of second samples among all insomnia types, interpolation is performed between any two intermediate patient sample data for the insomnia type to generate new intermediate patient sample data, so that the difference between the number of intermediate patient sample data for the insomnia type and the maximum value satisfies a preset difference condition. All intermediate patient sample data obtained after generation will be used as the final patient sample data.
[0010] In one possible implementation, when the processor trains the two-stage classification model using patient sample data as samples and insomnia type as labels, it performs the following steps: Each patient sample data is input into the two-stage classification model to obtain the predicted typing results; The two-stage classification model is trained based on all patient sample data, the insomnia type labels corresponding to each patient sample data, the predicted classification results corresponding to each patient sample data, and the type balance weights corresponding to each patient sample data; the type balance weights are used to balance the attention of the two-stage classification model to samples of each insomnia type.
[0011] In one possible implementation, the processor is configured to determine the type balance weights corresponding to each first patient sample data through the following steps; For any type of insomnia, the number of patient sample data for that type of insomnia is counted to obtain a first value; Calculate the product of the first value and the total number of all types of insomnia to obtain the second value; The ratio between the number of all patient sample data and the second value is determined as the type balance weight corresponding to the patient sample data of the insomnia type.
[0012] In one possible implementation, the processor is configured to determine the first insomnia feature dimension through the following steps: Based on the importance index values corresponding to each second insomnia feature dimension, the first insomnia feature dimension is selected; the importance index value corresponding to each second insomnia feature dimension is used to characterize the importance of the second insomnia feature dimension when the two-stage classification model performs insomnia classification.
[0013] In one possible implementation, the processor is configured to determine the second insomnia feature dimension through the following steps: Based on the correlation index between each preset insomnia feature dimension and insomnia type, a second insomnia feature dimension is selected from all preset insomnia feature dimensions.
[0014] Secondly, embodiments of this application also provide a computer-readable storage medium storing a computer program, the computer program being executed by a processor as described in the first aspect to perform the steps executed by the processor.
[0015] This application provides an insomnia typing device, comprising a processor, a storage medium, and a bus. The storage medium stores machine-readable instructions executable by the processor. When the device is running, the processor communicates with the storage medium via the bus. The processor performs the following steps: inputting insomnia feature data into a first insomnia typing module in a two-stage classification model to obtain an initial typing result for the target patient; the first insomnia typing module determines whether the target patient has primary insomnia; if the initial typing result is non-primary insomnia, the insomnia feature data is input into a second insomnia typing module in the two-stage classification model to obtain a target typing result for the target patient; the second insomnia typing module determines the insomnia type of the target patient from other insomnia types besides primary insomnia. This application enables insomnia typing in two stages, improving typing accuracy. Attached Figure Description
[0016] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This diagram illustrates a structural diagram of an insomnia classification device provided in an embodiment of this application; Figure 2 The following is a flowchart illustrating the execution process of the processor provided in an embodiment of this application; Figure 3 The flowchart of training a two-stage classification model provided in an embodiment of this application is shown; Figure 4 This paper illustrates the category distribution of the sampled training set data provided in an embodiment of this application. Figure 5 This illustration shows a confusion matrix diagram of the first insomnia classification module provided in an embodiment of this application; Figure 6 This illustration shows a confusion matrix diagram of the second insomnia classification module provided in an embodiment of this application; Figure 7 A schematic diagram illustrating the importance of the various features provided in the embodiments of this application is shown; Figure 8 This paper illustrates a confusion matrix diagram of the two-stage classification model provided in an embodiment of this application. Figure 9 This paper shows a schematic diagram of the ROC curve of the two-stage classification model provided in the embodiments of this application; Figure 10This paper shows a schematic diagram of the PR curve of the two-stage classification model provided in the embodiments of this application; Figure 11 This diagram illustrates the average absolute value of the SHAP values of the first insomnia classification module provided in this embodiment of the application. Figure 12 This paper shows an interpretation diagram of the SHAP values of a single sample from the first insomnia classification module provided in an embodiment of this application; Figure 13 This diagram illustrates the average absolute value of the SHAP values of the second insomnia classification module provided in this embodiment of the application. Figure 14 This paper illustrates the SHAP value interpretation diagram of a single sample from the second insomnia subtyping module provided in an embodiment of this application. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.
[0019] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0020] To enable those skilled in the art to utilize the content of this application, and in conjunction with the specific application scenario of "data processing technology," the following embodiments are provided. For those skilled in the art, the general principles defined herein can be applied to other embodiments and application scenarios without departing from the spirit and scope of this application. Although this application is primarily described within the "data processing technology field," it should be understood that this is merely an exemplary embodiment.
[0021] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.
[0022] Reference Figure 1 The diagram shown is a structural diagram of an insomnia classification device 100 provided in an embodiment of this application. It includes a processor 101, a storage medium (i.e., a memory 102), and a bus. The storage medium stores machine-readable instructions executable by the processor 101. When the device is running, the processor 101 communicates with the memory 102 via the bus. The processor 101 is used to perform the following steps: Reference Figure 2 The following is a flowchart illustrating the execution process of the processor provided in an embodiment of this application: S201. Obtain insomnia characteristic data of the target patient under each of the first insomnia characteristic dimensions.
[0023] In this application's implementation, the first insomnia feature dimension is an insomnia feature dimension used to classify insomnia in target patients in practical applications. The insomnia feature dimension refers to a feature dimension related to insomnia classification. Insomnia types include primary insomnia, depressive insomnia, anxiety insomnia, etc. The insomnia feature data includes data of the target patient under the first insomnia feature dimension. After the user clicks the "Predict" button, the insomnia feature data of the target patient under each of the first insomnia feature dimensions is obtained.
[0024] Primary insomnia refers to insomnia without a clear organic or psychological cause. Depressive insomnia is one of the core symptoms of depression, caused directly by depressive mood. Anxiety-related insomnia is caused by anxiety or anxiety disorder, with anxiety being the core trigger.
[0025] In addition, the first dimension of insomnia characteristics includes, but is not limited to, mental health (MH), Insomnia Severity Index (ISI) score, systolic blood pressure, Snyder-Hamilton Pleasure Scale (SHAPS) (psychological assessment) total score, physiological function (PF), diastolic blood pressure, total physical health measurement (PCS), Sleep Personal Beliefs and Attitudes Scale (DBAS) total score, general health status (GH), energy (VT), White Index score, Health Questionnaire-15 (PHQ-15) (psychological assessment) total score, respiration (breaths / min), age, and body mass index.
[0026] S202. Input the insomnia characteristic data into the first insomnia classification module to obtain the initial classification result of the target patient; the first insomnia classification module is used to determine whether the target patient has primary insomnia.
[0027] In this embodiment, the first insomnia classification module is used to perform a first-stage insomnia classification on the target patient, i.e., to determine whether the target patient has primary insomnia. The initial classification result includes two categories: primary insomnia and non-primary insomnia. If the initial classification result is primary insomnia, then the target patient has primary insomnia, and there is no need to perform the next stage of insomnia classification.
[0028] S203. If the initial classification result is non-primary insomnia, then the insomnia characteristic data is input into the second insomnia classification module to obtain the target classification result of the target patient; the second insomnia classification module is used to determine the insomnia type to which the target patient belongs from other insomnia types besides primary insomnia.
[0029] In this embodiment, if the initial classification result is non-primary insomnia, it indicates that the target patient does not have primary insomnia. However, to determine the specific type of insomnia, a second-stage insomnia classification is required. Therefore, insomnia characteristic data is input into the second insomnia classification module to obtain the target classification result for the target patient. The target classification result is any type of insomnia other than primary insomnia.
[0030] Other types of insomnia besides primary insomnia include, but are not limited to, depressive insomnia and anxiety insomnia.
[0031] Here, the embodiments of this application, by combining the first insomnia classification module and the second insomnia classification module to obtain a two-stage classification model, can effectively solve the misclassification problem caused by the excessive number of insomnia categories and unclear category boundaries in existing single classifiers, mainly based on the following core mechanisms: 1. The problem of category space decomposition and simplification: When the number of categories is too large, directly using a single classifier requires learning a highly complex decision boundary, where the distinguishing features between categories may be very subtle or overlapping, leading to overfitting or underfitting of the model and increasing the risk of misclassification. This application's embodiment offers a two-stage solution: Stage 1 (coarse classification): The original large number of insomnia categories are summarized into broad categories such as "primary insomnia" and "non-primary insomnia." This significantly reduces the number of categories, allowing the first insomnia subtyping module to focus on learning the macroscopic feature differences between broad categories, whose boundaries are usually clearer and easier to learn. Stage 2 (fine classification): Within each coarse-grained broad category (i.e., non-primary insomnia), an independent classifier is used to distinguish fine-grained categories. Since the fine classifier only processes categories within a subset, the number of categories is reduced, the decision boundary is relatively simple, and the model can learn local features within the subset more precisely. Technical impact: This decomposition reduces the overall complexity of the model, reduces the parameter search space, makes the training process more stable, and improves generalization ability.
[0032] 2. Optimization of Hierarchical Decision Boundaries: When class boundaries are unclear, a single classifier may fail to accurately capture subtle differences across all classes, especially in regions with significant feature space overlap. Two-stage solution: Stage 1: Learn decision boundaries between major classes (i.e., non-primary insomnia). These boundaries are typically based on more salient and stable features, resulting in clearer boundaries and lower misclassification rates. Stage 2: Within each major class (i.e., non-primary insomnia), a finer classifier (i.e., a second insomnia subtyping module) can focus on learning local features that are more discriminative within the major class. Because the differences between classes within a major class are smaller, the finer classifier can capture subtle patterns using a more complex model without being affected by other major classes. Technical impact: Hierarchical decision-making allows the model to use different feature representations and classification strategies at different levels, thus more effectively handling the problem of ambiguous boundaries.
[0033] Furthermore, the two-stage classification model is trained based on patient sample data under each second insomnia feature dimension, and the insomnia type corresponding to the two-stage classification model and the patient sample data. The two-stage classification model is either the first insomnia classification module or the second insomnia classification module. The insomnia type corresponding to the first insomnia classification module is primary insomnia or non-primary insomnia. The insomnia type corresponding to the second insomnia classification module is any insomnia type other than primary insomnia. This application embodiment obtains the two-stage classification model through multiple steps, including data collection, data preprocessing, model construction, and model training. Specifically: Step 1: Determine the source of the research subjects.
[0034] The research subjects in this application embodiment are derived from four visit questionnaires of real insomnia patients.
[0035] Step 2: Data collection.
[0036] (1) Using structured query language (SQL), demographic information, vital signs, lifestyle and medical history, family medical history, routine physical examination records, sleep quality scale results, life health scale results, mental and psychological assessment results, life event scale results, and mental and psychological assessment results of insomnia patients were extracted from the hospital database. A total of 2,607 samples were collected (including 2,149 patients with primary insomnia, 105 patients with anxiety insomnia, and 353 patients with depressive insomnia), with a total of 67 characteristics.
[0037] (2) Demographic characteristics information: including the patient’s name, gender, age, contact information, address and other basic demographic information.
[0038] (3) Vital signs: including the patient's heart rate, pulse, diastolic blood pressure, systolic blood pressure, BMI, height, weight, etc.
[0039] (4) Lifestyle and medical history: including exercise, sleep, history of diabetes, history of hypertension, history of coronary heart disease, drug allergy, history of drug abuse or dependence, etc.
[0040] (5) Family medical history: Whether any other relatives have been diagnosed with insomnia or related diseases by doctors.
[0041] Routine physical examination record form: including whether the skin, heart, lungs, chest, etc. are normal.
[0042] (6) Sleep quality scales: Sleep Personal Beliefs and Attitudes Scale (DBAS) and Epworth Sleepiness Scale (ESS).
[0043] (7) Life and Health Scales: including physiological function, physiological function (RP), bodily pain (BP), general health status (GH), energy (VT), social function (SF), emotional function (RE), mental health (MH), total physical health measurement (PCS), total mental health measurement (MCS), and Health Questionnaire-15 (PHQ-15), etc.
[0044] (8) Psychological assessment results: Health Questionnaire-9 (PHQ-9), Self-Assessment Scale for Cognitive Deficits-5 (PDQ-D-5), Visual Digit Rating for Pain, Whiteley Index (WI), Snaith-Hamilton Pleasure Scale (SHAPS), Diagnostic Scale for Drug Dependence (SCID-DD), Generalized Anxiety Disorder Scale (GAD-7).
[0045] Step 3: Data preprocessing.
[0046] (1) Data cleaning: Remove features with a missing value ratio of more than 30%; handle erroneous values of some features such as systolic blood pressure and diastolic blood pressure; use isolated forest to identify outliers.
[0047] (2) Categorical variables are labeled or one-hot encoded.
[0048] (3) Treat outliers under each feature as null values.
[0049] (4) Use Impute.SimpleImputer in the preprocessing module of the Python machine learning library Sklearn to fill in the missing values with the median.
[0050] Step 4: Model Building.
[0051] In this embodiment, because XGBoost possesses characteristics such as high computational efficiency, strong resistance to overfitting, feature interaction capture, and handling of class imbalance, two binary classification models are constructed based on XGBoost: a first insomnia classification module and a second insomnia classification module, resulting in a two-stage classification model. The first insomnia classification module is used for the first stage of insomnia classification, i.e., determining whether the target patient has primary insomnia. The second insomnia classification module is used for the second stage of insomnia classification, i.e., classifying other types of insomnia besides primary insomnia.
[0052] Step 5: Model Training. (Refer to...) Figure 3 The diagram shown is a flowchart of training a two-stage classification model provided in an embodiment of this application: S301. Obtain patient sample data under each of the second insomnia feature dimensions, and the insomnia type corresponding to the patient sample data.
[0053] In this embodiment, the second insomnia feature dimension refers to the insomnia feature dimension corresponding to the patient sample data used to train the two-stage classification model. Here, the insomnia type corresponding to the patient sample data includes the insomnia type corresponding to the first insomnia classification module and the insomnia type corresponding to the second insomnia classification module. For the first insomnia classification module, the patient sample data is reconstructed and encoded, and the corresponding insomnia type is marked as 0 or 1, where 0 represents primary insomnia and 1 represents non-primary insomnia (complex insomnia, referring to depressive insomnia, anxiety insomnia, physical illness-related insomnia, etc.). For the second insomnia classification module, the patient sample data is reconstructed and encoded, and the corresponding insomnia type is marked as a numerical code such as 0, 1, 2, or 3, where each numerical code represents a non-primary insomnia (such as complex insomnia, referring to depressive insomnia, anxiety insomnia, or physical illness-related insomnia, etc.).
[0054] Furthermore, data analysis revealed a significant class imbalance in the insomnia classification of the samples, with class 0 samples (primary insomnia) accounting for a significantly higher proportion than non-class 0 samples (anxiety-related insomnia, depressive insomnia, etc.). Due to the uneven data distribution and ambiguous class boundaries, the model tends to misclassify a large number of samples that are actually non-class 0 as class 0.
[0055] In this embodiment, to address the class imbalance problem in the data, the SMOTEENN hybrid sampling technique is first applied, combining the advantages of SMOTE oversampling and ENN undersampling. This method both expands the data scale by synthesizing minority class samples through interpolation and removes boundary noise samples to maintain the rationality of the data distribution. Figure 4 The image shown is a distribution diagram of the categories of the sampled training set data provided in an embodiment of this application.
[0056] Specifically, when the processor acquires patient sample data for each of the second insomnia feature dimensions, it performs the following steps: Step 1: Obtain initial patient sample data under multiple second insomnia feature dimensions, and the insomnia type corresponding to the initial patient sample data.
[0057] In this embodiment, based on the preprocessing of the data, and combined with data characteristics and prior knowledge, features with low relevance to insomnia and redundant features, such as ethnicity, religion, monthly income level, and some physical examination details, are removed, retaining a total of 32 features. Specifically, the dimensions of the data obtained after preprocessing (i.e., the names of each data item in the data collection step, such as name, gender, pulse, etc.) are the preset insomnia feature dimensions. Before model construction and training, a second insomnia feature dimension needs to be selected from all preset insomnia feature dimensions based on the correlation index between each preset insomnia feature dimension and the insomnia type. Then, based on each second insomnia feature dimension, the corresponding initial patient sample data is extracted from each preprocessed data. Each initial patient sample data includes the feature values of the corresponding preprocessed data under each second insomnia feature dimension.
[0058] Here, the correlation index between each preset insomnia feature dimension and insomnia type is obtained using Pearson correlation analysis. Pearson correlation analysis is a statistical method used to measure the strength and direction of the linear relationship between preset insomnia feature dimensions and insomnia types. Specifically, based on the preprocessed data and the corresponding insomnia types of patients, the Pearson correlation coefficient between each preset insomnia feature dimension and insomnia type is calculated, yielding the correlation index between each preset insomnia feature dimension and insomnia type. Furthermore, based on the correlation index between each preset insomnia feature dimension and insomnia type, a second insomnia feature dimension is selected from all preset insomnia feature dimensions, including selecting the preset dimensions with the highest correlation index as the second insomnia feature dimension. The number of preset dimensions can be 32.
[0059] Step 2: Delete noisy samples and boundary samples from the initial patient sample data to obtain intermediate patient sample data.
[0060] In this embodiment, the advantage of ENN undersampling is applied to address the class imbalance problem in the data. Noisy and boundary samples are removed based on the nearest neighbor rule. For each sample, if most of its nearest neighbors belong to other classes, it is considered noise or an outlier and removed. This helps to clarify class boundaries and avoid overfitting. The specific process is as follows: i. Calculate the distance between every two initial patient sample data.
[0061] In this embodiment, one of the two initial patient sample data is referred to as the first initial patient sample data, and the other initial patient sample data is referred to as the second initial patient sample data. Specifically, the Euclidean distance between the numerical data in the first initial patient sample data and the numerical data in the second initial patient sample data is calculated to obtain the first distance; the cosine similarity between the textual data in the first initial patient sample data and the textual data in the second initial patient sample data is calculated to obtain the second distance; the average of the first distance and the second distance is determined as the distance between the first initial patient sample data and the second initial patient sample data.
[0062] ii. For each initial patient sample data, determine a preset number of nearest neighbor initial patient sample data whose distance from the initial patient sample data is less than a preset distance threshold, based on a preset number.
[0063] In this embodiment, other initial patient sample data whose distance from the initial patient sample data is less than a preset distance threshold are determined as initial nearest neighbor initial patient sample data. If the number of initial nearest neighbor initial patient sample data is greater than the preset number, then the preset number of initial nearest neighbor initial patient sample data closest to the initial patient sample data are used as the final nearest neighbor initial patient sample data. If the number of initial nearest neighbor initial patient sample data is less than or equal to the preset number, then all initial nearest neighbor initial patient sample data are used as the final nearest neighbor initial patient sample data.
[0064] iii. Count the number of first samples of the nearest neighbor initial patient sample data that have different insomnia types from the initial patient sample data.
[0065] In this embodiment of the application, for each initial patient sample data, the number of first samples of the nearest neighbor initial patient sample data that have a different insomnia type from the initial patient sample data is counted.
[0066] iv. If the number of samples exceeds a preset sample number threshold, the initial patient sample data will be deleted.
[0067] In this embodiment, the larger the number of first samples of nearest-neighbor initial patient sample data that differ from the insomnia type of the initial patient sample data, the greater the likelihood that the initial patient sample data is a noise sample or a boundary sample. Therefore, if the number of the first samples exceeds a preset sample number threshold, the initial patient sample data is deleted. After deleting all noise samples or boundary samples, intermediate patient sample data is obtained.
[0068] Step 3: Balance the number of samples for each type of insomnia in the intermediate patient sample data to obtain the final patient sample data.
[0069] In this application's implementation, the advantages of SMOTE oversampling are also applied to address the class imbalance problem in the data. SMOTE increases the number of minority class samples by interpolating between minority class samples to generate new synthetic samples. It selects the k nearest neighbors of a minority class sample, randomly selects one of these neighbors, and generates new samples between them. The specific process is as follows: i. Count the number of second samples for each type of insomnia from the intermediate patient sample data.
[0070] ii. For insomnia types where the number of second samples is less than the maximum number of second samples among all insomnia types, interpolation is performed between any two intermediate patient sample data of the insomnia type to generate new intermediate patient sample data, so that the difference between the number of intermediate patient sample data of the insomnia type and the maximum value satisfies a preset difference condition.
[0071] In this application's implementation, linear interpolation can be used for numerical data. For example, if the body temperature in the first intermediate patient sample is 36 degrees Celsius and the body temperature in the second intermediate patient sample is 38 degrees Celsius, then the body temperature in the new intermediate patient sample will be 37 degrees Celsius. For textual data, semantic gradation can be used, such as by employing a temporal data prediction model based on the temporal Transformer architecture. For instance, if the text data in the first intermediate patient sample is "cough" and the text data in the second intermediate patient sample is "cough + fever", then the text data in the new intermediate patient sample can be "cough + mild fever".
[0072] The preset difference condition can be that the difference between the number of intermediate patient sample data for this type of insomnia and the maximum value is less than a preset difference.
[0073] iii. All intermediate patient sample data obtained after generation will be used as the final patient sample data.
[0074] S302. Using patient sample data as samples and insomnia type as labels, train the two-stage classification model.
[0075] In this embodiment of the application, the data of each patient sample is input into a two-stage classification model to obtain the predicted classification result; the two-stage classification model is trained based on all patient sample data, the insomnia type label corresponding to each patient sample data, the predicted classification result corresponding to each patient sample data, and the type balance weight corresponding to each patient sample data; the type balance weight is used to balance the attention of the two-stage classification model to samples of each insomnia type.
[0076] Here, an inverse proportional weighting strategy is implemented using the `compute_sample_weight` function of Scikit-Learn, assigning higher weights to samples from minority classes to ensure balanced attention to different classes during model training. Specifically, the processor determines the type balance weights corresponding to each first patient sample data through the following steps: For any insomnia type, the number of patient sample data for that insomnia type is counted to obtain a first value. The product of the first value and the total number of all insomnia types is calculated to obtain a second value. The ratio between the number of all patient sample data and the second value is determined as the type balance weight corresponding to the patient sample data for that insomnia type. The formula can be expressed as: ; in, Insomnia type The type balance weights corresponding to the patient sample data The number of patient sample data. The total number of all types of insomnia. It is the first value.
[0077] Here, in this embodiment of the application, 80% of the samples were randomly selected as the training set (2085 training samples, including 1719 cases of primary insomnia, 84 cases of anxiety-related insomnia, and 282 cases of depressive insomnia) to train the model; 20% of the samples were selected as the test set (522 test samples, including 430 cases of primary insomnia, 21 cases of anxiety-related insomnia, and 71 cases of depressive insomnia) to evaluate the performance of the model.
[0078] In the first stage, the original labels are reconstructed and encoded, with category 0 marked as 0 (primary insomnia), and non-category 1 and 2 uniformly marked as 1 (complex insomnia, referring to depressive insomnia, anxiety insomnia, and somatic disease-related insomnia). The model parameters are optimized through grid search, as shown in Table 1, which is the parameter table for the first insomnia classification module provided in this embodiment. The first-stage model is used to classify categories 0 and non-0, referring to... Figure 5 The diagram shown is a confusion matrix diagram of the first insomnia subtyping module provided in an embodiment of this application.
[0079] Table 1
[0080] In the second stage, based on the results of the first stage, the classification of the original labels into categories 0 and non-zero has been completed to reduce misclassification caused by an excessive number of primary insomnia categories and unclear category boundaries. Refer to Table 2, which shows the parameter table of the second insomnia classification module provided in this application embodiment. Anxiety-related insomnia (labeled 0) and depressive insomnia (labeled 1) in the samples are classified, referring to... Figure 6 The diagram shown is a confusion matrix diagram of the second insomnia subtyping module provided in an embodiment of this application.
[0081] Table 2
[0082] In summary, a two-stage modeling approach was used to classify insomnia types such as primary insomnia, anxiety-related insomnia, and depressive insomnia.
[0083] Further, feature selection. After training, the first insomnia feature dimension is selected based on the importance index value corresponding to each second insomnia feature dimension; the importance index value corresponding to each second insomnia feature dimension is used to characterize the importance of the second insomnia feature dimension when the two-stage classification model performs insomnia classification.
[0084] In this embodiment of the application, in order to improve classification efficiency and model accuracy, the first insomnia feature dimension is selected based on the importance index value corresponding to each second insomnia feature dimension.
[0085] Here, selecting the most relevant and influential features from the samples can improve model performance and interpretability while saving storage and computational resources. Features are ranked according to their importance in the XGBoost model, such as... Figure 7 The diagram shown illustrates the importance of various features provided in the embodiments of this application. The 15 selected features include: x57: Mental Health (MH), x67: Insomnia Severity Index (ISI) score, x34: Systolic blood pressure, x64: Snaith-Hamilton Happiness Scale (SHAPS) (psychological assessment) total score, x50: Physical Function (PF), x35: Diastolic blood pressure, x58: Total Physical Health Measurement (PCS), x49: Sleep Personal Beliefs and Attitudes Scale (DBAS) total score, x53: General Health (GH), x54: Energy (VT), x63: White Index score, x60: Health Questionnaire-15 (PHQ-15) (psychological assessment) total score, x32: Breathing (breaths / min), x2: Age, and x5: Body Mass Index.
[0086] Furthermore, internal validation of the model was conducted. Based on the above work, the model's classification performance was further validated on a test set of 522 cases, including 430 cases of primary insomnia, 21 cases of anxiety-related insomnia, and 71 cases of depressive insomnia. Accuracy, precision, recall, and F1 score were used as evaluation metrics for the model. Table 3 shows the results of the test machine model using the two-stage classification model provided in this embodiment on the test set. Figure 8 The diagram shown is a confusion matrix of the two-stage classification model provided in the embodiments of this application.
[0087] .
[0088] .
[0089] .
[0090] .
[0091] in, The number of test samples whose insomnia type was labeled as primary insomnia and whose predicted classification result was primary insomnia. The insomnia type is labeled as a specific type of insomnia other than primary insomnia, and the predicted classification result is also the number of test samples for that insomnia type. The insomnia type is labeled as a type of insomnia other than primary insomnia, and the predicted classification result is the number of test samples with primary insomnia. The insomnia type is labeled as primary insomnia, and the predicted classification result is the number of test samples for a certain insomnia type other than the primary insomnia value.
[0092] Table 3
[0093] Reference Figure 9 The image shows a schematic diagram of the ROC curve of the two-stage classification model provided in this application embodiment. The ROC curve, or Receiver Operating Characteristic curve, is a core visualization tool in classification models for measuring predictive performance. Its core function is to demonstrate the trade-off between the "true positive rate" and the "false positive rate" at different thresholds. (Refer to...) Figure 10 The figure shows a schematic diagram of the PR curve of the two-stage classification model provided in this application. The PR curve, which stands for precision-recall curve, is a core tool for evaluating classification models, especially suitable for imbalanced data (such as a small number of positive samples in medical settings). Its core function is to show the trade-off between "precision" and "recall" at different thresholds.
[0094] As shown in the figure, the AUC values for all insomnia types are ≥0.90, indicating that the model has a strong ability to distinguish these three types. The current curves are significantly better than the diagonal curves, indicating that the model is much better than random guessing. The PR curve is used to evaluate the performance of imbalanced tasks. The AP (mean precision) for all categories is between 0.84 and 0.85, indicating that the model maintains a good balance between precision and recall.
[0095] In summary, the data-augmented two-stage classification model effectively improves the diversity and quality of training data. Compared to the single-stage classification model, it not only significantly alleviates model bias caused by class imbalance but also improves the model's ability to identify minority classes, enhances its generalization performance, and suppresses overfitting. Table 1 shows a comparison of the traditional single-stage model and the two-stage classification model of this application on the test set.
[0096] Table 4
[0097] Experimental results show that the proposed scheme effectively improves the recall rate of the minority class while maintaining the accuracy of majority class recognition, with both reaching over 80%.
[0098] Furthermore, there's the SHAP interpretation of the model. SHAP (SHapley Additive exPlanations) interprets a machine learning model by quantifying the contribution of each feature to the model's predictions. The main advantage of SHAP is that it provides both global and local interpretability. Global interpretations highlight the most influential features in the model's decision-making process. Local interpretations, on the other hand, explain individual predictions by assigning a specific value to each feature, showing the contribution of each feature to the prediction result for a particular instance.
[0099] Reference Figure 11 The diagram shows the average absolute value of the SHAP values for the first insomnia classification module provided in this application. It illustrates the importance of input features to the classification model when determining whether the insomnia is primary or non-primary insomnia in the first stage. The 15 features, ranked from largest to smallest contribution to the model, are: Insomnia Severity Index (ISI) score, Sleep Personal Beliefs and Attitudes Scale (DBAS) total score, Snaith-Hamilton Pleasure Scale (SHAPS) (psychological assessment) total score, Physical Function (PF), Mental Health (MH), Systolic Blood Pressure, Total Physical Health Measurement (PCS), Age, White Index score, Energy (VT), Breathing (breaths / min), General Health Status (GH), Body Mass Index, Health Questionnaire-15 (PHQ-15) (psychological assessment) total score, and Diastolic Blood Pressure.
[0100] Reference Figure 12The figure shows the SHAP value interpretation diagram of a single sample of the first insomnia classification module provided in this application. The single-sample SHAP value interpretation diagram of 15 features is used to explain the source of the predicted value of a sample in the model and the influence of the features on the final model output. Taking the 5th sample in the test set as an example, it can be seen from the figure that the red part represents features such as the Insomnia Severity Index (ISI) score and the total score of the Sleep Personal Beliefs and Attitudes Scale (DBAS) that increase the model output, while the blue part represents features such as the total score of energy (VT) and mental health (MH) that decrease the model output value. This sample is actually a depressive insomnia sample. In the first stage model (first insomnia classification module), it is non-primary insomnia, i.e., a Class 1 sample. A higher Insomnia Severity Index (ISI) score indicates increased insomnia severity, driving the output of non-primary insomnia; a higher energy (VT) score indicates a better mental state, which is generally unfavorable for anxiety / depressive insomnia, thus inhibiting the output of non-primary insomnia.
[0101] Reference Figure 13 The diagram shows the average absolute value of the SHAP values for the second insomnia classification module provided in this application. The average absolute value of the SHAP values demonstrates the importance of the input features to the classification model when determining whether the insomnia is anxiety-related or depressive insomnia in the second stage. The 15 features, ranked from highest to lowest contribution to the model, are: Snaith-Hamilton Pleasure Scale (SHAPS) total score, General Health Status (GH), Total Physical Health Measure (PCS), Health Questionnaire-15 (PHQ-15) total score, Physical Function (PF), Systolic Blood Pressure, Sleep Personal Beliefs and Attitudes Scale (DBAS) total score, Diastolic Blood Pressure, Age, Insomnia Severity Index (ISI) score, Body Mass Index (BMI), Mental Health (MH), White Index score, Energy Level (VT), and Respiration (breaths / min).
[0102] Reference Figure 14 The diagram shows the interpretation of SHAP values for a single sample in the second insomnia classification module provided in this application. Taking the fifth sample in the test set as an example, it is a non-zero sample in the first stage of the model and a class 1 sample in the second stage, representing depressive insomnia. The red part represents features such as the total score of the Snaith-Hamilton Hype Scale (SHAPS) and the total score of the Sleep Personal Beliefs and Attitudes Scale (DBAS), while the blue part represents features such as the total score of the Health Questionnaire-15 (PHQ-15) and the Total Physical Health Measure (PCS). For example, a lower total score of the Health Questionnaire-15 (PHQ-15) indicates the absence of physical symptoms, inhibiting the model's depressive output, while a higher total score of the Snaith-Hamilton Hype Scale (SHAPS) indicates anhedonia, promoting depressive insomnia.
[0103] Furthermore, this application provides an intuitive and structured interface for displaying and inputting characteristic information related to insomnia classification. Data sources include structured electronic questionnaires, clinical interview records, and basic demographic data. Data can be automatically retrieved from hospital information systems (HIS) or electronic medical records (EMR), and doctors are also allowed to manually enter or edit supplementary information to ensure data integrity and timeliness.
[0104] Furthermore, based on the aforementioned two-stage classification model, the system first determines whether the patient has primary insomnia. If not, it further classifies the condition as anxiety-related insomnia or depressive insomnia. After the user clicks the "Predict" button, the two-stage classification model is automatically invoked and the prediction result is returned. The entire process is fast and accurate, helping clinicians to perform preliminary classification of patients during initial consultations and improving clinical efficiency.
[0105] Furthermore, this application's embodiments incorporate current clinical guidelines and expert consensus for insomnia treatment, providing personalized clinical recommendations along with the classification results. These recommendations may include further evaluation, initiation of cognitive behavioral therapy, medication intervention suggestions, or psychological counseling pathways. This module helps standardize the initial diagnosis and treatment process and supports precision treatment for different types of insomnia patients.
[0106] In addition, to facilitate doctors' understanding and communication with patients, this device automatically generates a visual classification prediction report. The report includes: detailed input features, predicted classification category, risk probability for each category, model explanation, and corresponding preliminary treatment suggestions. The report style is concise and clear, suitable for doctors with different backgrounds, and can also be exported as a PDF for medical record management.
[0107] Specifically, the memory 102 and processor 101 described above can be general-purpose memory and processor, without any specific limitations. When the processor 101 runs the computer program stored in the memory 102, it can execute the above process.
[0108] Corresponding to the processor described above, this application embodiment also provides a computer-readable storage medium storing a computer program, which is executed by the processor to perform the above steps.
[0109] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the method embodiments, and will not be repeated here. In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some communication interfaces; the indirect coupling or communication connection of devices or modules can be electrical, mechanical, or other forms.
[0110] The modules described as separate components may or may not be physically separate. The components shown as modules 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.
[0111] In addition, the functional units in the various embodiments of this application 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.
[0112] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes 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 information processing methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.
[0113] The above are merely specific embodiments of this application, but the scope of protection of this application 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 application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. An insomnia classification device, characterized in that, The device includes a processor, a storage medium, and a bus. The storage medium stores machine-readable instructions executable by the processor. When the device is running, the processor communicates with the storage medium via the bus. The processor is used to perform the following steps: Acquire insomnia characteristic data of the target patient under each primary insomnia characteristic dimension; The insomnia feature data is input into the first insomnia classification module of the two-stage classification model to obtain the initial classification result of the target patient; the first insomnia classification module is used to determine whether the target patient has primary insomnia; If the initial classification result is non-primary insomnia, the insomnia feature data is input into the second insomnia classification module in the two-stage classification model to obtain the target classification result of the target patient; the second insomnia classification module is used to determine the insomnia type to which the target patient belongs from other insomnia types besides primary insomnia.
2. The insomnia classification device according to claim 1, characterized in that, The processor is used to train the two-stage classification model through the following steps: Obtain patient sample data under each second insomnia feature dimension, and the insomnia type corresponding to the patient sample data; The patient sample data is used as the sample, and the insomnia type is used as the label to train the two-stage classification model.
3. The insomnia classification device according to claim 2, characterized in that, When the processor acquires patient sample data under each of the second insomnia feature dimensions, it performs the following steps: Acquire initial patient sample data under multiple second insomnia feature dimensions, and the insomnia type corresponding to the initial patient sample data; Noisy and boundary samples are removed from the initial patient sample data to obtain intermediate patient sample data; The number of samples for each type of insomnia in the intermediate patient sample data is balanced to obtain the final patient sample data.
4. The insomnia classification device according to claim 3, characterized in that, When the processor performs the process of deleting noisy and boundary samples from the initial patient sample data to obtain intermediate patient sample data, it performs the following steps: Calculate the distance between every two initial patient sample data; For each initial patient sample data, the nearest neighbor initial patient sample data whose distance from the initial patient sample data is less than a preset distance threshold is determined according to a preset number; Count the number of the first samples of the nearest neighbor initial patient sample data that have a different insomnia type from the initial patient sample data; If the number of the first samples is greater than a preset sample number threshold, the initial patient sample data will be deleted.
5. The insomnia classification device according to claim 3, characterized in that, When the processor performs the process of balancing the number of samples for each type of insomnia in the intermediate patient sample data to obtain the final patient sample data, it performs the following steps: The number of second samples for each type of insomnia was counted from the intermediate patient sample data; For insomnia types where the number of second samples is less than the maximum number of second samples among all insomnia types, interpolation is performed between any two intermediate patient sample data for the insomnia type to generate new intermediate patient sample data, so that the difference between the number of intermediate patient sample data for the insomnia type and the maximum value satisfies a preset difference condition. All intermediate patient sample data obtained after generation will be used as the final patient sample data.
6. The insomnia classification device according to claim 2, characterized in that, When the processor trains a two-stage classification model using the patient sample data as samples and the insomnia type as a label, it performs the following steps: Each patient sample data is input into the two-stage classification model to obtain the predicted typing results; The two-stage classification model is trained based on all patient sample data, the insomnia type labels corresponding to each patient sample data, the predicted classification results corresponding to each patient sample data, and the type balance weights corresponding to each patient sample data; the type balance weights are used to balance the attention of the two-stage classification model to samples of each insomnia type.
7. The insomnia classification device according to claim 5, characterized in that, The processor is used to determine the type balance weights corresponding to each first patient sample data through the following steps; For any type of insomnia, the number of patient sample data for that type of insomnia is counted to obtain a first value; Calculate the product of the first value and the total number of all types of insomnia to obtain the second value; The ratio between the number of all patient sample data and the second value is determined as the type balance weight corresponding to the patient sample data of the insomnia type.
8. The insomnia classification device according to claim 2, characterized in that, The processor is used to determine the first insomnia feature dimension through the following steps: Based on the importance index values corresponding to each second insomnia feature dimension, the first insomnia feature dimension is selected; the importance index value corresponding to each second insomnia feature dimension is used to characterize the importance of the second insomnia feature dimension when the two-stage classification model performs insomnia classification.
9. The insomnia classification device according to claim 2, characterized in that, The processor is used to determine the second insomnia feature dimension through the following steps: Based on the correlation index between each preset insomnia feature dimension and insomnia type, a second insomnia feature dimension is selected from all preset insomnia feature dimensions.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a processor as described in any one of claims 1 to 9, performs the steps executed by the processor.
Citation Information
Patent Citations
Novel coronavirus patient condition classification system based on artificial intelligence
CN111446002A
Insomnia dialectical classification model training and classification method, system, equipment and medium
CN115935183A
Liver disease diagnosis method based on reconstruction and Tabular data
CN116759067A
Road traffic risk grade prediction method under vehicle-road cooperation condition
CN120220416A
Fetal health classification method, system and device and storage medium
CN120260931A