Method and device for generating feature vector and performing text classification based on feature vector

By generating a feature vector matrix and performing feature selection, combined with all features of text data, the problem of insufficient feature selection in the existing technology is solved, the accuracy and user experience of text classification are improved, and accurate classification of different business scenarios is achieved.

CN110119445BActive Publication Date: 2024-09-20BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201810034609.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2018-01-15
Publication Date
2024-09-20
Estimated Expiration
2038-01-15

AI Technical Summary

Technical Problem

In the existing technology, due to insufficient data coverage in text classification, feature selection is insufficient, resulting in unsatisfactory classification performance of the model in different business scenarios, and important features are ignored, which in turn affects the overall performance of the system.

Method used

By obtaining the feature weight matrix and word vector matrix of text data, combined with feature selection methods such as chi-square test, information gain, etc., a feature vector matrix is ​​generated, and the contribution of each feature to the business scenario category is obtained through convolution operation, and then the Feature selection and model training realize the utilization of all features.

Benefits of technology

It improves the accuracy of text classification based on business scenarios, ensures accurate classification of different business scenarios, improves user experience, saves time and energy, and simplifies post-maintenance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110119445B
    Figure CN110119445B
Patent Text Reader

Abstract

The present invention discloses a method and device for generating feature vectors and performing text classification based on feature vectors, and relates to the field of computer technology. A specific implementation of the method for generating feature vectors includes: obtaining a feature weight matrix and a word vector matrix of text data, wherein the feature weight matrix is ​​composed of the associated weights of the text data and the business scenario category; and generating a feature vector matrix by operating the feature weight matrix and the word vector matrix, wherein the feature vector matrix is ​​composed of feature vectors. This implementation can combine all features of the text data to realize text classification based on business scenarios, improve the accuracy of text classification based on different business scenarios, and facilitate improving user experience for different business scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for generating feature vectors and performing text classification based on the feature vectors. Background Art

[0002] With the advent of the big data era, big data analysis has also emerged. By analyzing the huge amount of data in its own data warehouse, the network platform can obtain useful resources to better guide website construction, enterprise operations, etc.

[0003] Taking the rapidly developing e-commerce as an example, with the rapid popularization of the Internet, online shopping has occupied a high proportion of the shopping life of the vast number of consumer users. How to better improve the user's consumption experience and expand the e-commerce market by analyzing the user's consumption records, comment information and other data has become the main battlefield for a large number of e-commerce companies to compete. Taking the analysis of user comment information as an example, based on the user's comment information and related news and other content, the user's comment information can be classified according to different business scenarios (for example: account security, false transactions, malicious orders, marketing risk control, etc.), and then the best-selling and slow-selling products can be determined, and the unfair competition of merchants or the deception of users can be eliminated to strictly control the merchants. Among them, the classification of user comment information is essentially the classification of text.

[0004] At present, most of the commonly used text classification methods based on business scenarios are based on existing machine learning technologies or various statistical learning methods. They are trained on existing annotated data and then predict online comment data. The implementation process of existing machine learning technologies or statistical learning methods is generally as follows: first, the text is segmented; then the relevance of each word to different business scenarios is calculated; then, the main features are selected based on the relevance, generally selecting features that meet the predetermined relevance threshold or a predetermined number of features that are ranked from high to low in relevance as the main features; finally, a text classification model is obtained by training the main features to classify and predict online text data.

[0005] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0006] In general, feature selection selects some of the top-ranked main features as the input of the training model, and then trains the model to classify and predict text data. In this case, because the data volume is not fully covered, the main features may only be suitable for some categories, resulting in underfitting of other categories, thereby ignoring some other features and losing relatively important features, resulting in unsatisfactory performance after the system is launched. Summary of the invention

[0007] In view of this, an embodiment of the present invention provides a method and device for generating feature vectors and performing text classification based on feature vectors, which can combine all features of text data to realize text classification based on business scenarios, improve the accuracy of text classification based on different business scenarios, and facilitate improving user experience for different business scenarios.

[0008] To achieve the above objective, according to one aspect of an embodiment of the present invention, a method for generating a feature vector is provided.

