Multi-level label classification and discrimination method and device under unbalanced small samples

By combining the fusion method of ruler and classification model in multi-level label classification of pre-packaged foods, the problem of long-tail distribution of small samples and high maintenance cost is solved, efficient multi-level label classification is achieved, the F1 value is improved and the F1 value is reduced. Maintenance costs.

CN117708330BActive Publication Date: 2024-09-10HEALTH HOPE (BEIJING) TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311759269.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-20
Publication Date
2024-09-10
Estimated Expiration
2043-12-20

AI Technical Summary

Technical Problem

The existing technology has the problems of high maintenance cost, accumulation of errors, and failure to consider the imbalance of long-tail distribution of small samples in the multi-level label classification of prepackaged foods.

Method used

The ruler calibration method is used to process small sample level labels, and the large sample level labels are processed through the classification model. The results of the two are fused through the discriminant conditions to form a multi-level label classification and discrimination method under unbalanced small samples.

Benefits of technology

It improves the F1 value of machine learning to 95%, reduces maintenance costs, and significantly reduces error accumulation and maintenance costs compared to multi-classification model solutions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117708330B
    Figure CN117708330B
Patent Text Reader

Abstract

The present invention discloses a multi-level label classification and discrimination method and device under unbalanced small samples, which relates to the technical field of text classification. The method comprises: obtaining a sample data set; counting the number of samples of the sample data set under each level of multi-level labels, and setting a sample number threshold for each level of labels; taking the sample data under each level of labels whose sample number is less than or equal to the sample number threshold as the first data set, and taking the sample data under the remaining labels as the second data set; classifying the first data set through a keyword library to obtain a first predicted label, and classifying the second data set through a classification model to obtain a second predicted label; fusing the first predicted label and the second predicted label; and predicting the multi-level labels corresponding to each food name in order from the upper label to the lower label. The present invention effectively improves the F1 value of machine learning and greatly reduces maintenance costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of text classification, and in particular to a multi-level label classification and discrimination method and device under unbalanced small samples. Background Art

[0002] Classifying the names of prepackaged foods is a common scenario in the prior art. For example, in prepackaged foods, the food name "×× brand salt-baked cashews 180g" corresponds to the classification label "snacks->nuts and roasted nuts->......->high-fat nuts and roasted nuts", which has the following characteristics:

[0003] (1) The tag level is three or more levels, and there is a parent-child relationship;

[0004] (2) Leaf nodes may correspond to primary labels, secondary labels, tertiary labels, etc.

[0005] (3) The number of database samples is small;

[0006] (4) There is a serious imbalance in the sample data under their respective labels. For example, the number of samples in some categories in the data set is small, while the number of samples in other categories is large, forming a long-tail distribution (long-tail distribution data is a skewed distribution, which means that a few categories, namely the head categories, contain a large number of samples, while most categories, namely the tail categories, have only a very small number of samples).

[0007] The existing technology usually adopts the following scheme to perform label classification and discrimination:

[0008] First, multiple classification models are used to identify multiple layers of labels. The advantage of this solution is that it uses multiple classification models to identify hierarchical labels in a fine-grained manner, which is effective and accurate. The disadvantage is that the maintenance cost of multiple models is high, and the series connection of models will lead to error accumulation.

[0009] Second, a single classification model is used to identify multi-level labels. The advantage of this solution is that a single model is easy to maintain and does not accumulate errors. The disadvantage is that the association between labels at different levels is ignored, and the model effect is not good.

[0010] Third, a hierarchical multi-label classification network model combining local and global models is used. The advantages of this solution are that it takes into account the relationship between labels at different levels, the maintenance cost of a single model is low, and the effect is good. The disadvantage is that it does not take into account the imbalance of the long-tail distribution of small samples under their respective labels. Summary of the invention

[0011] In view of the above defects or deficiencies in the prior art, the present invention provides a multi-level label classification and discrimination method and device under unbalanced small samples, which uses a rule calibration method for the hierarchical labels under the long-tail distribution of small samples, and uses a classification model discrimination method for the hierarchical labels of large samples, and merges the two classification results through discrimination conditions. The model structure of the present invention increases the F1 value of machine learning to 95%, an increase of 8% compared to the solution of a single classification model, and greatly reduces the maintenance cost compared to the solution of a multi-classification model.

