Tobacco industry small sample data abnormity early warning method based on prototype network
By employing a meta-learning method based on prototype networks, this study addresses the problem of early warning for data anomalies in the tobacco industry characterized by small samples, multiple types, and dynamic evolution. It achieves rapid adaptation and closed-loop optimization, reduces data annotation costs, and improves early warning accuracy and interpretability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-22
- Publication Date
- 2026-04-03
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing technologies are insufficient for providing early warnings of data anomalies in the tobacco industry, especially for small-sample, multi-type, and dynamically evolving data. Traditional methods cannot meet the needs of real-time early warning, rapid adaptation, and closed-loop optimization across the entire tobacco industry chain.
A meta-learning method based on prototype networks is adopted. By constructing a meta-learning task framework, designing a feature extraction network, calculating high-dimensional embedding vectors, and combining Euclidean distance and dynamic threshold, category classification and early warning are achieved. A closed-loop system is constructed for optimization.
It enables rapid adaptation to novel anomalies under small sample conditions, reduces data annotation costs, accurately identifies hidden risks, dynamically adjusts warning thresholds, reduces false alarm rates, and improves warning accuracy and interpretability.
Smart Images

Figure QLYQS_1 
Figure QLYQS_4 
Figure QLYQS_8
Abstract
Description
Technical Field
[0001] This invention belongs to the technical field of data early warning methods, specifically relating to an anomaly early warning method for small sample data in the tobacco industry based on prototype networks. Background Technology
[0002] In the era of big data, tobacco companies have accumulated massive amounts of core data across the entire industry chain, covering temperature and humidity, curing parameters in tobacco leaf planting, equipment operation indicators and physical parameters of cigarettes in cigarette production, and inventory data in tobacco monopoly distribution. These data contain key signals such as defects in tobacco product quality and operational compliance risks. How to accurately and in real time identify anomalies and trigger early warnings has become a core issue that urgently needs to be addressed in the digital transformation of the tobacco industry. Current mainstream data-driven early warning methods can be categorized into three types, but all suffer from significant shortcomings in meeting the actual needs of the tobacco industry. They struggle to satisfy the demands for early warning in scenarios involving small samples, multiple data types, and dynamic equilibrium. Statistical methods, such as control charts and time series analysis, rely heavily on strict assumptions about data distribution. However, tobacco data exhibits strong non-linear relationships, such as the dynamic coupling between tobacco curing temperature and humidity and mold levels, and the complex correlation between tobacco physical parameters and combustion performance. This results in low accuracy and high false negative rates in real-world scenarios, failing to capture hidden risk signals. Traditional machine learning methods, such as logistic regression, support vector machines, and random forests, inherently require large-scale labeled samples for model training. However, abnormal samples in the tobacco industry, such as low-probability tobacco mold, occasional process deviations, and concealed illegal distribution, are scarce and extremely costly to acquire, making it difficult to meet training data requirements. Furthermore, in small-sample scenarios, these models are prone to overfitting, only able to memorize existing sample features and unable to adapt to different scenarios. Generalizing to unseen anomaly types significantly increases the variance term, leading to poor prediction stability. While deep learning methods such as Long Short-Term Memory networks and autoencoders have made some progress in certain anomaly detection scenarios, they still fail to address the core pain points of the tobacco industry. First, their learning ability is weak with small samples; limited labeled data makes it difficult for the model to learn rich feature representations, resulting in persistently high generalization errors. Second, they have poor adaptability to new anomalies; tobacco anomaly types continue to evolve, such as new illegal circulation patterns and parameter deviations after process adjustments, requiring existing models to be retrained on a large scale to adapt, which is time-consuming and inefficient. Third, they lack dynamic balancing mechanisms; fixed threshold designs cannot balance false positives and false negatives. Either the threshold is too lenient, leading to frequent false positives that disrupt production and operations, or the threshold is too strict, leading to false negatives of key quality and compliance risks, making it difficult to match the practical needs of the tobacco industry. Fourth, they lack closed-loop optimization logic; the parameters are fixed after model training, making it impossible to continuously iterate based on actual early warning feedback, resulting in significant performance degradation after long-term use.
[0003] While there are explorations into the application of deep learning in anomaly detection in a single link of the tobacco industry, few solutions combine meta-learning with prototype networks to address the challenges of early warning in the tobacco industry chain, which involves small samples, multiple types, and dynamic evolution. At the same time, existing methods generally lack the ability to quickly adapt to new anomalies and closed-loop optimization mechanisms, failing to meet the actual needs of the tobacco industry for real-time early warning and continuous optimization. Summary of the Invention
[0004] The purpose of this invention is to provide a method for early warning of anomalies in small sample data in the tobacco industry based on prototype networks, which solves the problem that existing technologies cannot provide early warnings for tobacco anomaly detection.
[0005] The technical solution adopted in this invention is a method for early warning of anomalies in small sample data in the tobacco industry based on prototype networks, which is implemented according to the following steps: S1, preprocess tobacco industry data, construct a meta-learning task framework, and model the tobacco data early warning problem as an N-way K-shot meta-learning task; S2, a feature extraction network is designed based on tobacco data features to map the preprocessed data into high-dimensional embedding vectors; S3 calculates prototype vectors for each category of tobacco using high-dimensional embedding vectors, measures distance to achieve category classification, and outputs probability and confidence. S4, combine classification probability and confidence to design dynamic early warning thresholds to determine whether an early warning is issued and its level; S5 collects actual feedback data for early warning, builds a closed-loop system, adjusts network parameters, updates prototype vectors, and optimizes thresholds.
[0006] The technical solution of this invention is also characterized by, S1 specifically refers to: S1.1 Collect tobacco industry data, including time-series and non-time-series data. Time-series data includes tobacco leaf curing temperature and humidity data at 35-75℃ and production equipment operating temperature data at 25-60℃. Non-time-series data includes field temperature at 15-35℃, field humidity at 50%-90%, and tobacco sticks weighing 0.8-1.2g during the tobacco leaf planting process. Normalize all data to the [0,1] interval. S1.2, divide the training set, validation set and test set into a 6:2:2 ratio, define an N-way K-shot meta-learning task with N=2-5 and K=2-10, each task includes a support set and a query set, and select 10-30 samples for each category, of which K are used for the support set and 10-25 are used for the query set; S1.3 employs an inner-outer dual-loop optimization mechanism. The inner loop optimizes network parameters on a single tobacco task, while the outer loop optimizes initial parameters across 40-80 tobacco-related tasks.
[0007] S2 specifically refers to: S2.1: For the time series data preprocessed in S1.1, a feature extraction network is constructed using a GRU encoder or a Transformer encoder to capture the time dependencies of the data. S2.2, for the non-time-series data preprocessed in S1.1, a multi-layer fully connected network is used. The multi-layer fully connected network consists of an input layer, a 64-128 dimension fully connected layer, a batch normalization layer, a ReLU activation function, a Dropout layer with a dropout rate of 0.4-0.6, a 128-256 dimension fully connected layer, a batch normalization layer, a ReLU activation function, a Dropout layer with a dropout rate of 0.4-0.6, and a 128-256 dimension output layer in sequence. S2.3, through the feature extraction network for time-series data or the multi-layer fully connected network for non-time-series data, the corresponding type of tobacco data is mapped into a 128-256 dimension high-dimensional embedding vector.
[0008] S3 specifically refers to: S3.1, based on the high-dimensional embedding vector output by S2, combined with the support set samples in the S1 meta-learning task framework, calculates the prototype vector of tobacco category k according to formula (1), which is expressed as: (1) in, For the support set corresponding to the category sample set in S1.1, For S2, use the first feature extraction network or a multi-layer fully connected network to adapt to the query set sample types; S3.2, for the query set samples in the S1.1 meta-learning task framework, obtain their embedding representations through networks of different data types constructed in S2, and calculate the Euclidean distance between the embedding representation and the prototype vectors of each category; S3.3, use formula (2) to convert the Euclidean distance into a class probability distribution, and output the class probability p and confidence level conf. Formula (2) is expressed as: (2) In the formula, It is the Euclidean distance function. For each category's prototype vector, It remains the first feature extraction network or a multi-layer fully connected network in S2 that adapts to the sample type of the query set.
[0009] The Euclidean distance is calculated in S3.2 as follows: (3) In the formula, m = 128 - 256. Embedded vectors for the query set samples. Let be the prototype vector of category k.
[0010] S4 specifically refers to: S4.1, Based on the class probabilities and confidence levels output by S3.3, set the basic threshold. =0.5-0.7 and adjustment coefficient α=0.1-0.3, the early warning threshold is dynamically adjusted using formula (4), which is as follows: (4) Among them FP t 、FN t Total t These represent the number of false alarms, missed alarms, and total number of warnings detected based on S1.1 time-series or non-time-series data within time period t. S4.2, with a preset confidence threshold β = 0.8-0.9, when the predicted probability p output by S3 > τ t When the confidence level conf > β, a regular warning is triggered for anomalies in time-series or non-time-series data in S1, caused by the corresponding data exceeding the limit range of S1; when the confidence level conf is not less than 0.9-0.98, a high-level warning is triggered, and the anomaly type and confidence level are pushed synchronously. The anomaly category corresponds to the anomaly scenario of time-series or non-time-series data in S1, and the warning determination depends on the mapping results of the two networks in S2 and the classification results in S3.
[0011] Abnormal categories include mild mold growth on tobacco leaves, severe mold growth on tobacco leaves, deviations in the physical parameters of tobacco sticks, abnormal operation of production equipment, illegal distribution, and abnormal temperature and humidity in logistics. Mold growth in tobacco leaves is triggered by baking temperatures exceeding 35-75℃ or humidity exceeding 40%-85% in S1. The corresponding data is mapped by the feature extraction network in S2.1 and then classified by S3. Deviations in the physical parameters of tobacco sticks are triggered by tobacco stick weight deviations of 0.8-1.2g or length deviations of 84-100mm in S1.1. The corresponding data is mapped by the multi-layer fully connected network in S2.2 and then classified by S3. Abnormal operation of production equipment is triggered by equipment speed exceeding 500-3000r / min or operating temperature exceeding 25-60℃ in S1. Speed data is mapped by the multi-layer fully connected network in S2.2, and temperature time-series data is mapped by the feature extraction network in S2.1 and then classified by S3.
[0012] The closed-loop feedback optimization system in S5 includes a feedback collection module, a model optimization module, and a threshold adjustment module. The feedback collection module records whether the actual result of each warning in S4 is truly abnormal and the response time. New labeled data is collected every 1-3 months. The new labeled data includes new samples of time-series and non-time-series data in S1.1. The model optimization module uses a reweighted loss function to adjust the parameters of the feature extraction network and the multilayer fully connected network in S2; The threshold adjustment module is based on ROC curve analysis. It updates the warning threshold in S4 to make the working point closer to the maximum point of the Youden index. At the same time, it recalculates the prototype vectors of each tobacco category in S3. The calculation of prototype vectors still depends on the embedding vectors of the corresponding network mapping in S2.
[0013] The reweighted loss function in the model optimization module is as follows: (5) In the formula, This is a summation operation for all tobacco data samples, where i is a data sample in the tobacco scene, and w... i These are the weight coefficients of sample i. It is the true label of sample i. This is the category result output by the prototype network.
[0014] The beneficial effects of this invention are: (1) The tobacco industry small sample data anomaly early warning method based on prototype network provided by the present invention relies on the meta-learning characteristics of prototype network. Only 2-10 anomaly labeled samples are needed to build an effective early warning model, which is suitable for the scenario of scarce anomaly samples and high acquisition cost in the tobacco industry, and significantly reduces the data labeling cost. When facing new anomaly types, there is no need to retrain the entire model, and only 2-5 new labeled samples are needed for quick adaptation.
[0015] (2) The tobacco industry small sample data anomaly early warning method based on prototype network provided by the present invention can uniformly process multiple types of data in the entire tobacco industry chain by using a dedicated extraction network adapted to time series data and non-time series data, effectively capturing the nonlinear correlation characteristics of data, and breaking through the limitation of the narrow scope of application of traditional methods; based on the precise calculation of Euclidean distance metric and category prototype vector, combined with dynamic threshold optimization, the identification accuracy of hidden risks is high, and the precise prevention and control of risks in the whole process is realized.
[0016] (3) The tobacco industry small sample data anomaly early warning method based on prototype network provided by the present invention dynamically adjusts the early warning threshold by classifying probability and confidence level, so that the working point is close to the maximum point of Youden index. This ensures high sensitivity to key risks such as tobacco leaf mold and illegal circulation, and effectively controls the false alarm rate to avoid frequent false alarms from interfering with normal production and operation. At the same time, the early warning results can be associated with anomaly type, confidence level and historical similar cases, which has strong interpretability and helps managers quickly locate the root cause of the problem, so as to achieve the dual goals of precise risk prevention and control and efficient production operation. Detailed Implementation
[0017] The present invention will now be described in detail through specific embodiments.
[0018] Example 1 This invention provides a method for early warning of anomalies in small sample data in the tobacco industry based on prototype networks, which is implemented according to the following steps: S1, preprocess tobacco industry data, construct a meta-learning task framework, and model the tobacco data early warning problem as an N-way K-shot meta-learning task; S2, a feature extraction network is designed based on tobacco data features to map the preprocessed data into high-dimensional embedding vectors; S3 calculates prototype vectors for each category of tobacco using high-dimensional embedding vectors, measures distance to achieve category classification, and outputs probability and confidence. S4, combine classification probability and confidence to design dynamic early warning thresholds to determine whether an early warning is issued and its level; S5 collects actual feedback data for early warning, builds a closed-loop system, adjusts network parameters, updates prototype vectors, and optimizes thresholds.
[0019] In this embodiment, the tobacco data early warning problem is remodeled as an N-way K-shot meta-learning task, where N represents the number of early warning categories (e.g., normal, slightly moldy tobacco leaves, severely moldy tobacco leaves, etc.), and K represents the number of support samples used for modeling each category. Within this framework, the system extracts universal anomaly recognition patterns for tobacco through multi-task learning, with each task corresponding to a specific tobacco anomaly pattern recognition sub-problem. By performing meta-training on a large number of tobacco-related tasks, the model learns higher-order knowledge on "how to learn tobacco anomaly patterns," enabling it to quickly construct an effective early warning model with only K labeled samples when faced with newly emerging tobacco anomaly types, avoiding the drawback of traditional methods requiring large-scale retraining. The meta-training process employs an inner-outer dual-loop optimization mechanism: the inner loop optimizes model parameters on a single tobacco task, while the outer loop optimizes the initial model parameters across tobacco tasks, giving the model rapid adaptability.
[0020] Example 2 Based on Example 1, this example also provides: S1 specifically refers to: S1.1 Collect tobacco industry data, including time-series and non-time-series data. Time-series data includes tobacco leaf curing temperature and humidity data at 35-75℃ and production equipment operating temperature data at 25-60℃. Non-time-series data includes field temperature at 15-35℃, field humidity at 50%-90%, and tobacco sticks weighing 0.8-1.2g during the tobacco leaf planting process. Normalize all data to the [0,1] interval. S1.2, divide the training set, validation set and test set into a 6:2:2 ratio, define an N-way K-shot meta-learning task with N=2-5 and K=2-10, each task includes a support set and a query set, and select 10-30 samples for each category, of which K are used for the support set and 10-25 are used for the query set; S1.3 employs an inner-outer dual-loop optimization mechanism. The inner loop optimizes network parameters on a single tobacco task, while the outer loop optimizes initial parameters across 40-80 tobacco-related tasks.
[0021] Example 3 Based on Example 2, this example also provides: S2 specifically refers to: S2.1: For the time series data preprocessed in S1.1, a feature extraction network is constructed using a GRU encoder or a Transformer encoder to capture the time dependencies of the data. S2.2, for the non-time-series data preprocessed in S1.1, a multi-layer fully connected network is used. The multi-layer fully connected network consists of an input layer, a 64-128 dimension fully connected layer, a batch normalization layer, a ReLU activation function, a Dropout layer with a dropout rate of 0.4-0.6, a 128-256 dimension fully connected layer, a batch normalization layer, a ReLU activation function, a Dropout layer with a dropout rate of 0.4-0.6, and a 128-256 dimension output layer in sequence. S2.3, through the feature extraction network for time-series data or the multi-layer fully connected network for non-time-series data, the corresponding type of tobacco data is mapped into a 128-256 dimension high-dimensional embedding vector.
[0022] This implementation employs a flexible feature extraction network architecture tailored to different types of tobacco data characteristics (time-series or non-time-series). For non-time-series data, such as physical indicators like cigarette weight, circumference, and length, a multi-layer fully connected network structure is used, incorporating a combination of fully connected layers, batch normalization layers, ReLU activation functions, and Dropout layers to effectively extract high-dimensional features. For time-series data, such as tobacco curing temperature and humidity, and production equipment operating parameters, a gated recurrent unit (GRU) or Transformer encoder is introduced to capture time dependencies and long-term patterns. This network maps the input data to a metric-friendly embedding space, ensuring that data points of the same class have a small Euclidean distance and data points of different classes have a large distance. Given the input data... Feature extraction network Map it to an m-dimensional embedding vector , where parameters The embedding space is optimized through a meta-learning process to ensure good class discriminativeness.
[0023] Example 4 Based on Example 3, this example also provides: S3 specifically refers to: S3.1, based on the high-dimensional embedding vector output by S2, combined with the support set samples in the S1 meta-learning task framework, calculates the prototype vector of tobacco category k according to formula (1), which is expressed as: (1) in, For the support set corresponding to the category sample set in S1.1, For S2, use the first feature extraction network or a multi-layer fully connected network to adapt to the query set sample types; S3.2, for the query set samples in the S1.1 meta-learning task framework, obtain their embedding representations through networks of different data types constructed in S2, and calculate the Euclidean distance between the embedding representation and the prototype vectors of each category; S3.3, use formula (2) to convert the Euclidean distance into a class probability distribution, and output the class probability p and confidence level conf. Formula (2) is expressed as: (2) In the formula, It is the Euclidean distance function. For each category's prototype vector, It remains the first feature extraction network or a multi-layer fully connected network in S2 that adapts to the sample type of the query set.
[0024] The Euclidean distance is calculated in S3.2 as follows: (3) In the formula, m = 128 - 256. Embedded vectors for the query set samples. Let be the prototype vector of category k.
[0025] Example 5 Based on Example 4, this example also provides: S4 specifically refers to: S4.1, Based on the class probabilities and confidence levels output by S3.3, set the basic threshold. =0.5-0.7 and adjustment coefficient α=0.1-0.3, the early warning threshold is dynamically adjusted using formula (4), which is as follows: (4) Among them FP t 、FN t Total tThese represent the number of false alarms, missed alarms, and total number of warnings detected based on S1.1 time-series or non-time-series data within time period t. S4.2, with a preset confidence threshold β = 0.8-0.9, when the predicted probability p output by S3 > τ t When the confidence level conf > β, a regular warning is triggered for anomalies in time-series or non-time-series data in S1, caused by the corresponding data exceeding the limit range of S1; when the confidence level conf is not less than 0.9-0.98, a high-level warning is triggered, and the anomaly type and confidence level are pushed synchronously. The anomaly category corresponds to the anomaly scenario of time-series or non-time-series data in S1, and the warning determination depends on the mapping results of the two networks in S2 and the classification results in S3.
[0026] The abnormal categories include mild mold growth on tobacco leaves, severe mold growth on tobacco leaves, deviations in the physical parameters of tobacco sticks, abnormal operation of production equipment, illegal circulation, and abnormal temperature and humidity in logistics. Mold growth on tobacco leaves is triggered by baking temperatures exceeding 35-75℃ or humidity exceeding 40%-85% in S1, and the corresponding data is mapped by the feature extraction network in S2.1 and then classified by S3. Deviations in the physical parameters of tobacco sticks are triggered by tobacco stick weight deviations of 0.8-1.2g or length deviations of 84-100mm in S1.1, and the corresponding data is mapped by the multi-layer fully connected network in S2.2 and then classified by S3. Abnormal operation of production equipment is triggered by equipment speed exceeding 500-3000r / min or operating temperature exceeding 25-60℃ in S1, and the speed data is mapped by the multi-layer fully connected network in S2.2, and the temperature time series data is mapped by the feature extraction network in S2.1 and then classified by S3.
[0027] Example 6 Based on Example 5, this example also provides: The closed-loop feedback optimization system in S5 includes a feedback collection module, a model optimization module, and a threshold adjustment module. The feedback collection module records whether the actual result of each warning in S4 is truly abnormal and the response time. New labeled data is collected every 1-3 months. The new labeled data includes new samples of time-series and non-time-series data in S1.1. The model optimization module uses a reweighted loss function to adjust the parameters of the feature extraction network and multilayer fully connected network in S2. The threshold adjustment module updates the warning threshold in S4 based on ROC curve analysis so that the working point is close to the maximum point of the Youden exponent. At the same time, it recalculates the prototype vectors of each tobacco category in S3. The calculation of prototype vectors still depends on the embedding vectors mapped by the corresponding network in S2.
[0028] The reweighted loss function in the model optimization module is as follows: (5) In the formula, This is a summation operation for all tobacco data samples, where i is a data sample in the tobacco scene, and w... i These are the weight coefficients of sample i. It is the true label of sample i. This is the category result output by the prototype network.
[0029] Example 7 This embodiment provides a specific example, specifically: Step 1: Collect historical tobacco leaf quality data from tobacco companies, including 3600 historical records of a key indicator, such as tobacco leaf moisture content and color. Each record contains the indicator value and its status label (-1 indicates below the normal range, 0 indicates the normal range, and 1 indicates above the normal range). Normalize the raw data so that it is distributed within the [0,1] interval, which is convenient for neural network training.
[0030] Step 2: Divide the dataset into training, validation, and test sets in a 6:2:2 ratio. Define a 3-way 5-shot learning task, where each task contains 3 categories (below normal range, normal range, above normal range), with 5 samples for each category in the support set and 15 samples in the query set. Design a data sampler to randomly select 3 categories in each training iteration, selecting 20 samples for each category (5 for the support set and 15 for the query set).
[0031] Step 3: Construct a neural network based on fully connected layers, with the following structure: Input layer: Receives 1D tobacco quality index data; Fully connected layer 1: Maps the input to 64 dimensions; Batch normalization layer 1: Standardizes the feature distribution; ReLU activation function 1: Introduces non-linearity; Dropout layer 1: Dropout rate is set to 0.5 to prevent overfitting; Fully connected layer 2: Maps the 64 dimensions to 128 dimensions; Batch normalization layer 2: Standardizes the feature distribution; ReLU activation function 2: Introduces non-linearity; Dropout layer 2: Dropout rate is set to 0.5 to prevent overfitting; Fully connected layer 3: Maps the 128 dimensions to a 128-dimensional output, which serves as the embedding space representation.
[0032] Step 4: Use the Adam optimizer with an initial learning rate of 0.001, halving the learning rate after each training epoch. Train for 50 epochs, each containing 60 tasks. The loss function used is cross-entropy loss, with the formula: (2) in It is a sample The true category label.
[0033] Step 5: By analyzing the distribution of prediction confidence on the validation set, set the warning threshold: when the model predicts that an indicator is in an abnormal state (below or above the normal range) and the confidence level exceeds 0.85, trigger the warning; when the confidence level exceeds 0.95, trigger the high-level warning.
[0034] Step 6: Deploy the trained model into the tobacco company's tobacco leaf quality monitoring system. The system acquires the latest tobacco leaf quality indicator data hourly, calculates its embedding representation using a feature extraction network, and then calculates the distance to the three class prototype vectors to obtain the class probability distribution. When an anomaly is detected and the confidence level exceeds a threshold, an early warning notification is automatically sent to tobacco leaf quality management personnel, including the anomaly type, confidence level, and historical similar case references. The system records the actual result of each early warning (whether it is truly an anomaly) and performs model fine-tuning monthly: collecting new labeled data, updating prototype calculations, and adjusting the early warning threshold to adapt to changes in the distribution of tobacco leaf quality indicators and adjustments to business needs.
[0035] The model performance was evaluated on the test set, and the results showed an accuracy of 92.7%, a recall of 90.3%, and an F1 score of 91.5%. Compared with traditional methods (such as random forests and LSTM), this method performs better under small tobacco sample conditions, especially when there are only 5-10 labeled samples per category, the accuracy remains above 85%, while traditional methods drop below 70%. Furthermore, this method can quickly adapt to new tobacco anomaly patterns with only 2-3 samples, greatly reducing the cost and latency of model updates. Through the above implementation process, the tobacco data early warning method provided by this invention can effectively solve the anomaly detection problem under small tobacco sample conditions, providing a powerful tool for tobacco companies' risk management and decision support. It learns to identify tobacco anomaly patterns and has strong generalization and adaptability.
Claims
1. A method for early warning of anomalies in small sample data in the tobacco industry based on prototype networks, characterized in that, Includes the following steps: S1, preprocess tobacco industry data, construct a meta-learning task framework, and model the tobacco data early warning problem as an N-way K-shot meta-learning task; S2, a feature extraction network is designed based on tobacco data features to map the preprocessed data into high-dimensional embedding vectors; S3 calculates prototype vectors for each category of tobacco using high-dimensional embedding vectors, measures distance to achieve category classification, and outputs probability and confidence. S4, combine classification probability and confidence to design dynamic early warning thresholds to determine whether an early warning is issued and its level; S5 collects actual feedback data for early warning, builds a closed-loop system, adjusts network parameters, updates prototype vectors, and optimizes thresholds.
2. The method for early warning of anomalies in small sample data in the tobacco industry based on prototype networks according to claim 1, characterized in that, S1 specifically refers to: S1.1 Collect tobacco industry data, including time-series data and non-time-series data. The time-series data includes tobacco leaf curing temperature and humidity data at 35-75℃ and production equipment operating temperature data at 25-60℃. The non-time-series data includes field temperature at 15-35℃, field humidity at 50%-90%, and tobacco sticks weighing 0.8-1.2g during the tobacco leaf planting process. Normalize all data to the [0,1] interval. S1.2, divide the training set, validation set and test set into a 6:2:2 ratio, define an N-way K-shot meta-learning task with N=2-5 and K=2-10, each task includes a support set and a query set, and select 10-30 samples for each category, of which K are used for the support set and 10-25 are used for the query set; S1.3 employs an inner-outer dual-loop optimization mechanism. The inner loop optimizes network parameters on a single tobacco task, while the outer loop optimizes initial parameters across 40-80 tobacco-related tasks.
3. The method for early warning of anomalies in small sample data in the tobacco industry based on prototype networks according to claim 2, characterized in that, Specifically, S2 is: S2.1: For the time series data preprocessed in S1.1, a feature extraction network is constructed using a GRU encoder or a Transformer encoder to capture the time dependencies of the data. S2.2, For the non-time-series data preprocessed in S1.1, a multi-layer fully connected network is used. The multi-layer fully connected network consists of an input layer, a 64-128 dimensional fully connected layer, a batch normalization layer, a ReLU activation function, a Dropout layer with a dropout rate of 0.4-0.6, a 128-256 dimensional fully connected layer, a batch normalization layer, a ReLU activation function, a Dropout layer with a dropout rate of 0.4-0.6, and a 128-256 dimensional output layer in sequence. S2.3, through the feature extraction network for time-series data or the multi-layer fully connected network for non-time-series data, the corresponding type of tobacco data is mapped into a 128-256 dimension high-dimensional embedding vector.
4. The method for early warning of small sample data anomalies in the tobacco industry based on prototype networks according to claim 3, characterized in that, Specifically, S3 is: S3.1, based on the high-dimensional embedding vector output by S2, combined with the support set samples in the S1 meta-learning task framework, calculates the prototype vector of tobacco category k according to formula (1), which is expressed as: (1) in, For the support set corresponding to the category sample set in S1.1, For S2, use the first feature extraction network or a multi-layer fully connected network to adapt to the query set sample types; S3.2, for the query set samples in the S1.1 meta-learning task framework, obtain their embedding representations through networks of different data types constructed in S2, and calculate the Euclidean distance between the embedding representation and the prototype vectors of each category; S3.3, use formula (2) to convert the Euclidean distance into a class probability distribution, and output the class probability p and confidence level conf. Formula (2) is expressed as: (2) In the formula, It is the Euclidean distance function. For each category's prototype vector, It remains the first feature extraction network or a multi-layer fully connected network in S2 that adapts to the sample type of the query set.
5. The method for early warning of small sample data anomalies in the tobacco industry based on prototype networks according to claim 4, characterized in that, The Euclidean distance is calculated in S3.2 as follows: (3) In the formula, m = 128 - 256. Embedded vectors for the query set samples. Let be the prototype vector of category k.
6. The method for early warning of anomalies in small sample data in the tobacco industry based on prototype networks according to claim 4, characterized in that, Specifically, S4 is: S4.1, Based on the class probabilities and confidence levels output by S3.3, set the basic threshold. =0.5-0.7 and adjustment coefficient α=0.1-0.3, the early warning threshold is dynamically adjusted using formula (4), which is as follows: (4) Among them FP t 、FN t Total t These represent the number of false alarms, missed alarms, and total number of warnings detected based on S1.1 time-series or non-time-series data within time period t. S4.2, with a preset confidence threshold β = 0.8-0.9, when the predicted probability p output by S3 > τ t When the confidence level conf > β, a regular warning is triggered for anomalies in time-series or non-time-series data in S1, caused by the corresponding data exceeding the limit range of S1; when the confidence level conf is not less than 0.9-0.98, a high-level warning is triggered, and the anomaly type and confidence level are pushed synchronously. The anomaly category corresponds to the anomaly scenario of time-series or non-time-series data in S1, and the warning determination depends on the mapping results of the two networks in S2 and the classification results in S3.
7. The method for early warning of anomalies in small sample data in the tobacco industry based on prototype networks according to claim 6, characterized in that, The abnormality categories include mild mold growth on tobacco leaves, severe mold growth on tobacco leaves, deviations in the physical parameters of tobacco sticks, abnormal operation of production equipment, illegal distribution, and abnormal temperature and humidity in logistics. Mold growth in tobacco leaves is triggered by baking temperatures exceeding 35-75℃ or humidity exceeding 40%-85% in S1. The corresponding data is mapped by the feature extraction network in S2.1 and then classified by S3. Deviations in the physical parameters of tobacco sticks are triggered by weight deviations of 0.8-1.2g or length deviations of 84-100mm in S1.
1. The corresponding data is mapped by the multilayer fully connected network in S2.2 and then classified by S3. Abnormal operation of production equipment is triggered by the equipment speed exceeding 500-3000 r / min or the operating temperature exceeding 25-60℃ in S1. The speed data is mapped by the multi-layer fully connected network in S2.2 and the temperature time series data is mapped by the feature extraction network in S2.1 and then classified by S3.
8. The method for early warning of small sample data anomalies in the tobacco industry based on prototype networks according to claim 6, characterized in that, The closed-loop feedback optimization system in S5 includes a feedback collection module, a model optimization module, and a threshold adjustment module. The feedback collection module records whether the actual result of each warning in S4 is truly abnormal and the response time. New labeled data is collected every 1-3 months. The new labeled data includes new samples of time-series data and non-time-series data in S1.
1. The model optimization module uses a reweighted loss function to adjust the parameters of the feature extraction network and the multilayer fully connected network in S2; The threshold adjustment module is based on ROC curve analysis. It updates the warning threshold in S4 to make the working point closer to the maximum point of the Youden index. At the same time, it recalculates the prototype vectors of each tobacco category in S3. The calculation of prototype vectors still depends on the embedding vectors of the corresponding network mapping in S2.
9. The method for early warning of small sample data anomalies in the tobacco industry based on prototype networks according to claim 8, characterized in that, The reweighted loss function in the model optimization module is specifically as follows: (5) In the formula, This is a summation operation for all tobacco data samples, where i is a data sample in the tobacco scene, and w... i These are the weight coefficients of sample i. It is the true label of sample i. This is the category result output by the prototype network.