[0009] A method for generating a feature vector comprises: obtaining a feature weight matrix and a word vector matrix of text data, wherein the feature weight matrix is ​​composed of association weights between the text data and business scenario categories; and generating a feature vector matrix by operating the feature weight matrix and the word vector matrix, wherein the feature vector matrix is ​​composed of feature vectors.

[0010] Optionally, the step of obtaining a feature weight matrix of text data includes: performing a word segmentation operation on the text data; and for each word obtained by the word segmentation operation, calculating an association weight between each word and a business scenario category to obtain a feature weight matrix of the text data.

[0011] Optionally, the association weight between each word and the business scenario category is calculated using a feature selection method, and the feature selection method includes one of the following: chi-square test, information gain, correlation coefficient, Gini coefficient, data modeling, L1 norm regularization, and decision tree.

[0012] Optionally, the step of obtaining a word vector matrix of text data includes: performing a word segmentation operation on the text data; and obtaining a word vector matrix of the text data by calculating a word vector of each word obtained by the word segmentation operation.

[0013] Optionally, the operation is a convolution operation.

[0014] According to another aspect of an embodiment of the present invention, a method for text classification based on a feature vector is provided.

[0015] A method for text classification based on feature vectors, comprising: obtaining a feature weight matrix and a word vector matrix of text data, wherein the feature weight matrix is ​​composed of association weights between the text data and business scenario categories; generating a feature vector matrix by operating the feature weight matrix and the word vector matrix, wherein the feature vector matrix is ​​composed of feature vectors; training the feature vectors to obtain a text data classification model; and classifying the text data using the text data classification model.

[0016] Optionally, the step of training the feature vector to obtain a text data classification model includes: inputting the feature vector into the model to be trained to obtain an output value; comparing the output value with the actual value and calculating the error sum; adjusting the parameters of the model to be trained according to the error sum; repeating the above three steps until the error sum is less than a preset error threshold, and using the model to be trained with the error sum less than the preset error threshold as the text data classification model.

[0017] According to yet another aspect of an embodiment of the present invention, a device for generating a feature vector is provided.

[0018] A device for generating a feature vector comprises: a data acquisition module for acquiring a feature weight matrix and a word vector matrix of text data, wherein the feature weight matrix is ​​composed of association weights between the text data and business scenario categories; and a feature operation module for generating a feature vector matrix by operating the feature weight matrix and the word vector matrix, wherein the feature vector matrix is ​​composed of feature vectors.

[0019] Optionally, the data acquisition module is further used to: perform word segmentation operation on the text data; for each word obtained by the word segmentation operation, calculate the association weight between each word and the business scenario category to obtain a feature weight matrix of the text data.

[0020] Optionally, the data acquisition module calculates the association weight between each word and the business scenario category using a feature selection method, and the feature selection method includes one of the following: chi-square test, information gain, correlation coefficient, Gini coefficient and data modeling, L1 norm regularization, and decision tree.

[0021] Optionally, the data acquisition module is further used to: perform word segmentation operation on the text data; and obtain a word vector matrix of the text data by calculating the word vector of each word obtained by the word segmentation operation.

[0022] Optionally, the operation is a convolution operation.

[0023] According to yet another aspect of an embodiment of the present invention, a device for performing text classification based on a feature vector is provided.

[0024] A device for text classification based on feature vectors, comprising: a data acquisition module, used to acquire a feature weight matrix and a word vector matrix of text data, wherein the feature weight matrix is ​​composed of association weights between the text data and business scenario categories; a feature operation module, used to generate a feature vector matrix by operating the feature weight matrix and the word vector matrix, wherein the feature vector matrix is ​​composed of feature vectors; a model training module, used to train the feature vectors to obtain a text data classification model; and a text classification module, used to classify text data using the text data classification model.

[0025] Optionally, the model training module is also used to: input the feature vector into the model to be trained to obtain an output value; compare the output value with the actual value and calculate the error sum; adjust the parameters of the model to be trained according to the error sum; repeat the above three steps until the error sum is less than a preset error threshold, and use the model to be trained with the error sum less than the preset error threshold as a text data classification model.