[0012] One aspect of the present invention provides a multi-level label classification and discrimination method under unbalanced small samples, comprising:

[0013] Obtain a sample data set, wherein the sample data set includes food names as input samples and multi-level labels as output samples;

[0014] Counting the number of samples of the sample data set under each level of labels in the multi-level labels, and setting a sample number threshold for each level of labels;

[0015] The sample data under each level of labels whose sample number is less than or equal to the sample number threshold is taken as the first data set, and the sample data under the remaining labels is taken as the second data set;

[0016] Classifying the first data set by using a keyword library to obtain a first prediction label, and classifying the second data set by using a classification model to obtain a second prediction label;

[0017] The first predicted label and the second predicted label are fused, and the fused label is used as the final predicted current label;

[0018] According to the above steps, the multi-level labels corresponding to each food name are predicted in sequence from the upper-level label to the lower-level label.

[0019] Furthermore, the step of classifying the first data set through a keyword library to obtain a first predicted label includes:

[0020] The intersection of the sample data in the first data set and the keyword library corresponding to the sample data is calculated to obtain the key sample data, the tf-idf values ​​of the words in the key sample data under each level of labels are counted, and the tf-idf values ​​of the words under each level of labels are summed, and the label with the largest sum of tf-idf values ​​is used as the first predicted label.

[0021] Furthermore, the step of classifying the second data set by using a classification model to obtain a second prediction label includes:

[0022] The sample data in the second data set is vectorized using the classification model, the predicted label probability is output, and the label with the highest probability is used as the second predicted label.

[0023] Furthermore, the step of fusing the first predicted label and the second predicted label and using the fused label as the final predicted current label includes:

[0024] If the first predicted label and the second predicted label are both first-level labels, or the parent label of the first predicted label and the parent label of the second predicted label are the same, then determine whether the probability of the second predicted label is greater than or equal to a preset threshold, if so, take the second predicted label as the fused label, otherwise take the first predicted label as the fused label;

[0025] If the first predicted label and the second predicted label are not the same level label, or the parent label of the first predicted label and the parent label of the second predicted label are not the same, then determine whether the parent label of the first predicted label is consistent with the predicted upper-level label. If so, take the first predicted label as the fused label, otherwise take the second predicted label as the fused label;

[0026] The fused label is used as the final predicted current label.

[0027] Furthermore, the keyword library is obtained in the following manner:

[0028] The support S(a,b) is calculated according to the following formula:

[0029] S(a,b)=P(a,b)

[0030] The confidence C(a,b) is calculated according to the following formula:

[0031]

[0032] The lift L(a,b) is calculated according to the following formula:

[0033]

[0034] Where a is the name of the food, b is the label corresponding to the food name, P(a,b) represents the probability of the food name and the corresponding label appearing together, p(a) is the probability of the food name appearing, and p(b) is the probability of the label corresponding to the food name appearing;

[0035] Keywords in the first data set are extracted according to the support and the support threshold, the confidence and the confidence threshold, and the lift and the lift threshold to form the keyword library.

[0036] Another aspect of the present invention provides a multi-level label classification and discrimination device under unbalanced small samples, comprising:

[0037] An acquisition module is configured to acquire a sample data set, wherein the sample data set includes food names as input samples and multi-level labels as output samples;

[0038] A statistical module is configured to count the number of samples of the sample data set under each level of the multi-level labels, and set a sample number threshold for each level of the labels;

[0039] The label data partitioning module is configured to use the sample data under each level of labels whose sample number is less than or equal to the sample number threshold as the first data set, and use the sample data under the remaining labels as the second data set;

[0040] a classification module, configured to classify the first data set through a keyword library to obtain a first prediction label, and classify the second data set through a classification model to obtain a second prediction label;

[0041] A fusion module is configured to fuse the first predicted label and the second predicted label, and use the fused label as the final predicted current label;

[0042] The prediction module is configured to predict the multi-level labels corresponding to each food name in sequence from the upper-level label to the lower-level label according to the above steps.

[0043] Furthermore, the classification module is further configured as follows:

[0044] The intersection of the sample data in the first data set and the keyword library corresponding to the sample data is calculated to obtain the key sample data, the tf-idf values ​​of the words in the key sample data under each level of labels are counted, and the tf-idf values ​​of the words under each level of labels are summed, and the label with the largest sum of tf-idf values ​​is used as the first predicted label.

