Postoperative risk prediction method and system based on neighbor component analysis, and storage medium
Through a method based on nearest neighbor component analysis, the retrospective patient instance set was sampled and encoded, combined with cosine similarity measurement, the model was optimized to improve the accuracy and reliability of postoperative complication prediction, which solved the problem of insufficient generalization ability in traditional methods.
Patent Information
- Application Number
- CN202510536841.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-27
- Publication Date
- 2025-08-08
AI Technical Summary
The traditional method of predicting postoperative complications ignores the semantic information of retrospective patient instances during training and reasoning, resulting in insufficient generalization ability of the model, high computational cost, and low prediction accuracy.
Using a method based on nearest neighbor component analysis, additional retrospective patient instance sets were sampled through course learning strategies, patient instances were encoded using a nonlinear encoder, and distances between patient instances were calculated using a cosine similarity metric to optimize the model to improve prediction performance.
It effectively reduces the calculation cost, improves the generalization ability and prediction accuracy of the model, and can efficiently use retrospective patient data for postoperative risk prediction, optimize patient instance characterization, and reduce the risk of postoperative complications.
Smart Images

Figure CN120452783A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of application of artificial intelligence in perioperative clinical decision-making support technology and postoperative risk prediction technology, and in particular to a postoperative risk prediction method, system and storage medium based on nearest neighbor component analysis. Background Art
[0002] Death within 30 days of surgery has become the third leading cause of death worldwide, with postoperative complications being the leading cause. Therefore, effective perioperative risk management is crucial in clinical practice. Predicting a patient's likelihood of developing postoperative complications based on their preoperative information is a crucial component of perioperative risk management.
[0003] Currently, traditional postoperative complication prediction methods use only retrospective preoperative and postoperative outcome information from patients during the training phase. Furthermore, during the inference phase, they predict the risk of postoperative complications based solely on the patient's preoperative information and trained model parameters. These traditional prediction methods neglect the use of other semantic information from retrospective patient instances during training and inference. Summary of the Invention
[0004] The present invention provides a postoperative risk prediction method, system and storage medium based on nearest neighbor component analysis, establishes an additional retrospective patient instance set, and uses a sampler to sample it using a curriculum strategy to reduce computational costs and improve the generalization ability of the model. Next, a nonlinear encoder is used to encode the sampled instance set and the target patient instance to effectively characterize the patient instance. Subsequently, a cosine similarity metric is used to calculate the distance between the encoded target patient instance and the sampled retrospective patient instance. Finally, the predictor is used to combine the distance between the instances and the outcome information of the sampled instances to calculate the probability that each outcome event is a neighbor of the target patient instance, and through optimization during the training process, patient instances with the same outcome tend to cluster in the spatial representation, while patient instances with different outcomes are alienated from each other, thereby improving the prediction performance of the model.
[0005] To achieve the above object, the present invention adopts the following technical solutions: This specification discloses a postoperative risk prediction method based on nearest neighbor component analysis, including: S1. Sampling data from additional retrospective patient case sets; S2. Based on the sampled data, patient instance features are classified into continuous, categorical, and textual features. These features are fused through a self-attention mechanism to form a semantically informative patient instance representation. A nonlinear neural network is then used to map the patient instance representation to a low-dimensional space, yielding a semantically informative representation vector. S3. Obtain the target patient instance and perform encoding processing to obtain the target patient instance vector; S4. Using cosine similarity, calculate the distance between the target patient instance vector and each instance vector in the representation vector to form a distance vector; S5. Predict the outcome event of the target patient instance based on the distance vector.
[0006] In this specification, in S1, sampling is performed based on the sampling strategy of curriculum learning, and the additional retrospective patient instance set is divided into three different batch instance sets: uniformly distributed batch instance set, randomly distributed batch instance set, and unbalanced distribution batch instance set. Each batch instance set contains n small batch instance sets, which is consistent with the number of mini-batches in the model training process, and each small batch instance set contains m patient instances.
[0007] In this guide, each batch instance set is processed as follows: Uniformly distributed batch instance sets: generated using a stratified sampling algorithm with replacement, each mini-batch instance set contains the same number of positive and negative instances to promote model convergence; Randomly distributed batch instance sets: generated using a scrambled segmentation algorithm, the ratio of positive to negative instances in each mini-batch instance set is uncertain. The randomly distributed batch instance set includes all additional retrospective patient instances to ensure that each instance participates in training, thereby enhancing the generalization ability of the model; Imbalanced distribution batch instance set: generated using a probability-guided sampling algorithm with replacement to ensure that the distribution of positive and negative instances in each small batch instance set is consistent with the original additional retrospective patient instance set.
[0008] In this manual, the model training process gradually moves from simpler modes to more difficult modes; During the model training phase, each patient instance in a mini-batch shares a mini-batch instance set for neighbor component analysis, including: In the early stages of model training, a small batch of instances from a uniformly distributed batch of instances is used as the analysis set to promote model convergence; As the model gradually converges, we gradually switch to using randomly distributed batches of instances, and then to unbalanced batches of instances, to enhance the generalization ability of the model.
[0009] In this specification, in S2, patient instance features are divided into three categories: continuous features , categorical features and text features The specific processing methods are as follows: Continuous features : Perform quantile conversion on continuous features and use LR encoding to map continuous features into d-dimensional vectors ; Categorical features : Use the embedding lookup table to convert the categorical features into a vector of dimension d ; Text features :Use the SBERT pre-training model to embed text features and convert them into d-dimensional vectors with semantic information .
[0010] In this manual, the self-attention mechanism is used to fuse continuous feature vectors , categorical feature vector and text feature vectors , the specific fusion process is as follows: Continuous features , categorical features and text features Splice into a matrix , and through three different weight matrices 、 、 Map it into different vector spaces to form a query matrix , key matrix Sum Matrix ;The detailed processing process is shown in formula (1); (1); Calculate the query matrix and bond matrix The similarity between them is calculated by using vector dot product as the similarity metric to obtain the attention score matrix ; The detailed processing process is shown in formula (2); (2); The attention score matrix is processed by the Softmax function Normalize and get the attention weight matrix ; The detailed processing process is shown in formula (3); (3); The attention weight matrix Apply to the value matrix The final fused matrix is obtained by weighted summation ; The detailed processing process is shown in formula (4); (4).
[0011] In this specification, a nonlinear neural network is used to obtain the final patient instance representation vector , complex semantic information between features is fused through nonlinear transformation. The detailed processing process is shown in formula (5); (5).
[0012] In this specification, in S5, the outcome event of the target patient instance is predicted in different ways in the training phase and the inference phase; During the training phase, the negative log-likelihood loss function is optimized. The specific process is as follows: One-hot encoding of outcome data: outcome labels for a small batch of patient instances After one-hot encoding, an outcome embedding matrix containing only 0 and 1 is generated, where each row represents the outcome category of an instance and the columns correspond to negative and positive respectively; Neighbor probability normalization: The distance vector is normalized using the Softmax function to obtain an instance neighbor probability vector. The elements of this vector range from [0, 1] and the sum of the elements is 1, indicating the probability that each instance in the mini-batch instance set is a neighbor of the target patient instance. Calculate the neighbor probability of each outcome: perform a matrix product operation on the instance neighbor probability vector and the outcome embedding matrix, accumulate the neighbor rates of the positive and negative outcome instance vectors in the mini-batch instance set, and obtain the neighbor probability vector of each outcome for the target patient instance; Probability optimization and reasoning: During the training phase, the negative logarithm of the probability vector of each outcome’s nearest neighbor is Optimize as the loss value, where represents the probability that the target instance is a neighbor of the outcome event, and the optimization goal is to make The value is as small as possible, so that patient instances with the same outcome are close to each other in space, and patient instances with different outcomes are far away from each other in space; In the inference stage, the prediction results are directly output based on the nearest neighbor probabilities. The entire additional retrospective patient instance set is directly used as the analysis set. The outcome events of the target patient instance are predicted based on the nearest neighbor probability vectors of each outcome. The prediction result is the position corresponding to the maximum value in the nearest neighbor probability vector of each outcome, which represents the final outcome event of the target instance.
[0013] This specification also discloses a postoperative risk prediction system based on nearest neighbor component analysis, which is used to implement any of the above-mentioned postoperative risk prediction methods based on nearest neighbor component analysis. The postoperative risk prediction system based on nearest neighbor component analysis includes: Sampler module: used to sample data; Encoder module: used to obtain the representation vector and target patient instance vector; Metric module: used to calculate the distance between the target patient instance vector and each instance vector in the representation vector to form a distance vector; Predictor module: used to predict the outcome event of the target patient instance.
[0014] This specification also discloses a computer-readable storage medium, which stores computer instructions. When a computer reads the computer instructions, the computer executes any one of the above-mentioned postoperative risk prediction methods based on nearest neighbor component analysis.
[0015] In summary, the present invention has at least the following beneficial effects: The present invention provides a postoperative risk prediction method, system and storage medium based on nearest neighbor component analysis. An additional retrospective patient instance set is established and a sampler is used to sample the instance set and the target patient instance to reduce the computational cost and improve the generalization ability of the model. Next, a nonlinear encoder is used to encode the sampled instance set and the target patient instance to effectively represent the patient instance. Subsequently, a cosine similarity metric is used to calculate the distance between the encoded target patient instance and the sampled retrospective patient instance. Finally, the predictor is used to combine the distance between the instances and the outcome information of the sampled instance to calculate the probability that each outcome event is a neighbor of the target patient instance. During the training process, through optimization, patient instances with the same outcome tend to cluster in the spatial representation, while patient instances with different outcomes are alienated from each other, thereby improving the prediction performance of the model. It can efficiently utilize additional retrospective patient data for postoperative risk prediction, optimize patient instance representation, and improve the accuracy and reliability of the prediction results.
[0016] This paper uses preoperative and postoperative outcome data from retrospective and additional retrospective patients to model and predict the risk of postoperative complications in patients undergoing surgery. By combining this with neighbor component analysis, the paper proposes a new postoperative risk prediction framework. This paper can serve as an important component of the perioperative medical system. By predicting whether a patient will develop postoperative complications in advance, it can assist anesthesiologists or surgeons in developing appropriate medical resource plans for the patient, optimize the allocation of medical resources, and ultimately reduce the risk of death from postoperative complications. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0018] Figure 1Schematic diagram of the postoperative risk prediction method based on nearest component analysis involved in the present invention.
[0019] Figure 2 Schematic diagram comparing the traditional postoperative risk prediction framework involved in the present invention with the technical framework of the present invention.
[0020] Figure 3 Schematic diagram of the postoperative risk prediction system based on nearest component analysis involved in the present invention.
[0021] Figure 4 Schematic diagram of the sampling process of the sampler involved in the present invention.
[0022] Figure 5 Schematic diagram of the encoder processing process involved in the present invention.
[0023] Figure 6 Schematic diagram of the self-attention mechanism fusion process involved in the present invention.
[0024] Figure 7 Schematic diagram of the predictor processing process involved in the present invention. DETAILED DESCRIPTION
[0025] Hereinafter, only certain exemplary embodiments are briefly described. As will be appreciated by those skilled in the art, the described embodiments may be modified in various ways without departing from the spirit or scope of the embodiments of the present invention. Therefore, the drawings and description are to be regarded as illustrative in nature and not restrictive.
[0026] The disclosure below provides many different embodiments or examples for implementing different structures of the embodiments of the present invention. In order to simplify the disclosure of the embodiments of the present invention, the components and configurations of specific examples are described below. Of course, these are merely examples and are not intended to limit the embodiments of the present invention. In addition, the embodiments of the present invention may repeat reference numerals and / or reference letters in different examples. Such repetition is for the purpose of simplicity and clarity and does not in itself indicate the relationship between the various embodiments and / or configurations discussed.
[0027] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0028] like Figure 1 As shown, this embodiment provides a postoperative risk prediction method based on nearest neighbor component analysis, including: S1. Sampling data from additional retrospective patient case sets; S2. Based on the sampled data, patient instance features are classified into continuous, categorical, and textual features. These features are fused through a self-attention mechanism to form a semantically informative patient instance representation. A nonlinear neural network is then used to map the patient instance representation to a low-dimensional space, yielding a semantically informative representation vector. S3. Obtain the target patient instance and perform encoding processing to obtain the target patient instance vector; S4. Using cosine similarity, calculate the distance between the target patient instance vector and each instance vector in the representation vector to form a distance vector; S5. Predict the outcome event of the target patient instance based on the distance vector.
[0029] In some embodiments, in S1, sampling is performed based on a curriculum learning sampling strategy, and the additional retrospective patient instance set is divided into three different batch instance sets: a uniformly distributed batch instance set, a randomly distributed batch instance set, and an unbalanced distribution batch instance set. Each batch instance set contains n small batch instance sets, which is consistent with the number of mini-batches in the model training process, and each small batch instance set contains m patient instances.
[0030] In some embodiments, each batch of instances is processed as follows: Uniformly distributed batch instance sets: generated using a stratified sampling algorithm with replacement, each mini-batch instance set contains the same number of positive and negative instances to promote model convergence; Randomly distributed batch instance sets: generated using a scrambled segmentation algorithm, the ratio of positive to negative instances in each mini-batch instance set is uncertain. The randomly distributed batch instance set includes all additional retrospective patient instances to ensure that each instance participates in training, thereby enhancing the generalization ability of the model; Imbalanced distribution batch instance set: generated using a probability-guided sampling algorithm with replacement to ensure that the distribution of positive and negative instances in each small batch instance set is consistent with the original additional retrospective patient instance set.
[0031] In some embodiments, the model training process gradually shifts from simpler modes to more difficult modes; During the model training phase, each patient instance in a mini-batch shares a mini-batch instance set for neighbor component analysis, including: In the early stages of model training, a small batch of instances from a uniformly distributed batch of instances is used as the analysis set to promote model convergence; As the model gradually converges, we gradually switch to using randomly distributed batches of instances, and then to unbalanced batches of instances, to enhance the generalization ability of the model.
[0032] In some embodiments, in S2, patient instance features are divided into three categories: continuous features , categorical features and text features The specific processing methods are as follows: Continuous features : Perform quantile conversion on continuous features and use LR encoding to map continuous features into d-dimensional vectors ; Categorical features : Use the embedding lookup table to convert the categorical features into a vector of dimension d ; Text features :Use the SBERT pre-training model to embed text features and convert them into d-dimensional vectors with semantic information .
[0033] In some embodiments, a self-attention mechanism is used to fuse continuous feature vectors , categorical feature vector and text feature vectors , the specific fusion process is as follows: Continuous features , categorical features and text features Splice into a matrix , and through three different weight matrices 、 、 Map it into different vector spaces to form a query matrix , key matrix Sum Matrix ;The detailed processing process is shown in formula (1); (1); Calculate the query matrix and bond matrix The similarity between them is calculated by using vector dot product as the similarity metric to obtain the attention score matrix ; The detailed processing process is shown in formula (2); (2); The attention score matrix is processed by the Softmax function Normalize and get the attention weight matrix ; The detailed processing process is shown in formula (3); (3); The attention weight matrix Apply to the value matrix The final fused matrix is obtained by weighted summation ; The detailed processing process is shown in formula (4); (4).
[0034] In some embodiments, a nonlinear neural network is used to obtain the final patient instance representation vector , complex semantic information between features is fused through nonlinear transformation. The detailed processing process is shown in formula (5); (5).
[0035] In some embodiments, in S5, the outcome event of the target patient instance is predicted by different means in the training phase and the inference phase; During the training phase, the negative log-likelihood loss function is optimized. The specific process is as follows: One-hot encoding of outcome data: outcome labels for a small batch of patient instances After one-hot encoding, an outcome embedding matrix containing only 0 and 1 is generated, where each row represents the outcome category of an instance and the columns correspond to negative and positive respectively; Neighbor probability normalization: The distance vector is normalized using the Softmax function to obtain an instance neighbor probability vector. The elements of this vector range from [0, 1] and the sum of the elements is 1, indicating the probability that each instance in the mini-batch instance set is a neighbor of the target patient instance. Calculate the neighbor probability of each outcome: perform a matrix product operation on the instance neighbor probability vector and the outcome embedding matrix, accumulate the neighbor rates of the positive and negative outcome instance vectors in the mini-batch instance set, and obtain the neighbor probability vector of each outcome for the target patient instance; Probability optimization and reasoning: During the training phase, the negative logarithm of the probability vector of each outcome’s nearest neighbor is Optimize as the loss value, where represents the probability that the target instance is a neighbor of the outcome event, and the optimization goal is to make The value is as small as possible, so that patient instances with the same outcome are close to each other in space, and patient instances with different outcomes are far away from each other in space; In the inference stage, the prediction results are directly output based on the nearest neighbor probabilities. The entire additional retrospective patient instance set is directly used as the analysis set. The outcome events of the target patient instance are predicted based on the nearest neighbor probability vectors of each outcome. The prediction result is the position corresponding to the maximum value in the nearest neighbor probability vector of each outcome, which represents the final outcome event of the target instance.
[0036] This embodiment provides a postoperative risk prediction system based on nearest component analysis, which is used to implement any of the above-mentioned postoperative risk prediction methods based on nearest component analysis. The postoperative risk prediction system based on nearest component analysis includes: Sampler module: used to sample data; Encoder module: used to obtain the representation vector and target patient instance vector; Metric module: used to calculate the distance between the target patient instance vector and each instance vector in the representation vector to form a distance vector; Predictor module: used to predict the outcome event of the target patient instance.
[0037] This embodiment provides a computer-readable storage medium storing computer instructions. When a computer reads the computer instructions, the computer executes any one of the above-mentioned postoperative risk prediction methods based on nearest neighbor component analysis.
[0038] The technical ideas of the present invention are as follows: Figure 2 Schematic diagram comparing the traditional postoperative risk prediction framework and the present invention. Figure 2 In the traditional postoperative risk prediction framework, there are three key issues that need to be addressed: (1) How to deal with the high computational cost of the analysis set, which leads to excessive consumption of computing resources and time in the training optimization process; (2) How to introduce text data containing important semantic information into the nearest component analysis; (3) How to select a measurement method suitable for the field of postoperative complication prediction.
[0039] Figure 2 Figure b is a schematic diagram of the technical framework of the present invention. In response to the above three key issues, the present invention proposes the following solutions: (1) Curriculum Learning-Based Sampling: To reduce the high computational cost of performing NCCA on the entire set of additional retrospective patient instances, we adopt a curriculum learning-based sampling strategy to sample the retrospective patient instance set and perform NCCA on the sampled mini-batch instance set. This approach not only effectively reduces computational cost but also enhances the generalization ability of the model.
[0040] (2) Nonlinear encoding strategy: In order to incorporate preoperative diagnostic text data with important semantic information into the nearest component analysis, improve the expressiveness of patient instance representation, and avoid model underfitting, the present invention uses a nonlinear encoder to encode patient instances. Specifically, the preoperative diagnostic text data is embedded using the SBERT pre-trained model, continuous features are quantile transformed and LR encoded, and categorical features are embedded in a lookup table. In addition, the Self-Attention mechanism is used to fuse the feature information, and finally the semantic information between the features is further fused through a nonlinear neural network, and the dimension of the patient instance representation is reduced.
[0041] (3) Cosine similarity as a measurement method: Due to the large amount of preoperative feature information of patients, the patient instance representation vector generated by the encoder still has a high dimensionality. Cosine similarity as a measurement method can effectively address this problem. Cosine similarity measures the similarity in space by comparing the angle between two vectors, without being affected by the absolute size of the vector values, thus being able to capture the complex semantic relationship of patient instances in high-dimensional space.
[0042] In order to construct the "postoperative risk prediction method, system and storage medium based on nearest neighbor component analysis" proposed in the present invention, a deep learning method was adopted to design the system by taking advantage of the advantages of deep learning in natural language text processing and representation. On this basis, an additional set of retrospective patient instances was established, and a sampler was used to sample them using a curriculum strategy to reduce computational costs and improve the generalization ability of the model. Next, a nonlinear encoder was used to encode the sampled instance set and the target patient instance to effectively represent the patient instance. Subsequently, a cosine similarity metric was used to calculate the distance between the encoded target patient instance and the sampled retrospective patient instance. Finally, the predictor, combined with the distance between instances and the outcome information of the sampled instances, calculated the probability that each outcome event is a neighbor of the target patient instance. During the training process, optimization was performed so that patient instances with the same outcome tended to cluster in the spatial representation, while patient instances with different outcomes were distant from each other, thereby improving the prediction performance of the model.
[0043] The system of the present invention is as follows Figure 3 As shown in the figure, it mainly consists of four modules: (1) sampler; (2) encoder; (3) measurer; (4) predictor.
[0044] right Figure 3 The definitions of the symbols in the shown system are as follows: represents the set of additional retrospective patient instances, where e represents the number of additional retrospective patient instances and c represents the number of preoperative features; represents the target patient instance, which is an instance in the retrospective patient instance set (training set) during the training phase and the patient instance to be predicted during the inference phase; represents the encoding vector of the target patient instance after being processed by the encoder, where d represents the dimension of the vector; represents the mini-batch instance vector set sampled from the additional retrospective patient instance set and processed by the encoder, where m represents the number of patients in the batch; Represents the target patient instance vector With a small batch of instance vectors The cosine distance between them; Represents a mini-batch instance vector set The ending events corresponding to each instance in; Represents the target patient instance The neighbor probabilities of each outcome, where the first element represents the probability of a negative outcome being a neighbor, and the second element represents the probability of a positive outcome being a neighbor.
[0045] Through the above system, additional retrospective patient data can be efficiently utilized for postoperative risk prediction, optimize patient case characterization, and improve the accuracy and reliability of prediction results.
[0046] (1) Sampler: In order to reduce the computational cost during training and improve the generalization ability of the model, the present invention uses a sampler to sample some data from the additional retrospective patient instance set for metric learning training. Due to the large number of additional retrospective patient instances, if all instances are directly used for training without sampling, it will consume a lot of computing resources and training time. The usual approach is to randomly sample the additional retrospective patient instance set. However, in the field of postoperative complication prediction, the distribution of patient outcomes is extremely unbalanced. Direct random sampling may lead to an imbalance in the outcome distribution of the sampled data, thereby affecting the effectiveness of model training.
[0047] To solve this problem, the present invention adopts a sampling strategy based on curriculum learning to sample additional retrospective patient instance sets. The specific sampling process is as follows: Figure 4 As shown in the figure, based on the concept of curriculum learning, the model training process starts with simple patterns and gradually moves to more difficult patterns. Using different sampling algorithms, the additional retrospective patient instance set is divided into three different batches: uniformly distributed batches, randomly distributed batches, and imbalanced batches. This improves the model's generalization ability while reducing computational costs.
[0048] Each batch instance set contains n mini-batch instance sets, which is consistent with the number of mini-batches in the model training process. Each mini-batch instance set contains m patient instances. Specifically, each batch instance set is processed as follows: Evenly distributed batches of instances: These are generated using a stratified sampling algorithm with replacement. Each mini-batch contains an equal number of positive and negative instances. This helps the model learn the characteristics of positive and negative instances faster in the initial stages, promoting faster model convergence.
[0049] Randomly distributed batch instance sets: generated using a scrambled segmentation algorithm. The ratio of positive to negative instances in each small batch instance set is uncertain, but the batch instance set contains all additional retrospective patient instances, ensuring that each instance participates in training, thereby enhancing the generalization ability of the model.
[0050] Imbalanced distribution batch instance set: generated using a probability-guided sampling algorithm with replacement to ensure that the distribution of positive and negative instances in each small batch instance set is consistent with the original additional retrospective patient instance set.
[0051] During model training, each patient instance in a mini-batch shares a common mini-batch set for neighbor component analysis. Specifically, in the initial stages of model training, a mini-batch set of instances from a uniformly distributed batch set is used as the analysis set to accelerate convergence. As the model converges, the analysis is gradually switched to a randomly distributed batch set, and then to an imbalanced batch set, to improve the model's generalization ability.
[0052] (2) Encoder: In the method of the present invention, the main function of the encoder module is to convert the patient instance into a representation vector with semantic information. Different processing strategies are adopted for different types of data, and the features are fused through the self-attention mechanism to form a patient instance representation with more semantic information. Finally, a nonlinear neural network is used to map the representation of the patient instance to a low-dimensional space to reduce the computational cost and improve the semantic expression effect. The processing process is as follows: Figure 5 shown.
[0053] For the i-th patient instance in the instance set , the features of patient instances are divided into three categories: continuous features , categorical features and text features The specific processing methods are as follows: Continuous features :First, the continuous features are quantile transformed to reduce the interference of outliers. Then, LR encoding (consisting of a linear layer and ReLU activation function) is used to map the continuous features into a d-dimensional vector This method expands the representation dimension through linear layers and captures the complex relationship between features through nonlinear ReLU activation functions, thereby improving semantic expression capabilities.
[0054] Categorical features : Use the embedding lookup table to convert the categorical features into a vector of dimension d The embedding lookup table is a trainable weight matrix. Specifically, using the categorical feature value as an index, the corresponding vector is found in the embedding lookup table. This vector is the vector representation of the categorical feature. This method not only converts categorical features into a low-dimensional vector representation of fixed dimension, but also continuously updates and optimizes it during training, thereby more accurately representing the semantics of categorical features.
[0055] Text features :Use the SBERT pre-training model to embed text features and convert them into d-dimensional vectors with semantic information Specifically, the jina-embeddings-v2-base-zh pre-trained model is used.
[0056] For the feature representation processed by different encoding strategies, a common method is to simply concatenate the vectors and use the concatenated vectors as the representation of the patient instance. However, this method does not consider the possible correlation between features and therefore cannot accurately express the semantic information of the patient instance. To this end, the present invention uses a self-attention mechanism to fuse continuous feature vectors. , categorical feature vector and text feature vectors The specific fusion process is as follows Figure 6 shown.
[0057] Specifically, first concatenate the continuous, categorical, and text feature vectors into a matrix , and through three different weight matrices 、 、 Map it into different vector spaces to form a query matrix , key matrix Sum Matrix , the specific calculation process is shown in formula (1).
[0058] Next, calculate the query matrix and bond matrix The similarity between them is calculated by using vector dot product as the similarity metric. The detailed calculation process is shown in formula (2). The attention score matrix is calculated by the Softmax function. Normalize and get the attention weight matrix , the calculation process is shown in formula (3). Finally, the attention weight matrix Apply to the value matrix The final fused matrix is obtained by weighted summation , the calculation process is shown in formula (4).
[0059] Since the patient instance representation output by the self-attention mechanism is a two-dimensional matrix , it needs to be converted into a one-dimensional vector form. A common practice is to flatten the two-dimensional matrix into a vector However, this method may lead to excessive dimension, increase the complexity of subsequent calculations and increase the difficulty of distance measurement. Therefore, the present invention uses a nonlinear neural network to reduce the dimension of the flattened vector and obtain the final patient instance representation vector , through nonlinear transformation to fuse the complex semantic information between features. The detailed processing process is shown in formula (5). The neural network consists of a fully connected layer (Linear), layer normalization (LayerNorm), ReLU activation function and Dropout. It aims to capture the complex nonlinear relationship between features, accelerate the training process, and improve the generalization ability of the model.
[0060] (1); (2); (3); (4); (5); (3) Metric: The metric module in this invention is mainly used to calculate the target patient instance vector With a small batch of instance vectors The distance between instance vectors in the dataset. Traditional metric methods often use Euclidean distance. However, because preoperative patient data contains a large amount of semantic information, its representation vector after encoder processing still has certain high-dimensional characteristics. In high-dimensional space, Euclidean distance is prone to failure and cannot accurately reflect the true semantic relationship between instances.
[0061] To address this issue, we chose to use cosine similarity as a distance metric. Cosine similarity measures the spatial similarity of two vectors by comparing the angle between them. It is unaffected by the absolute magnitude of the vector values and can better capture the complex semantic relationships between patient instance vectors in high-dimensional space.
[0062] Specifically, the target patient instance vector and The cosine values between each vector in are calculated to form a distance vector Each element of this distance vector represents A vector in the target patient instance vector The cosine similarity of the target instance is in the range of [−1, 1]. The larger the value, the closer the two are, and the higher the possibility that the corresponding instance is a neighbor of the target instance.
[0063] (4) Predictor: The predictor module in the present invention is mainly used to predict the outcome event of the target patient instance based on the neighbor probability of the target patient instance vector. In the training phase, the predictor optimizes the negative log-likelihood loss function to make the patient instances with the same outcome closer in space and the patient instances with different outcomes farther apart; in the inference phase, the predictor directly outputs the prediction result based on the neighbor probability. The detailed process is as follows: Figure 7 The specific processing flow is as follows: One-hot encoding of outcome data: outcome labels for a small batch of patient instances After one-hot encoding, a matrix containing only 0 and 1 is generated Each row represents the outcome category of an instance, and the columns correspond to negative and positive, respectively. Outcome labels for small batches of patient instances One-to-one correspondence with the small batch of patient instances, the specific acquisition process is: the additional retrospective patient instance outcome set is sampled using the same sampler as the additional retrospective patient instance set.
[0064] Neighbor probability normalization: distance vector Use the Softmax function to normalize and get the instance neighbor probability vector The elements of this vector range from [0, 1], and the sum of the elements is 1, indicating the probability that each instance in the mini-batch instance set is a neighbor of the target patient instance.
[0065] Calculate the neighbor probability of each outcome: the neighbor probability vector Embedded matrix with the ending Perform matrix product operations, accumulate the neighbor probabilities of the positive and negative outcome instance vectors in the small batch instance set, and obtain the neighbor probability vectors of each outcome of the target patient instance .in: The first element of represents the probability that a negative outcome is a neighbor of the target patient instance; the second element represents the probability that a positive outcome is a neighbor of the target patient instance.
[0066] Probabilistic optimization and inference: During the training phase, the negative logarithm of the probability Optimize as the loss value, where represents the probability that the target instance is a neighbor of the outcome event. The optimization goal is to make The value is as small as possible, so that: patient instances with the same outcome are close to each other in space; patient instances with different outcomes are far away from each other in space.
[0067] During the inference phase, since there is no need to backpropagate to calculate gradients, the model directly uses the entire additional set of retrospective patient instances. As the analysis set, and based on the outcome neighbor probability vector output by the model , predict the outcome event of the target patient instance. The prediction result is The position corresponding to the maximum value in represents the final outcome event of the target instance.
[0068] The above embodiments are intended to illustrate the present invention, not to limit the present invention. Therefore, changes in illustrative values or substitutions of equivalent components should still fall within the scope of the present invention.
[0069] From the above detailed description, it will be clear to those skilled in the art that the present invention can indeed achieve the aforementioned objectives and is in compliance with the provisions of the Patent Law.
[0070] Although preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic inventive concepts. Therefore, the appended claims are intended to be interpreted as covering the preferred embodiments and all changes and modifications that fall within the scope of the invention. The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. It should be noted that any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
[0071] It should be noted that the above description of the relevant processes is for illustration and purpose only and does not limit the scope of application of this specification. For those skilled in the art, various modifications and changes can be made to the processes under the guidance of this specification. However, such modifications and changes are still within the scope of this specification.
[0072] The basic concepts have been described above. It will be apparent to those skilled in the art after reading this application that the above disclosures are merely illustrative and do not constitute limitations on this application. Although not explicitly stated herein, those skilled in the art may make various modifications, improvements, and amendments to this application. Such modifications, improvements, and amendments are suggested in this application and remain within the spirit and scope of the exemplary embodiments of this application.
[0073] At the same time, this application uses specific terms to describe the embodiments of this application. For example, "one embodiment," "an embodiment," and / or "some embodiments" refer to a certain feature, structure, or characteristic related to at least one embodiment of this application. Therefore, it should be emphasized and noted that "one embodiment," "an embodiment," or "an alternative embodiment" mentioned twice or more in different places in this specification does not necessarily refer to the same embodiment. In addition, certain features, structures, or characteristics in one or more embodiments of this application may be appropriately combined.
[0074] Furthermore, those skilled in the art will appreciate that various aspects of the present application may be illustrated and described in terms of a number of patentable categories or situations, including any new and useful process, machine, product, or combination of substances, or any new and useful improvement thereof. Thus, various aspects of the present application may be implemented entirely in hardware, entirely in software (including firmware, resident software, microcode, etc.), or in a combination of hardware and software. Each of the above hardware and software may be referred to as a "unit," "module," or "system." Furthermore, various aspects of the present application may take the form of a computer program product embodied in one or more computer-readable media, with computer-readable program code embodied therein.
[0075] The computer program code required for the operation of each part of this application can be written in any one or more programming languages, including object-oriented programming languages such as Java, Scala, Smalltalk, Eiffel, JADE, Emerald, C++, C#, VB.NET, Python, etc., conventional procedural programming languages such as C programming language, Visual Basic, Fortran2103, Perl, COBOL2102, PHP, ABAP, dynamic programming languages such as Python, Ruby and Groovy, or other programming languages. The program code can be run entirely on the user's computer, or as a standalone software package on the user's computer, or partly on the user's computer and partly on a remote computer, or entirely on a remote computer or server. In the latter case, the remote computer can be connected to the user's computer via any network form, such as a local area network (LAN) or a wide area network (WAN), or connected to an external computer (e.g., via the Internet), or in a cloud computing environment, or used as a service such as software as a service (SaaS).
[0076] In addition, unless expressly stated in the claims, the order of the processing elements and sequences described in this application, the use of alphanumeric characters, or the use of other names are not intended to limit the order of the processes and methods of this application. Although the above disclosure discusses some embodiments of the invention that are currently considered useful through various examples, it should be understood that such details are only for illustrative purposes, and the attached claims are not limited to the disclosed embodiments. On the contrary, the claims are intended to cover all modifications and equivalent combinations that are consistent with the essence and scope of the embodiments of this application. For example, although the implementation of the various components described above can be embodied in a hardware device, it can also be implemented as a pure software solution, for example, installation on an existing server or mobile device.
[0077] Similarly, it should be noted that in order to simplify the presentation of this disclosure and thereby facilitate understanding of one or more of the invention's embodiments, the foregoing descriptions of the embodiments of this disclosure sometimes combine multiple features into a single embodiment, figure, or description thereof. However, this approach should not be interpreted as reflecting an intention that the claimed subject matter requires more features than expressly recited in each claim. Rather, the subject matter of the invention may possess fewer features than the single embodiment described above.
Claims
1. A postoperative risk prediction method based on nearest neighbor component analysis, characterized in that: include: S1. Sampling data from additional retrospective patient case sets; S2. Based on the sampled data, patient instance features are classified into continuous, categorical, and textual features. These features are fused through a self-attention mechanism to form a semantically informative patient instance representation. A nonlinear neural network is then used to map the patient instance representation to a low-dimensional space, yielding a semantically informative representation vector. S3. Obtain the target patient instance and perform encoding processing to obtain the target patient instance vector; S4. Using cosine similarity, calculate the distance between the target patient instance vector and each instance vector in the representation vector to form a distance vector; S5. Predict the outcome event of the target patient instance based on the distance vector.
2. The postoperative risk prediction method based on nearest neighbor component analysis according to claim 1, characterized in that: In S1, sampling is performed based on the curriculum learning sampling strategy, and the additional retrospective patient instance set is divided into three different batch instance sets: uniformly distributed batch instance set, randomly distributed batch instance set, and imbalanced distribution batch instance set. Each batch instance set contains n small batch instance sets, which is consistent with the number of mini-batches in the model training process, and each small batch instance set contains m patient instances.
3. The postoperative risk prediction method based on nearest neighbor component analysis according to claim 2, characterized in that: Each batch of instances is processed as follows: Uniformly distributed batch instance sets: generated using a stratified sampling algorithm with replacement, each mini-batch instance set contains the same number of positive and negative instances to promote model convergence; Randomly distributed batch instance sets: generated using a scrambled segmentation algorithm, the ratio of positive to negative instances in each mini-batch instance set is uncertain. The randomly distributed batch instance set includes all additional retrospective patient instances to ensure that each instance participates in training, thereby enhancing the generalization ability of the model; Imbalanced distribution batch instance set: generated using a probability-guided sampling algorithm with replacement to ensure that the distribution of positive and negative instances in each small batch instance set is consistent with the original additional retrospective patient instance set.
4. The postoperative risk prediction method based on nearest neighbor component analysis according to claim 2, characterized in that: The model training process gradually shifts from simpler modes to more difficult modes; During the model training phase, each patient instance in a mini-batch shares a mini-batch instance set for neighbor component analysis, including: In the early stages of model training, a small batch of instances from a uniformly distributed batch of instances is used as the analysis set to promote model convergence; As the model gradually converges, we gradually switch to using randomly distributed batches of instances, and then to unbalanced batches of instances, to enhance the generalization ability of the model.
5. The postoperative risk prediction method based on nearest neighbor component analysis according to claim 1, characterized in that: In S2, patient instance features are divided into three categories: continuous features , categorical features and text features The specific processing methods are as follows: Continuous features : Perform quantile conversion on continuous features and use LR encoding to map continuous features into d-dimensional vectors ; Categorical features : Use the embedding lookup table to convert the categorical features into a vector of dimension d ; Text features :Use the SBERT pre-training model to embed text features and convert them into d-dimensional vectors with semantic information .
6. The postoperative risk prediction method based on nearest neighbor component analysis according to claim 5, characterized in that: Use self-attention mechanism to fuse continuous feature vectors , categorical feature vector and text feature vectors , the specific fusion process is as follows: Continuous features , categorical features and text features Splice into a matrix , and through three different weight matrices 、 、 Map it into different vector spaces to form a query matrix , key matrix Sum Matrix ; The detailed processing process is shown in formula (1); (1); Calculate the query matrix and bond matrix The similarity between them is calculated by using vector dot product as the similarity metric to obtain the attention score matrix ; The detailed processing process is shown in formula (2); (2); The attention score matrix is processed by the Softmax function Normalize and get the attention weight matrix ; The detailed processing process is shown in formula (3); (3); The attention weight matrix Apply to the value matrix The final fused matrix is obtained by weighted summation ; The detailed processing process is shown in formula (4); (4)。 7. The postoperative risk prediction method based on nearest neighbor component analysis according to claim 1, characterized in that: Use nonlinear neural network to get the final patient instance representation vector , complex semantic information between features is fused through nonlinear transformation. The detailed processing process is shown in formula (5); (5)。 8. The postoperative risk prediction method based on nearest neighbor component analysis according to claim 2, characterized in that: In S5, the outcome event of the target patient instance is predicted by different means in the training phase and the inference phase; During the training phase, the negative log-likelihood loss function is optimized. The specific process is as follows: One-hot encoding of outcome data: outcome labels for a small batch of patient instances After one-hot encoding, an outcome embedding matrix containing only 0 and 1 is generated, where each row represents the outcome category of an instance and the columns correspond to negative and positive respectively; Neighbor probability normalization: The distance vector is normalized using the Softmax function to obtain an instance neighbor probability vector. The elements of this vector range from [0, 1] and the sum of the elements is 1, indicating the probability that each instance in the mini-batch instance set is a neighbor of the target patient instance. Calculate the neighbor probability of each outcome: perform a matrix product operation on the instance neighbor probability vector and the outcome embedding matrix, accumulate the neighbor rates of the positive and negative outcome instance vectors in the mini-batch instance set, and obtain the neighbor probability vector of each outcome for the target patient instance; Probability optimization and reasoning: During the training phase, the negative logarithm of the probability vector of each outcome’s nearest neighbor is Optimize as the loss value, where represents the probability that the target instance is a neighbor of the outcome event, and the optimization goal is to make The value is as small as possible, so that patient instances with the same outcome are close to each other in space, and patient instances with different outcomes are far away from each other in space; In the inference stage, the prediction results are directly output based on the nearest neighbor probabilities. The entire additional retrospective patient instance set is directly used as the analysis set. The outcome events of the target patient instance are predicted based on the nearest neighbor probability vectors of each outcome. The prediction result is the position corresponding to the maximum value in the nearest neighbor probability vector of each outcome, which represents the final outcome event of the target instance.
9. A postoperative risk prediction system based on nearest neighbor component analysis, characterized in that: For implementing the postoperative risk prediction method based on nearest component analysis according to any one of claims 1 to 8, the postoperative risk prediction system based on nearest component analysis comprises: Sampler module: used to sample data; Encoder module: used to obtain the representation vector and target patient instance vector; Metric module: used to calculate the distance between the target patient instance vector and each instance vector in the representation vector to form a distance vector; Predictor module: used to predict the outcome event of the target patient instance.
10. A computer-readable storage medium, characterized in that The storage medium stores computer instructions. When a computer reads the computer instructions, the computer executes the postoperative risk prediction method based on neighbor component analysis according to any one of claims 1 to 8.