[0026] According to yet another aspect of the embodiments of the present invention, an electronic device is provided.

[0027] An electronic device comprises: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method for generating feature vectors and / or performing text classification based on feature vectors provided in an embodiment of the present invention.

[0028] According to yet another aspect of an embodiment of the present invention, a computer readable medium is provided.

[0029] A computer-readable medium stores a computer program, which, when executed by a processor, implements a method for generating a feature vector and / or performing text classification based on a feature vector provided in an embodiment of the present invention.

[0030] An embodiment of the above invention has the following advantages or beneficial effects: by obtaining the feature weight matrix and word vector matrix of text data, the correlation between all features of text data and business scenario categories, as well as the vectors corresponding to all features of text data can be obtained; then, the feature weight matrix and word vector matrix are operated to generate a new feature vector matrix, and the contribution of each feature to each business scenario category can be obtained, so that feature selection can be better performed, and the problem of feature loss caused by insufficient data coverage can be overcome; by training the feature vector to obtain a text data classification model and using the text data classification model to classify text data, it is possible to quickly classify text data, save a lot of time and energy, and facilitate later maintenance. According to the technical solution of the present invention, it is possible to combine all features of text data to realize text classification based on business scenarios, improve the accuracy of text classification based on different business scenarios, and facilitate improving user experience for different business scenarios.

[0031] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0033] Figure 1 is a schematic diagram of the main process of a method for generating a feature vector according to an embodiment of the present invention;

[0034] Figure 2 is a schematic diagram of the main process of a method for text classification based on feature vectors according to an embodiment of the present invention;

[0035] Figure 3 is a schematic diagram of main modules of a device for generating a feature vector according to an embodiment of the present invention;

[0036] Figure 4 is a schematic diagram of main modules of a device for text classification based on feature vectors according to an embodiment of the present invention;

[0037] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0038] Figure 6 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0039] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0040] Figure 1 FIG. 1 is a schematic diagram of the main process of the method for generating a feature vector according to an embodiment of the present invention. Figure 1 As shown, the method for generating a feature vector of the present invention mainly includes the following steps S101 and S102.

[0041] Step S101: Obtain a feature weight matrix and a word vector matrix of text data, wherein the feature weight matrix is ​​composed of association weights between text data and business scenario categories.

[0042] Wherein, step S101 can be performed according to the following steps when it is specifically performed:

[0043] Step S1011: performing word segmentation operation on text data;

[0044] Step S1012: for each word obtained by the word segmentation operation, the association weight between each word and the business scenario category is calculated to obtain a feature weight matrix of the text data;

[0045] Step S1013: For each word obtained by the word segmentation operation, a word vector matrix of the text data is obtained by calculating the word vector of each word.

[0046] Among them, the execution order of step S1012 and step S1013 can be set as needed, and can be executed simultaneously, or step S1012 can be executed first and then step S1013, or step S1013 can be executed first and then step S1012.

[0047] For the data stored in the data warehouse, text data can be obtained through data parsing.

[0048] When the text data is segmented in step S1011, non-essential contents such as stop words, conjunctions, and prepositions can also be removed to reduce the workload of subsequent generation of feature weight matrices and word vector matrices and improve processing efficiency. Commonly used Chinese word segmentation tools such as Jieba Chinese word segmentation, Chinese lexical analysis system ICTCLAS (abbreviation of Institute of Computing Technology, Chinese Lexical Analysis System), simple Chinese word segmentation system SCWS (abbreviation of Simple Chinese Words Segmentation), etc. can all realize the word segmentation function of the present invention.

[0049] It should be noted that when performing word segmentation on text data, the result of the word segmentation operation includes not only specific words, but also corresponding symbols, such as punctuation marks, emoticons, etc., because punctuation marks can express the intensity of emotions. Similarly, emoticons can also intuitively express the user's emotions. In other words, the words obtained after the word segmentation operation can be specific words or symbols. For each word obtained after the word segmentation operation, it is necessary to generate a feature weight matrix and a word vector matrix so that the generated feature vector matrix contains all the features, so as to better realize text classification based on business scenarios, improve the accuracy of text classification based on different business scenarios, and improve user experience for different business scenarios. Among them, the business scenario refers to a process or sub-process of a certain business, including goals, participants, operation procedures, and information transmission processes. Business scenarios are mainly classified according to business needs or business goals. Taking the e-commerce industry as an example, business scenario categories include malicious orders, false transactions, account security, marketing risk control, etc.