[0045] Furthermore, the classification module is further configured as follows:

[0046] The sample data in the second data set is vectorized using the classification model, the predicted label probability is output, and the label with the highest probability is used as the second predicted label.

[0047] Furthermore, the fusion module is further configured as follows:

[0048] If the first predicted label and the second predicted label are both first-level labels, or the parent label of the first predicted label and the parent label of the second predicted label are the same, then determine whether the probability of the second predicted label is greater than or equal to a preset threshold, if so, take the second predicted label as the fused label, otherwise take the first predicted label as the fused label;

[0049] If the first predicted label and the second predicted label are not the same level label, or the parent label of the first predicted label and the parent label of the second predicted label are not the same, then determine whether the parent label of the first predicted label is consistent with the predicted upper-level label. If so, take the first predicted label as the fused label, otherwise take the second predicted label as the fused label;

[0050] The fused label is used as the final predicted current label.

[0051] Furthermore, it also includes a keyword library acquisition module, which is configured to:

[0052] The support S(a,b) is calculated according to the following formula:

[0053] S(a,b)=P(a,b)

[0054] The confidence C(a,b) is calculated according to the following formula:

[0055]

[0056] The lift L(a,b) is calculated according to the following formula:

[0057]

[0058] Where a is the name of the food, b is the label corresponding to the food name, P(a,b) represents the probability of the food name and the corresponding label appearing together, p(a) is the probability of the food name appearing, and p(b) is the probability of the label corresponding to the food name appearing;

[0059] Keywords in the first data set are extracted according to the support and the support threshold, the confidence and the confidence threshold, and the lift and the lift threshold to form the keyword library.

[0060] The multi-level label classification and discrimination method and device under unbalanced small samples provided by the present invention use a rule calibration method for the level labels under the long-tail distribution of small samples, and use a classification model discrimination method for the level labels of large samples, and integrate the two classification results together through the discrimination conditions, effectively improving the F1 value of machine learning, and greatly reducing the maintenance cost compared with the multi-classification model solution. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:

[0062] Figure 1 It is a schematic diagram of the multi-level labeling system under unbalanced small samples in the field of pre-packaged foods;

[0063] Figure 2 This is a first logic flow chart of a multi-level label classification and discrimination method under unbalanced small samples provided by an embodiment of the present application;

[0064] Figure 3 This is a second logic flow chart of a multi-level label classification and discrimination method under unbalanced small samples provided by an embodiment of the present application;

[0065] Figure 4 It is a structural diagram of a multi-level label classification and discrimination device under unbalanced small samples provided by an embodiment of the present application. DETAILED DESCRIPTION

[0066] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0067] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings.

[0068] It should be understood that although the terms first, second, third, etc. may be used to describe the acquisition modules in the embodiments of the present invention, the acquisition modules should not be limited to these terms. These terms are only used to distinguish the acquisition modules from each other.

[0069] The word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrases "if it is determined" or "if (stated condition or event) is detected" may be interpreted as "when it is determined" or "in response to determining" or "when detecting (stated condition or event)" or "in response to detecting (stated condition or event)", depending on the context.

[0070] It should be noted that the directional words such as "upper", "lower", "left", and "right" described in the embodiments of the present invention are described at the angles shown in the drawings and should not be understood as limiting the embodiments of the present invention. In addition, in the context, it should also be understood that when it is mentioned that an element is formed "on" or "under" another element, it can not only be formed directly "on" or "under" another element, but also be formed "on" or "under" another element indirectly through an intermediate element.

[0071] Figure 1 The structure of the multi-level labeling system under the unbalanced small sample in the field of pre-packaged food is shown. The labeling system in the figure includes three levels, namely the first-level label (snacks, grain and oil seasoning, beverage mixing), the second-level label (nuts and fried seeds, candy / chocolate, meat / meat jerky, cooking oil, northern and southern dry goods, coffee, milk tea, etc.), and the third-level label (high-starch nuts and fried seeds, high-fat nuts and fried seeds...vegetable oil, animal oil...soybean flour, etc.).

