Training method and classification method of first-class classifier, computing equipment and storage medium
By dividing the target class sample set and extracting residual features, suppressing intra-class information and preserving inter-class information, a classifier is trained, which solves the problem of misjudgment caused by feature overlap in spectral anomaly detection and improves detection accuracy and robustness.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-09
- Publication Date
- 2026-04-14
AI Technical Summary
One type of classifier has insufficient classification accuracy and robustness in spectral anomaly detection due to the overlap of feature distributions between the target class and the anomaly class, especially when there are few anomaly samples, it is difficult to effectively reduce the overlap of distributions in the feature space.
By dividing the target class sample set into multiple subsets, the reconstruction model is used to learn intra-class information and extract residual features, suppress intra-class information, retain inter-class information, train a classifier and optimize its performance, thereby improving the inter-class-intra-class distance ratio (IIDR) of features and reducing distribution overlap.
It significantly improves the accuracy and robustness of a classifier in anomaly classification and detection, especially for detecting minute anomalies, and realizes an end-to-end anomaly detection solution.
Smart Images

Figure CN121858985A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of spectral analysis technology, specifically to a training method, classification method, computing device, and storage medium for a classifier. Background Technology
[0002] In chemical analysis, spectral anomaly detection is a key technique for identifying fraudulent components, impurities, or abnormal phenomena in samples. Near-infrared spectroscopy, infrared spectroscopy, and Raman spectroscopy, due to their ability to rapidly and non-destructively acquire information about the composition and structure of substances, have become core tools in this field. Spectral data typically possesses high dimensionality, and the spectral features of the target class (normal samples) and the anomaly class (such as adulterated or contaminated samples) often overlap, making direct anomaly identification difficult. One type of classifier is a special type of machine learning model characterized by its ability to form a decision boundary surrounding the target class simply by training with samples of the target class, thereby classifying unknown samples. This characteristic makes it widely used in spectral anomaly detection because, in many practical scenarios, obtaining a large number of diverse anomaly samples is costly or impractical.
[0003] The detection accuracy of a classifier directly depends on the degree of overlap between the target class and the anomaly class in the feature space. The greater the overlap, the more prone the classifier is to misclassification. For example, some food additives and food ingredients have similar molecular structures, resulting in a high degree of overlap in their spectral features, which seriously affects the accuracy of the classifier. However, how to improve the classification accuracy of a classifier remains a subject of ongoing research.
[0004] The preceding description is intended to provide general background information and does not necessarily constitute prior art. Summary of the Invention
[0005] To address the aforementioned technical problems, this application provides a training method, classification method, computing device, and storage medium for a classifier, which can effectively improve the classification accuracy and robustness of a classifier in anomaly detection.
[0006] In a first aspect, this application provides a method for training a classifier, applicable to computing devices, comprising the following steps: Obtain the target class sample set; The target class sample set is divided into a first sample subset, a second sample subset, and a third sample subset; The reconstruction model is trained using a subset of the first sample so that it learns the intra-class information of the target class samples; the intra-class information is used to reflect the inherent differences within the target class samples. Based on the reconstructed model after training, feature extraction is performed on the second and third sample subsets to obtain the residual features of the second and third sample subsets. The residual features are used to suppress intra-class information while retaining inter-class information, and the inter-class information is used to reflect the difference between the abnormal class and the target class. A classifier is trained based on the residual features of the second sample subset, and its performance is optimized based on the residual features of the third sample subset to obtain an optimized classifier.
[0007] Optionally, feature extraction is performed on the second and third sample subsets based on the trained reconstruction model to obtain the residual features of the second and third sample subsets, including: The original features of the second and third sample subsets are input into the trained reconstruction model to obtain the reconstructed features of the second and third sample subsets output by the trained reconstruction model. The difference between the original features of the second sample subset and the reconstructed features of the second sample subset is calculated to obtain the residual features of the second sample subset; The difference between the original features of the third sample subset and the reconstructed features of the third sample subset is calculated to obtain the residual features of the third sample subset.
[0008] Optionally, the model can be reconstructed as a principal component analysis model.
[0009] Optionally, when training the principal component analysis model, at least 99% of the principal components that can explain the variance of the first sample subset of data are retained.
[0010] Optionally, the reconstructed model is an autoencoder neural network model.
[0011] Optionally, one classifier can be any one of the following: an isolation forest, a support vector machine, or a local outlier algorithm.
[0012] Optionally, the target sample set is spectral data, which includes any one of near-infrared spectral data, infrared spectral data, or Raman spectral data.
[0013] Secondly, this application also provides a classification method, the method comprising: Obtain the data to be classified; Input the data to be classified into a classifier and obtain the classification result output by the classifier. Among them, one classifier is obtained based on the training method of the one classifier described in any of the first aspects.
[0014] Thirdly, this application also provides a computing device, including: a memory and a processor, wherein the memory stores a processing program, and when the processing program is executed by the processor, it implements the methods of the first aspect and / or the second aspect described above.
[0015] Fourthly, this application also provides a storage medium storing a computer program that, when executed by a processor, implements the methods of the first and / or second aspects described above.
[0016] As described above, the training method for a classifier of this application can be applied to a computing device, including: acquiring a target class sample set; dividing the target class sample set into a first sample subset, a second sample subset, and a third sample subset; training a reconstruction model using the first sample subset to enable the reconstruction model to learn intra-class information of the target class samples; the intra-class information is used to reflect the inherent differences within the target class samples; performing feature extraction processing on the second sample subset and the third sample subset based on the trained reconstruction model to obtain residual features of the second sample subset and residual features of the third sample subset; the residual features are used to suppress intra-class information while retaining inter-class information, and the inter-class information is used to reflect the differences between the abnormal class and the target class; training a classifier based on the residual features of the second sample subset, and optimizing the performance of the classifier based on the residual features of the third sample subset to obtain an optimized classifier. The above technical solution enables model training for anomaly detection using only target class samples. By extracting residual features to effectively suppress intra-class information and retain inter-class information, the inter-class-intra-class distance ratio (IIDR) of features is significantly improved. This effectively solves the problem of insufficient anomaly samples in single-class classification scenarios, which prevents the effective reduction of the overlap between target and anomaly class distributions in the feature space. In other words, it effectively solves the misjudgment problem caused by feature overlap, thereby significantly improving the overall detection accuracy and robustness of unknown anomaly samples. This effectively improves the classification accuracy and robustness of a single-class classifier in anomaly classification and detection. Attached Figure Description
[0017] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, those skilled in the art can obtain other drawings based on these drawings without any creative effort.
[0018] Figure 1 This is a flowchart illustrating a training method for a classifier according to one embodiment.
[0019] Figure 2This is a schematic diagram illustrating the training process of a classifier according to one embodiment.
[0020] Figure 3 This is a flowchart illustrating a classification method according to one embodiment.
[0021] The realization of the objectives, functional features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. The accompanying drawings have illustrated specific embodiments of this application, which will be described in more detail below. These drawings and textual descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concepts of this application to those skilled in the art through reference to specific embodiments. Detailed Implementation
[0022] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application.
[0023] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, components, features, and elements with the same names in different embodiments of this application may have the same meaning or different meanings, the specific meaning of which must be determined by its interpretation in that specific embodiment or further in conjunction with the context of that specific embodiment.
[0024] It should be understood that although the terms first, second, third, etc., may be used herein to describe various information, such information should not be limited to these terms. These terms are used only to distinguish information of the same type from one another. For example, without departing from the scope of this document, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if," as used herein, may be interpreted as "when," "when," or "in response to determination." Furthermore, as used herein, the singular forms "a," "an," and "the" are intended to also include the plural forms unless the context indicates otherwise. It should be further understood that the terms "comprising," "including," indicate the presence of the stated feature, step, operation, element, component, item, kind, and / or group, but do not exclude the presence, occurrence, or addition of one or more other features, steps, operations, elements, components, items, kinds, and / or groups. The terms "or," "and / or," "including at least one of the following," etc., as used in this application, may be interpreted as inclusive, or mean any one or any combination thereof. For example, "including at least one of the following: A, B, C" means "any one of the following: A; B; C; A and B; A and C; B and C; A and B and C." Similarly, "A, B, or C" or "A, B, and / or C" means "any one of the following: A; B; C; A and B; A and C; B and C; A and B and C." Exceptions to this definition only occur when the combination of elements, functions, steps, or operations is inherently mutually exclusive in some way.
[0025] It should be understood that although the steps in the flowcharts of this application's embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some of the steps in the figures may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be performed alternately or in turn with other steps or at least a portion of the sub-steps or stages of other steps.
[0026] Depending on the context, the words “if” or “suppose” as used here can be interpreted as “when” or “in response to determination” or “in response to detection.” Similarly, depending on the context, the phrases “if determination” or “if detection (of the stated condition or event)” can be interpreted as “when determination” or “in response to determination” or “when detection (of the stated condition or event)” or “in response to detection (of the stated condition or event).”
[0027] It should be noted that step designations such as S1 and S2 are used in this document for the purpose of more clearly and concisely describing the corresponding content, and do not constitute a substantial limitation on the order. In specific implementation, those skilled in the art may execute S2 first and then S1, etc., but these should all be within the protection scope of this application.
[0028] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.
[0029] In the following description, the use of suffixes such as "module," "part," or "unit" to denote elements is solely for the purpose of illustrative purposes and has no specific meaning in itself. Therefore, "module," "part," or "unit" may be used interchangeably.
[0030] Computing devices can be implemented in various forms. For example, the computing devices described in this application may include mobile terminals such as mobile phones, tablets, laptops, handheld computers, personal digital assistants (PDAs), portable media players (PMPs), navigation devices, wearable devices, smart bracelets, pedometers, and fixed terminals such as digital TVs and desktop computers.
[0031] Reference Figure 1 , Figure 1 This is a flowchart illustrating a training method for a classifier according to an embodiment of this application. The training method for a classifier according to this embodiment can be applied to computing devices (such as computers), and includes the following steps: S1. Obtain the target class sample set.
[0032] S2. Divide the target class sample set into a first sample subset, a second sample subset, and a third sample subset.
[0033] S3. The reconstruction model is trained using the first sample subset so that the reconstruction model learns the intra-class information of the target class samples; the intra-class information is used to reflect the inherent differences within the target class samples.
[0034] S4. Based on the reconstructed model after training, feature extraction is performed on the second and third sample subsets to obtain the residual features of the second and third sample subsets. The residual features are used to suppress intra-class information while retaining inter-class information. The inter-class information is used to reflect the difference between the abnormal class and the target class.
[0035] S5. Train a classifier based on the residual features of the second sample subset, and optimize the performance of the classifier based on the residual features of the third sample subset to obtain an optimized classifier.
[0036] One type of classifier is a special classification model that uses only samples from a single class (i.e., the target class) during the training phase. Its core task is to define a decision boundary that distinguishes the target class samples from all other possible anomaly class samples. The target class sample set typically includes tens, hundreds, or even thousands of target class samples. In anomaly detection scenarios, the target class samples represent the "normal" or "compliant" state, and the training of the one-class classifier depends solely on these samples. The anomaly class, in contrast to the target class, is the set of samples representing the "abnormal," "defective," or "non-compliant" state, and these samples cannot be used in the training process of the one-class classifier. Intra-class information refers to the inherent differences and fluctuations within the target class sample set, such as the natural spectral fluctuations caused by minor deviations in the manufacturing process of the same batch of qualified products. This type of information is the main reason for the overlap in the distribution of the target class and the anomaly class in the feature space. Inter-class information refers to the key feature information that can distinguish the anomaly class from the target class. It is introduced by abnormal components (such as adulterants or impurities), and this type of information is the basis for effective anomaly detection. A reconstruction model is an unsupervised learning model whose goal is to learn the underlying distribution or structure of input data and reconstruct the original input from its internal representation. In this embodiment, a reconstruction model specifically refers to a model trained only on target class samples to learn its intra-class information. Residual features are the difference between the original input features and the reconstructed features output by the reconstruction model; this difference represents the portion of the original data that cannot be explained by the reconstruction model. In this embodiment, through specific design, residual features are intended to suppress intra-class information while preserving inter-class information.
[0037] In this embodiment, a fundamental assumption is first proposed: abnormal samples can be viewed as a superposition of target class samples and abnormal information. Based on this, the implementation principle of the method provided in this embodiment is as follows: the input features are reconstructed using a reconstruction model that has only learned from target class samples. Since this model has never encountered abnormal class samples, its reconstruction result can only reproduce the intra-class information of the target class. By calculating the residual between the original features and the reconstructed features, the intra-class information can be effectively suppressed (or subtracted), thereby highlighting the inter-class information retained in the residual features. Finally, the purified residual features are used to train and optimize a classifier to significantly reduce the distribution overlap of the two classes of samples and improve the accuracy and robustness of anomaly detection.
[0038] Specifically, firstly, a clean target class sample set (all normal samples) is obtained and divided into three mutually exclusive subsets: a first subset, a second subset, and a third subset. Next, the reconstruction model is trained using only the first subset. The training goal is for the reconstruction model to learn to capture and reproduce the typical features and fluctuations of the target class samples, i.e., to fully learn its intra-class information. Then, the original features of the second and third subsets are input into the trained reconstruction model for feature extraction, resulting in residual features for the second and third subsets, respectively. During this process, intra-class information is significantly suppressed in the residuals due to the reconstruction model's interpretation (leaving only a small amount of incompletely interpreted intra-class information and noise), while inter-class information is preserved. Finally, the residual features of the second subset are used as training data to initially train a classifier (such as an isolated forest, a support vector machine, or a local anomaly factor). Next, the residual features of the third sample subset are used to optimize the performance of the trained classifier. This optimization process may include adjusting model hyperparameters, model selection, etc., with the aim of obtaining an optimized classifier with optimal performance.
[0039] The performance of a classifier can be evaluated using sensitivity (the ability to correctly identify target classes), specificity (the ability to correctly identify outlier classes), and accuracy (the arithmetic mean of sensitivity and specificity).
[0040] The above method enables model training for anomaly detection using only target class samples. By extracting residual features to effectively suppress intra-class information and retain inter-class information, the inter-class-intra-class distance ratio (IIDR) of features is significantly improved. This effectively solves the problem of insufficient anomaly samples in single-class classification scenarios, which prevents the effective reduction of the overlap between target and anomaly class distributions in the feature space. In other words, it effectively solves the misjudgment problem caused by feature overlap, thus significantly improving the overall detection accuracy and robustness of unknown anomaly samples. This effectively improves the classification accuracy and robustness of a single-class classifier in anomaly classification and detection, especially for the detection of minor anomalies (such as low-concentration adulteration).
[0041] In one embodiment, feature extraction is performed on the second and third sample subsets based on the trained reconstruction model to obtain the residual features of the second and third sample subsets, including: The original features of the second and third sample subsets are input into the trained reconstruction model to obtain the reconstructed features of the second and third sample subsets output by the trained reconstruction model. The difference between the original features of the second sample subset and the reconstructed features of the second sample subset is calculated to obtain the residual features of the second sample subset; The difference between the original features of the third sample subset and the reconstructed features of the third sample subset is calculated to obtain the residual features of the third sample subset.
[0042] Specifically, the original features of the second and third sample subsets are input into the pre-trained reconstruction model to obtain the reconstruction features of the second and third sample subsets, respectively. The difference between the original features and the reconstruction features of the two subsets is calculated to obtain the residual features of the second and third sample subsets.
[0043] See Figure 2 Based on the assumption that anomalous samples are formed by superimposing anomalous information onto target class samples, if only target class samples are used to train the reconstruction model (principal component analysis or neural network), the model can only explain intra-class information but not inter-class information. Instead, the original features of the target class and anomalous class samples are input into the trained reconstruction model to obtain reconstructed features. The difference between the original features and the reconstructed features is calculated as residual features to achieve intra-class information suppression and inter-class information preservation, thereby reducing distribution overlap.
[0044] It is understandable that by subtracting the reconstructed features from the original features to obtain residual features, the intra-class information learned by the reconstructed model is effectively subtracted, while inter-class information that the model cannot interpret is highlighted in the residuals. This allows the theoretical concept of "suppressing intra-class information and preserving inter-class information" to be accurately implemented. Moreover, this process is differentiable and differentiable, facilitating end-to-end integration with models such as neural networks. In addition, the residual features retain inter-class information of different anomaly patterns, which can provide a basis for the source analysis of abnormal data (such as determining the type of adulteration).
[0045] In one implementation, the reconstruction model is a principal component analysis (PCA) model. PCA is a linear reconstruction model that achieves effective learning and reconstruction of intra-class information by retaining principal components that explain the vast majority (e.g., ≥99%) of the data variance.
[0046] Principal component analysis (PCA), as a linear, unsupervised method, can reliably capture the main variation patterns (i.e., intra-class information) in the spectra of target class samples. It is particularly suitable for scenarios with high dimensionality and collinearity in spectral data, and it boasts fast training speed and low resource consumption, making it easy to deploy in embedded systems or online detection devices. Furthermore, by retaining principal components that explain at least 99% of the variance, it achieves an optimal balance between learning "sufficient" intra-class information and avoiding "overfitting" noise.
[0047] In one embodiment, the reconstruction model is an autoencoder neural network model. An autoencoder neural network model is a non-linear reconstruction model that minimizes the reconstruction error between the input and output through an encoder-decoder structure, thereby achieving a more complex fit to intra-class information.
[0048] It is understandable that for scenarios where there is a complex nonlinear relationship between spectral features and intra-class information, autoencoders can achieve more accurate fitting through their deep nonlinear structure, thereby achieving more thorough suppression of intra-class information and making the inter-class information in the residual features purer. This is especially suitable for processing highly complex or mixed spectral data.
[0049] In one implementation, a classifier is any one of an isolated forest, a support vector machine, or a local anomaly factor algorithm.
[0050] It is understandable that regardless of whether a classifier is based on density estimation (such as LOF), boundary construction (such as OCSVM), or random segmentation (such as isolated forest), the residual features provided in this embodiment can provide it with more discriminative input, enabling it to be flexibly embedded into various existing anomaly detection frameworks and adapt to different spectral data types and detection needs, with high compatibility.
[0051] In one embodiment, the target sample set is spectral data, which includes any one of near-infrared spectral data, infrared spectral data, or Raman spectral data.
[0052] It is understandable that near-infrared, infrared, and Raman spectroscopy are commonly used tools for quality control in the food, pharmaceutical, and other fields, and often face the dilemma of "normal samples are easy to obtain, but abnormal samples are difficult to find". The method provided in this embodiment directly solves the core pain point of overlapping features due to similar chemical composition in the detection of spectral anomalies, and has extremely high industrial application value.
[0053] Based on the same inventive concept as the foregoing embodiments, this embodiment provides a classification method, see below. Figure 3 The method includes: S10. Obtain the data to be classified; S20. Input the data to be classified into a classifier and obtain the classification result output by the classifier. One type of classifier is obtained based on the training method of the one type of classifier described above.
[0054] Specifically, firstly, after receiving unknown data to be classified (such as the spectrum of a drug or food to be detected), the original features of the data are input into a pre-trained reconstruction model that is from the same source as the training phase, to obtain the reconstructed features of the data to be classified. Next, the difference between the original features and the reconstructed features of the data to be classified is calculated as the residual features of the data to be classified. Then, the calculated residual features of the data to be classified are input into an optimized classifier, so that the classifier can determine whether the data to be classified falls within the decision boundary of the target class based on the residual features of the data to be classified, and output the final classification result ("normal" or "abnormal").
[0055] By using the above method, the residual characteristics of the sample to be tested are calculated in real time and input into the optimized classifier, completing the closed loop from "training" to "application". This achieves an end-to-end anomaly detection solution, which can quickly and accurately provide identification results on the production line or on-site. It realizes the transformation of theoretical advantages into practical value and provides a reliable technical tool for online monitoring in the fields of food safety and drug quality.
[0056] The examples listed above are for reference only. To avoid redundancy, they will not be listed one by one here. In actual development or application, they can be flexibly combined according to actual needs. However, any combination belongs to the technical solution of this application and is covered by the protection scope of this application.
[0057] This application also provides a computing device, including a memory and a processor. The memory stores a processing program, and when the processing program is executed by the processor, it implements a training method or classification method for a classifier in any of the above embodiments.
[0058] This application embodiment also provides a storage medium storing a processing program, which, when executed by a processor, implements a training method or classification method for a classifier in any of the above embodiments.
[0059] In the embodiments of the computing device and storage medium provided in this application, all the technical features of any of the above-described processing method embodiments may be included. The extended and explanatory content of the specification is basically the same as that of the embodiments of the above methods, and will not be repeated here.
[0060] This application also provides a computer program product, which includes computer program code. When the computer program code is run on a computer, it causes the computer to perform the methods described in the various possible implementations above.
[0061] This application also provides a chip, including a memory and a processor. The memory is used to store a computer program, and the processor is used to call and run the computer program from the memory, so that a device with the chip installed performs the methods described in the various possible implementations above.
[0062] It is understood that the above scenarios are merely examples and do not constitute a limitation on the application scenarios of the technical solutions provided in the embodiments of this application. The technical solutions of this application can also be applied to other scenarios. For example, as those skilled in the art will know, with the evolution of system architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0063] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0064] The steps in the method of this application embodiment can be adjusted, combined, or deleted according to actual needs.
[0065] The units in the device of this application embodiment can be merged, divided, and deleted according to actual needs.
[0066] In this application, the same or similar terms, concepts, technical solutions and / or application scenario descriptions are generally described in detail only when they appear for the first time. When they appear again, they are generally not repeated for the sake of brevity. When understanding the technical solutions and other contents of this application, the same or similar terms, concepts, technical solutions and / or application scenario descriptions that are not described in detail later can be referred to their previous relevant detailed descriptions.
[0067] In this application, the descriptions of the various embodiments have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0068] The technical features of the present application can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of the present application.
[0069] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, controlled terminal, or network device, etc.) to execute the methods of each embodiment of this application.
[0070] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A 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 flow or function according to the embodiments of this application is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a storage medium or transmitted from one storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, storage disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).
[0071] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
Claims
1. A method for training a classifier, characterized in that, include: Obtain the target class sample set; The target class sample set is divided into a first sample subset, a second sample subset, and a third sample subset; The reconstruction model is trained using the first sample subset so that it learns the intra-class information of the target class samples; Intra-class information is used to reflect the inherent differences within samples of the target class; Based on the reconstructed model after training, feature extraction is performed on the second and third sample subsets to obtain the residual features of the second and third sample subsets. Residual features are used to suppress intra-class information while preserving inter-class information, which is used to reflect the differences between the abnormal class and the target class. A classifier is trained based on the residual features of the second sample subset, and its performance is optimized based on the residual features of the third sample subset to obtain an optimized classifier.
2. The method as described in claim 1, characterized in that, Based on the trained reconstruction model, feature extraction is performed on the second and third sample subsets to obtain the residual features of the second and third sample subsets, including: The original features of the second and third sample subsets are input into the trained reconstruction model to obtain the reconstructed features of the second and third sample subsets output by the trained reconstruction model. The difference between the original features of the second sample subset and the reconstructed features of the second sample subset is calculated to obtain the residual features of the second sample subset; The difference between the original features of the third sample subset and the reconstructed features of the third sample subset is calculated to obtain the residual features of the third sample subset.
3. The method as described in claim 1 or 2, characterized in that, The reconstructed model is a principal component analysis model.
4. The method as described in claim 3, characterized in that, When training the principal component analysis model, retain at least 99% of the principal components that can explain the variance of the first sample subset of data.
5. The method as described in claim 1 or 2, characterized in that, The reconstructed model is an autoencoder neural network model.
6. The method as described in claim 1 or 2, characterized in that, One type of classifier is any one of the following: Isolation Forest, Support Vector Machine, or Local Outlier Algorithm.
7. The method as described in claim 1 or 2, characterized in that, The target sample set is spectral data, which includes any one of near-infrared spectral data, infrared spectral data, or Raman spectral data.
8. A classification method, characterized in that, The method includes: Obtain the data to be classified; Input the data to be classified into a classifier and obtain the classification result output by the classifier. Among them, one type of classifier is obtained based on the training method of the one type of classifier according to any one of claims 1-7.
9. A computing device, characterized in that, include: A memory and a processor, wherein the memory stores a processing program, which, when executed by the processor, implements the method as described in any one of claims 1 to 8.
10. A storage medium, characterized in that, The storage medium stores a processing program, which, when executed by a processor, implements the method as described in any one of claims 1 to 8.