[0050] After the word segmentation operation is completed, the feature weight matrix and word vector matrix of the text data will be generated according to step S1012 and step S1013.

[0051] When generating a feature weight matrix for text data, the feature selection method can be used to calculate the association weight between each word and the business scenario category obtained after word segmentation, and then the association weight between each word and different business scenario categories is used as a row vector, and all row vectors form the feature weight matrix of the text data. Feature selection methods may include, for example: chi-square test, information gain, correlation coefficient, Gini coefficient, data modeling, L1 norm regularization, decision tree, etc., which are used to calculate the degree of linear correlation between variables. In specific implementation, any of the above feature selection methods can be used.

[0052] In an embodiment of the present invention, the feature selection method is, for example, a chi-square test. The chi-square test is a widely used hypothesis testing method, which is to calculate the degree of deviation between the actual observed value and the theoretical inference value of the statistical sample. The degree of deviation between the actual observed value and the theoretical inference value determines the size of the chi-square value. The larger the chi-square value, the less consistent it is; the smaller the chi-square value, the smaller the deviation, and the closer it is to consistent. If the two values ​​are completely equal, the chi-square value is 0, indicating that the theoretical value is completely consistent.

[0053] When using the chi-square test method to calculate the association weight between each word and a business scenario category, assuming that a certain word is not related to a certain business scenario category, then the larger the value of irrelevance, the greater the association weight between this word and this business scenario. Based on this, the association weight between this word and different business scenario categories can be obtained, that is, a row vector of the feature weight matrix of the text data can be obtained. For each word obtained after the word segmentation operation, this method is used to calculate its association weight with the business scenario category, and finally, the feature weight matrix of the text data can be obtained.

[0054] Similarly, when generating a word vector matrix for text data, you can first generate a word vector for each word, then use each word vector as a row vector of the matrix, and then use these word vectors to form a word vector matrix for the text data. When generating a word vector for each word, you can use One-Hot Encode (also called dumb encoding) to generate it, or you can use a ready-made word vector generation tool (such as word2vec) to train the word to generate a word vector. Among them, when generating a word vector using One-Hot Encode, first count the number of all words in the text data; then, create an index for these words and sort them by index; finally, generate a vector for each word with all positions 0 except the position itself being 1.

[0055] Based on the above content, the feature weight matrix and word vector matrix of text data can be generated.

[0056] Step S102: generating a feature vector matrix by operating the feature weight matrix and the word vector matrix, wherein the feature vector matrix is ​​composed of feature vectors.

[0057] According to the feature weight matrix, we can get the correlation between all the features of the text data and the business scenario categories; according to the word vector matrix, we can get the vectors corresponding to all the features of the text data. By calculating the feature weight matrix and the word vector matrix, we can get the contribution of each feature to each business scenario category, so as to better perform feature selection.

[0058] The operation of the two matrices is a convolution operation. According to the feature weight matrix of each business scenario corresponding to the word obtained after word segmentation and the generated word vector matrix, each word vector is convolved in a one-to-one correspondence method to generate a new feature vector matrix. When performing the convolution operation, the feature weight matrix can be used as a map to gradually convolve the tensor composed of word vectors to generate the final feature vector matrix.

[0059] According to an embodiment of the present invention, when performing convolution operations on the feature weight matrix and the word vector matrix, the two-dimensional convolution in the convolutional neural network CNN (Convolutional Neural Network) can be used (the word vectors are spliced ​​side by side), or a sequence similar to the long short-term memory network LSTM (Long Short-Term Memory) can be used to perform a one-dimensional convolution (all the word vectors are spliced ​​into one row).