[0072] For example, the food name "×× brand salt-baked cashews 180g" corresponds to the category label "snacks->nuts and roasted nuts->high-fat nuts and roasted nuts", which has the following characteristics: the label hierarchy is three-level, and there is a parent-child relationship between the labels at each level; the leaf nodes may correspond to the first-level label, the second-level label, and the third-level label; the total number of data in the database is generally around 20,000, the number of third-level label types is more than 100, and the number of second-level labels is more than 40, and the number of samples is small; the sample data is seriously unbalanced under each label, forming a long-tail distribution. Long-tail distribution data is a skewed distribution, which means that a few categories, namely the head category, contain a large number of samples, while most categories, namely the tail category, have only a very small number of samples.

[0073] See also Figure 2 In order to construct a classification and discrimination system of multi-level labels under unbalanced small samples, the present invention provides a classification and discrimination method of multi-level labels under unbalanced small samples, comprising the following steps:

[0074] Step S101 : obtaining a sample data set, wherein the sample data set includes food names as input samples and multi-level labels as output samples.

[0075] The input of the classification and discrimination model of the present embodiment is the name of food, and the output is the label of the corresponding food name, for example: the input food name is "180g of salt-baked cashew nuts from orchard old farmer", and the output label corresponds to "snack food". The classification and discrimination model of the present embodiment is to classify the data set of the above-mentioned food names with multi-level labels. Therefore, first obtain a food name data set, which includes multiple food names and corresponding multi-level labels, perform a pre-processing operation to remove special symbols on the food name, and perform word segmentation on each food name by a third-party tool, for example: "180g of salt-baked cashew nuts from orchard old farmer" will generate words such as "orchard / old farmer / salt-baked cashew nuts / 180g" after word segmentation, and these words will correspond to the label "snack food". In other words, each word will correspond to a label, and these labels are labels of multiple different levels, the words after word segmentation constitute the input sample set, the labels corresponding to the words constitute the output sample set, and the input sample set and the output sample set constitute the sample data set.

[0076] Step S102 , counting the number of samples of the sample data set under each level of labels in the multi-level labels, and setting a sample number threshold for each level of labels.

[0077] Specifically, since the sample data in the scenario of this embodiment is small sample data, and the sample data is seriously unbalanced under each label, for example, the number of samples of some categories in the data set is small, while the number of samples of other categories is large, forming a long-tail distribution. Therefore, this step needs to count the number of samples under each label, and formulate the sample number threshold of each level of label, so as to judge whether the number of samples under the label belongs to large sample data or small sample data through the threshold. Figure 1 Taking the label system as an example, the number of samples under the first-level label, second-level label, and third-level label of food data are counted and sorted, and then the sample number threshold V1 of the first-level label, the sample number threshold V2 of the second-level label, and the sample number threshold V3 of the third-level label are set respectively.

[0078] Step S103: taking sample data under each level of labels whose sample number is less than or equal to the sample number threshold as the first data set, and taking sample data under the remaining labels as the second data set.

[0079] Specifically, the sample data with the number of samples under the first-level label less than or equal to the sample number threshold V1 of the first-level label, the sample data with the number of samples under the second-level label less than or equal to the sample number threshold V2 of the second-level label, and the sample data with the number of samples under the third-level label less than or equal to the sample number threshold V3 of the third-level label are divided and recorded as the first data set; the remaining data is recorded as the second data set. Among them, the first data set is the set sum of small sample data under each level of label, and the second data set is the set sum of large sample data under each level of label.

[0080] Step S104, classifying the first data set through a keyword library to obtain a first prediction label, and classifying the second data set through a classification model to obtain a second prediction label.

[0081] Specifically, in order to cope with the long-tail distribution characteristics of sample data, the present invention specially sets up a rule generator to process labels with a relatively small number of samples in the long-tail distribution. The core idea of ​​the rule generator of the present invention is to classify text by keywords and use statistical methods to mine keywords through association rule algorithms. The association rule algorithm mainly counts: support S, that is, Support(a,b)=P(a,b), support S represents the probability of co-occurrence of food name / word a and corresponding label b, P(a,b) represents the probability of co-occurrence of food name / word a and corresponding label b; confidence C, that is The confidence C represents the probability of the corresponding label b appearing when the food name / word a appears, and p(a) is the probability of the food name / word a appearing; the lift L, that is, The lift L represents the lift of the corresponding label b on the appearance of the food name / word a, analyzing the correlation between b and a, and p(b) is the probability of the label corresponding to the food name appearing.

