Classification model training method and device, equipment, medium and product
By calculating word frequency and IDF, screening and training classification models, it solves the problems of single word vector preprocessing and low classification accuracy in the existing technology, improves the accuracy and efficiency of text classification, and supports efficient public opinion monitoring.
Patent Information
- Application Number
- CN202310983199.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-07
- Publication Date
- 2024-10-18
AI Technical Summary
Existing text classification models ignore the characteristics of word vectors under different business categories during the word vector preprocessing process, resulting in low classification accuracy, low manual analysis efficiency, incomplete spot check samples, and inability to effectively support public opinion-oriented analysis.
By obtaining target samples corresponding to multiple preset text types, calculating the frequency and inverse file frequency IDF of each word, filtering out representative words, and determining the text type to which the words belong based on probability, and training the classification model based on the filtered words , optimize feature expression and feature selection.
It improves the accuracy and generalization ability of the classification model, reduces redundant features, extracts more distinctive vocabulary, enhances information-rich feature vocabulary, improves the accuracy of the classification model, and supports efficient public opinion monitoring and risk management. Control.
Smart Images

Figure CN118797041A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of text data processing, and in particular to a classification model training method, device, equipment, medium and product. Background Art
[0002] The operator's customer service hotline telephone recordings and work order text service data are huge. To determine whether these service data contain risk information, a large amount of manual data analysis is required, which is inefficient and the spot check samples are incomplete. In addition, the complaint categories are not comprehensive enough to support public opinion-oriented analysis. In addition, the existing text classification model ignores the characteristics of word vectors under different business categories during the preprocessing of word vectors, and the category label information is not fully utilized, resulting in the low accuracy of the final text classification model. Summary of the invention
[0003] The present application provides a classification model training method, device, equipment, medium and product, which can improve the classification accuracy of the classification model.
[0004] In a first aspect, an embodiment of the present application provides a classification model training method, the method comprising:
[0005] Obtain target samples corresponding to multiple preset text types;
[0006] For the first word in each target sample, obtain the frequency of the first word in the target sample and the inverse document frequency (IDF) of the first word, where IDF is used to characterize the rarity of the word in the preset corpus;
[0007] For each first word, according to the frequency of occurrence of the first word in all target samples and the IDF of the first word, all words are filtered to obtain a first screening word;
[0008] For each second word in the first screening vocabulary, obtaining the probability that the second word belongs to each text type, and determining the target text type to which the second word belongs based on the probability;
[0009] Based on the first screening vocabulary and the target text type of each second vocabulary, the basic model is trained to obtain a classification model.
[0010] In a second aspect, the present application provides a classification model training device, the device comprising:
[0011] A first acquisition module is used to acquire target samples corresponding to a plurality of preset text types;
[0012] A second acquisition module is used to acquire, for each target sample, a frequency of occurrence of the first word in the target sample and an inverse document frequency (IDF) of the first word, where the IDF is used to characterize the rarity of the word in a preset corpus;
[0013] A filtering module, for filtering all words for each first word according to the frequency of occurrence of the first word in all target samples and the IDF of the first word, to obtain a first screening word;
[0014] A third acquisition module is used to acquire, for each second word in the first screening vocabulary, the probability that the second word belongs to each text type, and determine the target text type to which the second word belongs based on the probability;
[0015] The training module is used to train the basic model based on the first screening vocabulary and the target text type of each second vocabulary to obtain a classification model.
[0016] In a third aspect, an embodiment of the present application provides an electronic device, the electronic device comprising: a processor and a memory storing computer program instructions;
[0017] When the processor executes the computer program instructions, it implements the classification model training method as in any one of the embodiments of the first aspect.
[0018] In a fourth aspect, an embodiment of the present application provides a computer storage medium having computer program instructions stored thereon, and when the computer program instructions are executed by a processor, a classification model training method as in any one of the embodiments in the first aspect is implemented.
[0019] In a fifth aspect, an embodiment of the present application provides a computer program product. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes a classification model training method as in any one of the embodiments in the first aspect above.
[0020] In a classification model training method, device, equipment, medium and product provided in an embodiment of the present application, target samples corresponding to a plurality of preset text types are obtained; for the first word in each target sample, the frequency of the first word in the target sample and the inverse document frequency IDF of the first word are obtained, and IDF is used to characterize the rarity of the word in the preset corpus; for each first word, all words are filtered according to the frequency of the first word in all target samples and the IDF of the first word to obtain a first screening word; for each second word in the first screening word, the probability that the second word belongs to each text type is obtained, and the target text type to which the second word belongs is determined based on the probability; based on the first screening word and the target text type of each second word, the basic model is trained to obtain a classification model. In the above manner, by obtaining the frequency and inverse document frequency IDF of the first word in the target sample, combined with the frequency and IDF of the first word in all target samples, all words are filtered to obtain the first screening word. It helps to reduce redundant features and extract more discriminative words, thereby optimizing feature expression, which can improve the accuracy of the final classification model. By using IDF as the basis for feature selection, more informative feature words can be obtained, thus improving the accuracy of the classification model. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0022] Figure 1 It is a flowchart of a classification model training method provided by an embodiment of the present application;
[0023] Figure 2 It is a flowchart of another classification model training method provided by an embodiment of the present application;
[0024] Figure 3 It is a structural schematic diagram of a classification model training device provided in an embodiment of the present application;
[0025] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0027] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0028] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprising a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0029] The operator's customer service hotline recordings and work order text service data are huge. In this huge service data, judging whether it contains public opinion and risk information requires a lot of manual data analysis, which is inefficient and the sampling is incomplete; in addition, the complaint categories are not comprehensive enough to support public opinion-oriented analysis, and the existing text classification is independently classified by customer service personnel, which is too subjective and inaccurate. Therefore, it is particularly important to establish an efficient and accurate public opinion monitoring device, make targeted improvements based on public opinion categories, and effectively improve user satisfaction.
[0030] In the prior art, the method for public opinion monitoring and analysis of telephone recordings and work order texts is usually to analyze the text information involved in telephone recordings and work order texts based on the correlation analysis method, so as to monitor public opinion, or to analyze the text information involved in telephone recordings and work order texts based on the Euclidean distance between speech feature vectors, so as to monitor public opinion. However, the above methods all have the following defects: the word vector preprocessing process is single, the word vector is not combined with different complaint scenarios for feature selection and derivation, and the word vector characteristics under different complaint scenarios are not fully explored. Synonyms are not replaced. When words have similar meanings, if they are given weights separately, the importance of keywords will be reduced, and the problem of feature collinearity will not be solved. The classification method of text similarity matching, the model effect depends on the quality of the preset template or the professional word segmentation dictionary established manually, there are industry barriers, and the model generalization ability is weak. The model efficiency is low, and the method of traversing historical complaint work order data to calculate the correlation has the problems of large calculation amount and slow speed. The standard for public opinion judgment is whether the number of relevant public opinions reaches the threshold, which fails to combine the actual data distribution and lacks objectivity. The fusion method adopts weighted averaging and does not derive features for different topics, which will result in better application effects only on documents with distinct topics, but poor application effects on documents with vague topics. It does not perform dimensionality reduction on features with collinearity, which affects the model training effect.
[0031] In order to solve the problems existing in the prior art, the embodiments of the present application provide a classification model training method, device, equipment, medium and product.
[0032] The present application embodiment provides a classification model training method, device, equipment, medium and product. The classification model training method provided by the present application embodiment is first introduced below. Figure 1 As shown, the method specifically comprises the following steps:
[0033] S100, obtaining target samples corresponding to a plurality of preset text types.
[0034] Optionally, in an embodiment of the present application, the target text may be a complaint text, and the text type may be different complaint types.
[0035] Optionally, in an embodiment of the present application, in order to obtain target samples corresponding to a plurality of preset text types, the text data can be divided according to different classification criteria to define different text types through professional domain knowledge or business needs. For example, complaint data can be divided into different categories, such as network problems, service quality, billing problems, etc., and customer service telephone recording data can be divided into different topics, such as complaints, consultations, suggestions, etc. Then, the existing data set is screened and labeled according to the text type to construct a corresponding target sample set. If the existing data is not enough to cover all target text types, the comprehensiveness and representativeness of the target sample set can be ensured by actively collecting or crawling relevant data. In addition, in order to improve the generalization ability of the model, data enhancement technology can also be introduced to expand the target sample set to increase the diversity and quantity of samples. The diversity and richness of the target samples help to improve the accuracy and generalization ability of the model, so as to better cope with the processing challenges of large-scale text data.
[0036] S200, for a first word in each target sample, obtain the frequency of occurrence of the first word in the target sample and the inverse document frequency (IDF) of the first word, where the IDF is used to represent the rarity of a word in a preset corpus.
[0037] Optionally, in an embodiment of the present application, the target sample can be firstly segmented to split the text into words or phrases for subsequent statistics and calculations. The frequency of occurrence refers to the ratio of the number of times a certain word appears in the target sample to the total number of words in the target sample. The frequency can be obtained by traversing each word of the target sample, counting the number of times the first word appears therein, and then dividing it by the total number of words in the target sample. The calculation result of the frequency reflects the importance and prevalence of the first word in the target sample. In addition, we also need to calculate the inverse document frequency IDF (Inverse Document Frequency, IDF) of the first word. IDF is an indicator for measuring the rarity of a word in the entire preset corpus. The calculation method of IDF is to reflect its rarity by the number of texts containing a certain word in the preset corpus. The larger the IDF value, the less the word appears in the preset corpus, and it may have a greater amount of information and discrimination. By obtaining the frequency and IDF value of the first word, important reference information can be provided for subsequent feature selection and model training. This helps to select representative and discriminative feature words and improve the accuracy and generalization ability of the model for text classification and risk information identification.
[0038] S300 , for each first word, according to the frequency of occurrence of the first word in all target samples and the IDF of the first word, all words are filtered to obtain a first screening word.
[0039] Optionally, in an embodiment of the present application, the screening conditions can be set first, that is, which words are selected to be retained according to the frequency and IDF value. Different thresholds can be set according to actual needs, such as setting a frequency threshold and an IDF threshold, and only retaining words with a frequency higher than the threshold and an IDF greater than the threshold. Such a setting can filter out words that appear less frequently in the target sample and are more common in the entire preset corpus, and retain those important and discriminative words in the target sample. Then, all words will be filtered according to the set screening conditions. Traverse each word in the target sample, calculate its frequency and IDF value, and compare it with the set threshold. If a word meets the screening conditions, that is, its frequency is higher than the set threshold and its IDF is greater than the set threshold, we will retain the word as the first screening word. Otherwise, it will be filtered out and not included in the subsequent feature selection and model training. Through such a filtering process, the first screening words are obtained, which have a high amount of information and discrimination, and can be used as an important feature of model training. In the subsequent model training, the first screening words will be used as a feature set to construct a more representative and discriminative text representation, thereby improving the accuracy and classification effect of the model.
[0040] S400: For each second word in the first screening vocabulary, obtain the probability that the second word belongs to each text type, and determine the target text type to which the second word belongs based on the probability.
[0041] Optionally, in an embodiment of the present application, each word in the first screening vocabulary can be further processed to obtain the probability that they belong to each text type, and determine the target text type to which they belong based on the probability. First, for each word in the first screening vocabulary, we need to calculate their probability of occurrence in different text types. This can be done by counting the frequency of the word appearing in different text types in the target sample, and normalizing it to obtain a probability value. Then, we determine the target text type to which each second word belongs based on the calculated probability value. For a certain second word, we select the text type with the maximum probability value as its belonging type. Through such a probability calculation and type determination process, we assign a target text type label to each second word, thereby achieving a more refined classification of the first screening vocabulary. This helps to improve the model's ability to recognize and classify different text types, and further improves the accuracy and generalization ability of the model.
[0042] S500: Based on the first screening vocabulary and the target text type of each second vocabulary, a basic model is trained to obtain a classification model.
[0043] Optionally, in an embodiment of the present application, a feature set can be constructed first. The feature set includes a first screening vocabulary and each second vocabulary, as well as the target text type to which they belong. Such a feature set is a labeled data set, in which each sample contains multiple features, including the first screening vocabulary and their probability values, and each second vocabulary and the target text type to which they belong. These features will serve as input for model training. Next, we select a suitable classification algorithm to build a classification model. For example, it includes logistic regression, decision tree, random forest, etc. According to the data scale and feature dimension, a suitable algorithm can be selected. In an embodiment of the present application, logistic regression can be selected as the basic model.
[0044] The feature set can then be used to train a logistic regression classification model. During the training process, the model will learn the association between the features and the target text type to achieve text classification. During the training process, techniques such as cross-validation can be used to evaluate the performance and generalization ability of the model to ensure that the model performs well on unknown data. After the training is completed, a classification model is obtained, which can make classification predictions based on the input text features.
[0045] In practical applications, the model can be used to automatically classify and identify risk information for operator customer service hotline recordings, work order text service data, etc. The accuracy and generalization ability of the model will be improved, effectively solving problems such as huge data, inefficient manual analysis, and low accuracy of classification models, providing operators with more efficient and accurate public opinion monitoring and risk management support.
[0046] In a classification model training method provided in an embodiment of the present application, target samples corresponding to a plurality of preset text types are obtained; for the first word in each target sample, the frequency of the first word in the target sample and the inverse document frequency IDF of the first word are obtained, and IDF is used to characterize the rarity of the word in the preset corpus; for each first word, all words are filtered according to the frequency of the first word in all target samples and the IDF of the first word to obtain a first screening word; for each second word in the first screening word, the probability that the second word belongs to each text type is obtained, and the target text type to which the second word belongs is determined based on the probability; based on the first screening word and the target text type of each second word, the basic model is trained to obtain a classification model. In the above manner, by obtaining the frequency and inverse document frequency IDF of the first word in the target sample, combined with the frequency and IDF of the first word in all target samples, all words are filtered to obtain the first screening word. It helps to reduce redundant features and extract more discriminative words, thereby optimizing feature expression, which can improve the accuracy of the final classification model. By using IDF as the basis for feature selection, more informative feature words can be obtained, thus improving the accuracy of the classification model.
[0047] In one embodiment, the above step 100 may specifically perform the following steps:
[0048] S110, obtain initial sample
[0049] S120, classifying the initial sample to obtain text data of different text types;
[0050] S130, performing text cleaning on the text data to remove noise data and duplicate data in the text data to obtain a processed sample.
[0051] Optionally, in the implementation of this application, the initial sample may refer to a set of text data with labels or classifications, which is used to train a classification model. For example, the initial sample may be collected from data such as operator customer service hotline recordings and work order text services.
[0052] Specifically, relevant text data can be first collected from data sources such as operator customer service hotline recordings and work order text services. These data can include various text contents such as user complaints, customer inquiries, and service feedback. The collected text data is then manually or automatically annotated and assigned corresponding classification labels. For example, the text can be classified into different types such as complaints, inquiries, suggestions, and praises. The annotated text data is then cleaned to remove irrelevant content, special characters, HTML tags, and other noise data to ensure the quality and accuracy of the sample.
[0053] Optionally, in the embodiments of the present application, text cleaning is to process the noise and redundant information in the text data to ensure the accuracy and efficiency of subsequent processing. In the embodiments of the present application, it may be necessary to perform text cleaning on the classified text data to remove the noise data and duplicate data to obtain the processed samples.
[0054] Specifically, the text data can be preprocessed first to remove some irrelevant information, such as HTML tags, special characters, web links, etc. These information are meaningless for classification and feature extraction and should be removed. Subsequently, in the large-scale text data, there may be duplicate text samples. Therefore, the text data can be de-duplicated to avoid repeated operations on the same samples in the subsequent processing. Then the text data is normalized, such as converting to lowercase letters, removing punctuation marks and numbers, etc. This helps to unify the text format and simplify the subsequent text processing process. Some common stop words, such as "de", "shi", "zai", etc., can also be removed. These words are not helpful for text classification and should be filtered out. Through the above text cleaning steps, the processed sample data can be obtained, which contains clean and standardized text content, removing the noise and redundant information, providing a clean basis for subsequent word segmentation and feature extraction.
[0055] S140, Based on a preset dictionary, perform word segmentation processing on all text segments in the processed sample to obtain multiple segmented words.
[0056] Optionally, in the embodiments of the present application, the text segments in the processed sample can be segmented into multiple segmented words based on a preset dictionary, that is, the text is split into individual lexical units for subsequent processing and feature extraction.
[0057] Specifically, a preset dictionary can be established first, which contains some common words and phrases. The preset dictionary can include domain-specific vocabulary, common words, etc. This dictionary will be used as a reference for word segmentation. Subsequently, for each text segment in the processed sample, the preset dictionary is used for segmentation. During the segmentation process, the text can be split into several lexical units, that is, segmented words. And during the segmentation process, each word in the text is matched to check whether there is a corresponding word in the preset dictionary. If there is a match, then the word is taken as one of the segmented words; if there is no match, the word can be split into smaller words or kept as a single character. Through the above word segmentation steps, the text segments in the processed sample can be split into multiple segmented words, providing a finer-grained input for subsequent feature extraction and text processing. The segmented words will be part of the feature set and are used to train the classification model and extract text features.
[0058] S150, replacing segmented words with the same meaning among the multiple segmented words with a target word to obtain a target sample, wherein the meaning of the target word is the same as the meaning of the replaced segmented word.
[0059] Optionally, in the embodiment of the present application, after the word segmentation process, a plurality of segmented words are obtained, among which there may be some synonyms or word variants with the same meaning. In order to reduce the feature dimension and redundant information, these synonyms can be replaced to obtain the target sample.
[0060] Specifically, we can first identify synonyms or words with similar meanings in the text through semantic similarity or word vector technology. This can be achieved through a pre-trained word vector model or word meaning similarity calculation. Then, for the identified synonyms, we need to find a suitable target word to replace it in the preset target word set. The target word should have the same meaning as the replaced segmented word and be a more common and general vocabulary. Then, the identified synonyms are replaced with the target word to form a new processing sample. The replacement operation can be implemented using string replacement technology or string matching algorithm. This helps to reduce feature dimensions, eliminate feature redundancy caused by synonyms, and improve the efficiency and accuracy of text processing. The obtained target sample will be used as input for subsequent feature extraction and classification model training, thereby improving the accuracy and generalization ability of the classification model.
[0061] Optionally, in a possible implementation of the present application, manual labeling of samples can be implemented. Determine which type of complaint the sample belongs to (for example: channel complaints, marketing case complaints, broadband complaints or installation and maintenance complaints, etc.), as text data; then perform text cleaning on the text data, including removing noise data, removing duplicate data, removing labels, converting uppercase and lowercase, converting full and half-width, punctuation processing, word order processing and other operations; perform word segmentation on the cleaned data. Based on the statistical dictionary, a prefix dictionary is constructed; the input text is segmented using the prefix dictionary to obtain all possible segmentations, and a directed acyclic graph is constructed according to the segmentation position; the maximum probability path, that is, the final segmentation form, is calculated through a dynamic programming algorithm; the segmentation result is subjected to synonym replacement processing. Since there may be similar meanings between words, such as: "way", "method", "method", if they are given weights separately, the importance of the keywords will be reduced, so words with similar meanings are replaced to increase the frequency of some words.
[0062] In these optional embodiments, by classifying and cleaning the initial samples, a clean and standardized text data set can be obtained, reducing the interference of noise and redundant information. Lexical segmentation and synonym replacement help to extract more semantic features, reduce feature dimensions, and make the model more efficient. The combination of these preprocessing steps provides a more reliable foundation for subsequent model training and public opinion monitoring, realizes accurate classification and effective analysis of large-scale text data, and improves the accuracy and generalization ability of the classification model, while reducing the complexity and noise of processing text data.
[0063] In one embodiment, the above step 140 may specifically perform the following steps:
[0064] S141, for each first paragraph in the text segment, perform lexical segmentation processing on the first paragraph according to a preset dictionary to obtain multiple segmentation states of the first paragraph, wherein the segmentation state includes segmentation positions between two words in the first paragraph.
[0065] Optionally, in the embodiment of the present application, for each text segment, a lexical segmentation process can be performed according to a preset dictionary to obtain multiple segmentation states of the segment. That is, the first segment can be split into several lexical units, each lexical unit represents a segmentation state, and contains segmentation position information between two words. For example, for the segment "Today's weather is really good", according to the preset dictionary, the following segmentation states can be obtained: "Today", "Weather", "Really good"; or, "Today's weather", "Really good".
[0066] S142, constructing a directed acyclic graph corresponding to the first paragraph based on the multiple segmentation states, wherein the nodes in the directed acyclic graph indicate the positions of the second vocabulary in the first paragraph under different segmentation states, and two second vocabulary having a connection relationship in the directed acyclic graph are connected by a directed edge.
[0067] Optionally, in an embodiment of the present application, a directed acyclic graph corresponding to the first paragraph can be constructed based on multiple segmentation states. In the graph, each node represents the position of the second vocabulary in the first paragraph under different segmentation states, that is, corresponds to each vocabulary unit after segmentation. The number of nodes in the directed acyclic graph depends on the number of different vocabulary units obtained after segmentation. The connection relationship between the nodes represents the possible connection relationship between the two second vocabularies under different segmentation states. By constructing directed edges to connect different nodes, a directed acyclic graph representing all segmentation states and their connection relationships is formed. In the graph, each path represents the possibility of a segmentation state.
[0068] S143, based on a dynamic programming algorithm, calculate the probability of each path in the directed acyclic graph.
[0069] Optionally, in an embodiment of the present application, in a directed acyclic graph, each path represents the possibility of a segmentation state. The probability of each path can be calculated by a dynamic programming algorithm, that is, the possibility of each segmentation state is calculated. Specifically, starting from the starting node, the probability of each node can be calculated backward step by step. For each node, all paths from its predecessor node to the node are considered, and the path with the highest probability is selected as the probability of the node. By continuously recursively backward, the probability of each node is finally obtained.
[0070] S144, obtaining a target segmentation state of the first paragraph according to the probability of each path in the directed acyclic graph, and obtaining a plurality of segmentation words based on the target segmentation state.
[0071] Optionally, in an embodiment of the present application, based on the probability of each path in the directed acyclic graph, the path with the highest probability can be selected as the target segmentation state of the first paragraph. This target segmentation state is the optimal segmentation state of the first paragraph, representing the optimal combination of vocabulary units after segmentation. After obtaining the target segmentation state, multiple segmentation words can be obtained based on the state. The specific method is to segment the first paragraph into multiple corresponding segmentation words according to the segmentation position in the target segmentation state. These segmentation words are optimized vocabulary units, which are used for subsequent feature extraction and text processing.
[0072] Optionally, in a possible implementation of the present application, a prefix dictionary can be constructed based on a statistical dictionary; the input text is segmented using the prefix dictionary to obtain all possible segmentation positions, and a directed acyclic graph is constructed based on the segmentation positions; and the maximum probability path, i.e., the target segmentation state, is calculated through a dynamic programming algorithm.
[0073] In these optional embodiments, by constructing multiple segmentation states and calculating path probabilities, the optimal segmentation state can be selected to obtain more semantic segmentation words, reducing feature dimensions and redundant information. This helps to improve the accuracy and generalization ability of the classification model, while reducing the complexity of model training. This enables more efficient public opinion monitoring and risk identification, as well as optimized segmentation of text segments, thereby improving the accuracy and efficiency of feature extraction.
[0074] In one embodiment, the above step 200 may specifically perform the following steps:
[0075] S210, for each first word, taking the quotient of the number of the first word and the number of all words in the target sample as the frequency of occurrence of the first word in the target sample;
[0076] S220, obtaining the total number of all reference documents in a preset corpus and the number of first documents containing the first vocabulary;
[0077] S230: Taking the logarithm of the quotient of the total number of documents and the first number of documents to obtain the IDF of the first word.
[0078] Optionally, in the embodiment of the present application, the word frequency (TF) is first calculated: it represents the frequency of occurrence of a word in the text. The formula is:
[0079]
[0080] Among them, n ij is the number of the first vocabulary, ∑ k n kj is the total number of words in the target sample.
[0081] Then calculate the inverse document frequency (IDF): The IDF of a particular word can be obtained by dividing the total number of documents by the number of documents containing the word, and then taking the logarithm of the quotient. If the fewer documents contain a certain word, the larger the IDF, it means that the word has a good ability to distinguish categories. The formula is:
[0082]
[0083] where |D| is the total number of documents in the corpus, |{j:t i ∈d j}| means it contains the word t i The number of files (i.e. n i,j ≠0). If the word is not in the corpus, the denominator will be zero, so 1+|{j:t i ∈d j}|.
[0084] Calculate TF-IDF: Actually it is TF*IDF. The formula is: TF-IDF = TF*IDF
[0085] Alternatively, a high word frequency within a particular document, and a low document frequency of that word in the entire document collection, can produce a high weighted TF-IDF. Therefore, TF-IDF tends to filter out common words and retain important words.
[0086] In these optional embodiments, by calculating the frequency and IDF of each first word in the target sample, its importance and prevalence in the text can be accurately measured, which helps to distinguish keywords from common words. This improves the accuracy of feature expression and the accuracy of model training. This helps to build a more effective classification model and achieve accurate public opinion monitoring and risk identification.
[0087] In one embodiment, the above step 300 may specifically perform the following steps:
[0088] S310 , for each first word, multiply the frequency of the first word in the target sample by the IDF of the first word to obtain a first reference value corresponding to the first word.
[0089] Optionally, in the embodiment of the present application, for each first word, we can multiply its word frequency in the target sample by its corresponding IDF value to obtain a first reference value of the word. This reference value comprehensively considers the frequency of occurrence of the word in the target sample and its rarity in the entire corpus, and is used to measure the importance and feature weight of the word in the text.
[0090] S320 , for each first word, when the first reference value is within a preset reference value range, filtering the first word to obtain a filtered target sample.
[0091] Optionally, in the embodiment of the present application, for each first word, we can set a preset reference value range. If the first reference value corresponding to the word is within the preset range, that is, the reference value condition is met, then the first word will be retained in the target sample. On the contrary, if the reference value exceeds the preset range, the word is considered unimportant and will be filtered out, thereby obtaining a filtered target sample.
[0092] S330, performing principal component analysis and dimensionality reduction processing on the filtered target samples to obtain a first screening vocabulary.
[0093] For the filtered target samples, we can use the principal component analysis (PCA) technique to reduce the dimension. PCA can convert the high-dimensional feature space into a low-dimensional feature space, thereby retaining the most important feature information. Through PCA dimensionality reduction processing, we get the first screening vocabulary, that is, the key vocabulary set after feature selection and dimensionality reduction. Such processing helps to reduce feature dimensions and redundant information, and improve the training efficiency and classification accuracy of the model.
[0094] Optionally, in a possible implementation of the present application, PCA dimensionality reduction can be performed on the result after the initial TF-IDF processing. Because the features are sparse and there is collinearity between the features, by extracting important information from the features, the original dimensional data is projected into a low-dimensional space, the collinearity effect is eliminated, and the data sparsity problem is solved.
[0095] In these optional embodiments, by multiplying the word frequency of each first word by the IDF to obtain the first reference value, the frequency of occurrence of the word in the target sample and its importance in the entire corpus are effectively combined, thereby enhancing the weight of the keyword. Secondly, the words are filtered according to the preset reference value range, and those unimportant words are excluded, thereby reducing noise data and redundant information and improving the robustness of the model. Finally, through the principal component analysis dimensionality reduction processing, the feature dimension is reduced, the main feature information is retained, the model training process is accelerated, and the classification accuracy is further improved.
[0096] In one embodiment, the above step 400 may specifically perform the following steps:
[0097] S410, for each second word, obtaining a plurality of attribution probabilities of the second word belonging to each text type;
[0098] S420, for each second word, when the first attribution probability is greater than a preset probability threshold, attributing the second word to the first text type corresponding to the first attribution probability, where the first attribution probability is any one of a plurality of attribution probabilities;
[0099] S430, when there are multiple first text types, if the proportion of the number of the multiple first text types in the total number of the multiple text types is greater than a preset proportion, then remove the first word;
[0100] S440, in the case where there are multiple first text types, if the proportion of the number of the multiple first text types in the total number of the multiple text types is less than or equal to the preset proportion, the second vocabulary is classified into a target text type, and the target text type is a text type corresponding to the maximum attribution probability among the multiple attribution probabilities.
[0101] Optionally, in the embodiment of the present application, it is necessary to perform probabilistic topic model (Latent Dirichlet Allocation, LDA) processing on the word segmentation results in each complaint scenario. Specifically, the number of topic categories m (i.e. the number of complaint categories) can be first input; then the probability of a word corresponding to complaint category t is calculated, and the formula is: Where N wi represents the number of the i-th word corresponding to complaint category t, and N represents the total number of words corresponding to complaint category t; the probability matrix of "topic-word" is obtained. For each complaint category, the probability of different words is generated φ t [p w1 ,p w2 ...p wm ], where P wi Represents the probability of corresponding to the i-th word in complaint category t.
[0102] It should be noted that if duplicate keywords occur, the following methods can be used to remove them: 1) If the proportion of complaint categories containing the keyword is greater than 50% of the total number of complaint categories, the keyword will be removed; 2) If the proportion of complaint categories containing the keyword is less than or equal to 50% of the total number of complaint categories, the keyword will be assigned to a category with a higher weight to ensure that there is no intersection between the keywords under each complaint category.
[0103] Then, the TF-IDF value and the LDA value can be multiplied, and n (adjustable parameter) features with higher scores are retained as expanded features, that is, the first reference value and the probability of the second word belonging to each text type are multiplied.
[0104] In these optional embodiments, by obtaining the probability of the second vocabulary belonging to each text type, it is helpful to understand the possibility of its category. By setting a probability threshold, the classification results with high probability are screened out to improve accuracy. Excessively concentrated text types are eliminated to prevent overfitting. The second vocabulary is attributed to the text type with the highest probability, and the most representative results are selected, which helps to improve the efficiency and accuracy of the model.
[0105] In one embodiment, the above step 500 may specifically perform the following steps:
[0106] S510: Integrate the first screening vocabulary and the target text type of each second vocabulary to obtain input parameters.
[0107] Optionally, in an embodiment of the present application, the first screening vocabulary and the target text type of each second vocabulary are integrated to obtain input parameters. Specifically, the first screening vocabulary can be used as a feature and the target text type of each second vocabulary can be used as a label to construct a data set. Each sample of the data set contains a first screening vocabulary and its corresponding target text type, and such a data structure can provide suitable input for subsequent classifier training. By integrating this information, features can be associated with labels, providing meaningful training data for the classifier, so that the classification model can learn the relationship between features and target text types.
[0108] S520, inputting the input parameters into a logistic regression classifier for training to obtain a classification model.
[0109] Optionally, in an embodiment of the present application, the integrated input parameters can be input into a logistic regression classifier for training to obtain a desired classification model. Logistic regression is applicable to binary classification problems and can predict the probability that a sample belongs to a certain category. By using the input parameters as a training set, the logistic regression model will learn the mapping relationship between features and target text types based on the training data, thereby obtaining a classification model. After the training is completed, the classification model can be used to classify and predict new samples to help identify the target text types to which different texts belong.
[0110] In one embodiment, after the above step 520, the method further includes:
[0111] S530, analyzing the operation samples generated by different operation agencies according to the classification model to obtain analysis results corresponding to the different operation agencies. The operation samples are texts generated by users for preset business activities, and the analysis results are used to indicate the user's satisfaction with different operation agencies.
[0112] Optionally, in an embodiment of the present application, after obtaining a trained classification model, the model can be used to analyze the operation samples generated by different operating agencies. These operation samples contain texts generated by users for preset business activities, such as user complaints, feedback, or evaluations. By inputting the characteristics of the samples into the classification model, we can predict the user's satisfaction with different operating agencies, that is, predict the user's possible target text type. Such analysis results can help operating agencies understand user feedback and satisfaction, so as to make targeted improvements and optimizations to improve service quality and user satisfaction.
[0113] Optionally, in a possible implementation of the present application, the features after PCA dimensionality reduction (i.e., the first screened vocabulary) are integrated with the target text type of each second vocabulary as a model input wide table. And input the logistic regression classifier for training, and output the classification result. The classification results are then matched with the corresponding marketing activities or operator services, and the content that requires public opinion monitoring is obtained through user distribution. For example: A province conducts public opinion monitoring. In a certain stage, complaints about business hall A account for 10% (the historical level is 2%) in channel complaints, complaints about business hall B account for 5% (the historical level is 1%), and complaints about business hall C account for 8% (the historical level is 7%). Business halls A and B are judged to be abnormal concentration points and need to be focused on. C is the focus of attention.
[0114] Optionally, as shown in the figure, in a complete implementation of the present application, S1 performs manual labeling on the samples; S2 performs text cleaning on the training samples; S3 performs word segmentation on the cleaned data; S4 performs synonym replacement on the results after word segmentation; S5 processes the results after synonym replacement; S6 extracts the subject keywords from the word segmentation results in each complaint scenario and filters the repeated keywords; S7 performs product operation on values and derives new features; S8 performs dimensionality reduction on the processed results; S9 integrates the dimensionality reduction features with the expanded features in S6; S10 performs logistic regression classifier training; S11 matches the classification results to the corresponding marketing activities or operator services, and obtains the content that needs public opinion monitoring through user distribution. The accuracy of public opinion monitoring is improved by fully exploring the subject relationship between text words and through supervised feature selection and feature derivation.
[0115] Optionally, in an embodiment of the present application, TF-IDF and LDA fusion algorithms are used for feature selection and feature derivation, the relationship between words and different complaint scenarios is considered, and a logistic regression algorithm is used to predict the fusion results, thereby improving the robustness of the model; the results after word segmentation are replaced with synonyms to increase the frequency of some words and the importance of keywords; PCA dimensionality reduction is performed on some dimensions after TF-IDF processing to solve the collinearity problem between features and improve the stability of the model; compared with the classification method based on text similarity matching, the classification algorithm based on machine learning has a fast prediction speed, does not require a classification template library, has a strong model generalization ability, and can be applied to multiple business scenarios; according to the classification results, the corresponding specific marketing activities or operator services are matched, and the potential public opinion content is judged by analyzing the distribution of user complaint categories to facilitate timely management and control.
[0116] Optionally, in an embodiment of the present application, the word segmentation results in each complaint scenario are processed by LDA topic keywords (single topic), the weight of the words under a specific topic belonging to the complaint type is calculated, and the TF-IDF value and the LDA value are multiplied, and the features with higher scores (adjustable parameters) are retained to perform supervised feature selection and feature derivation; the results after word segmentation are processed by synonym replacement. Since there may be similar meanings between words, words with similar meanings are replaced to increase the frequency of some words and improve the importance of keywords; according to the classification results, the corresponding specific marketing activities or operator services are matched, and through the analysis of user distribution (that is, the number of users participating in marketing activities or handling operator services), abnormal concentration points (that is, content that requires public opinion monitoring) are found, and then manual intervention is performed for management and control.
[0117] Figure 3 A structural schematic diagram of a classification model training device provided in another embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0118] Reference Figure 3 , the classification model training device may include:
[0119] A first acquisition module 301 is used to acquire target samples corresponding to a plurality of preset text types;
[0120] A second acquisition module 302 is used to acquire, for each target sample, the frequency of occurrence of the first word in the target sample and the inverse document frequency (IDF) of the first word, where the IDF is used to represent the rarity of the word in a preset corpus;
[0121] A filtering module 303 is used to filter all words for each first word according to the frequency of occurrence of the first word in all target samples and the IDF of the first word to obtain a first screening word;
[0122] A third acquisition module 304 is used to acquire, for each second word in the first screening vocabulary, the probability that the second word belongs to each text type, and determine the target text type to which the second word belongs based on the probability;
[0123] The training module 305 is used to train the basic model based on the first screening vocabulary and the target text type of each second vocabulary to obtain a classification model.
[0124] In one embodiment, the first acquisition module 301 may include:
[0125] A first acquisition submodule is used to acquire an initial sample;
[0126] The first classification submodule is used to classify the initial samples to obtain text data of different text types;
[0127] The first cleaning submodule is used to perform text cleaning on the text data to remove noise data and duplicate data in the text data to obtain a processed sample;
[0128] The first segmentation module is used to perform lexical segmentation on all text segments in the processing sample based on a preset dictionary to obtain multiple segmented words;
[0129] The first replacement submodule is used to replace segmented words with the same meaning among multiple segmented words with a target word to obtain a target sample, wherein the meaning of the target word is the same as the meaning of the replaced segmented word.
[0130] In one embodiment, the first cutting submodule may include:
[0131] The first segmentation unit is used for performing lexical segmentation processing on each first segment in the text segment according to a preset dictionary to obtain multiple segmentation states of the first segment, wherein the segmentation state includes segmentation positions between two words in the first segment;
[0132] A first construction unit is used to construct a directed acyclic graph corresponding to the first paragraph based on the multiple segmentation states, wherein the nodes in the directed acyclic graph indicate the positions of the second vocabulary in the first paragraph under different segmentation states, and two second vocabulary having a connection relationship in the directed acyclic graph are connected through a directed edge;
[0133] A first calculation unit, used for calculating the probability of each path in the directed acyclic graph based on a dynamic programming algorithm;
[0134] The first determination unit is used to obtain a target segmentation state of the first paragraph according to the probability of each path in the directed acyclic graph, and obtain a plurality of segmentation words based on the target segmentation state.
[0135] In one embodiment, the second acquisition module 302 may include:
[0136] A first determination submodule is used for, for each first word, taking the quotient of the number of the first word and the number of all words in the target sample as the frequency of occurrence of the first word in the target sample;
[0137] A second acquisition submodule is used to acquire the total number of documents of all reference documents in a preset corpus and the number of first documents containing the first vocabulary;
[0138] The second determination submodule is used to take the logarithm of the quotient of the total number of documents and the first number of documents to obtain the IDF of the first word.
[0139] In one embodiment, the filtering module 303 may include:
[0140] A third determination submodule is used to, for each first word, multiply the frequency of the first word in the target sample by the IDF of the first word to obtain a first reference value corresponding to the first word;
[0141] A first filtering submodule, for filtering each first word, when the first reference value is within a preset reference value range, the first word to obtain a filtered target sample;
[0142] The first dimensionality reduction submodule is used to perform principal component analysis and dimensionality reduction processing on the filtered target samples to obtain a first screening vocabulary.
[0143] In one embodiment, the third acquisition module 304 may include:
[0144] A third acquisition submodule is used to acquire, for each second word, a plurality of attribution probabilities of the second word belonging to each text type;
[0145] A first attribution submodule is used to, for each second word, when the first attribution probability is greater than a preset probability threshold, attribute the second word to a first text type corresponding to the first attribution probability, where the first attribution probability is any one of a plurality of attribution probabilities;
[0146] A fourth determination submodule is used to remove the first vocabulary if the number of the plurality of first text types accounts for more than a preset proportion in the total number of the plurality of text types when there are a plurality of first text types;
[0147] The fifth determination submodule is used to, when there are multiple first text types, if the proportion of the number of the multiple first text types in the total number of the multiple text types is less than or equal to a preset proportion, then classify the second vocabulary into a target text type, and the target text type is the text type corresponding to the maximum attribution probability among the multiple attribution probabilities.
[0148] In one embodiment, the training module 305 may include:
[0149] A first integration submodule is used to integrate the first screening vocabulary and the target text type of each second vocabulary to obtain an input parameter;
[0150] The first training submodule is used to input the input parameters into the logistic regression classifier for training to obtain a classification model.
[0151] In one embodiment, the classification model training device may further include:
[0152] The analysis module is used to analyze the operation samples generated by different operation agencies according to the classification model to obtain the analysis results corresponding to the different operation agencies. The operation samples are the texts generated by users for preset business activities. The analysis results are used to indicate the user's satisfaction with different operation agencies.
[0153] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application, and are devices corresponding to the above-mentioned battery thermal runaway warning method. All implementation methods in the above-mentioned method embodiment are applicable to the embodiments of the device. Its specific functions and technical effects can be found in the method embodiment part, which will not be repeated here.
[0154] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0155] Figure 4 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application is shown.
[0156] The device may include a processor 401 and a memory 402 storing program instructions.
[0157] When the processor 401 executes the program, the steps in any of the above method embodiments are implemented.
[0158] Exemplarily, the program may be divided into one or more modules / units, one or more modules / units are stored in the memory 402, and executed by the processor 401 to complete the present application. One or more modules / units may be a series of program instruction segments capable of completing a specific function, and the instruction segments are used to describe the execution process of the program in the device.
[0159] Specifically, the processor 401 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0160] Memory 402 may include a large capacity memory for data or instructions. By way of example and not limitation, memory 402 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, memory 402 may include a removable or non-removable (or fixed) medium. In appropriate cases, memory 402 may be inside or outside of an integrated gateway disaster recovery device. In a specific embodiment, memory 402 is a non-volatile solid-state memory.
[0161] The memory may include read-only memory (ROM), random access memory (RAM), magnetic disk storage media devices, optical storage media devices, flash memory devices, electrical, optical or other physical / tangible memory storage devices. Thus, typically, the memory includes one or more tangible (non-transitory) readable storage media (e.g., memory devices) encoded with software including computer executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to an aspect of the present disclosure.
[0162] The processor 401 implements any one of the methods in the above embodiments by reading and executing program instructions stored in the memory 402 .
[0163] In one example, the electronic device may further include a communication interface 403 and a bus 410. The processor 401, the memory 402, and the communication interface 403 are connected via the bus 410 and communicate with each other.
[0164] The communication interface 403 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0165] Bus 410 includes hardware, software or both, and the parts of online data flow billing equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front-side bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 410 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the present application considers any suitable bus or interconnection.
[0166] In addition, in combination with the method in the above embodiment, the embodiment of the present application can provide a storage medium for implementation. The storage medium stores program instructions; when the program instructions are executed by a processor, any one of the methods in the above embodiment is implemented.
[0167] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface and the processor are coupled, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0168] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0169] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the above-mentioned method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0170] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.
[0171] The functional modules shown in the above block diagram can be implemented as hardware, software, firmware or their combination. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), suitable firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. Programs or code segments can be stored in machine-readable media, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable media" can include any medium that can store or transmit information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. Code segments can be downloaded via computer grids such as the Internet, intranets, etc.
[0172] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.
[0173] Aspects of the present disclosure are described above with reference to the flowchart and / or block diagram of the method, device (system) and program product according to the embodiment of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor or a field programmable logic circuit. It can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0174] The above are only specific implementation methods of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.
Claims
1. A text classification model training method, characterized in that: The method comprises: Obtain target samples corresponding to multiple preset text types; For each first word in the target sample, obtaining the frequency of occurrence of the first word in the target sample and an inverse document frequency (IDF) of the first word, wherein the IDF is used to characterize the rarity of the word in a preset corpus; For each first word, filtering all words according to the frequency of occurrence of the first word in all target samples and the IDF of the first word to obtain a first screening word; For each second word in the first screening vocabulary, obtaining a probability that the second word belongs to each text type, and determining a target text type to which the second word belongs based on the probability; Based on the first screening vocabulary and the target text type of each second vocabulary, the basic model is trained to obtain a classification model.
2. The method according to claim 1, characterized in that The step of obtaining target samples corresponding to a plurality of preset text types includes: Obtaining an initial sample; Classifying the initial samples to obtain text data of different text types; Performing text cleaning on the text data to remove noise data and duplicate data in the text data to obtain a processed sample; Based on a preset dictionary, all text segments in the processing sample are subjected to lexical segmentation processing to obtain a plurality of segmented words; The segmented words with the same meaning among the multiple segmented words are replaced with target words to obtain the target sample, wherein the meaning of the target word is the same as the meaning of the replaced segmented words.
3. The method according to claim 2, characterized in that Based on the preset dictionary, all text segments in the processing sample are subjected to lexical segmentation processing to obtain multiple segmented words, including: For each first segment in the text segment, performing a lexical segmentation process on the first segment according to the preset dictionary to obtain a plurality of segmentation states of the first segment, wherein the segmentation state includes a segmentation position between two words in the first segment; constructing a directed acyclic graph corresponding to the first paragraph based on the multiple segmentation states, wherein nodes in the directed acyclic graph indicate positions of second words in the first paragraph under different segmentation states, and two second words having a connection relationship in the directed acyclic graph are connected by a directed edge; Based on a dynamic programming algorithm, calculating the probability of each path in the directed acyclic graph; According to the probability of each path in the directed acyclic graph, a target segmentation state of the first paragraph is obtained, and based on the target segmentation state, the plurality of segmentation words are obtained.
4. The method according to claim 1, characterized in that: For each first word in the target sample, obtaining the frequency of occurrence of the first word in the target sample and the inverse document frequency (IDF) of the first word includes: For each of the first words, taking the quotient of the number of the first words and the number of all words in the target sample as the frequency of occurrence of the first word in the target sample; Obtaining the total number of all reference documents in the preset corpus and the number of first documents containing the first vocabulary; The IDF of the first word is obtained by taking the logarithm of the quotient of the total number of documents and the first number of documents.
5. The method according to claim 1, characterized in that For each first word, according to the frequency of occurrence of the first word in all target samples and the IDF of the first word, all words are filtered to obtain a first screening word, including: For each of the first words, multiplying the frequency of the first word in the target sample by the IDF of the first word to obtain a first reference value corresponding to the first word; For each of the first words, when the first reference value is within a preset reference value range, filtering the first words to obtain a filtered target sample; The filtered target samples are subjected to principal component analysis and dimensionality reduction processing to obtain the first screening vocabulary.
6. The method according to claim 1, characterized in that The step of obtaining, for each second word in the first screening vocabulary, a probability that the second word belongs to each text type, and determining a target text type to which the second word belongs based on the probability, comprises: For each of the second words, obtaining a plurality of attribution probabilities of the second word belonging to each text type; For each of the second words, when the first attribution probability is greater than a preset probability threshold, attributing the second word to the first text type corresponding to the first attribution probability, where the first attribution probability is any one of the multiple attribution probabilities; In the case where there are multiple first text types, if the proportion of the number of the multiple first text types in the total number of the multiple text types is greater than a preset proportion, the first vocabulary is eliminated; In the case where there are multiple first text types, if the proportion of the number of the multiple first text types in the total number of the multiple text types is less than or equal to the preset proportion, the second vocabulary is classified into a target text type, and the target text type is the text type corresponding to the maximum attribution probability among the multiple attribution probabilities.
7. The method according to claim 1, characterized in that The step of training a basic model based on the first screening vocabulary and the target text type of each second vocabulary to obtain a classification model includes: Integrate the first screening vocabulary and the target text type of each second vocabulary to obtain input parameters; Inputting the input parameters into a logistic regression classifier for training to obtain the classification model; After inputting the input parameters into the logistic regression classifier for training to obtain the classification model, the method further includes: According to the classification model, the operation samples generated by different operation agencies are analyzed to obtain analysis results corresponding to the different operation agencies. The operation samples are texts generated by users for preset business activities, and the analysis results are used to indicate the user's satisfaction with different operation agencies.
8. A classification model training device, characterized in that: The device comprises: A first acquisition module is used to acquire target samples corresponding to a plurality of preset text types; A second acquisition module is used to acquire, for each first word in the target sample, the frequency of occurrence of the first word in the target sample and an inverse document frequency (IDF) of the first word, wherein the IDF is used to characterize the rarity of the word in a preset corpus; A filtering module, configured to filter all words for each first word according to the frequency of occurrence of the first word in all target samples and the IDF of the first word to obtain a first screening word; A third acquisition module is used to acquire, for each second word in the first screening vocabulary, a probability that the second word belongs to each text type, and determine a target text type to which the second word belongs based on the probability; The training module is used to train the basic model based on the first screening vocabulary and the target text type of each second vocabulary to obtain a classification model.
9. An electronic device, characterized in that: The device comprises: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, it implements the classification model training method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by the processor, the classification model training method according to any one of claims 1 to 7 is implemented.
11. A computer program product, characterized in that When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the classification model training method as described in any one of claims 1-7.
Citation Information
Cited By
Main body name classification method, main body name model training method, computer equipment and storage medium
CN119128161A