[0060] According to step S101 and step S102, all features of the text data can be combined to implement text classification based on business scenarios, thereby improving the accuracy of text classification based on different business scenarios and facilitating improving user experience for different business scenarios.

[0061] After the feature vector is generated according to the method described above, the text data can be classified by performing model training on the feature vector to obtain a text classification model.

[0062] The embodiment of the present invention also provides a method for text classification based on feature vectors. Figure 2 It is a schematic diagram of the main process of the method for text classification based on feature vectors according to an embodiment of the present invention.

[0063] like Figure 2 As shown, the method for text classification based on feature vectors according to the embodiment of the present invention further includes steps S103 and S104 after generating feature vectors according to steps S101 and S102.

[0064] Step S103: training the feature vector to obtain a text data classification model.

[0065] According to an embodiment of the present invention, step S103 may be specifically performed according to the following steps:

[0066] Step S1031: input the feature vector into the model to be trained to obtain an output value;

[0067] Step S1032: Compare the output value with the actual value and calculate the error sum;

[0068] Step S1033: adjusting the parameters of the model to be trained according to the error;

[0069] Step S1034: Repeat the above three steps until the error sum is less than a preset error threshold, and use the to-be-trained model whose error sum is less than the preset error threshold as a text data classification model.

[0070] The implementation process of step S103 is described below in conjunction with a specific embodiment.

[0071] First, select the model to be trained according to the needs of the application scenario. Commonly used machine learning models include: Naive Bayes model, Logistic Regression model, Linear Regression model, KNN (k-NearestNeighbor) model, Decision Tree model, Support Vector Machine (SVM) model, K-Means clustering model, etc. By analyzing the applicable scenarios and advantages and disadvantages of each model, the required model to be trained can be screened out. In an embodiment of the present invention, the selected model to be trained is a support vector machine model. The support vector machine model has high accuracy, provides a good theoretical guarantee to avoid overfitting, and even if the data is linearly inseparable in the original feature space, as long as a suitable kernel function is given, it can run well, which is particularly popular in text classification problems with ultra-high dimensions. The model can solve high-dimensional problems, that is, large feature spaces; can handle the interaction of nonlinear features; does not need to rely on the entire data; can improve generalization ability, and so on.

[0072] Then, the feature vector obtained in step S102 is continuously input into the model to be trained, and the output value of the model is obtained. After that, the output value corresponding to each word is compared with its actual value (i.e., the category label corresponding to the word) to obtain the error, and the error sum between the output value corresponding to all words and the actual value is obtained. Finally, it is determined whether the error sum is less than the predetermined error threshold. If the error sum is less than the error threshold, the model to be trained that satisfies the error sum less than the preset error threshold is used as the text data classification model; otherwise, the parameters of the model to be trained are automatically adjusted according to the error sum, and the steps described above are repeated, the feature vector obtained in step S102 is continuously input into the adjusted model to be trained, the output value of the model is obtained, and then the error sum is calculated by comparing with the actual value until the error sum obtained is less than the predetermined error threshold, and the model to be trained that satisfies the error sum less than the preset error threshold is used as the text data classification model.

[0073] According to the machine learning process introduced above, after training the feature vector to obtain the text data classification model, some parameters in the model can also be manually adjusted to achieve parameter optimization. In the present invention, the parameters that cannot be automatically adjusted through training and need to be manually set are defined as hyperparameters. The process of adjusting the hyperparameters is as follows: first, take out some data from the text data of the training model as a verification data set for parameter optimization; second, input the text data in the verification data set into the text data classification model obtained before, and use methods such as style search with input suggestion prompts to adjust the hyperparameters to obtain a better text data classification model.

[0074] Finally, the obtained text data classification model can be saved for use in text data classification.

[0075] Step S104: using the text data classification model to classify the text data.

[0076] According to step S101 to step S104, feature vectors are generated by operating the feature weight matrix and word vector matrix of the text data, and the feature vectors are trained to obtain a text classification model, and then the text data is classified. This can combine all the features of the text data to achieve text classification based on business scenarios, thereby improving the accuracy of text classification based on different business scenarios and facilitating improving user experience for different business scenarios.