[0082] For example, the word after the word segmentation of the food name "Guyuan Laonong Salt-baked Cashews 180g" is "Guyuan / Laonong / Salted Cashews / 180g", and the corresponding label is "Leisure Food". Analyze the relationship between the word "Salted Cashews" and the label "Leisure Food", calculate the values ​​of support S, confidence C, and lift L according to the above formula, and set the corresponding thresholds S1, C1, and L1. Similarly, analyze the relationship between the words "Guyuan", "Laonong", "180g" and the label "Leisure Food", calculate the values ​​of support S, confidence C, and lift L corresponding to each word according to the above formula, and set the corresponding thresholds S1, C1, and L1. If there are multiple food names, analyze the relationship between the words of each food name and the corresponding label according to the above steps, calculate the values ​​of support S, confidence C, and lift L corresponding to each word, and set the corresponding thresholds S1, C1, and L1. Finally, according to the size of the support S and the support threshold S1, the size of the confidence C and the confidence threshold C1, and the size of the lift L and the lift threshold L1, the keywords in the data set are extracted to form a keyword library. For example, when the support S of a word and the corresponding label is greater than the support threshold S1, the confidence C is greater than the confidence threshold C1, and the lift L is greater than the lift threshold L1, the word is used as a keyword until all the keywords in the data set are extracted.

[0083] Furthermore, after obtaining the keyword library, the intersection of the sample data in the first data set and the keyword library corresponding to the sample data is calculated to obtain the key sample data, the tf-idf values ​​of the words in the key sample data under each level of labels are counted, and the tf-idf values ​​of the words under each level of labels are summed, and the label with the largest sum of tf-idf values ​​is used as the first predicted label.

[0084] Further, the sample data in the second data set is vectorized using the classification model, the predicted label probability is output, and the label with the highest probability is used as the second predicted label. The classification model in this embodiment can adopt the hierarchical multi-label classification network model combining the local and global models mentioned in the background technology, but is not limited thereto.

[0085] Step S105 , fusing the first predicted label and the second predicted label, and using the fused label as the final predicted current label.

[0086] The purpose of this step is to use judgment logic to determine whether the final predicted current label is the first predicted label or the second predicted label, that is, whether the predicted current label is the prediction result of the selection rule or the prediction result of the selection classification model.

[0087] The specific fusion processing logic is: if the first predicted label and the second predicted label are both first-level labels, or the parent label of the first predicted label and the parent label of the second predicted label are the same, then determine whether the probability of the second predicted label is greater than or equal to the preset threshold. If so, the second predicted label is used as the label after fusion processing, otherwise the first predicted label is used as the label after fusion processing. If the first predicted label and the second predicted label are not first-level labels, or the parent label of the first predicted label and the parent label of the second predicted label are not the same, then determine whether the parent label of the first predicted label is consistent with the predicted upper-level label. If so, the first predicted label is used as the label after fusion processing, otherwise the second predicted label is used as the label after fusion processing; the fusion-processed label is used as the final predicted current label.

[0088] Step S106, according to the above steps, predict the multi-level labels corresponding to each food name in order from the upper-level label to the lower-level label.

[0089] Steps S101 to S105 are the current label prediction method. Since the purpose of the present invention is to give appropriate first-level labels, second-level labels, third-level labels, and so on, to multi-level labels for the input food name, the order of predicting labels in the present invention is from the upper-level label to the lower-level label, and the multi-level labels corresponding to each food name are predicted in turn. Figure 1For example, a food name is input into the model of the present invention, and the first-level label is predicted first, the second-level label is predicted, and the third-level label is predicted. Therefore, in step S106, steps S101 to S105 are executed cyclically until all multi-level labels corresponding to the food name are predicted.

[0090] The multi-level label classification and discrimination method under unbalanced small samples provided in this embodiment uses a rule calibration method for the level labels under the long-tail distribution of small samples, and uses a classification model discrimination method for the level labels of large samples, and combines the two classification results together through the discrimination conditions, effectively improving the F1 value of machine learning, and at the same time greatly reducing the maintenance cost compared to the multi-classification model solution.

[0091] See also Figure 3 Another embodiment of the present invention further provides a multi-level label classification and discrimination device 200 under unbalanced small samples, including an acquisition module 201, a statistical module 202, a label data division module 203, a classification module 204, a fusion module 205, and a prediction module 206. The classification and discrimination device 200 can execute the multi-level label classification and discrimination method under unbalanced small samples in the method embodiment.

