An artificial intelligence-based biochemical reaction curve anomaly detection method and system
Through the artificial intelligence-based biochemical reaction curve anomaly detection method, multiple artificial intelligence models are used to preprocess and analyze biochemical reaction curve data, which solves the problems of low efficiency and poor accuracy in existing technologies and achieves efficient, accurate anomaly detection and timely response.
Patent Information
- Application Number
- CN202410981553.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2044-07-22
AI Technical Summary
The existing technology for detecting anomalies in biochemical reaction curves has low efficiency and poor accuracy. It is difficult to process multi-dimensional, high-noise biochemical reaction data, and cannot analyze large amounts of data in real time and capture complex nonlinear patterns.
An artificial intelligence-based biochemical reaction curve anomaly detection method is adopted. By obtaining biochemical reaction curve data for preprocessing, a variety of artificial intelligence models such as SNN, LSTM, 1DCNN and random weight neural network are used for analysis, and a multi-level alarm mechanism is set up to achieve automated and intelligent anomaly detection.
It improves the efficiency and accuracy of anomaly detection in biochemical reaction curves, can effectively capture complex nonlinear patterns, enhance the robustness and generalization ability of the model, and achieve refined management and timely response to abnormal situations.
Smart Images

Figure CN118937657B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and specifically to a method and system for detecting anomalies in biochemical reaction curves based on artificial intelligence. Background Art
[0002] Biochemical analyzers are essential instruments widely used in clinical testing. Their detection principles are primarily based on colorimetry or turbidimetry. Currently, clinical laboratories rely primarily on in-house quality control to assess the status of reagents and instruments, reviewing reaction curves only when quality control is compromised or interference is suspected. However, reaction curves contain a wealth of information, enabling them to assess instrument status and abnormal results, as well as monitor reaction interferences, calculate high-concentration sample concentrations, and analyze reagent quality.
[0003] Traditional methods for detecting anomalies in biochemical reaction curves mainly rely on manual experience or simple statistical methods. These methods have the following defects:
[0004] Manual judgment is inefficient and cannot meet the real-time analysis needs of large amounts of data. Simple statistical methods are difficult to capture complex nonlinear patterns, which can easily lead to missed detections or false alarms, and are difficult to process multi-dimensional, high-noise biochemical reaction data. Summary of the Invention
[0005] In view of this, the present application provides a biochemical reaction curve anomaly detection method and system based on artificial intelligence, which solves the problems of low efficiency and poor accuracy of biochemical reaction curve anomaly detection in the existing technology.
[0006] An embodiment of the present application provides an artificial intelligence-based biochemical reaction curve anomaly detection method, comprising: acquiring biochemical reaction curve data; preprocessing the biochemical reaction curve data to obtain preprocessed data; analyzing the preprocessed data using an artificial intelligence model to identify abnormal reaction curves; and triggering a corresponding alarm mechanism based on the analysis results of the artificial intelligence model.
[0007] The obtaining of biochemical reaction curve data includes: collecting reaction curve data from a biochemical analyzer in real time; and extracting stored reaction curve data from a historical database.
[0008] The preprocessing of the biochemical reaction curve data includes: removing noise and outliers; normalizing the biochemical reaction curve data; and performing data enhancement processing on the normalized biochemical reaction curve data, including superimposing random noise that obeys a Gaussian distribution on the biochemical reaction curve data, or performing a nonlinear transformation on the time axis to simulate changes in reaction speed.
[0009] Before using the artificial intelligence model to analyze the preprocessed data, the method also includes: extracting time series features, including slope and curvature; extracting frequency domain features, including main frequency and energy distribution; and calculating relevant biochemical indicators, including reaction rate and substrate concentration.
[0010] The artificial intelligence model is a pulse neural network (SNN), and the method further includes: constructing a multi-layer SNN network structure, including an input layer, a hidden layer, and an output layer; training the SNN using a training data set; performing compression and concealment on the SNN; and updating the parameters of the SNN.
[0011] The artificial intelligence model is a long short-term memory network LSTM, and the method also includes: constructing an LSTM network structure, including an input layer, an LSTM layer and an output layer; training the LSTM using a training data set; using a standard Monte Carlo method to perform a first parameter adjustment on the LSTM; and using a quasi-Monte Carlo method to perform a second parameter adjustment on the LSTM.
[0012] The artificial intelligence model is a one-dimensional convolutional neural network 1DCNN, and the method also includes: constructing a 1DCNN network structure, including a convolutional layer, a pooling layer and a fully connected layer; using a hybrid meta-heuristic algorithm to optimize the hyperparameters of the 1DCNN; using a training data set to train the 1DCNN, and using a machine learning model to assist in optimizing the training process of the 1DCNN.
[0013] The artificial intelligence model is a neural network with random weights and learning biases. The method also includes: constructing a random weight neural network structure, including an input layer, a random weight hidden layer and a learnable bias output layer; designing and optimizing learning biases, including initializing bias values and updating strategies; and optimizing network parameters using an improved covariance matrix adaptive evolution strategy (CMAES) multimodal optimization algorithm.
[0014] The analysis results based on the artificial intelligence model trigger a corresponding alarm mechanism, including: setting multiple alarm levels corresponding to different degrees of abnormal situations; triggering alarms of corresponding levels according to the degree of abnormality; and sending alarm signals through various means, including system prompts, SMS notifications, and email alerts.
[0015] An embodiment of the present application also provides a computer device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the above-mentioned method for detecting anomalies in biochemical reaction curves based on artificial intelligence.
[0016] An embodiment of the present application also provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to execute the above-mentioned method for detecting anomalies in biochemical reaction curves based on artificial intelligence.
[0017] An embodiment of the present application also provides a computer program product, including computer instructions, characterized in that when the computer instructions are executed by a processor, the steps of the above-mentioned method for detecting anomalies in biochemical reaction curves based on artificial intelligence are implemented.
[0018] This application has the following technical effects:
[0019] By introducing artificial intelligence models, we have achieved automated and intelligent anomaly detection of biochemical reaction curves, significantly improving detection efficiency and accuracy.
[0020] Adopting a variety of advanced artificial intelligence models, such as SNN, LSTM, 1DCNN and random weight neural network, it can effectively capture complex nonlinear patterns and improve the accuracy of anomaly detection;
[0021] Through data preprocessing and feature extraction, the robustness and generalization ability of the model are enhanced;
[0022] The introduction of multiple parameter optimization and model compression technologies improves the performance and efficiency of the model;
[0023] A multi-level alarm mechanism has been designed to achieve refined management and timely response to abnormal situations. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the disclosed embodiments in the embodiments of the present application, the following will briefly introduce the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without any creative work.
[0025] Figure 1 A schematic diagram of a process for detecting anomalies in biochemical reaction curves based on artificial intelligence provided in an embodiment of the present application;
[0026] Figure 2a A schematic diagram of a biochemical reaction curve in one embodiment;
[0027] Figure 2b A schematic diagram of a biochemical reaction curve in another embodiment;
[0028] Figure 2c A schematic diagram of a biochemical reaction curve in another embodiment;
[0029] Figure 2d A schematic diagram of a biochemical reaction curve in another embodiment;
[0030] Figure 3 A schematic diagram of the architecture of an artificial intelligence-based biochemical reaction curve anomaly detection system provided in one embodiment;
[0031] Figure 4 A schematic diagram of the architecture of a computer device provided by an embodiment. DETAILED DESCRIPTION
[0032] The embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
[0033] It should be clear that the following embodiments of the present disclosure are described through specific concrete examples, and those skilled in the art can easily understand other advantages and effects of the present disclosure from the contents disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all the embodiments. The present disclosure can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present disclosure. It should be noted that the following embodiments and features in the embodiments can be combined with each other in the absence of conflict. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present disclosure.
[0034] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein can be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on this disclosure, it should be understood by those skilled in the art that an aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number of aspects described herein can be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein can be used to implement this device and / or practice this method.
[0035] It should also be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present disclosure. The illustrations only show components related to the present disclosure and are not drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component can be changed at will, and the component layout type may also be more complicated.
[0036] Additionally, in the following description, specific details are provided to provide a thorough understanding of the examples. However, one skilled in the art will appreciate that the aspects described can be practiced without these specific details.
[0037] Example 1
[0038] like Figure 1 As shown, the embodiment of the present application provides a method for detecting anomalies in biochemical reaction curves based on artificial intelligence, including:
[0039] S1: Obtain biochemical reaction curve data;
[0040] Obtaining biochemical reaction curve data is the starting point of the entire anomaly detection process. Biochemical reaction curve data reflects the changes in various parameters over time during the chemical reaction process and is the basis for anomaly detection.
[0041] S1.1: Real-time collection of reaction curve data from the biochemical analyzer;
[0042] By establishing a real-time data connection with a biochemical analyzer, real-time reaction curve data can be acquired using a standardized communication protocol (such as ASTM, HL7, or a custom protocol). For example, using the RS-232 serial communication protocol, reaction curve data can be collected at a frequency of 10 data points per second. The data format includes information such as timestamp, absorbance value, and reaction temperature.
[0043] The reaction curve is as follows Figure 2a and Figure 2b As shown, the horizontal axis represents time (minutes) and the vertical axis represents absorbance. Figure 2a and Figure 2b Different reaction reagents were added at different time periods (such as the 6th minute), causing a sudden change in the absorbance value, showing a nonlinear relationship. If no mutation occurs at this time, it proves that the biochemical reaction curve is abnormal.
[0044] S1.2: Extracting stored reaction curve data from the historical database;
[0045] Through database query and data mining technology, relevant reaction curve data is extracted from the historical database to provide more reference samples and training data for anomaly detection.
[0046] You can use the SQL query statement "SELECT FROM reaction_curves WHERE test_type = 'glucose' AND date > '2023-01-01' ORDER BY date DESC LIMIT 1000" to extract the reaction curve data of the most recent 1000 glucose tests.
[0047] For example Figure 2c and Figure 2d , its horizontal and vertical axes and Figure 2a , Figure 2bThe results are the same, but the values presented are different. Manual analysis of the graph alone cannot determine whether it is normal or abnormal. It is necessary to combine clinical trial scenarios and artificial intelligence analysis to infer whether it is abnormal.
[0048] For example, Table 1 is a numerical statistic of the absorbance values of the main wavelength of blood glucose over a period of time.
[0049] Table 1
[0050]
[0051]
[0052] From the last two rows in Table 1, we can see that the main wavelength absorbance value of blood glucose 11.153 is higher than the absorbance value of 11.279. Therefore, there are many factors that may affect the absorbance, and more accurate conclusions need to be obtained through analysis of artificial intelligence models.
[0053] S2: Preprocess the biochemical reaction curve data to obtain preprocessed data
[0054] Preprocessing is a critical step to improve the accuracy of subsequent analysis by removing noise, standardizing data, and enhancing datasets to provide high-quality input for AI models.
[0055] S2.1: Remove noise and outliers
[0056] Use signal processing and statistical methods to identify and remove noise and outliers in data to improve data quality.
[0057] For example, a median filter is applied to remove impulse noise; a wavelet transform is used to remove multi-scale noise; an outlier detection algorithm based on a moving window is implemented; and a Hampel filter is used to identify and replace local outliers.
[0058] For a response curve containing 100 data points, a median filter with a length of 5 was used to remove high-frequency noise, and then the 3σ principle was applied to identify and eliminate outliers.
[0059] S2.2: Normalize biochemical reaction curve data
[0060] By converting the data to a unified scale range, the dimensional differences between different response curves are eliminated and the generalization ability of the model is improved.
[0061] You can use methods such as minimum-maximum normalization and Z-score normalization to select the most suitable normalization method based on the data distribution characteristics;
[0062] Specifically, min-max normalization is applied to the absorbance data to map the values to the [0, 1] interval: normalized_value = (value min_value) / (max_value min_value).
[0063] S2.3: Data enhancement processing of the normalized biochemical reaction curve data
[0064] Data augmentation is an effective means to improve the robustness and generalization ability of the model. By creating diverse training samples, the model can better cope with various situations in the actual environment.
[0065] S2.3.1: Superimpose Gaussian random noise on biochemical reaction curve data
[0066] Random noise is added to simulate the uncertainty in actual measurements and improve the model's tolerance to noise.
[0067] Specifically include:
[0068] 1. Implement a Gaussian noise generator with adjustable mean and standard deviation;
[0069] 2. Design a noise intensity adaptive mechanism to dynamically adjust the noise level according to the strength of the original signal;
[0070] 3. Realize the local noise addition function to simulate the noise characteristics of different reaction stages;
[0071] 4. Provide a visualization tool for noise superposition to facilitate debugging and verification.
[0072] In one embodiment, Gaussian noise with a mean of 0 and a standard deviation of 0.01 is added to the normalized response curve data: noisy_data=original_data+np.random.normal(0,0.01,size=original_data.shape).
[0073] S2.3.2: Apply nonlinear transformations to the time axis to simulate changes in reaction speed
[0074] By performing nonlinear transformation on the time axis, the effects of different environmental conditions (such as temperature and pH value) on the reaction rate are simulated, thereby enhancing the model's adaptability to changes in reaction kinetics.
[0075] Specifically include:
[0076] 1. Implement a variety of nonlinear transformation functions, such as quadratic function, exponential function, logarithmic function, etc.;
[0077] 2. Design a random sampling strategy for transformation parameters to generate diverse timeline transformation effects;
[0078] 3. Ensure that the transformed time series is still monotonically increasing;
[0079] 4. Implement the inverse transformation function for interpretation and verification of the results.
[0080] For example, a quadratic function is used to perform time axis transformation: t_new=at^2+b t+c, where a, b, and c are randomly generated parameters that meet certain constraints to ensure the rationality of the transformation.
[0081] S3: Extract features and calculate metrics
[0082] Feature extraction and indicator calculation are the processes of converting raw data into more representative and discriminative information, providing high-quality input for subsequent artificial intelligence model analysis.
[0083] S3.1: Extract time series features, including slope and curvature
[0084] By calculating the first-order derivative (slope) and second-order derivative (curvature) of the reaction curve at different time points, the changing characteristics of the reaction kinetics are captured.
[0085] Specifically include:
[0086] 1. Implement numerical differentiation algorithms, such as central difference method, five-point difference method, etc.;
[0087] 2. Using sliding window techniques, calculate local slope and curvature;
[0088] 3. Apply smoothing techniques (such as Savitzky-Golay filtering) to reduce noise amplification during the differentiation process;
[0089] 4. Implement adaptive step size selection to balance computational accuracy and efficiency.
[0090] Specifically, in an embodiment of the present invention, for a time series data point t[i], y[i]), the slope is calculated using the central difference method:
[0091] slope[i]=y[i+1]-y[i-1]) / (t[i+1]-t[i-1]), i is from 1 to n-1.
[0092] S3.2: Extract frequency domain features, including main frequency and energy distribution
[0093] By converting the time domain signal into the frequency domain, the periodic characteristics and energy distribution of the response curve are extracted, which may reflect certain abnormal patterns.
[0094] For example, implement the fast Fourier transform (FFT) algorithm to efficiently calculate the spectrum; apply window functions (such as Hamming window) to reduce spectrum leakage; calculate the power spectral density (PSD) to analyze the distribution of signal energy at different frequencies; implement the main frequency extraction algorithm, such as peak detection or centroid method.
[0095] Specifically, you can use the FFT function of the NumPy library to calculate the spectrum: spectrum = np.fft.fft signal), and then find the non-zero frequency component with the largest amplitude as the main frequency.
[0096] S3.3: Calculate relevant biochemical indicators, including reaction rate, substrate concentration, absorbance, etc.
[0097] Based on reaction kinetics theory, key biochemical indicators are extracted from the reaction curve, which directly reflect the progress and efficiency of the reaction.
[0098] Implement reaction rate calculation algorithms, such as the initial rate method and the integral method; use nonlinear regression technology to fit the Michaelis-Menten equation to estimate kinetic parameters; implement a dynamic estimation algorithm for substrate concentration, taking into account the consumption of substrates during the reaction; design indicator anomaly detection rules, such as rate mutations and abnormal substrate consumption.
[0099] The reaction rate was calculated using the initial rate method. The first 10% time period of the reaction curve was selected and the slope was obtained by linear regression as the initial reaction rate.
[0100] S4: Use artificial intelligence models to analyze pre-processed data and identify abnormal reaction curves
[0101] This step is the core of the entire method. It analyzes the preprocessed data through a variety of advanced artificial intelligence models to achieve intelligent identification of abnormal reaction curves.
[0102] In one embodiment, S4 includes steps A1-A4:
[0103] Step A1: Dataset Division
[0104] Step A1.1: Divide the dataset into training set, validation set and test set in a ratio of 8:1:1
[0105] Step A1.2: Ensure that the ratio of normal samples to abnormal samples in each subset is consistent
[0106] Step A2: Select an appropriate artificial intelligence algorithm, such as a machine learning algorithm and / or a deep learning algorithm.
[0107] Step A2.1: Use classification algorithms such as Support Vector Machine (SVM) and Random Forest
[0108] Step A2.2: Build a deep learning model, such as a long short-term memory network (LSTM) or a one-dimensional convolutional neural network (1DCNN)
[0109] Step A3: Model training
[0110] Step AA1: Train the selected model using the training set
[0111] Step AA2: Tune model hyperparameters through cross-validation
[0112] Step A4: Model evaluation and optimization
[0113] Step A4.1: Evaluate model performance on the validation set and calculate indicators such as accuracy, precision, and recall
[0114] Step A4.2: Optimize model structure or parameters based on evaluation results
[0115] The specific instructions for steps A1-A4 are as follows:
[0116] A1 Dataset Division
[0117] A1.1 Training, Validation, and Test Set Division
[0118] The dataset is divided into training set, validation set and test set in a ratio of 8:1:1. Stratified sampling method can be used to ensure the same ratio of normal samples and abnormal samples in each subset.
[0119] Implementation code example:
[0120] ```Python
[0121] from sklearn.model_selection import train_test_split
[0122] X_train_val,X_test,y_train_val,y_test=train_test_split(X,y,test_size=0.1,stratify=y,random_state=42)
[0123] X_train,
[0124] ```
[0125] A1.2 Data Balancing Processing
[0126] Check the ratio of normal samples to abnormal samples in the training set
[0127] If there is a severe class imbalance, consider using one of the following methods:
[0128] 1. Oversampling technology (such as SMOTE)
[0129] 2. Undersampling techniques (such as random undersampling)
[0130] Category A weight adjustment
[0131] Implementation code example (using SMOTE):
[0132] ```Python
[0133] from imblearn.over_sampling import SMOTE
[0134] smote=SMOTE(random_state=42)
[0135] X_train_resampled,y_train_resampled=smote.fit_resample(X_train,y_train)
[0136] ```
[0137] A2 Selecting an appropriate machine learning algorithm
[0138] A2.1 Algorithms Considered
[0139] 1. Support Vector Machine (SVM)
[0140] Advantages: Applicable to high-dimensional feature space, good effect on small sample data sets
[0141] Note: Feature scaling is required, and kernel function selection has a significant impact on performance
[0142] 2. Random Forest
[0143] Advantages: Can handle high-dimensional data, not prone to overfitting, can evaluate feature importance
[0144] Note: Relatively insensitive to hyperparameters, but still requires tuning
[0145] 3. Gradient Boosted Decision Tree (GBDT), such as XGBoost or LightGBM
[0146] Advantages: Generally has good predictive performance and can handle different types of features
[0147] Note: It is more prone to overfitting than random forests and requires careful parameter adjustment.
[0148] A2.2 Deep Learning Model Selection
[0149] 1. Long Short-Term Memory (LSTM)
[0150] Advantages: Suitable for processing sequence data and can capture long-term dependencies
[0151] Note: A larger dataset is required and the training time may be longer.
[0152] 2. One-dimensional Convolutional Neural Network (1DCNN)
[0153] Advantages: suitable for extracting local features, high computational efficiency
[0154] Note: It is necessary to design a suitable network structure, which may require more experiments
[0155] A3 model training
[0156] A3.1 Basic Model Training
[0157] Perform initial training using default parameters or parameters based on experience
[0158] For each algorithm, implement the basic training process
[0159] Sample code (taking random forest as an example):
[0160] ```Python
[0161] from sklearn.ensemble import RandomForestClassifier
[0162] from sklearn.metrics import accuracy_score,classification_report
[0163] rf_model=RandomForestClassifier(random_state=42)
[0164] rf_model.fit(X_train,y_train)
[0165] y_pred=rf_model.predict(X_val)
[0166] print(f"Validation Accuracy:{accuracy_score(y_val,y_pred)}")
[0167] print(classification_report(y_val,y_pred))
[0168] ```
[0169] A2 deep learning model training
[0170] Design the network structure, including the number of layers, the number of neurons in each layer, etc.
[0171] Choose an appropriate optimizer and learning rate
[0172] Implement the training loop, including forward propagation, backpropagation, and parameter updates
[0173] Sample code (taking LSTM as an example):
[0174] ```Python
[0175] import torch
[0176] import torch.nn as nn
[0177] import torch.optim as optim
[0178] class LSTMModel(nn.Module):
[0179] def__init__(self,input_size,hidden_size,num_layers,output_size):
[0180] super(LSTMModel,self).__init__()
[0181] self.lstm=nn.LSTM(input_size,hidden_size,num_layers,batch_first=True)
[0182] self.fc=nn.Linear(hidden_size,output_size)
[0183] def forward(self,x):
[0184] out,_=self.lstm(x)
[0185] out=self.fc(out[:,1,:])
[0186] return out
[0187] model=LSTMModel(input_size=18,hidden_size=64,num_layers=2,output_size=1)
[0188] criterion=nn.BCEWithLogitsLoss()
[0189] optimizer=optim.Adam(model.parameters())
[0190] num_epochs=100
[0191] for epoch in range(num_epochs):
[0192] model.train()
[0193] for batch_X,batch_y in train_loader:
[0194] optimizer.zero_grad()
[0195] outputs=model(batch_X)
[0196] loss=criterion(outputs,batch_y.unsqueeze(1))
[0197] loss.backward()
[0198] optimizer.step()
[0199] 验证
[0200] model.eval()
[0201] with torch.no_grad():
[0202] val_outputs=model(X_val)
[0203] val_loss=criterion(val_outputs,y_val.unsqueeze(1))
[0204] print(f"Epoch[{epoch+1} / {num_epochs}],Loss:{loss.item():.4f},ValLoss:{val_loss.item():.4f}")
[0205] ```
[0206] A4 Model Evaluation and Optimization
[0207] A4.1 Performance Evaluation
[0208] Evaluate model performance on the validation set
[0209] Calculate key indicators: accuracy, precision, recall, F1 score, AUCROC, etc.
[0210] Plot confusion matrix and ROC curve
[0211] Sample code:
[0212] ```Python
[0213] from sklearn.metrics import confusion_matrix,roc_auc_score,roc_curveimport matplotlib.pyplot as plt
[0214] import seaborn as sns
[0215] def plot_confusion_matrix(y_true,y_pred):
[0216] cm=confusion_matrix(y_true,y_pred)
[0217] plt.figure(figsize=(8,6))
[0218] sns.heatmap(cm,annot=True,fmt='d',cmap='Blues')
[0219] plt.title('Confusion Matrix')
[0220] plt.ylabel('True Label')
[0221] plt.xlabel('Predicted Label')
[0222] plt.show()
[0223] def plot_roc_curve(y_true,y_pred_proba):
[0224] fpr,tpr,_=roc_curve(y_true,y_pred_proba)
[0225] auc=roc_auc_score(y_true,y_pred_proba)
[0226] plt.figure(figsize=(8,6))
[0227] plt.plot(fpr,tpr,label=f'ROC Curve(AUC={auc:.2f})')
[0228] plt.plot([0,1],[0,1],linestyle=”,label='Random Classifier')
[0229] plt.xlabel('False Positive Rate')
[0230] plt.ylabel('True Positive Rate')
[0231] plt.title('Receiver Operating Characteristic(ROC)Curve')
[0232] plt.legend()
[0233] plt.show()
[0234] 使用示例
[0235] y_pred=model.predict(X_val)
[0236] y_pred_proba=model.predict_proba(X_val)[:,1]
[0237] plot_confusion_matrix(y_val,y_pred)
[0238] plot_roc_curve(y_val,y_pred_proba)
[0239] ```
[0240] A4.2 Hyperparameter Tuning
[0241] Hyperparameter tuning using methods such as grid search, random search, or Bayesian optimization
[0242] For traditional machine learning models, you can use sklearn's GridSearchCV or RandomizedSearchCV
[0243] For deep learning models, more complex hyperparameter optimization can be performed using libraries such as Optuna
[0244] Example code (using GridSearchCV):
[0245] ```Python
[0246] from sklearn.model_selection import GridSearchCV
[0247] param_grid = {
[0248] 'n_estimators':[100,200,300],
[0249] 'max_depth':[None,10,20,30],
[0250] 'min_samples_split':[2,5,10],
[0251] 'min_samples_leaf':[1,2,4]
[0252] }
[0253] rf_model=RandomForestClassifier(random_state=42)
[0254] grid_search=GridSearchCV(estimator=rf_model,param_grid=param_grid,cv=5,scoring='f1',n_jobs=1)
[0255] grid_search.fit(X_train,y_train)
[0256] print("Best parameters:",grid_search.best_params_)
[0257] print("Best crossvalidation score:",grid_search.best_score_)
[0258] ```
[0259] A4.3 Model Integration
[0260] Consider using ensemble methods to improve model performance, such as:
[0261] 1. Voting Classifier
[0262] 2. Stack Integration
[0263] A Blending
[0264] Example code (simple voting classifier):
[0265] ```Python
[0266] from sklearn.ensemble import VotingClassifier
[0267] model1=RandomForestClassifier(random_state=42)
[0268] model2=GradientBoostingClassifier(random_state=42)
[0269] model3=SVC(probability=True,random_state=42)
[0270] voting_model=VotingClassifier(
[0271] estimators=[('rf',model1),('gb',model2),('svm',model3)],
[0272] voting='soft' )
[0274] voting_model.fit(X_train,y_train)
[0275] y_pred=voting_model.predict(X_val)
[0276] print(classification_report(y_val,y_pred))
[0277] ```
[0278] A5 Model Explanatory Analysis
[0279] A5.1 Feature Importance Analysis
[0280] For tree-based models, extract feature importance
[0281] For other models, consider using SHAP (SHapley Additive exPlanations) values
[0282] Example code (Random Forest Feature Importance):
[0283] ```Python
[0284] import pandas as pd
[0285] feature_importance=pd.DataFrame({
[0286] 'feature':X_train.columns,
[0287] 'importance':rf_model.feature_importances_
[0288] }).sort_values('importance', ascending=False)
[0289] plt.figure(figsize=(10,6))
[0290] sns.barplot(x='importance',y='feature',data=feature_importance.head(10))
[0291] plt.title('Top 10Most Important Features')
[0292] plt.show()
[0293] ```
[0294] A5.2 Local Interpretative Analysis
[0295] Analyzing individual predictions using LIME (Local Interpretable Modelagnostic Explanations)
[0296] For deep learning models, consider using visualization techniques such as GradCAM
[0297] Example code (using LIME):
[0298] ```Python
[0299] Import lime
[0300] import lime.lime_tabular
[0301] explainer=lime.lime_tabular.LimeTabularExplainer(
[0302] X_train.values,
[0303] feature_names=X_train.columns,
[0304] class_names=['Normal','Abnormal'],
[0305] mode='classification' )
[0307] Explaining a single instance
[0308] idx=0 selects the instance index to be explained
[0309] exp=explainer.explain_instance(
[0310] X_val.iloc[idx].values,
[0311] rf_model.predict_proba,
[0312] num_features=10 )
[0314] exp.show_in_notebook(show_table=True)
[0315] ```
[0316] Through the detailed steps above, the present invention can construct a powerful machine learning model to identify abnormal biochemical reaction curves. This process involves multiple aspects, including data processing, model selection, training, evaluation, and optimization. Each step is crucial to the performance of the final model. In practical applications, multiple iterations and adjustments may be required to achieve optimal results.
[0317] Specifically, assume that the embodiment of the present invention has a preprocessed biochemical reaction curve data represented as a time series. Each data point contains the time and the corresponding measurement value. For example:
[0318] ``` [
[0320] (0,0.1),(5,0.3),(10,0.5),(15,0.8),(20,1.2),
[0321] (25,1.5),(30,1.7),(35,1.8),(40,1.9),(45,2.0) ]
[0323] ```
[0324] This sequence represents the reaction process from 0 to 45 seconds, with the measured value rising from 0.1 to 2.0. Output example:
[0325] Model outputs may include:
[0326] 1. Classification results: normal / abnormal
[0327] 2. Abnormal probability: a value between 0 and 1
[0328] 3. Exception type (if an exception is detected)
[0329] For example:
[0330] ```
[0331] {
[0332] "classification": "Abnormal",
[0333] "anomaly_probability":0.92,
[0334] "anomaly_type":"Anomaly in reaction rate"
[0335] }
[0336] ```
[0337] Several possible situations of abnormal reaction curves:
[0338] 1. Abnormal reaction rate:
[0339] Too fast reaction speed: the curve rises sharply in a short period of time.
[0340] The response speed is too slow: the curve rises significantly slower than expected.
[0341] 2. Abnormal plateau period:
[0342] Reaching the plateau prematurely: The curve flattens too early.
[0343] Failure to reach a plateau: The curve does not flatten within the expected time.
[0344] 3. Baseline drift:
[0345] Abnormal starting point: The initial measurement deviates significantly from the expected baseline.
[0346] Continuous drift: The entire curve shows a continuous upward or downward trend.
[0347] 4. Abnormal noise:
[0348] High-frequency fluctuation: The curve shows abnormal rapid fluctuations.
[0349] Sudden peak: Abnormal peaks or valleys appear in the curve.
[0350] 5. Abnormal inflection point:
[0351] Multiple inflection points: The curve has multiple inflection points that should not exist.
[0352] Abnormal inflection point location: The inflection point appears at an unexpected location.
[0353] 6. Abnormal endpoint:
[0354] Endpoint value too high: The final measurement value is significantly higher than expected.
[0355] Endpoint value too low: The final measured value is significantly lower than expected.
[0356] 7. Abnormal shape:
[0357] S-shaped anomaly: The curve that should have been growing smoothly takes on an S-shape.
[0358] Staircase: The curve rises in steps rather than smoothly.
[0359] 8. Delayed reaction:
[0360] Delayed reaction start: The curve remains flat at first and then suddenly starts to rise.
[0361] 9. Interrupt exception:
[0362] Data interruption: A situation where data is missing from a curve or the measured value suddenly returns to zero.
[0363] 10. Periodic anomalies:
[0364] Unexpected cyclical fluctuations: The curve shows cyclical changes that should not occur.
[0365] An AI model (such as a 1DCNN, LSTM, or random weight neural network) analyzes these features and, based on the learned patterns, determines whether the curve is abnormal and what type of anomaly it belongs to. The model's training dataset should contain a variety of normal and abnormal samples to ensure that it can identify multiple abnormal situations.
[0366] For example, the present invention will provide specific instructions for when the artificial intelligence model is a spike neural network SNN, a long short-term memory network LSTM, a one-dimensional convolutional neural network 1DCNN, or a neural network with random weights and learning biases, respectively, using steps 4.1, 4.2, 4.3, and 4.4 for explanation:
[0367] S4.1: Analysis using Spiking Neural Networks (SNNs);
[0368] Spiking neural networks (SNNs) are artificial neural networks that mimic the workings of biological nervous systems. Unlike traditional artificial neural networks, neurons in SNNs communicate via discrete pulse signals, a method more similar to the workings of the human brain. SNNs have unique advantages when processing time series data (such as biochemical reaction curves), effectively capturing the temporal dynamics of the data.
[0369] It includes:
[0370] Pulse encoding: converting continuous biochemical reaction curve data into discrete pulse trains.
[0371] Neuron model selection: Select an appropriate neuron model based on task requirements, such as the Leaky Integrate-and-Fire (LIF) model.
[0372] Network topology design: determine the number of network layers, the number of neurons in each layer, and the connection method.
[0373] Learning rule implementation: Implement learning algorithms suitable for SNN, such as learning rules based on spike timing-dependent plasticity (STDP).
[0374] For a biochemical reaction curve containing 20-30 time points, embodiments of the present invention can use frequency encoding to convert it into a pulse sequence. For example, the value of each time point can be mapped to a firing frequency range of 0-100 Hz. These pulse sequences are then used as input to the SNN, which processes the network and outputs a classification result (normal or abnormal).
[0375] S4.1.1: Build a multi-layer SNN network structure, including input layer, hidden layer, and output layer;
[0376] The multi-layer SNN structure allows the network to extract and process features layer by layer, thereby achieving complex nonlinear mapping. By designing a suitable hierarchical structure, SNN can effectively learn time-dependent features and abnormal patterns in biochemical reaction curves.
[0377] Specifically:
[0378] Input layer design: The number of neurons is determined based on the dimension of the input data, usually corresponding to the length of the time series.
[0379] Hidden layer design: Determine the number of hidden layers and the number of neurons in each layer. Usually, more hidden layers can extract more complex features.
[0380] Output layer design: Determine the number of output neurons based on the task type (such as binary classification problem).
[0381] Connection mode: Determines the type of connection between layers, such as full connection, local connection, or sparse connection.
[0382] Activation function: Choose an activation function suitable for SNN, such as a threshold function or a more complex dynamic equation.
[0383] Assuming that there is a 100-point biochemical reaction curve in the embodiment of the present invention, the following SNN structure can be designed:
[0384] Input layer: 100 LIF neurons, corresponding to 100 time points
[0385] Hidden layer 1: 200 Izhikevich model neurons
[0386] Hidden layer 2: 100 Izhikevich model neurons
[0387] Output layer: 2 LIF neurons, representing normal and abnormal categories respectively
[0388] Each layer is fully connected, and STDP is used as the learning rule to adjust the synaptic weights.
[0389] S4.1.2: Train the SNN using the training dataset;
[0390] The goal of SNN training is to adjust network parameters (primarily synaptic weights) so that the network can correctly classify the input biochemical reaction curve. Due to the discrete nature of SNNs, traditional backpropagation algorithms cannot be directly applied, and learning algorithms designed specifically for SNNs are required. Specifically, they include:
[0391] Data preparation: Convert the biochemical reaction curves in the training dataset into pulse trains.
[0392] Learning algorithm selection: Implement a learning algorithm suitable for SNN, such as SpikeProp, STDP or its improved versions.
[0393] Loss function definition: Design a loss function suitable for SNN, such as cross entropy loss based on spike count.
[0394] Parameter update: Iteratively update network parameters based on the learning algorithm and loss function.
[0395] Training strategy: Implement training strategies such as batch processing, learning rate scheduling, and early stopping.
[0396] Performance evaluation: Regularly evaluate model performance on the validation set to monitor the training progress.
[0397] Example:
[0398] Prepare a training dataset containing 1000 normal reaction curves and 1000 abnormal reaction curves.
[0399] The improved STDP algorithm is used for training, and each epoch contains 100 mini-batches.
[0400] The loss function uses the cross entropy based on the number of spikes: L = -Σ(y log(p) + (1-y)log(1-p)), where y is the true label and p is the normalized number of spikes of the output neuron.
[0401] The initial learning rate is set to 0.01 and decays by 10% every 50 epochs.
[0402] Train for 1000 epochs or until the validation set accuracy does not improve for 10 consecutive epochs.
[0403] The model performance is evaluated on the validation set every 10 epochs, and the accuracy, precision, and recall are recorded.
[0404] S4.1.3: Compression and Hidden Display on SNN
[0405] Compression is a network optimization technique that aims to reduce the number of network parameters and computational complexity while maintaining or improving model performance. This is particularly important for SNNs, as they typically require more neurons to process time series data, which can lead to excessive consumption of computing resources.
[0406] S4.1.3.1: Add an autoencoder structure to the hidden layer
[0407] An autoencoder is an unsupervised learning method that discovers effective representations of data by learning to compress the input into a low-dimensional representation and then reconstruct it back to the original input. Incorporating an autoencoder structure into an SNN can help the network learn more compact feature representations.
[0408] In this step, we design a spike-based autoencoder architecture, including both the encoder and decoder components. We implement an autoencoder training algorithm suitable for SNNs, such as time-based spike backpropagation (STBP). We determine the size of the autoencoder's bottleneck layer to balance compression rate and reconstruction error. We integrate the autoencoder loss with the classification loss to jointly optimize the network.
[0409] Assuming that the original SNN hidden layer has 500 neurons, the embodiment of the present invention can design a spike autoencoder to compress the 500-dimensional input to 100 dimensions and then reconstruct it back to 500 dimensions. The loss function of the autoencoder can be defined as the mean squared error between the original spike train and the reconstructed spike train.
[0410] ```Python
[0411] class SpikeAutoencoder(nn.Module):
[0412] def__init__(self,input_size=500,bottleneck_size=100):
[0413] super().__init__()
[0414] self.encoder=SpikingLinear(input_size,bottleneck_size)
[0415] self.decoder=SpikingLinear(bottleneck_size,input_size)
[0416] def forward(self,x):
[0417] encoded=self.encoder(x)
[0418] decoded = self.decoder(encoded)
[0419] return decoded
[0420] # Add autoencoder after each hidden layer of SNN
[0421] snn_with_ae = nn.Sequential(
[0422] SpikingLinear(100, 500),
[0423] SpikeAutoencoder(500, 100),
[0424] SpikingLinear(500, 2) )
[0426] ```
[0427] S4.1.3.2: Design bottleneck layer to force SNN to learn compressed representation by reducing neuron number
[0428] By introducing a layer with significantly reduced neuron number (bottleneck layer) in the network, the network is forced to learn a compressed representation of the data, thereby extracting the most critical features.
[0429] Specifically, first, determine the optimal position of the bottleneck layer, usually in the middle layer of the network. Second, implement a dynamic bottleneck layer width adjustment mechanism to adaptively adjust according to task difficulty. Third, design residual connections to allow partial information to bypass the bottleneck layer, preventing information loss. Finally, implement a hierarchical training strategy, first train the part before the bottleneck layer, then train the entire network.
[0430] For example, in an embodiment of the present invention, the original 500-500-500 three-layer hidden layer structure is changed to a 500-100-500 bottleneck structure.
[0431] ```python
[0432] class SNNWithBottleneck(nn.Module):
[0433] def __init__(self):
[0434] super().__init__()
[0435] self.layer1 = SpikingLinear(100, 500)
[0436] self.bottleneck=SpikingLinear(500,100)
[0437] self.layer3=SpikingLinear(100,500)
[0438] self.output=SpikingLinear(500,2)
[0439] def forward(self,x):
[0440] x = self.layer1(x)
[0441] bottleneck=self.bottleneck(x)
[0442] x=self.layer3(bottleneck)+x#residual connection
[0443] return self.output(x)
[0444] ```
[0445] S4.1.3.3: Use sparse constraints to limit the number of activated neurons and reduce the network parameters of SNN
[0446] By introducing sparsity constraints, most neurons remain silent and only a few neurons are activated, thereby reducing the number of effective network parameters.
[0447] Among them, a variety of sparsity constraint methods are implemented, such as L1 regularization, KL divergence constraint, etc. In addition, it is necessary to design a dynamic threshold mechanism to adaptively adjust the activation threshold of neurons.
[0448] In addition, a sparsity monitoring tool is implemented to observe the sparsity of the network in real time, a sparsity reward mechanism is designed, and sparsity measurement is added to the optimization target.
[0449] Add an L1 regularization term to the output of each layer of SNN.
[0450] ```Python
[0451] def sparse_loss(model):
[0452] loss=0
[0453] for name,paramin model.named_parameters():
[0454] if'weight'in name:
[0455] loss+=torch.sum(torch.abs(param))
[0456] return loss
[0457] #In the training loop
[0458] optimizer.zero_grad()
[0459] outputs = model(inputs)
[0460] classification_loss=criterion(outputs,labels)
[0461] sparsity_loss=sparse_loss(model)
[0462] total_loss=classification_loss+0.001sparsity_loss
[0463] total_loss.backward()
[0464] optimizer.step()
[0465] ```
[0466] S4.1.3.4: Apply pruning technology to remove connections in the SNN with weights less than the weight threshold by setting the weight threshold
[0467] Pruning technology reduces network parameters and computational complexity while maintaining network performance by removing unimportant connections in the network (connections with weights close to zero).
[0468] In the embodiment of the present invention, an amplitude pruning function is implemented:
[0469] ```Python
[0470] def prune_network(model,prune_threshold):
[0471] for name,paramin model.named_parameters():
[0472] if'weight'in name:
[0473] mask=torch.abs(param.data)>prune_threshold
[0474] param.data*=mask
[0475] param.grad.data*=mask
[0476] #Apply pruning periodically during training
[0477] if epoch%prune_interval==0:
[0478] prune_threshold = calculate_threshold(model) #Calculate the threshold based on the weight distribution prune_network(model,prune_threshold)
[0479] ```
[0480] By leveraging these compression and concealment techniques, embodiments of the present invention can significantly reduce the number of parameters and computational complexity of SNNs, while maintaining or even improving their performance in biochemical reaction curve anomaly detection tasks. This is particularly useful for deploying SNN models in resource-constrained environments, such as implementing real-time anomaly detection on portable biochemical analysis devices.
[0481] S4.1.4: Update SNN parameters
[0482] In practical applications, SNNs need to be able to adapt to new data and categories while maintaining the memory of learned knowledge. This step aims to improve the scalability and adaptability of SNNs.
[0483] S4.1.4.1: Design a scalable network structure to support the addition of new categories
[0484] Designing a flexible network structure enables SNN to be extended to new categories or tasks without retraining the entire network.
[0485] Specifically include:
[0486] 1. Implement a dynamic output layer, where new output neurons can be added as needed.
[0487] 2. Design a modular network structure to facilitate the addition of new functional modules.
[0488] 3. Decouple the feature extractor and classifier so that the feature extraction part can remain stable and expand the classifier.
[0489] 4. Design a parameter sharing mechanism to enable new categories to leverage learned knowledge.
[0490] The sample code is as follows:
[0491] ```Python
[0492] class ExpandableSNN(nn.Module):
[0493] def__init__(self,input_size,initial_num_classes):
[0494] super().__init__()
[0495] self.feature_extractor=SpikingFeatureExtractor(input_size,256)
[0496] self.classifier=SpikingLinear(256,initial_num_classes)
[0497] def expand(self,num_new_classes):
[0498] new_classifier=SpikingLinear(256,self.classifier.out_features+num_new_classes)
[0499] new_classifier.weight.data[:self.classifier.out_features]=self.classifier.weight.data
[0500] self.classifier=new_classifier
[0501] def forward(self,x):
[0502] features=self.feature_extractor(x)
[0503] return self.classifier(features)
[0504] #Example
[0505] model=ExpandableSNN(input_size=100,initial_num_classes=2)
[0506] #When you need to add a new category
[0507] model.expand(num_new_classes=1)
[0508] ```
[0509] S4.1.4.2: Implement dynamic weight adjustment mechanism
[0510] Dynamically adjusting network weights enables SNN to quickly adapt to new data distributions or task requirements while maintaining memory of the original knowledge.
[0511] Specifically include:
[0512] 1. Implement elastic weight adjustment algorithms, such as Elastic Weight Consolidation (EWC).
[0513] 2. Design an importance scoring mechanism to identify the weights that are important for specific tasks.
[0514] 3. Implement a progressive learning strategy to gradually adjust the network to adapt to new tasks.
[0515] 4. Design a learning rate scheduler to dynamically adjust the learning rate based on the novelty of the task.
[0516] Sample code:
[0517] ```Python
[0518] class EWC(object):
[0519] def__init__(self,model,dataset):
[0520] self.model = model
[0521] self.dataset = dataset
[0522] self.params={n:p for n,p in self.model.named_parameters()ifp.requires_grad}
[0523] self._means = {}
[0524] self._fisher=self._calculate_fisher()
[0525] def_calculate_fisher(self):
[0526] fisher={n:torch.zeros_like(p)for n,p in self.params.items()}
[0527] self.model.eval()
[0528] for input,target in self.dataset:
[0529] self.model.zero_grad()
[0530] output=self.model(input).view(1,-1)
[0531] label=output.max(1)[1].view(-1)
[0532] loss=F.nll_loss(F.log_softmax(output,dim=1),label)
[0533] loss.backward()
[0534] for n,p in self.model.named_parameters():
[0535] if p.grad is not None:
[0536] fisher[n]+=p.grad.data*2 / len(self.dataset)
[0537] return fisher
[0538] def penalty(self,model):
[0539] loss=0
[0540] for n,p in model.named_parameters():
[0541] _loss=self._fisher[n](p self._means[n])*2
[0542] loss+=_loss.sum()
[0543] return loss
[0544] #Example
[0545] ewc=EWC(model,old_task_dataset)
[0546] for input,target in new_task_dataset:
[0547] output=model(input)
[0548] loss=criterion(output,target)+lambda_ewc ewc.penalty(model)
[0549] loss.backward()
[0550] optimizer.step()
[0551] ```
[0552] S4.1.4.3: Use knowledge distillation techniques to transfer the knowledge of the trained SNN teacher model to the newly trained SNN student model
[0553] Knowledge distillation is a technique that transfers knowledge from a complex model (teacher model) to a simpler model (student model). Applying knowledge distillation in SNNs can help the new model learn faster while retaining the original knowledge.
[0554] Specifically, it includes:
[0555] 1. Design a distillation loss function suitable for SNN, considering the characteristics of pulse sequences.
[0556] 2. Implement a temperature scaling mechanism to control the "softness" of knowledge transfer.
[0557] 3. Design the encoding method of the teacher model output to make it suitable for SNN learning.
[0558] 4. Implement a progressive distillation strategy to gradually transfer knowledge from the teacher model to the student model.
[0559] Sample code:
[0560] ```Python
[0561] class DistillationLoss(nn.Module):
[0562] def__init__(self,T=2):
[0563] super().__init__()
[0564] self.T=T
[0565] def forward(self,student_outputs,teacher_outputs,targets):
[0566] soft_targets=F.softmax(teacher_outputs / self.T,dim=1)
[0567] student_log_softmax=F.log_softmax(student_outputs / self.T,dim=1)
[0568] distillation_loss=F.kl_div(student_log_softmax,soft_targets,reduction='batchmean')(self.T*2)
[0569] student_loss=F.cross_entropy(student_outputs,targets)
[0570] return student_loss+distillation_loss
[0571] #使用示例
[0572] teacher_model=TrainedSNN()
[0573] student_model=NewSNN()
[0574] distillation_criterion=DistillationLoss(T=2)
[0575] for inputs,targets in train_loader:
[0576] teacher_outputs=teacher_model(inputs)
[0577] student_outputs=student_model(inputs)
[0578] loss=distillation_criterion(student_outputs,teacher_outputs,targets)
[0579] loss.backward()
[0580] optimizer.step()
[0581] ```
[0582] S4.1.4.4: Maintain a sample buffer to store representative samples of response curve data
[0583] Maintaining a sample buffer to store representative response curve data can help SNN keep the memory of important samples during the updating process and prevent catastrophic forgetting.
[0584] 1. Design sample selection strategies, such as selection based on uncertainty, diversity, or importance.
[0585] 2. Implement a dynamic buffer update mechanism to update samples while keeping the buffer size unchanged.
[0586] 3. Design a strategy for using buffer samples, such as mixing new and old samples during training.
[0587] 4. Implement a sample importance weighting mechanism to assign different learning weights to different samples.
[0588] Sample code:
[0589] ```Python
[0590] class ReplayBuffer:
[0591] def__init__(self, capacity):
[0592] self.capacity = capacity
[0593] self.buffer = []
[0594] self.position = 0
[0595] def push(self,sample):
[0596] if len(self.buffer)<self.capacity:
[0597] self.buffer.append(None)
[0598] self.buffer[self.position]=sample
[0599] self.position=(self.position+1)%self.capacity
[0600] def sample(self,batch_size):
[0601] return random.sample(self.buffer,batch_size)
[0602] def__len__(self):
[0603] return len(self.buffer)
[0604] #使用示例
[0605] buffer=ReplayBuffer(10000)
[0606] #训练过程
[0607] for epoch in range(num_epochs):
[0608] for inputs,targets in train_loader:
[0609] #将新样本添加到缓冲区
[0610] for input,target in zip(inputs,targets):
[0611] buffer.push((input,target))
[0612] #从缓冲区采样
[0613] if len(buffer)>batch_size:
[0614] replay_inputs,replay_targets=zip(*buffer.sample(batch_size / / 2))
[0615] inputs=torch.cat([inputs[:batch_size / / 2],replay_inputs])
[0616] targets=torch.cat([targets[:batch_size / / 2],replay_targets])
[0617] outputs = model(inputs)
[0618] loss=criterion(outputs,targets)
[0619] loss.backward()
[0620] optimizer.step()
[0621] ```
[0622] Through these techniques, embodiments of the present invention can make SNNs more flexible and adaptable, able to handle new categories and tasks while retaining the memory of previously learned knowledge. This is particularly important for biochemical reaction curve anomaly detection systems in practical applications, as they need to constantly adapt to new reaction types and anomaly patterns.
[0623] S4.2: Analysis using Long Short-Term Memory (LSTM)
[0624] Long short-term memory (LSTM) networks are a special type of recurrent neural network that can effectively process long sequences of data and capture long-term dependencies. In anomaly detection of biochemical reaction curves, LSTM can learn the temporal dynamic characteristics of the curves and identify complex abnormal patterns.
[0625] LSTM controls the flow of information through its unique gating mechanism (input gate, forget gate, and output gate), deciding when to remember, forget, or output information. This makes LSTM particularly suitable for processing time series data with long-term dependencies, such as biochemical reaction curves.
[0626] When applying LSTM to detect anomalies in biochemical reaction curves, the embodiments of the present invention need to consider factors such as sequence length, batch processing strategy, and the number of LSTM units to balance the model's expressive power and computational efficiency.
[0627] S4.2.1: Build the LSTM network structure, including the input layer, LSTM layer, and output layer
[0628] Building the LSTM network architecture is the foundation of the entire analysis process. The input layer is responsible for receiving the pre-processed biochemical reaction curve data, the LSTM layer processes the time-series information, and the output layer gives the final classification results.
[0629] The design of the input layer needs to consider the characteristics of the data. For biochemical reaction curves, the input can be the measurement at each time point or multiple measurements within a sliding window. The number of neurons in the input layer should match the number of features at each time step.
[0630] The LSTM layer is the core of the network, responsible for learning and remembering important information in the sequence. Multiple LSTM layers can be stacked to enhance the model's expressive power. The number of units in each LSTM layer needs to be balanced according to the task complexity and available computational resources.
[0631] In addition, Dropout layers can be added between LSTM layers to prevent overfitting. Dropout enhances the model's generalization ability by randomly "turning off" a portion of neurons during training.
[0632] The output layer usually uses a fully connected layer, with the number of neurons depending on the task type. For binary classification (normal / abnormal), the output layer can have only one neuron with a sigmoid activation function. For multi-classification, the number of neurons in the output layer should equal the number of classes, with a softmax activation function.
[0633] S4.2.2: Train the LSTM using the training dataset
[0634] Training an LSTM network is an iterative optimization process aimed at minimizing the difference between predicted results and true labels.
[0635] First, suitable training data for LSTM needs to be prepared. This includes organizing biochemical reaction curve data into appropriate sequence form and preparing corresponding labels. Data augmentation, such as adding noise, time warping, etc., may be needed to improve the robustness of the model.
[0636] Choosing the right loss function is crucial. For binary classification, the binary cross-entropy loss is usually used; for multi-classification, the categorical cross-entropy loss is used.
[0637] The choice of optimizer is also important. Common choices include Adam, RMSprop, etc. These optimizers can adaptively adjust the learning rate, helping to speed up convergence and improve performance.
[0638] During training, the mini-batch gradient descent method is used. Each mini-batch should contain multiple complete sequences to fully utilize parallel computing capabilities. The choice of batch size needs to balance training stability and computational efficiency.
[0639] Implementing an early stopping strategy can prevent overfitting. Monitor the performance on the validation set and stop training when performance stops improving.
[0640] In addition, it is also important to implement a learning rate scheduling strategy. Techniques such as learning rate decay or cyclical learning rates can be used to achieve finer parameter adjustments in the later stages of training.
[0641] During the training process, the model performance is regularly evaluated on the validation set, monitoring indicators such as accuracy, precision, recall, etc. This helps to promptly identify and resolve problems in training, such as overfitting or underfitting.
[0642] Finally, the best model from the training process is saved for later use or further fine-tuning. This is usually judged based on performance metrics on the validation set.
[0643] S4.2.3: Perform the first parameter adjustment of LSTM using the standard Monte Carlo method
[0644] The standard Monte Carlo method is an optimization technique based on random sampling, used to find the optimal configuration in a large parameter space. Applying this method to the LSTM model can help embodiments of the present invention find better initial parameter settings, thereby improving model performance.
[0645] The core idea of this method is to explore the parameter space through random sampling, evaluate the performance of multiple parameter combinations, and then select the best combination. It is particularly suitable for situations where the parameter space is large and there may be complex interactions between parameters, such as hyperparameter tuning of LSTM networks.
[0646] S4.2.3.1: Define the parameter search space, including learning rate, number of LSTM units, and number of layers
[0647] Defining the parameter search space is the first step in the Monte Carlo method, which determines the range and granularity of parameters to be explored in the embodiments of the present invention. For LSTM networks, the following parameters are mainly considered:
[0648] Learning rate: Usually defined on a logarithmic scale, for example, from 1e-5 to 1e-1. This is because the learning rate has a significant impact on model training, and the optimal value is usually significantly different in magnitude.
[0649] Number of LSTM units: This can be defined as an integer range, such as 32 to 512. The number of units affects the capacity and complexity of the model, requiring a balance between expressiveness and computational efficiency.
[0650] Number of layers: Usually defined as a small integer, such as 1 to 5. Increasing the number of layers can improve the expressiveness of the model, but it also increases the risk of overfitting and computational complexity.
[0651] In addition, other parameters can also be considered, such as dropout rate, batch size, etc. Each parameter should have a reasonable value range, which can be determined based on domain knowledge or preliminary experimental results.
[0652] S4.2.3.2: Generate multiple parameter combinations from the parameter search space based on random sampling function
[0653] Random sampling is the core of the Monte Carlo method. The embodiment of the present invention needs to implement a sampling function that can randomly generate parameter combinations from a defined parameter space.
[0654] For continuous parameters (such as learning rate), you can use uniform distribution or log uniform distribution for sampling. For discrete parameters (such as the number of layers), you can use discrete uniform distribution.
[0655] The sampling process should take into account the dependencies between parameters. For example, when the number of layers increases, it may be necessary to reduce the number of units in each layer to control the overall complexity of the model.
[0656] The number of parameter combinations generated is a trade-off between exploration sufficiency and computational resources. Typically, generating tens to hundreds of combinations is a reasonable starting point.
[0657] S4.2.3.3: Calculate the performance indicators of each parameter group in multiple parameter combinations based on the evaluation function
[0658] The evaluation function is used to measure the performance of each set of parameters. For the task of anomaly detection in biochemical reaction curves, the following indicators can be considered:
[0659] Accuracy: The proportion of samples that are correctly classified.
[0660] Precision and Recall: Special attention is paid to the performance of anomaly detection.
[0661] F1 score: the harmonic average of precision and recall.
[0662] AUC-ROC: Evaluates the performance of the model at different decision thresholds.
[0663] The evaluation process typically involves training the model with given parameters and then testing its performance on a validation set. To reduce the effects of randomness, multiple training and evaluation cycles can be performed and the average performance can be taken.
[0664] Considering the limitation of computing resources, early stopping strategy or limiting the number of training rounds can be used to speed up the evaluation process.
[0665] S4.2.3.4: Iterate and optimize to select the first parameter combination with the best performance
[0666] After evaluating all parameter combinations, embodiments of the present invention need to analyze the results and select the best combination, which is usually based on key performance indicators such as the F1 score or AUC-ROC value on the validation set.
[0667] In addition to selecting a single optimal combination, the impact trend of parameters on performance should also be analyzed. This can help embodiments of the present invention understand the interaction between parameters and provide guidance for subsequent optimization.
[0668] Visualization techniques such as scatter plots or heat maps can be used to show the relationship between parameters and performance. This helps to intuitively understand the structure of the parameter space.
[0669] After selecting the best parameter combination, the model should be retrained on the full training set using these parameters and a final evaluation should be performed on the test set to verify the effectiveness of the parameters.
[0670] Finally, record the findings and optimal parameter combinations throughout the process to provide a basis for subsequent model iteration and optimization. This process may need to be repeated multiple times, each time adjusting the parameter search space based on the previous results to gradually approach the global optimal solution.
[0671] S4.2.4: Second parameter adjustment of LSTM using quasi-Monte Carlo method
[0672] Quasi-Monte Carlo methods are an improvement on standard Monte Carlo methods that use low-discrepancy sequences instead of pure random sampling to more evenly cover the parameter space. Such methods often converge to the optimal solution faster, especially in high-dimensional parameter spaces.
[0673] Using a quasi-Monte Carlo method in LSTM parameter tuning can more effectively explore the parameter space, especially in the refinement search phase after the first parameter adjustment. This method can provide more comprehensive and uniform coverage of the parameter space with a smaller number of sampling points.
[0674] S4.2.4.1: Select low-discrepancy sequences, including Sobol or Halton sequences
[0675] Low-discrepancy sequences are the core of quasi-Monte Carlo methods. These sequences are more evenly distributed in the parameter space and can more effectively explore the interactions between parameters.
[0676] The Sobol sequence is a commonly used low-discrepancy sequence that performs well in high-dimensional spaces and maintains good uniformity. The Sobol sequence is generated based on a series of direction numbers, which can gradually generate sampling points.
[0677] Another popular choice is the Halton sequence, which generates sequences based on the base expansion of different prime numbers. The Halton sequence performs well in low-dimensional spaces, but may exhibit correlation in high-dimensional spaces.
[0678] The choice of sequence depends on the dimensionality and characteristics of the problem. For LSTM parameter tuning, if there are many parameters to tune (high dimensionality), the Sobol sequence may be more appropriate; if there are few parameters (low dimensionality), the Halton sequence may be sufficient.
[0679] S4.2.4.2: Generate low-discrepancy points using a sampling function based on a low-discrepancy sequence
[0680] Based on the selected low-discrepancy sequence, embodiments of the present invention need to implement a sampling function to generate low-discrepancy points in the parameter space. This process involves mapping the low-discrepancy sequence to actual parameter values.
[0681] For each parameter, its range and distribution need to be defined. For example, the learning rate may be uniformly distributed on a logarithmic scale, while the number of LSTM units may be uniformly distributed on a linear scale.
[0682] The sampling function should be able to generate a predetermined number of sampling points. The number of sampling points should be large enough to cover the parameter space, but also take into account the limitations of computing resources.
[0683] The generated low-discrepancy points should cover the entire parameter space, including edge cases. This helps discover extreme parameter combinations that might be missed by random sampling.
[0684] S4.2.4.3: Map the generated low-difference points to the first parameter combination to generate the second parameter combination
[0685] This step maps the points generated by the low-discrepancy sequence to actual parameter values to generate candidate combinations for the second round of parameter adjustment.
[0686] The mapping process should take into account the results of the first parameter adjustment. You can focus the search range around the areas that performed well in the first adjustment to conduct a more refined search.
[0687] For continuous parameters (such as learning rate), linear or nonlinear mapping functions can be used to convert low-difference points to actual parameter values. For discrete parameters (such as the number of layers), rounding or thresholding methods can be used.
[0688] When mapping, care should be taken to maintain a reasonable relationship between parameters. For example, ensure that deeper networks do not have too many LSTM units to avoid over-parameterization.
[0689] The resulting second parameter combination should include both small adjustments to the first best result as well as some larger changes to balance local optimization and global exploration.
[0690] S4.2.4.4: Evaluate the second parameter combination after mapping
[0691] The process of evaluating the second parameter combination is similar to the first parameter adjustment, but can be more refined and rigorous.
[0692] Use the same evaluation metrics as the first tuning, such as accuracy, F1 score, AUC-ROC, etc., to maintain consistency and comparability.
[0693] Consider increasing the rigor of your evaluation, for example using k-fold cross-validation to obtain more stable performance estimates.
[0694] New evaluation indicators, such as model convergence speed and overfitting degree, can be introduced to comprehensively evaluate the performance of parameter combinations.
[0695] Compare the second parameter combination with the best result of the first adjustment and analyze the magnitude and pattern of performance improvement.
[0696] Record and visualize evaluation results to identify trends and patterns in parameter adjustments. This can help understand the impact of different parameters on model performance.
[0697] Based on the evaluation results, the best parameter combination is selected. If the second adjustment does not bring significant improvement, the results of the first adjustment can be considered.
[0698] Finally, the final model is trained on the full dataset using the selected optimal parameters, and a final evaluation is performed on an independent test set to verify the effectiveness of the parameter tuning.
[0699] S4.3: Analysis using one-dimensional convolutional neural network 1DCNN
[0700] One-dimensional convolutional neural networks (1DCNNs) are powerful tools for processing sequential data, particularly for analyzing time series data such as biochemical reaction curves. 1DCNNs can automatically learn local features and long-range dependencies, effectively extracting features while preserving temporal information, making them ideal for anomaly detection tasks.
[0701] The main advantage of 1DCNN is its ability to capture local patterns and features while learning more complex temporal dependencies through deep structures. This property enables 1DCNN to identify subtle changes and abnormal patterns in biochemical reaction curves, even if these patterns appear at different time scales.
[0702] When applying 1DCNN in biochemical reaction curve anomaly detection, embodiments of the present invention need to consider factors such as network depth, convolution kernel size, and pooling strategy to balance the model's expressive power, computational efficiency, and generalization performance.
[0703] S4.3.1: Build a 1DCNN network structure, including convolutional layers, pooling layers, and fully connected layers
[0704] Building a 1DCNN network structure is the foundation of the entire analysis process. A typical 1DCNN structure consists of multiple convolutional layers, pooling layers, and finally a fully connected layer. Each component has its own specific role and design considerations:
[0705] Convolutional layer:
[0706] The convolution layer is the core of 1DCNN and is responsible for extracting local features. In biochemical reaction curve analysis, the convolution operation can capture the change pattern in a short period of time.
[0707] The following factors need to be considered when designing convolutional layers:
[0708] 1. Convolution kernel size: This determines the size of the time window considered in each convolution operation. Smaller kernels can capture rapid changes, while larger kernels can capture longer-term patterns.
[0709] 2. Number of convolution kernels: More convolution kernels can learn more diverse features, but also increase the complexity of the model.
[0710] 3. Step size: controls the sliding speed of the convolution operation and affects the temporal resolution of the output.
[0711] 4. Padding strategy: You can use zero padding to maintain the output size, or use efficient convolution to reduce the output size.
[0712] Pooling layer:
[0713] The pooling layer is used to reduce the resolution of the feature map and extract the most significant features. In 1DCNN, maximum pooling or average pooling is commonly used.
[0714] Design considerations for the pooling layer:
[0715] 1. Pooling window size: determines the degree of feature compression.
[0716] 2. Step size: Usually the same as the window size to avoid overlap.
[0717] 3. Pooling type: Max pooling focuses more on salient features, while average pooling retains more overall information.
[0718] Fully connected layer:
[0719] The fully connected layer is located at the end of the network and is responsible for mapping the learned features to the final classification results.
[0720] Design considerations for the fully connected layer:
[0721] 1. Number of layers: Usually 1-2 fully connected layers are used. Too many fully connected layers may lead to overfitting.
[0722] 2. Number of neurons: The number of neurons in the first fully connected layer is usually large, and then decreases layer by layer.
[0723] 3. Activation function: ReLU activation function is usually used, and the last layer uses sigmoid (binary classification) or softmax (multi-classification).
[0724] Other considerations for network structure design:
[0725] 1. Depth: Increasing the network depth can improve the expressiveness of the model, but it also increases the risk of overfitting and computational complexity.
[0726] 2. Residual connection: In deep networks, you can consider adding residual connections to alleviate the gradient disappearance problem.
[0727] 3. Batch Normalization: Adding a batch normalization layer after the convolutional layer can speed up training and improve model stability.
[0728] 4.Dropout: Adding Dropout between fully connected layers can reduce overfitting.
[0729] Finally, the specific design of the network structure should be adjusted and optimized based on the characteristics of the biochemical reaction curve data (such as sequence length and sampling frequency) and the task requirements (such as real-time requirements and available computing resources). It is recommended to start with a relatively simple structure and gradually increase the complexity until the optimal balance is found.
[0730] S4.3.2: Optimizing 1DCNN Hyperparameters Using a Hybrid Metaheuristic Algorithm
[0731] The hybrid metaheuristic algorithm combines the advantages of multiple optimization methods to solve complex hyperparameter optimization problems. This method is particularly suitable for 1DCNN hyperparameter tuning because it can effectively find near-optimal solutions in large-scale, high-dimensional search spaces.
[0732] S4.3.2.1: Construct genetic algorithm GA, particle swarm optimization PSO and simulated annealing SA algorithm
[0733] Genetic Algorithm (GA):
[0734] GA simulates the biological evolution process and optimizes hyperparameters through selection, crossover and mutation operations.
[0735] Key components include: chromosome encoding (representing hyperparameter combinations), fitness function (evaluating performance), selection mechanism, crossover operation, and mutation operation.
[0736] GA is good at exploring the solution space in a large range and can jump out of local optimum.
[0737] Particle Swarm Optimization (PSO):
[0738] PSO simulates group behavior, with each particle representing a set of hyperparameters moving in the search space.
[0739] Key components include: update rules for particle position and velocity, tracking of individual optimal position and global optimal position.
[0740] PSO is good at quickly converging to promising areas, but may fall into local optimum.
[0741] Simulated Annealing (SA):
[0742] SA simulates the metal cooling process, allowing to accept worse solutions with a certain probability to jump out of local optimum.
[0743] Key components include: temperature scheduling (control the probability of accepting worse solutions), neighborhood generation (generate new hyperparameter combinations), acceptance criteria.
[0744] SA performs well in local search and can fine-tune hyperparameters in the later stage.
[0745] S4.3.2.2: Design switching conditions and information exchange mechanisms for the above algorithms
[0746] Switching conditions:
[0747] Based on iteration number: switch algorithms every fixed number of iterations.
[0748] Based on performance improvement: switch when the current algorithm stagnates.
[0749] Based on exploration-exploitation balance: prefer GA and PSO in the early stage and SA in the later stage.
[0750] Information exchange mechanisms:
[0751] Population / swarm sharing: share the best individual between GA and PSO.
[0752] Optimal solution transfer: transfer the global optimal solution between algorithms.
[0753] Solution space partitioning: different algorithms are responsible for different parameter subspaces.
[0754] Collaboration strategy:
[0755] Parallel execution: Run multiple algorithms simultaneously, exchanging information periodically.
[0756] Sequential operation: Run each algorithm in a predetermined order, and each run inherits the optimal solution of the previous algorithm.
[0757] S4.3.2.3: Define the hyperparameter search space, including convolution kernel size, number of layers, and learning rate
[0758] Convolution kernel size:
[0759] Range: Usually an odd number, such as [3,5,7,9,11].
[0760] Considerations: Smaller kernels capture local features, larger kernels capture long-term dependencies.
[0761] Number of network layers:
[0762] Range: such as [2,3,4,5,6] (including convolutional layers and fully connected layers).
[0763] Considerations: Increasing the number of layers increases model complexity but also increases the risk of overfitting.
[0764] Learning rate:
[0765] Range: Typically on a logarithmic scale, like [1e-4, 1e-3, 1e-2, 1e-1].
[0766] Factors to consider: affecting the convergence speed and stability of the model.
[0767] Other possible hyperparameters:
[0768] Number of convolution kernels: such as [16, 32, 64, 128].
[0769] Pooling size: such as [2,3,4].
[0770] Dropout rate: such as [0.1, 0.3, 0.5].
[0771] Batch size: such as [32, 64, 128, 256].
[0772] S4.3.2.4: Generate and evaluate hyperparameter combinations using a hybrid strategy
[0773] Generate strategy:
[0774] Initialization: Use Latin hypercube sampling to generate the initial population to ensure coverage of the entire search space.
[0775] GA generation: Generate new hyperparameter combinations through crossover and mutation.
[0776] PSO generation: Generate new combinations by updating particle positions.
[0777] SA generation: Generates disturbances around the current optimal solution.
[0778] Evaluation strategy:
[0779] Performance indicators: such as accuracy on the validation set, F1 score, AUC, etc.
[0780] Computational cost: Consider model size and training time.
[0781] Cross-validation: Use k-fold cross-validation to improve evaluation stability.
[0782] Optimization process:
[0783] 1. Initialization: Generate different initial hyperparameter combinations.
[0784] 2. Evaluation: Train the model and evaluate the performance on the validation set.
[0785] 3. Update: Update the hyperparameter combination based on the currently used algorithm.
[0786] 4. Switch: Switch the optimization algorithm according to predefined conditions.
[0787] 5. Information exchange: Share optimal solutions and search information between different algorithms.
[0788] 6. Repeat steps 2-5 until the stopping condition is met (such as reaching the maximum number of iterations or performance no longer significantly improving).
[0789] Final selection:
[0790] Select the optimal hyperparameter combination.
[0791] Consider performance and model complexity.
[0792] Final evaluation is performed on an independent test set.
[0793] Through this hybrid metaheuristic method, the embodiments of the present invention can fully utilize the advantages of various optimization algorithms to efficiently find the optimal configuration of 1DCNN in a complex hyperparameter space, thereby improving the performance of the model in the task of biochemical reaction curve anomaly detection.
[0794] S4.3.3: Use the training dataset to train 1DCNN and use the machine learning model to assist in optimizing the training process of 1DCNN
[0795] This step combines the 1DCNN training process with the hyperparameter optimization strategy based on the machine learning model, aiming to find the optimal model configuration more efficiently.
[0796] Training 1D CNN:
[0797] Model training is performed using the prepared training dataset.
[0798] Standard deep learning training procedures are implemented, including forward propagation, backpropagation, gradient update, etc.
[0799] Appropriate learning rate scheduling strategies are adopted, such as learning rate decay or periodic learning rate.
[0800] Early stopping strategies are implemented to prevent overfitting.
[0801] S4.3.3.1: Constructing Gaussian Process Regression (GPR) or Random Forest (RF) Regression Model
[0802] Gaussian Process Regression (GPR):
[0803] GPR is a probabilistic model that can provide uncertainty estimates for predictions.
[0804] Suitable for continuous hyperparameter spaces, can capture complex nonlinear relationships.
[0805] Computational cost increases rapidly with data volume, suitable for small and medium-sized hyperparameter optimization tasks.
[0806] Random Forest Regression (RF):
[0807] RF is an ensemble learning method composed of multiple decision trees.
[0808] Suitable for discrete and continuous hyperparameter spaces, not sensitive to outliers.
[0809] Fast training speed, can handle large-scale data.
[0810] Does not directly provide uncertainty estimates for predictions, but can be approximated by tree variance.
[0811] Model construction:
[0812] Select appropriate kernel functions (GPR) or set the number and depth of trees (RF).
[0813] Use the evaluated hyperparameter combinations and their performance as training data.
[0814] Consider feature engineering, such as normalizing or encoding hyperparameters.
[0815] S4.3.3.2: Predict the performance of un-evaluated hyperparameter combinations using GPR or RF regression models
[0816] Generate candidate hyperparameter combinations:
[0817] Generate potential hyperparameter combinations using a hybrid metaheuristic algorithm.
[0818] Make sure the generated combinations cover different areas of the search space.
[0819] Performance prediction:
[0820] The candidate hyperparameter combinations are input into the trained GPR or RF model.
[0821] For GPR, get the mean and variance of the predictions.
[0822] For RF, the predicted values and the between-tree variance (as an estimate of uncertainty) are obtained.
[0823] Forecast result analysis:
[0824] Identify hyperparameter combinations with high predictive performance.
[0825] Consider the uncertainty of predictions and balance exploration and exploitation.
[0826] S4.3.3.3: Guiding the search direction of the hybrid metaheuristic algorithm based on the prediction results
[0827] Update search strategy:
[0828] Add the hyperparameter combination with high prediction performance to the population of GA, the particle swarm of PSO or the current solution of SA.
[0829] Adjust algorithm parameters such as crossover probability for GA, velocity weight for PSO, or temperature for SA to bias towards promising regions.
[0830] Explore unknown areas:
[0831] Identify areas of high forecast uncertainty, which may indicate potential high-performance areas.
[0832] Allocate a portion of computing resources to evaluating these high-uncertainty hyperparameter combinations.
[0833] Using known information:
[0834] Focus resources on evaluating hyperparameter combinations that have high predictive performance and low uncertainty.
[0835] Updated search: More fine-grained searches around known high-performing areas.
[0836] S4.3.3.4: Dynamically adjust search strategies to balance exploration and exploitation
[0837] Adaptive sampling strategy:
[0838] Initially, the algorithm tends to explore and search a wide range of hyperparameter spaces.
[0839] As the search progresses, gradually increase the proportion of utilization and focus on promising areas.
[0840] Multi-objective optimization:
[0841] Consider both prediction performance and prediction uncertainty.
[0842] The Pareto optimization method is used to select the hyperparameter combination to be evaluated next.
[0843] Dynamic resource allocation:
[0844] Dynamically adjust resource allocation of different algorithms (GA, PSO, SA) according to the current optimal solution and search progress.
[0845] Allocate more resources to algorithms that perform well, but reserve certain resources for other algorithms to maintain diversity.
[0846] Online learning and updates:
[0847] Periodically retrain the GPR or RF model to incorporate new evaluation results.
[0848] Adjust the model's hyperparameters (such as the kernel function parameters for GPR or the number of trees for RF) to adapt to changes in the search process.
[0849] Termination conditions:
[0850] Set multiple termination conditions, such as reaching a predetermined number of evaluations, performance improvement below a threshold, computation time limit, etc.
[0851] Implement a soft termination strategy to gradually reduce exploration and increase utilization when some termination conditions are met.
[0852] Result verification and analysis:
[0853] The optimal hyperparameter combination found is evaluated multiple times independently to ensure the stability of the results.
[0854] Analyze the impact of hyperparameters on performance.
[0855] By combining this approach with machine learning models, embodiments of the present invention can more intelligently guide the 1DCNN hyperparameter optimization process, finding a more optimal model configuration within limited computing resources. This approach is particularly well-suited for complex biochemical reaction curve anomaly detection tasks, effectively improving model performance and accelerating the development process.
[0856] S4.4: Analysis using neural networks with random weights and learning biases
[0857] This special neural network structure combines random weights and learnable biases to provide a computationally efficient and adaptable model that is particularly suitable for processing complex time series data such as biochemical reaction curves.
[0858] The core idea of random weight neural networks is to keep the weights of the input to the hidden layer fixed (randomly initialized and no longer updated) and only learn the bias of the output layer. This approach can greatly reduce the number of parameters that need to be optimized and speed up training while still maintaining good performance in some tasks.
[0859] S4.4.1: Construct a random weight neural network structure, including an input layer, a random weight hidden layer, and a learnable bias output layer
[0860] Input layer:
[0861] Design the input layer to match the dimensions of the biochemical response curve data.
[0862] Random weight hidden layer:
[0863] Decide on the number of hidden layers and the number of neurons in each layer. Generally, using more hidden layers can improve the expressive power of the model.
[0864] Initialization strategy: Use an appropriate random distribution to initialize weights, such as uniform distribution or Gaussian distribution. The scale of weights has an important impact on model performance.
[0865] Activation function: Choose a suitable nonlinear activation function, such as ReLU, tanh, or sigmoid. Different activation functions may lead to different feature extraction capabilities.
[0866] Learnable bias output layer:
[0867] Design the structure of the output layer to make it suitable for the anomaly detection task. For binary classification problems, a single output neuron can be used.
[0868] Initialize the biases of the output layer. These biases are the only learnable parameters in the model.
[0869] Network structure considerations:
[0870] Inter-layer connections: Consider whether to add skip connections or residual connections, which may help information flow and gradient propagation.
[0871] Regularization: Although the hidden layer weights are fixed, you can still consider using regularization techniques on the output layer, such as L1 / L2 regularization.
[0872] S4.4.2: Design and optimize learning biases, including initializing bias values and updating strategies
[0873] Bias initialization:
[0874] Consider initializing the biases with small random values, such as those sampled from a uniform or Gaussian distribution.
[0875] The initialization strategy should take into account the characteristics of the activation function to avoid saturation problems.
[0876] Update strategy:
[0877] Choose a suitable optimization algorithm such as Stochastic Gradient Descent (SGD), Adam, or RMSprop.
[0878] Design a learning rate scheduling strategy, such as learning rate decay or periodic learning rate adjustment.
[0879] Special considerations for biased learning:
[0880] Since only the bias of the output layer needs to be learned, a larger learning rate can be used to speed up the convergence.
[0881] Implement early stopping strategy to prevent overfitting.
[0882] Consider using momentum or adaptive learning rate methods to improve learning stability and efficiency.
[0883] Optimization goal:
[0884] Design a loss function suitable for the anomaly detection task, such as binary cross entropy or focal loss.
[0885] Consider adding regularization terms to the loss function to control model complexity.
[0886] Dynamic adjustment of deviation updates:
[0887] Implement a dynamic bias adjustment mechanism to adaptively adjust the bias update strategy based on model performance and data characteristics.
[0888] Consider using validation set performance to guide the bias update process, such as reducing the learning rate when validation performance stops improving.
[0889] Ensemble methods:
[0890] Consider training multiple models with different random weight initializations and then ensembling their predictions.
[0891] Explore different ensemble strategies such as simple averaging, weighted averaging, or voting.
[0892] Continuous learning and adaptation:
[0893] Design mechanisms to allow models to continue fine-tuning bias after deployment to adapt to potential changes in data distribution.
[0894] Implement an incremental learning strategy so that the model can gradually absorb new data samples.
[0895] Evaluation and Validation:
[0896] Use techniques such as cross-validation to assess the stability of model performance.
[0897] Analyze the impact of different initialization and update strategies on model performance.
[0898] By carefully designing and optimizing this neural network with random weights and learning biases, embodiments of the present invention create a computationally efficient and adaptable model, particularly well-suited for anomaly detection in biochemical reaction curves. This approach maintains model simplicity while still capturing complex data patterns, providing an effective solution for real-time or resource-constrained environments.
[0899] S4.4.3: Optimize network parameters using the improved covariance matrix adaptive evolution strategy CMAES multimodal optimization algorithm
[0900] The Covariance Matrix Adaptive Evolution Strategy (CMAES) is a powerful optimization algorithm that is particularly suitable for handling complex nonlinear optimization problems. In the optimization of random weight neural networks, CMAES can effectively optimize the learnable bias parameters.
[0901] S4.4.3.1: Build the CMAES framework
[0902] Core components of CMAES:
[0903] 1. Population: A set of candidate solutions, each of which represents a set of network bias parameters.
[0904] 2. Mean vector: represents the estimate of the current optimal solution.
[0905] 3. Covariance matrix: describes the correlation between parameters and the search direction.
[0906] 4. Step size: controls the size of the search range.
[0907] The main steps of CMAES include:
[0908] 1. Initialization: Set the initial mean vector, covariance matrix and step size.
[0909] 2. Sampling: Generate new candidate solutions based on the current distribution.
[0910] 3. Evaluation: Calculate the fitness (network performance) of each candidate solution.
[0911] 4. Selection: Select the best candidate solution to update the mean vector.
[0912] 5. Update: Update the covariance matrix and step size based on the selection results.
[0913] 6. Iteration: Repeat steps 2-5 until the termination condition is met.
[0914] S4.4.3.2: Integrate the distance-based niche method to maintain multiple excellent solutions
[0915] Among them, the introduction of the niche method includes:
[0916] 1. Define the distance metric: design a distance function that is suitable for the deviation parameter space.
[0917] 2. Niche formation: similar solutions are clustered into niches based on a distance threshold.
[0918] 3. Multimodal maintenance: retaining the local optimal solution in each ecological niche.
[0919] The main implementation steps are as follows:
[0920] 1. Cluster the population of each generation to form multiple ecological niches.
[0921] 2. Perform CMAES updates within each niche.
[0922] 3. Maintain a global elite set that includes excellent solutions from different ecological niches.
[0923] S4.4.3.3: Design a niche radius adaptive adjustment mechanism
[0924] Niche radius determines the size of the niche and affects the exploration-exploitation balance of the algorithm.
[0925] The adaptive adjustment strategy specifically includes:
[0926] 1. Initialization: Set a larger initial niche radius.
[0927] 2. Contraction mechanism: As the iteration progresses, the niche radius is gradually reduced and the local search intensity is increased.
[0928] 3. Expansion mechanism: When a new excellent solution is discovered, the niche radius is temporarily increased to promote exploration.
[0929] 4. Density-dependent adjustment: Dynamically adjust the radius based on the density of solutions within the niche.
[0930] For example, an adaptive formula such as r = r0(1t / T) can be used. α , where t is the current iteration number, T is the maximum iteration number, α is the adjustment coefficient, r and r0 are the niche radius and niche initial radius respectively.
[0931] S4.4.3.4: Implementing Step Size Adaptive Adjustment Strategy
[0932] The role of step size is to control the range and precision of CMAES search, affecting the convergence speed and solution quality.
[0933] The adaptive adjustment strategy includes:
[0934] 1. Success rate tracking: Record the rate of generating improved solutions.
[0935] 2. 1 / 5 rule: If the success rate is higher than 1 / 5, increase the step size; if it is lower than 1 / 5, decrease the step size.
[0936] 3. Exponential smoothing: Use exponential moving average to smooth the changes in step size.
[0937] The implementation method is as follows:
[0938] σ(t+1) = σ(t)exp((ps 0.2) / 0.8), where ps is the success rate and σ is the step size.
[0939] S4.4.3.5: Designing Population Diversity Maintenance Mechanism
[0940] Maintaining population diversity can prevent premature convergence and help explore a wider solution space.
[0941] The diversity maintenance strategy includes:
[0942] 1. Distance penalty: Add a distance penalty term in fitness evaluation to encourage the dispersion between solutions.
[0943] 2. Crowding degree sorting: Consider the crowding degree of solutions in selection operations, preferentially select solutions in sparse areas.
[0944] 3. Restart mechanism: When the diversity is below a certain threshold, partially reinitialize the population.
[0945] 4. Cross operation: Introduce appropriate cross operation to promote information exchange and new solution generation.
[0946] The specific implementation method is as follows:
[0947] 1. Define diversity metrics, such as the average Euclidean distance between solutions in the population.
[0948] 2. Calculate and monitor the diversity index in each iteration.
[0949] 3. When the diversity falls below a certain threshold, trigger the diversity maintenance operation.
[0950] These improvements enable the CMAES algorithm to more effectively handle multimodal optimization problems and adapt to the complexity of anomaly detection in biochemical reaction curves. This approach can find multiple high-quality solutions in parameter space, improving the model's robustness and generalization capabilities. Furthermore, the introduction of adaptive mechanisms enables the algorithm to better balance exploration and exploitation, enhancing search efficiency and solution quality.
[0951] The following three examples illustrate how to use different AI models for abnormal curve detection:
[0952] Example 1: Using a long short-term memory network (LSTM) to analyze biochemical reaction time series data, and adjusting the parameters of the LSTM algorithm based on standard Monte Carlo and quasi-Monte Carlo methods.
[0953] B1. Data Preparation and Preprocessing
[0954] B1.1. Collecting biochemical reaction time series data
[0955] B1.1.1. Obtain reaction data at multiple time points from the biochemical analyzer
[0956] B1.1.2. Collect corresponding label information (normal / abnormal)
[0957] B1.2. Data Cleaning
[0958] B1.2.1. Removing noise and outliers
[0959] B1.2.2. Handling missing data
[0960] B1.3. Data Standardization
[0961] B1.3.1. Normalizing Time Series Data
[0962] B1.3.2. Ensure that all sequences have the same length (padding or truncating if necessary)
[0963] B1.4. Dataset Division
[0964] B1.4.1. Divide the dataset into training, validation, and test sets
[0965] B1.4.2. Ensure that the proportion of normal and abnormal samples in each subset is consistent
[0966] B2. LSTM model design
[0967] B2.1. Define LSTM network structure
[0968] B2.1.1. Design the input layer (considering time steps and feature dimensions)
[0969] B2.1.2. Add one or more LSTM layers
[0970] B2.1.3. Design the output layer (for classification or regression)
[0971] B2.2. Choosing an activation function
[0972] B2.2.1. Choose an appropriate activation function (such as tanh) for the LSTM layer
[0973] B2.2.2. Choose an activation function for the output layer (e.g., sigmoid for binary classification)
[0974] B2.3. Defining loss function and optimizer
[0975] B2.3.1. Choose a loss function appropriate for the task (e.g., binary cross entropy)
[0976] B2.3.2. Selecting an optimization algorithm (such as Adam)
[0977] B3. Monte Carlo method implementation
[0978] B3.1. Standard Monte Carlo (MC) method
[0979] B3.1.1. Define the parameter search space (learning rate, number of LSTM units, number of layers, etc.)
[0980] B3.1.2. Implement a random sampling function to generate parameter combinations from the search space
[0981] B3.1.3. Design an evaluation function to calculate the performance index for each set of parameters
[0982] B3.2. Quasi-Monte Carlo (QMC) method
[0983] B3.2.1. Select an appropriate low-discrepancy sequence (such as Sobol sequence or Halton sequence)
[0984] B3.2.2. Implementing a sampling function based on a selected sequence
[0985] B3.2.3. Mapping the generated low-discrepancy points to the parameter search space
[0986] B4.LSTM parameter adjustment process
[0987] B4.1. Initial parameter settings
[0988] B4.1.1. Set initial LSTM parameters (based on experience or default values)
[0989] B4.1.2. Define the number of iterations for parameter adjustment
[0990] B4.2.MC / QMC Sampling and Evaluation
[0991] B4.2.1. Generate parameter combinations using MC or QMC methods
[0992] B4.2.2. Model training and evaluation for each set of parameters
[0993] B4.2.3. Record the performance indicators of each set of parameters
[0994] B4.3. Parameter Optimization
[0995] B4.3.1. Analyze the evaluation results and select the parameter combination with the best performance
[0996] B4.3.2. Based on the optimal parameters, narrow the search space for the next round of iteration
[0997] B4.4. Iterative Optimization
[0998] B4.4.1. Repeat steps B4.2 and B4.3 until the predetermined number of iterations is reached or the performance converges
[0999] B4.4.2. Record the best parameters and corresponding performance indicators for each iteration
[1000] B5. Model training and validation
[1001] B5.1. Training the LSTM model using optimized parameters
[1002] B5.1.1. Training the model on the training set
[1003] B5.1.2. Using the validation set for model tuning
[1004] B5.2. Model Evaluation
[1005] B5.2.1. Evaluate model performance on the test set
[1006] B5.2.2. Calculate key metrics (such as accuracy, precision, recall, and F1 score)
[1007] B5.3. Model Interpretation Analysis
[1008] B5.3.1. Visualizing the activation state of the LSTM layer
[1009] B5.3.2. Analyzing the model's attention to different time steps
[1010] B6.System Integration and Deployment
[1011] B6.1. Develop real-time data processing modules
[1012] B6.1.1. Implementing data interface with biochemical analyzer
[1013] B6.1.2. Design a real-time data preprocessing process
[1014] B6.2. Ensemble LSTM Model
[1015] B6.2.1. Integrate the trained LSTM model into the system
[1016] B6.2.2. Realize real-time prediction function
[1017] B6.3. Result display and alarm system
[1018] B6.3.1. Design a user interface to display forecast results and key indicators
[1019] B6.3.2. Implement anomaly detection and alarm mechanism
[1020] B7. System Verification and Continuous Optimization
[1021] B7.1. Laboratory Validation
[1022] B7.1.1. Conduct system testing in a simulated environment
[1023] B7.1.2. Evaluate the accuracy and real-time performance of the system
[1024] B7.2. Clinical trials
[1025] B7.2.1. Deploy the system in a real clinical setting
[1026] B7.2.2. Collect clinical feedback and evaluate system effectiveness
[1027] B7.3. Continuous Optimization
[1028] B7.3.1. Regularly update the model with new data
[1029] B7.3.2. Adjust parameters and model structure based on clinical feedback
[1030] These steps describe how to use an LSTM network to analyze biochemical reaction time series data and tune the LSTM algorithm parameters using standard Monte Carlo and quasi-Monte Carlo methods. This approach effectively captures long-term dependencies in time series data while improving model performance and stability through advanced parameter tuning techniques.
[1031] Example 2: Using a one-dimensional convolutional neural network (1DCNN) to identify biochemical reaction curve patterns, and in the process, using a hybrid metaheuristic and machine learning model to optimize
[1032] C1. Data Preparation and Preprocessing
[1033] C1.1. Collecting Biochemical Reaction Curve Data
[1034] C1.1.1. Obtaining Reaction Curve Data from Biochemical Analyzers
[1035] C1.1.2. Collecting Corresponding Label Information (Normal / Abnormal / Specific Abnormal Type)
[1036] C1.2. Data Cleaning and Standardization
[1037] C1.2.1. Removing Noise and Outliers
[1038] C1.2.2. Normalizing Data
[1039] C1.3. Data Augmentation
[1040] C1.3.1. Applying Time Warping Techniques
[1041] C1.3.2. Adding Gaussian Noise
[1042] C1.4. Dataset Division
[1043] C1.4.1. Dividing Dataset into Training, Validation, and Test Sets
[1044] C1.4.2. Ensuring Consistent Proportions of Each Class in Subsets
[1045] C2.1 DCNN Model Design
[1046] C2.1. Defining Network Structure
[1047] C2.1.1. Designing Input Layer (Considering Time Series Length and Feature Dimension)
[1048] C2.1.2. Adding Multiple One-Dimensional Convolution Layers and Pooling Layers
[1049] C2.1.3. Designing Fully Connected Layers and Output Layer
[1050] C2.2. Selecting Activation Functions
[1051] C2.2.1. Selecting Activation Functions for Convolution Layers and Fully Connected Layers (e.g., ReLU)
[1052] C2.2.2. Selecting Appropriate Activation Functions for Output Layer (e.g., Softmax for Multi-Classification)
[1053] C2.3. Defining Loss Function and Optimizer
[1054] C2.3.1. Selecting Suitable Loss Function for Task (e.g., Cross-Entropy)
[1055] C2.3.2. Select an optimization algorithm (such as Adam or RMSprop)
[1056] C3. Hybrid metaheuristic optimization algorithm design
[1057] C3.1. Selecting a Base Metaheuristic Algorithm
[1058] C3.1.1. Implementing a Genetic Algorithm (GA)
[1059] C3.1.2. Implementing Particle Swarm Optimization (PSO)
[1060] C3.1.3. Implementing the Simulated Annealing Algorithm (SA)
[1061] C3.2. Designing Hybrid Strategies
[1062] C3.2.1. Define algorithm switching conditions
[1063] C3.2.2. Implementing information exchange mechanisms between algorithms
[1064] C3.3. Defining the search space
[1065] C3.3.1. Determine the hyperparameters that need to be optimized (such as convolution kernel size, number of layers, learning rate, etc.)
[1066] C3.3.2. Define a range of values for each hyperparameter
[1067] C4. Machine Learning Model-Assisted Optimization
[1068] C4.1. Selecting an auxiliary learning model
[1069] C4.1.1. Implementing the Gaussian Process Regression (GPR) Model
[1070] C4.1.2. Implementing a Random Forest (RF) Regression Model
[1071] C4.2. Training auxiliary models
[1072] C4.2.1. Use initial hyperparameter combinations and their performance as training data
[1073] C4.2.2. Update the model regularly to incorporate new assessment results
[1074] C4.3. Prediction Performance and Guided Search
[1075] C4.3.1. Using Auxiliary Models to Predict Performance for Unevaluated Hyperparameter Combinations
[1076] C4.3.2. Guiding the search direction of the hybrid metaheuristic algorithm based on prediction results
[1077] C5.1DCNN parameter optimization process
[1078] C5.1. Initialization
[1079] C5.1.1. Randomly generate an initial population of hyperparameter combinations
[1080] C5.1.2. Evaluating the Performance of the Initial Population
[1081] C5.2. Iterative Optimization
[1082] C5.2.1. Generating New Hyperparameter Combinations Using Hybrid Metaheuristics
[1083] C5.2.2. Use auxiliary learning models to pre-screen potential combinations
[1084] C5.2.3. Training and evaluating the filtered 1DCNN model
[1085] C5.2.4. Updating the Optimal Solution and Population
[1086] C5.3. Dynamic Adjustment
[1087] C5.3.1. Dynamically adjust the hybrid strategy based on the optimization progress
[1088] C5.3.2. Adaptive adjustment of search range
[1089] C5.4. Termination Conditions
[1090] C5.4.1. Reaching the predetermined number of iterations or computation time
[1091] C5.4.2. Performance improvement is lower than the set threshold
[1092] C6. Model training and validation
[1093] C6.1. Training the 1DCNN model using optimized parameters
[1094] C6.1.1. Training the model on the training set
[1095] C6.1.2. Using the Validation Set for Model Tuning
[1096] C6.2. Model Evaluation
[1097] C6.2.1. Evaluate model performance on the test set
[1098] C6.2.2. Calculate key metrics (such as accuracy, F1 score, AUCROC, etc.)
[1099] C6.3. Model Interpretability Analysis
[1100] C6.3.1. Visualizing Convolutional Kernels and Activation Maps
[1101] C6.3.2. Analyze the sensitivity of the model to different response curve characteristics
[1102] C7. System Integration and Deployment
[1103] C7.1. Develop real-time data processing modules
[1104] C7.1.1. Implementing a real-time data interface with a biochemical analyzer
[1105] C7.1.2. Design data preprocessing and feature extraction process
[1106] C7.2. Integrated optimized 1DCNN model
[1107] C7.2.1. Deploy the trained model to a production environment
[1108] C7.2.2. Implementing Real-time Prediction and Classification Functions
[1109] C7.3. Result display and alarm system
[1110] C7.3.1. Design a user-friendly interface to display identification results and key indicators
[1111] C7.3.2. Implement a multi-level anomaly detection and alarm mechanism
[1112] C8. System Verification and Continuous Optimization
[1113] C8.1. Laboratory Validation
[1114] C8.1.1. System testing in a simulated environment
[1115] C8.1.2. Evaluate the accuracy, real-time performance, and stability of the system
[1116] C8.2. Clinical trials
[1117] C8.2.1. Deploy the system in a real clinical setting
[1118] C8.2.2. Collect clinical feedback and evaluate system effectiveness
[1119] C8.3. Continuous Optimization
[1120] C8.3.1. Regularly update the model with new data
[1121] C8.3.2. Adjust model structure and optimization strategy based on clinical feedback
[1122] C8.3.3. Explore transfer learning techniques to adapt to new biochemical reaction types
[1123] These steps describe in detail how to use a one-dimensional convolutional neural network (1DCNN) to identify biochemical response curve patterns and optimize them through a hybrid metaheuristic and machine learning model. This approach combines the advantages of 1DCNN in processing time series data with advanced optimization techniques to effectively improve model performance and adaptability, thereby more accurately identifying various biochemical response curve patterns.
[1124] Example 3. A neural network with random weights and learning biases for identifying and detecting outliers in biochemical reaction curves, using an improved CMAES multimodal optimization algorithm: integrating the Niching strategy and the dynamic adaptation mechanism.
[1125] D1. Data preparation and preprocessing
[1126] D1.1. Collect biochemical reaction curve data
[1127] D1.1.1. Obtaining reaction curve data from the biochemical analyzer
[1128] D1.1.2. Label known outliers and normal data points
[1129] D1.2. Data cleaning and standardization
[1130] D1.2.1. Removing Obvious Noise and Erroneous Data
[1131] D1.2.2. Normalize the data
[1132] D1.3. Data Augmentation
[1133] D1.3.1. Creating samples using sliding window techniques
[1134] D1.3.2. Apply a small amount of random perturbation to increase data diversity
[1135] D1.4. Dataset Division
[1136] D1.4.1. Divide the dataset into training, validation, and test sets
[1137] D1.4.2. Ensure that the ratio of outliers to normal data in each subset is consistent
[1138] D2. Random Weight Neural Network (RWNN) Design
[1139] D2.1. Network structure definition
[1140] D2.1.1. Design the input layer (considering the time window size and feature dimension)
[1141] D2.1.2. Add one or more hidden layers with random weights
[1142] D2.1.3. Design the output layer (for outlier identification)
[1143] D2.2. Random Weight Initialization
[1144] D2.2.1. Generating random weight matrices for hidden layers
[1145] D2.2.2. Choose an appropriate random distribution (such as uniform distribution or Gaussian distribution)
[1146] D2.3. Learning Bias Design
[1147] D2.3.1. Introducing a learnable bias term in the output layer
[1148] D2.3.2. Initialization bias value
[1149] D3. Improved CMAES multimodal optimization algorithm design
[1150] D3.1. Standard CMAES Implementation
[1151] D3.1.1. Implementing the Basic Framework of the Covariance Matrix Adaptive Evolution Strategy (CMAES)
[1152] D3.1.2. Define the objective function (e.g., minimize the error rate of outlier detection)
[1153] D3.2. Niching Strategy Fusion
[1154] D3.2.1. Implementing the distance-based Niching method
[1155] D3.2.2. Designing a Niche Radius Adaptive Adjustment Mechanism
[1156] D3.3. Dynamic Adaptation Mechanism
[1157] D3.3.1. Implementing adaptive step size adjustment
[1158] D3.3.2. Design strategies for maintaining population diversity
[1159] D4. RWNN parameter optimization process
[1160] D4.1. Initialization
[1161] D4.1.1. Generate an initial population, where each individual represents a set of learning biases
[1162] D4.1.2. Evaluating the fitness of the initial population
[1163] D4.2. Iterative Optimization
[1164] D4.2.1. Generating New Learning Bias Combinations Using Improved CMAES
[1165] D4.2.2. Update the bias term of the RWNN model
[1166] D4.2.3. Evaluate model performance on the validation set
[1167] D4.2.4. Update population and fitness information
[1168] D4.3.Niching operation
[1169] D4.3.1. Identify and maintain niches with multiple excellent solutions
[1170] D4.3.2. Local Search within a Niche
[1171] D4.4. Dynamic Adaptation
[1172] D4.4.1. Adjusting step size based on optimization progress
[1173] D4.4.2. Dynamically adjust the niche radius
[1174] D4.5. Termination conditions
[1175] D4.5.1. Reaching the scheduled number of iterations
[1176] D4.5.2. The improvement of the best solution is lower than the threshold
[1177] D5. Model training and validation
[1178] D5.1. RWNN model training
[1179] D5.1.1. Training RWNN with Optimized Learning Bias
[1180] D5.1.2. Perform forward propagation and error calculation on the training set
[1181] D5.1.3. Update the learnable bias of the output layer only
[1182] D5.2. Model Evaluation
[1183] D5.2.1. Evaluate model performance on the test set
[1184] D5.2.2. Calculate key metrics (such as accuracy, precision, recall, and F1 score)
[1185] D5.3. Outlier detection threshold optimization
[1186] D5.3.1. Determine the optimal detection threshold using ROC curve analysis
[1187] D5.3.2. Balancing assay sensitivity and specificity
[1188] D6. Ensemble Learning and Model Fusion
[1189] D6.1. Building an RWNN Ensemble
[1190] D6.1.1. Training multiple RWNN models with different random weights
[1191] D6.1.2. Design an ensemble strategy (e.g., majority voting or averaging)
[1192] D6.2. Anomaly Detector Fusion
[1193] D6.2.1. Combining RWNN ensemble results with traditional anomaly detection methods
[1194] D6.2.2. Designing a weighted fusion mechanism
[1195] D7. System Implementation and Deployment
[1196] D7.1. Real-time data processing module
[1197] D7.1.1. Implement real-time data interface with biochemical analyzer
[1198] D7.1.2. Design real-time data preprocessing and feature extraction process
[1199] D7.2. Outlier Detection Module
[1200] D7.2.1. Integrated Optimized RWNN Model and Fusion Strategy
[1201] D7.2.2. Implementing real-time outlier detection
[1202] D7.3. Result display and alarm system
[1203] D7.3.1. Design an intuitive visual interface to display test results and suspicious data points
[1204] D7.3.2. Implement a multi-level outlier alarm mechanism
[1205] D8. System Verification and Continuous Optimization
[1206] D8.1. Laboratory Validation
[1207] D8.1.1. Conduct system testing in a simulated environment
[1208] D8.1.2. Evaluate the accuracy, real-time performance, and robustness of the system
[1209] D8.2. Clinical trials
[1210] D8.2.1. Deploy the system in a real clinical setting
[1211] D8.2.2. Collect clinical feedback and evaluate system effectiveness
[1212] D8.3. Continuous Optimization
[1213] D8.3.1. Regularly update models and optimize parameters using new data
[1214] D8.3.2. Adjust detection thresholds and alarm strategies based on clinical feedback
[1215] D8.3.3. Explore incremental learning techniques to enable models to adapt to new anomaly patterns
[1216] These steps describe in detail how to use a neural network with random weights and learning biases for outlier identification and detection in biochemical reaction curves, optimized using a modified CMAES multimodal optimization algorithm. This approach combines the fast training and good generalization capabilities of random weight neural networks with advanced optimization techniques to effectively improve the accuracy and robustness of outlier detection while being adaptable to multimodal problem spaces.
[1217] S5: Based on the analysis results of the artificial intelligence model, trigger the corresponding alarm mechanism
[1218] This step aims to convert the analysis results of the artificial intelligence model into practical and actionable alerts to ensure that abnormal situations in the biochemical reaction process are discovered and handled in a timely manner.
[1219] S5.1: Set multiple alarm levels to correspond to different degrees of abnormal situations
[1220] Example of alarm level setting:
[1221] 1. Low-level alert (Level 1):
[1222] Abnormal probability: 0.50 0.70
[1223] Situation: A slight deviation from the normal range that requires attention but is not urgent. For example: a reaction rate slightly lower than expected, or a slight baseline drift. 2. Intermediate Alarm (Level 2):
[1224] Abnormal probability: 0.70 0.85
[1225] Situation: obvious abnormality, requiring prompt treatment, for example: the response does not reach the expected plateau, or obvious noise abnormality occurs. 3. Advanced Alarm (Level 3):
[1226] Probability of anomaly: 0.85 0.95
[1227] Case: Severe anomaly, requires immediate attention e.g. reaction rate significantly abnormal, or unexpected multiple inflection points 4. Emergency alert (Level 4):
[1228] Probability of anomaly: >0.95
[1229] Case: Extreme anomaly, likely to cause experiment failure or equipment damage e.g. data interruption, or reaction curve presents completely abnormal shape S5.2: Trigger corresponding level of alert according to the degree of anomaly
[1230] Example of trigger logic:
[1231] 1. Low-level alert (Level 1):
[1232] Display yellow warning icon on system interface
[1233] Log warning information to log file
[1234] Send low-priority notification to laboratory management system
[1235] 2. Medium-level alert (Level 2):
[1236] Display orange warning icon on system interface and pop-up prompt window, send SMS notification to experiment operator
[1237] Create medium-priority event in laboratory management system
[1238] 3. High-level alert (Level 3):
[1239] Display red warning icon on system interface, pop-up prompt window and play alarm sound, send SMS and email notification to experiment operator and laboratory supervisor, create high-priority event in laboratory management system
[1240] Start automatic protection program, such as pausing sample delivery
[1241] 4. Emergency alert (Level 4):
[1242] Display red warning on system interface full screen, play continuous alarm sound, send emergency SMS and email to all relevant personnel (including technical support team), create highest-priority event in laboratory management system, automatically execute emergency protection measures such as stopping experiment process, protecting critical equipment
[1243] S5.3: Issue alert signals through multiple ways, including system prompt, SMS notification, email alarm
[1244] Specific solutions for implementing multiple alarm modes:
[1245] 1. System prompts:
[1246] Designing the alarm display area in the experimental control software interface
[1247] Use different colors and icons to visually display alert levels
[1248] Implement pop-up window function to display detailed exception information and suggested actions
[1249] Integrated sound alarm system, plays different alarm tones according to the alarm level
[1250] 2. SMS notification:
[1251] Integrate SMS sending API (such as Twilio or local telecom provider's API)
[1252] Maintain a contact database containing contact information for people in different roles
[1253] Select notification targets based on the alarm level, for example, level 1 alarm only notifies operators, and level 4 alarm notifies all relevant personnel
[1254] Design concise and clear SMS templates that include key information such as alert level, exception type, timestamp and brief description
[1255] 3. Email Alerts:
[1256] Use SMTP protocol or email sending service (such as SendGrid) to implement email sending function
[1257] Design a detailed email template, including:
[1258] Alert Level and Urgency
[1259] Detailed exception description
[1260] Response curve diagram (if possible)
[1261] Recommended treatment steps
[1262] Relevant contact information
[1263] Implement email tracking function to ensure that critical alert emails are read in time
[1264] 4. Laboratory management system integration:
[1265] Develop API interface with laboratory management system
[1266] Automatically create and update exception event records
[1267] Track alert processing status to ensure each alert is handled appropriately
[1268] 5. Mobile application push:
[1269] Develop supporting mobile applications to support real-time push notifications
[1270] Realize alarm confirmation and simple feedback functions to facilitate remote and rapid response
[1271] 6. Automated response system:
[1272] Automate responses to high-level and critical alerts
[1273] For example, automatically adjust experimental parameters, pause injections, or safely shut down the device in extreme situations
[1274] 7. Alarm escalation mechanism:
[1275] If a low-level alarm is not handled within a certain period of time, the alarm level will be automatically upgraded
[1276] Implement an alarm confirmation and processing tracking system to ensure that all alarms receive timely attention
[1277] This multi-level, multi-channel alarm mechanism ensures that abnormal situations can be discovered and handled in a timely manner, minimizing the risk of experimental failure and equipment damage, and improving the reliability and efficiency of the entire biochemical analysis process.
[1278] Example 2
[1279] like Figure 3 As shown, the embodiment of the present application further provides an artificial intelligence-based biochemical reaction curve anomaly detection system 30, comprising:
[1280] Data acquisition module 31, used to obtain biochemical reaction curve data;
[1281] A data preprocessing module 32 is used to preprocess the biochemical reaction curve data;
[1282] Artificial intelligence analysis module 33, used to analyze the pre-processed data using an artificial intelligence model and identify abnormal reaction curves;
[1283] The alarm module 34 is used to trigger a corresponding alarm mechanism based on the analysis results of the artificial intelligence model.
[1284] Example 3
[1285] The present application also provides a computer device, such as Figure 4 As shown, the computer device includes:
[1286] at least one processor; and,
[1287] a memory communicatively connected to the at least one processor; wherein,
[1288] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the above-mentioned artificial intelligence-based biochemical reaction curve anomaly detection method.
[1289] An embodiment of the present application also provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable a computer to execute the above-mentioned artificial intelligence-based biochemical reaction curve anomaly detection method.
[1290] An embodiment of the present application also provides a computer program product, including computer instructions, characterized in that when the computer instructions are executed by a processor, the steps of the above-mentioned artificial intelligence-based biochemical reaction curve anomaly detection method are implemented.
[1291] Each module in the aforementioned AI-based biochemical reaction curve anomaly detection system can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor within a computer device in hardware form, or stored in a computer device memory in software form, allowing the processor to call and execute the corresponding operations of each module.
[1292] In one embodiment, a computer device is further provided. The computer device is the artificial intelligence-based biochemical reaction curve anomaly detection system mentioned in the above method embodiment. The internal structure diagram thereof can be as follows: Figure 4 As shown. The computer device includes a processor, a memory, an input / output interface (I / O), and a communication interface. The processor, memory, and I / O interface are connected via a system bus, and the communication interface is connected to the system bus via the I / O interface.
[1293] Among them, the processor of the computer device is used to provide computing and control capabilities, and can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but is not limited thereto. The processor may include one or more processors, for example, one or more central processing units (CPUs). When the processor is a CPU, the CPU may be a single-core CPU or a multi-core CPU. The processor may also include one or more special-purpose processors, which may include GPUs, FPGAs, etc. for accelerating processing. The processor is used to call the program code and data in the memory and execute the steps in the above-mentioned method embodiment. For details, please refer to the description in the method embodiment, which will not be repeated here.
[1294] The memory of the computer device includes, but is not limited to, non-volatile storage media and internal memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium.
[1295] The input / output interface of the computer device is used to exchange information between the processor and external devices.
[1296] The communication interface of the computer device is used to communicate with an external terminal via a network connection.
[1297] When the computer program is executed by a processor, a method for seabed geological imaging is implemented.
[1298] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the division of each unit / module is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. The mutual coupling, direct coupling, or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the system or unit can be electrical, mechanical or other forms.
[1299] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[1300] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions according to the embodiments of the present application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable system. The computer instructions may be stored in a computer-readable storage medium or transmitted via the computer-readable storage medium. The computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated therein. The available medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic medium such as a floppy disk, a hard disk, a tape, a magnetic disk, or an optical medium such as a digital versatile disc (DVD), or a semiconductor medium such as a solid state disk (SSD).
[1301] The system of the embodiments of the present disclosure can execute the method provided by the embodiments of the present disclosure, and the implementation principles are similar. The actions performed by each module in the system of each embodiment of the present disclosure correspond to the steps in the method of each embodiment of the present disclosure. For the detailed functional description of each module of the system, please refer to the description in the corresponding method shown in the previous text, which will not be repeated here.
[1302] The above description is only an optional implementation method for some implementation scenarios of the present disclosure. It should be pointed out that for ordinary technicians in this technical field, without departing from the technical concept of the solution of the present disclosure, other similar implementation methods based on the technical ideas of the present disclosure also fall within the protection scope of the embodiments of the present disclosure.
Claims
1. A biochemical reaction curve anomaly detection method based on artificial intelligence, characterized in that: The following steps are involved: Obtain biochemical reaction curve data; Preprocessing the biochemical reaction curve data to obtain preprocessed data; Analyzing the preprocessed data using an artificial intelligence model to identify abnormal reaction curves; Based on the analysis results of the artificial intelligence model, trigger a corresponding alarm mechanism; Wherein, the artificial intelligence model is a long short-term memory network LSTM, and the method further includes: Construct an LSTM structure, including input layer, LSTM layer and output layer; Training the LSTM using a training dataset; The first parameter adjustment of the LSTM is performed using the standard Monte Carlo method; A second parameter adjustment of the LSTM is performed using a quasi-Monte Carlo method; The first parameter adjustment of the LSTM is performed using the standard Monte Carlo method, including: Define the parameter search space, including the learning rate, the number of units and layers of the LSTM; generating a plurality of parameter combinations from the parameter search space based on a random sampling function; Calculating the performance index of each parameter group in the plurality of parameter combinations based on the evaluation function; Iterative optimization to select the first parameter combination with the best performance; The LSTM is adjusted for the second time using the quasi-Monte Carlo method, including: Select low-discrepancy sequences, including Sobol sequences or Halton sequences; generating low-discrepancy points using a sampling function based on the low-discrepancy sequence; Mapping the low-difference point to the first parameter combination to generate a second parameter combination; evaluating the second parameter combination; Wherein, the artificial intelligence model is a one-dimensional convolutional neural network 1DCNN, and the method further includes: Construct a 1DCNN structure, including convolutional layers, pooling layers, and fully connected layers; Optimize the hyperparameters of the 1DCNN using a hybrid meta-heuristic algorithm; Using a training dataset to train the 1DCNN, and using a machine learning model to assist in optimizing the training process of the 1DCNN; The hybrid meta-heuristic algorithm is used to optimize the hyperparameters of the 1DCNN, including: Construct genetic algorithm GA, particle swarm optimization PSO and simulated annealing SA algorithms; Design the switching conditions and information exchange mechanism of the genetic algorithm GA, particle swarm optimization PSO and simulated annealing SA algorithm; Define the hyperparameter search space, including convolution kernel size, number of layers, and learning rate; Generate and evaluate hyperparameter combinations using a hybrid strategy; The use of a machine learning model to assist in optimizing the training process of the 1DCNN includes: Build Gaussian process regression GPR or random forest RF regression model; Use the Gaussian Process Regression (GPR) or Random Forest (RF) regression model to predict the performance of un-evaluated hyperparameter combinations; guiding the search direction of the hybrid metaheuristic algorithm based on the prediction results; Dynamically adjust search strategies to balance exploration and exploitation.
2. The method according to claim 1, characterized in that The obtaining of biochemical reaction curve data includes: Real-time collection of reaction curve data from a biochemical analyzer; Extract stored reaction curve data from the historical database.
3. The method according to claim 2, characterized in that Preprocessing of biochemical reaction curve data, including: Remove noise and outliers; performing normalization processing on the biochemical reaction curve data; The normalized biochemical reaction curve data is subjected to data enhancement processing, including superimposing random noise obeying Gaussian distribution on the biochemical reaction curve data, or performing nonlinear transformation on the time axis to simulate the change of reaction speed.
4. The method according to claim 1, wherein Before analyzing the pre-processed data using the artificial intelligence model, the method further includes: Extract time series features, including slope and curvature; Extract frequency domain features, including main frequency and energy distribution; Calculate relevant biochemical indicators, including reaction rate and substrate concentration.
5. The method according to claim 2, characterized in that The artificial intelligence model is a spiking neural network (SNN), and the method further includes: Constructing a multi-layer network structure of the SNN, including an input layer, a hidden layer, and an output layer; Training the SNN using a training dataset; Performing compression and concealment on the SNN; Updating parameters of the SNN; The compression and concealment are performed on the SNN, including: Adding an autoencoder structure to the hidden layer; Design a bottleneck layer to force the SNN to learn compressed representations by reducing the number of neurons; Use sparse constraints to limit the number of activated neurons and reduce the network parameters of the SNN; Applying pruning technology to remove connections in the SNN with weights less than the weight threshold by setting a weight threshold; Wherein, updating the parameters of the SNN includes: Design a scalable network structure to support the addition of new categories; Implement dynamic weight adjustment mechanism; Use knowledge distillation technology to transfer the knowledge of the trained SNN teacher model to the newly trained SNN student model; A sample buffer is maintained to store representative samples of the response curve data.
6. The method according to claim 1, characterized in that The artificial intelligence model is a neural network with random weights and learning biases, and the method further includes: Construct a random weight neural network structure, including an input layer, a random weight hidden layer, and a learnable bias output layer; Design and optimize learning biases, including initializing bias values and updating strategies; The improved covariance matrix adaptive evolution strategy CMAES multimodal optimization algorithm is used to optimize network parameters, including: Build the CMAES framework; Integrate the distance-based niche method to maintain multiple excellent solutions; Design a niche radius adaptive adjustment mechanism; Implement step size adaptive adjustment strategy; Design mechanisms to maintain population diversity.
7. The method according to claim 1, characterized in that The analysis results based on the artificial intelligence model trigger corresponding alarm mechanisms including: Set multiple alarm levels to correspond to different degrees of abnormal situations; Trigger an alarm of corresponding level according to the degree of abnormality; Alarm signals are issued through various means, including system prompts, SMS notifications, and email alerts.
8. A biochemical reaction curve anomaly detection system based on artificial intelligence, characterized in that: include: Data acquisition module, used to obtain biochemical reaction curve data; A data preprocessing module, used for preprocessing the biochemical reaction curve data; Artificial intelligence analysis module, used to analyze pre-processed data using artificial intelligence models and identify abnormal reaction curves; An alarm module, configured to trigger a corresponding alarm mechanism based on the analysis results of the artificial intelligence model; The artificial intelligence model is a long short-term memory network (LSTM), and the artificial intelligence analysis module is further used to: Construct an LSTM structure, including input layer, LSTM layer and output layer; Training the LSTM using a training dataset; The first parameter adjustment of the LSTM is performed using the standard Monte Carlo method; A second parameter adjustment of the LSTM is performed using a quasi-Monte Carlo method; The first parameter adjustment of the LSTM is performed using the standard Monte Carlo method, including: Define the parameter search space, including the learning rate, the number of units and layers of the LSTM; generating a plurality of parameter combinations from the parameter search space based on a random sampling function; Calculating the performance index of each parameter group in the plurality of parameter combinations based on the evaluation function; Iterative optimization to select the first parameter combination with the best performance; The LSTM is adjusted for the second time using the quasi-Monte Carlo method, including: Select low-discrepancy sequences, including Sobol sequences or Halton sequences; generating low-discrepancy points using a sampling function based on the low-discrepancy sequence; Mapping the low-difference point to the first parameter combination to generate a second parameter combination; evaluating the second parameter combination; The artificial intelligence model is a one-dimensional convolutional neural network (1DCNN), and the artificial intelligence analysis module is further used to: Construct a 1DCNN structure, including convolutional layers, pooling layers, and fully connected layers; Optimize the hyperparameters of the 1DCNN using a hybrid meta-heuristic algorithm; Using a training dataset to train the 1DCNN, and using a machine learning model to assist in optimizing the training process of the 1DCNN; The hybrid meta-heuristic algorithm is used to optimize the hyperparameters of the 1DCNN, including: Construct genetic algorithm GA, particle swarm optimization PSO and simulated annealing SA algorithms; Design the switching conditions and information exchange mechanism of the genetic algorithm GA, particle swarm optimization PSO and simulated annealing SA algorithm; Define the hyperparameter search space, including convolution kernel size, number of layers, and learning rate; Generate and evaluate hyperparameter combinations using a hybrid strategy; The use of a machine learning model to assist in optimizing the training process of the 1DCNN includes: Build Gaussian process regression GPR or random forest RF regression model; Use the Gaussian Process Regression (GPR) or Random Forest (RF) regression model to predict the performance of un-evaluated hyperparameter combinations; guiding the search direction of the hybrid metaheuristic algorithm based on the prediction results; Dynamically adjust search strategies to balance exploration and exploitation.
Citation Information
Patent Citations
Method and apparatus for treating abnormity of reaction curve, biochemical analyzer and storage medium
CN107703132A