[0077] Figure 3 Schematic diagram of main modules of a device for generating a feature vector according to an embodiment of the present invention. Figure 3 As shown, the device 300 for generating a feature vector according to an embodiment of the present invention mainly includes a data acquisition module 301 and a feature operation module 302 .

[0078] The data acquisition module 301 is used to acquire a feature weight matrix and a word vector matrix of text data, wherein the feature weight matrix is ​​composed of association weights between text data and business scenario categories;

[0079] The feature operation module 302 is used to generate a feature vector matrix by operating the feature weight matrix and the word vector matrix. The feature vector matrix is ​​composed of feature vectors.

[0080] According to an embodiment of the present invention, the data acquisition module 301 may also be used for:

[0081] Perform word segmentation on text data;

[0082] For each word obtained by the word segmentation operation, the association weight between each word and the business scenario category is calculated to obtain the feature weight matrix of the text data.

[0083] Specifically, the data acquisition module 301 calculates the association weight between each word and the business scenario category using a feature selection method, wherein the feature selection method may include one of the following: chi-square test, information gain, correlation coefficient, Gini coefficient, data modeling, L1 norm regularization, and decision tree.

[0084] According to an embodiment of the present invention, the data acquisition module 301 may also be used for:

[0085] Perform word segmentation on text data;

[0086] For each word obtained by the word segmentation operation, the word vector of each word is calculated to obtain the word vector matrix of the text data.

[0087] Furthermore, the operation between the feature weight matrix and the word vector matrix is, for example, a convolution operation.

[0088] Figure 4 Schematic diagram of the main modules of the apparatus for text classification based on feature vectors according to an embodiment of the present invention. Figure 4 As shown, the apparatus 400 for text classification based on feature vectors according to an embodiment of the present invention mainly includes a data acquisition module 301 , a feature operation module 302 , a model training module 303 and a text classification module 304 .

[0089] The data acquisition module 301 is used to acquire a feature weight matrix and a word vector matrix of text data, wherein the feature weight matrix is ​​composed of association weights between text data and business scenario categories;

[0090] The feature operation module 302 is used to generate a feature vector matrix by operating the feature weight matrix and the word vector matrix, and the feature vector matrix is ​​composed of feature vectors;

[0091] The model training module 303 is used to train the feature vector to obtain a text data classification model;

[0092] The text classification module 304 is used to classify text data using a text data classification model.

[0093] According to an embodiment of the present invention, the model training module 303 may also be used to:

[0094] Input the feature vector into the model to be trained to obtain the output value;

[0095] Compare the output value with the actual value and calculate the error sum;

[0096] Adjust the parameters of the model to be trained based on the error;

[0097] Repeat the above three steps until the error sum is less than the preset error threshold, and use the model to be trained whose error sum is less than the preset error threshold as the text data classification model.

[0098] According to the technical solution of the embodiment of the present invention, by obtaining the feature weight matrix and word vector matrix of the text data, the correlation between all the features of the text data and the business scenario category, as well as the vectors corresponding to all the features of the text data can be obtained; then, the feature weight matrix and the word vector matrix are operated to generate a new feature vector matrix, and the contribution of each feature to each business scenario category can be obtained, so that feature selection can be better performed, and the problem of feature loss caused by insufficient data coverage can be overcome; by training the feature vector to obtain a text data classification model and using the text data classification model to classify the text data, it is possible to quickly classify the text data, saving a lot of time and energy, and facilitating later maintenance. According to the technical solution of the present invention, it is possible to combine all the features of the text data to realize text classification based on business scenarios, improve the accuracy of text classification based on different business scenarios, and facilitate improving user experience for different business scenarios; and it is possible to automatically classify data according to business scenarios, saving manpower and material resources.

[0099] Figure 5 An exemplary system architecture 500 is shown in which the method for generating a feature vector and / or performing text classification based on a feature vector or the apparatus for generating a feature vector and / or performing text classification based on a feature vector according to an embodiment of the present invention can be applied.

[0100] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505. Network 504 is used to provide a medium for communication links between terminal devices 501, 502, 503 and server 505. Network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0101] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).