[0092] Specifically, the classification and discrimination device 200 includes:

[0093] An acquisition module 201 is configured to acquire a sample data set, wherein the sample data set includes food names as input samples and multi-level labels as output samples;

[0094] The statistical module 202 is configured to count the number of samples of the sample data set under each level of the multi-level label, and set a sample number threshold for each level of the label;

[0095] The label data partitioning module 203 is configured to use the sample data under each level of labels whose sample number is less than or equal to the sample number threshold as the first data set, and use the sample data under the remaining labels as the second data set;

[0096] The classification module 204 is configured to classify the first data set through a keyword library to obtain a first prediction label, and classify the second data set through a classification model to obtain a second prediction label;

[0097] The fusion module 205 is configured to fuse the first predicted label and the second predicted label, and use the fused label as the final predicted current label;

[0098] The prediction module 206 is configured to predict the multi-level labels corresponding to each food name in sequence from the upper-level label to the lower-level label according to the above steps.

[0099] The classification module 204 can be further configured to: find the intersection of the sample data in the first data set and the keyword library corresponding to the sample data to obtain key sample data, count the tf-idf values ​​of the words in the key sample data under each level of labels, and sum the tf-idf values ​​of the words under each level of labels, and take the label with the largest sum of tf-idf values ​​as the first predicted label.

[0100] The classification module 204 may be further configured to: vectorize the sample data in the second data set using the classification model, output the predicted label probability, and use the label with the highest probability as the second predicted label.

[0101] The fusion module 205 may be further configured to: if the first predicted label and the second predicted label are both first-level labels, or the parent label of the first predicted label and the parent label of the second predicted label are the same, then determine whether the probability of the second predicted label is greater than or equal to a preset threshold, if so, take the second predicted label as the label after fusion processing, otherwise take the first predicted label as the label after fusion processing;

[0102] If the first predicted label and the second predicted label are not the same level label, or the parent label of the first predicted label and the parent label of the second predicted label are not the same, then determine whether the parent label of the first predicted label is consistent with the predicted upper-level label. If so, take the first predicted label as the fused label, otherwise take the second predicted label as the fused label;

[0103] The fused label is used as the final predicted current label.

[0104] Furthermore, it also includes a keyword library acquisition module, which is configured to:

[0105] The support S(a,b) is calculated according to the following formula:

[0106] S(a,b)=P(a,b)

[0107] The confidence C(a,b) is calculated according to the following formula:

[0108]

[0109] The lift L(a,b) is calculated according to the following formula:

[0110]

[0111] Where a is the name of the food, b is the label corresponding to the food name, P(a,b) represents the probability of the food name and the corresponding label appearing together, p(a) is the probability of the food name appearing, and p(b) is the probability of the label corresponding to the food name appearing;

[0112] Keywords in the first data set are extracted according to the support and the support threshold, the confidence and the confidence threshold, and the lift and the lift threshold to form the keyword library.

[0113] It should be noted that the classification and discrimination device 200 provided in this embodiment corresponds to a technical solution that can be used to execute each method embodiment, and its implementation principle and technical effect are similar to the method, which will not be repeated here.

[0114] The above description is only a preferred embodiment of the present invention. Those skilled in the art should understand that the disclosure scope involved in the present invention is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present invention (but not limited to) by each other to form a technical solution.

Claims

1. A multi-level label classification and discrimination method under unbalanced small samples, characterized in that: include: Obtain a sample data set, wherein the sample data set includes food names as input samples and multi-level labels as output samples; Counting the number of samples of the sample data set under each level of labels in the multi-level labels, and setting a sample number threshold for each level of labels; The sample data under each level of labels whose sample number is less than or equal to the sample number threshold is taken as the first data set, and the sample data under the remaining labels is taken as the second data set; The sample data in the first data set and the keyword library corresponding to the sample data are intersected to obtain key sample data, and the tf-idf values ​​of the words in the key sample data under each level of label are counted, and the tf-idf values ​​of the words under each level of label are summed, and the label with the largest sum of tf-idf values ​​is used as the first predicted label; Classify the second data set by using a classification model to obtain a second predicted label; If the first predicted label and the second predicted label are both first-level labels, or the parent label of the first predicted label and the parent label of the second predicted label are the same, then determine whether the probability of the second predicted label is greater than or equal to a preset threshold. If so, the second predicted label is used as the fused label, otherwise the first predicted label is used as the fused label; if the first predicted label and the second predicted label are not first-level labels, or the parent label of the first predicted label and the parent label of the second predicted label are not the same, then determine whether the parent label of the first predicted label is consistent with the predicted upper-level label. If so, the first predicted label is used as the fused label, otherwise the second predicted label is used as the fused label; the fused label is used as the final predicted current label; According to the above steps, the multi-level labels corresponding to each food name are predicted in sequence from the upper-level label to the lower-level label.