[0102] The terminal devices 501 , 502 , and 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0103] The server 505 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 501, 502, and 503. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information, product information - only an example) to the terminal device.

[0104] It should be noted that the method for generating feature vectors and / or performing text classification based on feature vectors provided in the embodiments of the present invention is generally executed by the server 505. Accordingly, the device for generating feature vectors and / or performing text classification based on feature vectors is generally arranged in the server 505.

[0105] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.

[0106] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device or a server suitable for implementing an embodiment of the present invention. Figure 6 The terminal device or server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0107] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0108] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.

[0109] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.

[0110] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0111] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0112] The units or modules involved in the embodiments of the present invention may be implemented in software or hardware. The units or modules described may also be provided in a processor, for example, may be described as: a processor including a data acquisition module and a feature operation module. The names of these units or modules do not, in certain cases, constitute limitations on the units or modules themselves, for example, the data acquisition module may also be described as a "module for acquiring feature weight matrices and word vector matrices for text data".

[0113] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: obtaining a feature weight matrix and a word vector matrix of text data, wherein the feature weight matrix is ​​composed of the association weights between the text data and the business scenario category; and generating a feature vector matrix by operating the feature weight matrix and the word vector matrix, wherein the feature vector matrix is ​​composed of feature vectors.

[0114] According to the technical solution of the embodiment of the present invention, by obtaining the feature weight matrix and word vector matrix of the text data, the correlation between all the features of the text data and the business scenario category, as well as the vectors corresponding to all the features of the text data can be obtained; then, the feature weight matrix and the word vector matrix are operated to generate a new feature vector matrix, and the contribution of each feature to each business scenario category can be obtained, so that feature selection can be better performed, and the problem of feature loss caused by insufficient data coverage can be overcome; by training the feature vector to obtain a text data classification model and using the text data classification model to classify the text data, it is possible to quickly classify the text data, saving a lot of time and energy, and facilitating later maintenance. According to the technical solution of the present invention, it is possible to combine all the features of the text data to realize text classification based on business scenarios, improve the accuracy of text classification based on different business scenarios, and facilitate improving user experience for different business scenarios; and it is possible to automatically classify data according to business scenarios, saving manpower and material resources.

[0115] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for generating a feature vector, characterized in that: include: Obtain a feature weight matrix and a word vector matrix of the text data, wherein the feature weight matrix is ​​composed of association weights between the text data and business scenario categories; Generate a feature vector matrix by operating the feature weight matrix and the word vector matrix, wherein the feature vector matrix is ​​composed of feature vectors; The step of obtaining a word vector matrix of text data includes: performing a word segmentation operation on the text data; for each word obtained by the word segmentation operation, calculating the word vector of each word to obtain a word vector matrix of the text data, wherein each word is a term or a symbol; The word vector of each word is generated by using a one-hot encoding method, including: counting the number of all words in the text data; creating an index for each word and sorting by index; finally, generating a vector for each word in which all positions except the word itself are 1 and all other positions are 0; The step of obtaining the feature weight matrix of text data includes: performing word segmentation operation on the text data; for each word obtained by the word segmentation operation, using the feature selection method to calculate the association weight of each word with the business scenario category, taking the association weight of each word with different business scenario categories as a row vector, and obtaining the feature weight matrix of the text data based on all row vectors.

2. The method according to claim 1, characterized in that The feature selection method includes one of the following: chi-square test, information gain, correlation coefficient, Gini coefficient, data modeling, L1 norm regularization, and decision tree.

3. The method according to claim 1, characterized in that The operation is a convolution operation.