2. According to the method of multi-level label classification and discrimination under imbalanced small samples in claim 1, it is characterized by: The step of classifying the second data set by using a classification model to obtain a second prediction label includes: The sample data in the second data set is vectorized using the classification model, the predicted label probability is output, and the label with the highest probability is used as the second predicted label.

3. According to the method of multi-level label classification and discrimination under imbalanced small samples in claim 1, it is characterized by: The keyword library is obtained in the following way: The support S(a,b) is calculated according to the following formula: S(a,b)=P(a,b) The confidence C(a,b) is calculated according to the following formula: The lift L(a,b) is calculated according to the following formula: Where a is the name of the food, b is the label corresponding to the food name, P(a,b) represents the probability of the food name and the corresponding label appearing together, p(a) is the probability of the food name appearing, and p(b) is the probability of the label corresponding to the food name appearing; Keywords in the first data set are extracted according to the support and the support threshold, the confidence and the confidence threshold, and the lift and the lift threshold to form the keyword library.

4. A multi-level label classification and discrimination device under unbalanced small samples, characterized in that: include: An acquisition module is configured to acquire a sample data set, wherein the sample data set includes food names as input samples and multi-level labels as output samples; A statistical module is configured to count the number of samples of the sample data set under each level of labels in the multi-level labels, and set a sample number threshold for each level of labels; The label data partitioning module is configured to use the sample data under each level of labels whose sample number is less than or equal to the sample number threshold as the first data set, and use the sample data under the remaining labels as the second data set; A classification module is configured to obtain an intersection of the sample data in the first data set and the keyword library corresponding to the sample data to obtain key sample data, calculate the tf-idf value of the words in each level of the key sample data, and sum the tf-idf values ​​of the words in each level of the label, and take the label with the largest sum of tf-idf values ​​as the first predicted label; Classify the second data set by using a classification model to obtain a second predicted label; The fusion module is configured to determine whether the probability of the second predicted label is greater than or equal to a preset threshold if the first predicted label and the second predicted label are both first-level labels, or the parent label of the first predicted label and the parent label of the second predicted label are the same, and if so, the second predicted label is used as the fused label, otherwise the first predicted label is used as the fused label; if the first predicted label and the second predicted label are not first-level labels, or the parent label of the first predicted label and the parent label of the second predicted label are not the same, determine whether the parent label of the first predicted label is consistent with the predicted upper-level label, and if so, the first predicted label is used as the fused label, otherwise the second predicted label is used as the fused label; and the fused label is used as the final predicted current label; The prediction module is configured to predict the multi-level labels corresponding to each food name in sequence from the upper-level label to the lower-level label according to the above steps.

5. The device for multi-level label classification and discrimination under imbalanced small samples according to claim 4 is characterized in that: The classification module is further configured to: The sample data in the second data set is vectorized using the classification model, the predicted label probability is output, and the label with the highest probability is used as the second predicted label.

6. The device for multi-level label classification and discrimination under imbalanced small samples according to claim 4 is characterized in that: It also includes a keyword library acquisition module, which is configured as follows: The support S(a,b) is calculated according to the following formula: S(a,b)=P(a,b) The confidence C(a,b) is calculated according to the following formula: The lift L(a,b) is calculated according to the following formula: Where a is the name of the food, b is the label corresponding to the food name, P(a,b) represents the probability of the food name and the corresponding label appearing together, p(a) is the probability of the food name appearing, and p(b) is the probability of the label corresponding to the food name appearing; Keywords in the first data set are extracted according to the support and the support threshold, the confidence and the confidence threshold, and the lift and the lift threshold to form the keyword library.