4. A method for text classification based on feature vectors, characterized in that: include: Obtain a feature weight matrix and a word vector matrix of the text data, wherein the feature weight matrix is ​​composed of association weights between the text data and business scenario categories; Generate a feature vector matrix by operating the feature weight matrix and the word vector matrix, wherein the feature vector matrix is ​​composed of feature vectors; Training the feature vector to obtain a text data classification model; Using the text data classification model to classify text data; The step of obtaining a word vector matrix of text data includes: performing a word segmentation operation on the text data; for each word obtained by the word segmentation operation, calculating the word vector of each word to obtain a word vector matrix of the text data, wherein each word is a term or a symbol; The word vector of each word is generated by using a one-hot encoding method, including: counting the number of all words in the text data; creating an index for each word and sorting by index; finally, generating a vector for each word in which all positions except the word itself are 1 and all other positions are 0; The step of obtaining the feature weight matrix of text data includes: performing word segmentation operation on the text data; for each word obtained by the word segmentation operation, using the feature selection method to calculate the association weight of each word with the business scenario category, taking the association weight of each word with different business scenario categories as a row vector, and obtaining the feature weight matrix of the text data based on all row vectors.

5. The method according to claim 4, characterized in that The step of training the feature vector to obtain a text data classification model includes: Inputting the feature vector into the model to be trained to obtain an output value; Compare the output value with the actual value and calculate the error sum; Adjusting the parameters of the model to be trained according to the error; Repeat the above three steps until the error sum is less than a preset error threshold, and use the to-be-trained model whose error sum is less than the preset error threshold as a text data classification model.

6. A device for generating a feature vector, characterized in that: include: A data acquisition module, used to acquire a feature weight matrix and a word vector matrix of text data, wherein the feature weight matrix is ​​composed of association weights between the text data and business scenario categories; A feature operation module, used for generating a feature vector matrix by operating the feature weight matrix and the word vector matrix, wherein the feature vector matrix is ​​composed of feature vectors; The data acquisition module is also used to: perform word segmentation on the text data; for each word obtained by the word segmentation operation, calculate the word vector of each word to obtain the word vector matrix of the text data, wherein each word is a term or a symbol; wherein the word vector of each word is generated by using a one-hot encoding method, including: counting the number of all words in the text data; establishing an index for each word and sorting by index; and finally, generating a vector for each word, in which all positions except the word itself are 1 and all other positions are 0. The data acquisition module is also used to: perform word segmentation on the text data; for each word obtained by the word segmentation operation, use the feature selection method to calculate the association weight of each word with the business scenario category, use the association weight of each word with different business scenario categories as a row vector, and obtain the feature weight matrix of the text data based on all row vectors.

7. The device according to claim 6, characterized in that The feature selection method includes one of the following: chi-square test, information gain, correlation coefficient, Gini coefficient and data modeling, L1 norm regularization, and decision tree.

8. The device according to claim 6, characterized in that The operation is a convolution operation.

9. A device for text classification based on feature vectors, characterized in that: include: A data acquisition module, used to acquire a feature weight matrix and a word vector matrix of text data, wherein the feature weight matrix is ​​composed of association weights between the text data and business scenario categories; A feature operation module, used for generating a feature vector matrix by operating the feature weight matrix and the word vector matrix, wherein the feature vector matrix is ​​composed of feature vectors; A model training module, used for training the feature vector to obtain a text data classification model; A text classification module, used for classifying text data using the text data classification model; The data acquisition module is also used for: performing a word segmentation operation on the text data; for each word obtained by the word segmentation operation, calculating the word vector of each word to obtain a word vector matrix of the text data, wherein each word is a term or a symbol; wherein the word vector of each word is generated by using a one-hot encoding method, including: counting the number of all words in the text data; establishing an index for each word and sorting by the index; and finally, generating a vector for each word in which all positions are 0 except for the position of the word itself being 1; The data acquisition module is also used to: perform word segmentation on the text data; for each word obtained by the word segmentation operation, use the feature selection method to calculate the association weight of each word with the business scenario category, use the association weight of each word with different business scenario categories as a row vector, and obtain the feature weight matrix of the text data based on all row vectors.

10. The device according to claim 9, characterized in that The model training module is also used to: Inputting the feature vector into the model to be trained to obtain an output value; Compare the output value with the actual value and calculate the error sum; Adjusting the parameters of the model to be trained according to the error; Repeat the above three steps until the error sum is less than a preset error threshold, and use the to-be-trained model whose error sum is less than the preset error threshold as a text data classification model.

11. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method as claimed in any one of claims 1-3 and / or 4-5.

12. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1-3 and / or 4-5 is implemented.