A method and device for generating a classification model

Automatically divide data sets and select classification algorithms through knowledge graphs, combined with distributed training and integrated learning algorithms, solve the problem of low efficiency in generating classification models and achieve efficient model generation and deployment.

CN113743425BActive Publication Date: 2024-10-22BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 13 Cites 0 Cited by

Patent Information

Application Number
CN202010461491.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-05-27
Publication Date
2024-10-22
Estimated Expiration
2040-05-27

AI Technical Summary

Technical Problem

Algorithm engineers need to spend a lot of effort writing programs when generating classification models, and the written programs cannot be reused, resulting in low efficiency in generating classification models, and it is difficult to obtain better classification models due to limitations of personal experience.

Method used

Automatically divide the data set and select the classification algorithm through the knowledge graph, use the automatically selected classification algorithm to generate the classification model, improve the generation efficiency, and use distributed offline training or integrated learning algorithms during the training process to achieve rapid deployment of the classification model and efficient applications.

Benefits of technology

It improves the generation efficiency and training effect of the classification model, realizes the rapid online deployment and efficient application of the classification model, and improves the applicable scope and processing capabilities of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113743425B_ABST
    Figure CN113743425B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for generating a classification model, and relates to the field of computer technology. A specific implementation of the method includes: obtaining a first data set for training; constructing a feature wide table according to the first data set; based on a pre-constructed knowledge graph, according to the current target scenario and the data scale of the feature wide table, determining the division ratio corresponding to the feature wide table to divide the feature wide table into a training set and a test set; based on the knowledge graph, according to the current target scenario and the current classification problem, determining a classification algorithm, and one or more general parameters corresponding to the classification algorithm; according to the training set and the test set, using the classification algorithm for training to generate a classification model. This implementation can automatically perform data set division and classification algorithm and general parameters selection of the classification algorithm based on the knowledge graph, thereby improving the efficiency of generating a classification model.
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 a classification model. Background Art

[0002] With the rise and development of artificial intelligence, machine learning has become a research focus and hotspot, and classification problems such as binary classification problems and multi-classification problems have become a basic and important part of machine learning due to their broad application prospects.

[0003] In order to solve the classification problem, algorithm engineers often need to spend a lot of energy to write a program for training the classification model based on the existing algorithm framework, and the written program for training the classification model cannot be reused, which greatly reduces the efficiency of generating the classification model. In addition, before writing the program for training the classification model, the algorithm engineer needs to select the classification algorithm and divide the data set based on personal past experience, which wastes a lot of energy. Due to the limitations of personal past experience, it is impossible to obtain a better classification model based on the selected classification algorithm and the divided data set. Summary of the invention

[0004] In view of this, an embodiment of the present invention provides a method and device for generating a classification model, which can automatically divide the data set and select the classification algorithm and common parameters of the classification algorithm based on the knowledge graph, and generate a classification model based on the automatically selected classification algorithm, thereby improving the efficiency of generating the classification model.

[0005] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for generating a classification model is provided, comprising:

[0006] Obtaining a first data set for training;

[0007] Constructing a feature wide table according to the first data set, wherein the feature wide table indicates one or more feature values ​​and label information corresponding to one or more samples;

[0008] Based on the pre-built knowledge graph, according to the current target scenario and the data scale of the feature wide table, determine the division ratio corresponding to the feature wide table, so as to divide the feature wide table into a training set and a test set;

[0009] Based on the knowledge graph, according to the current target scenario and the current classification problem, determine a classification algorithm and one or more general parameters corresponding to the classification algorithm;

[0010] The classification algorithm is used to perform training based on the training set and the test set to generate a classification model.

[0011] Optionally, the knowledge graph is composed of one or more nodes and one or more edges connected to the nodes; wherein,

[0012] The node indicates any one of the following: target scenario, data scale, classification problem, classification algorithm, parameters corresponding to the classification algorithm, and data set division ratio;

[0013] The edge indicates any of the following: preferred, alternative, not recommended, configured, belongs to.

[0014] Optionally, it also includes:

[0015] Before dividing the feature wide table into a training set and a test set, one or more of the following preprocessing is performed on the feature values ​​in the feature wide table: correlation test, One-Hot encoding, feature value dimension unification, and feature value normalization.

[0016] Optionally, it also includes:

[0017] The format of the feature values ​​and the corresponding label information in the preprocessed feature width table is converted so that the formats of the converted feature values ​​and the label information are suitable for the classification algorithm.

[0018] Optionally, the training using the classification algorithm to generate a classification model based on the training set and the test set includes:

[0019] Loading a Docker image pre-packaged with the classification algorithm to start one or more Docker instances;

[0020] In the case where the classification algorithm supports distributed training, the training set and the test set are input into a distributed computing cluster corresponding to the classification algorithm to generate the classification model;

[0021] When the classification algorithm does not support distributed training, the training set and the test set are divided according to the number of the Docker instances, and the classification algorithm is executed based on the divided training set and the test set to generate one or more sub-classification models, and the one or more sub-classification models are integrated to generate a classification model.

[0022] Optionally, it also includes:

[0023] Start one or more Docker containers with the same configuration as the Docker image;

[0024] A corresponding agent program is deployed in each of the Docker containers, so that the agent program loads the classification model stored in the Hadoop distributed file system locally, and upon receiving a classification request sent by a client, calls the classification model to predict the classification result of the data indicated in the classification request.

[0025] Optionally, it also includes:

[0026] When receiving a classification request sent by a client, distribute the classification request to one or more proxy programs corresponding to the Docker containers through Nginx;

[0027] Or when receiving a classification request sent by the client, the classification request is distributed to the agent programs corresponding to one or more of the Docker containers through the Dubbo middleware and the Hessian protocol.

[0028] Optionally, the one or more sub-classification models are integrated to generate a classification model using any one of the following integration algorithms: bagging algorithm, boosting algorithm, stacking algorithm.

[0029] To achieve the above object, according to another aspect of an embodiment of the present invention, a device for generating a classification model is provided, comprising: a data set acquisition module, a feature wide table construction module, a feature wide table partitioning module, a classification algorithm determination module, and a classification model generation module; wherein,

[0030] The data set acquisition module is used to acquire a first data set for training;

[0031] The feature wide table construction module is used to construct a feature wide table according to the first data set, wherein the feature wide table indicates one or more feature values ​​and label information corresponding to one or more samples;

[0032] The feature wide table partitioning module is used to determine the partitioning ratio corresponding to the feature wide table based on the pre-built knowledge graph, according to the current target scenario and the data scale of the feature wide table, so as to divide the feature wide table into a training set and a test set;

[0033] The classification algorithm determination module is used to determine the classification algorithm and one or more general parameters corresponding to the classification algorithm based on the knowledge graph, according to the current target scenario and the current classification problem;

[0034] The classification model generation module is used to generate the classification model by training using the classification algorithm according to the training set and the test set.

[0035] Optionally, the knowledge graph is composed of one or more nodes and one or more edges connected to the nodes; wherein,

[0036] The node indicates any one of the following: target scenario, data scale, classification problem, classification algorithm, parameters corresponding to the classification algorithm, and data set division ratio;

[0037] The edge indicates any of the following: preferred, alternative, not recommended, configured, belongs to.

[0038] Optionally, the feature wide table partitioning module is further used to:

[0039] Before dividing the feature wide table into a training set and a test set, one or more of the following preprocessing is performed on the feature values ​​in the feature wide table: correlation test, One-Hot encoding, feature value dimension unification, and feature value normalization.

[0040] Optionally, the feature wide table partitioning module is further used to:

[0041] The format of the feature values ​​and the corresponding label information in the preprocessed feature width table is converted so that the formats of the converted feature values ​​and the label information are suitable for the classification algorithm.

[0042] Optionally, the training using the classification algorithm to generate the classification model according to the training set and the test set includes:

[0043] Loading a Docker image pre-packaged with the classification algorithm to start one or more Docker instances;

[0044] In the case where the classification algorithm supports distributed training, the training set and the test set are input into a distributed computing cluster corresponding to the classification algorithm to generate the classification model;

[0045] When the classification algorithm does not support distributed training, the training set and the test set are divided according to the number of the Docker instances, and the classification algorithm is executed based on the divided training set and the test set to generate one or more sub-classification models, and the one or more sub-classification models are integrated to generate a classification model.

[0046] Optionally, it further includes: a classification model deployment module; wherein the classification model deployment module is used to:

[0047] Start one or more Docker containers with the same configuration as the Docker image;

[0048] A corresponding agent program is deployed in each of the Docker containers, so that the agent program loads the classification model stored in the Hadoop distributed file system locally, and upon receiving a classification request sent by a client, calls the classification model to predict the classification result of the data indicated in the classification request.

[0049] Optionally, it further includes: a classification request distribution module; wherein the classification request distribution module is used to:

[0050] When receiving a classification request sent by a client, distribute the classification request to one or more proxy programs corresponding to the Docker containers through Nginx;

[0051] Or when receiving a classification request sent by a client, the classification request is load balanced to one or more proxy programs corresponding to the Docker containers through Dubbo middleware and Hessian protocol.

[0052] Optionally, the classification model generation module is used to integrate the one or more sub-classification models to generate a classification model using any one of the following integration algorithms: bagging algorithm, boosting algorithm, stacking algorithm.

[0053] To achieve the above object, according to another aspect of an embodiment of the present invention, there is provided an electronic device for generating a classification model, comprising:

[0054] one or more processors;

[0055] a storage device for storing one or more programs,

[0056] When the one or more programs are executed by the one or more processors, the one or more processors implement any of the methods described above for generating a classification model.

[0057] To achieve the above-mentioned purpose, according to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, any of the methods described above for generating a classification model is implemented.

[0058] The above invention has the following advantages or beneficial effects: based on the knowledge graph, the data set is automatically divided and the classification algorithm and the general parameters of the classification algorithm are selected, and the divided data set is trained with the selected classification algorithm to generate a classification model, thereby improving the generation efficiency of the classification model; in addition, in the process of training the classification model, the training efficiency and training effect of the classification model are further improved by using distributed offline training or integrated learning algorithms such as bagging algorithm and stacking algorithm; on this basis, the classification model is quickly deployed online based on Docker container technology, so that the classification result is predicted based on the classification model when the classification request from the client is received; further, the classification request is distributed to multiple Docker containers containing agent programs through Nginx or Dubbo middleware, thereby improving the application efficiency of the classification model.

[0059] 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

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

[0061] Figure 1 is a schematic diagram of the main process of a method for generating a classification model according to an embodiment of the present invention;

[0062] Figure 2 is a schematic diagram of a knowledge graph according to an embodiment of the present invention;

[0063] Figure 3 is a schematic diagram of the main process of another method for generating a classification model according to an embodiment of the present invention;

[0064] Figure 4 is a schematic diagram of the main process of the classification model training method according to an embodiment of the present invention;

[0065] Figure 5 is a schematic diagram of the main process of the classification model deployment method according to an embodiment of the present invention;

[0066] Figure 6 is a schematic diagram of main modules of an apparatus for generating a classification model according to an embodiment of the present invention;

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

[0068] Figure 8 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

[0069] 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.

[0070] Figure 1 is a schematic diagram of the main process of the method for generating a classification model according to an embodiment of the present invention, such as Figure 1 As shown, the method for generating a classification model may specifically include the following steps:

[0071] Step S101, obtaining a first data set for training.

[0072] The first data set refers to any data that can be used for machine learning based on actual needs. For example, determining whether a tumor is benign or malignant, determining the age of a patient, determining the gender of a user, etc. Specifically, taking the example of determining whether a user will buy a certain product, which is a typical binary classification problem, the corresponding first data set indicates the historical behavior of one or more users, and whether the user has purchased the product, etc., and uses users who have purchased the product as positive samples and samples that have not purchased the product as negative samples for machine learning training to generate a classification model that can predict whether a user will buy a product based on the user's historical behavior.

[0073] Step S102: construct a feature wide table according to the first data set, wherein the feature wide table indicates one or more feature values ​​and label information corresponding to one or more samples.

[0074] As shown in Table 1 below, the feature wide table includes M samples, each of which has N features and each sample has different N feature values, and the corresponding label information (Lable) is also different. Among them, the sample with label 1 is a positive sample, and the sample with label 0 is a negative sample. Specifically, still taking the example of judging whether a user has purchased a product based on the user's historical behavior, the features of each sample include but are not limited to: the product clicked by the user, the product browsed by the user, the product added to the shopping cart by the user, the product collected by the user, the number of purchases made by the user in the past month, etc.

[0075] Table 1 Example of feature width table

[0076] Feature 1 Feature 2 Feature 3 …… Feature N Label data11 data12 data13 …… data1N 1 data21 data22 data23 …… data2N 0 data31 data32 data33 …… data3N 0 …… …… …… …… …… …… dataM1 dataM2 dataM3 dataMn 1

[0077] On this basis, in order to avoid the problem of multicollinearity and inconsistent dimensions of the feature data in the feature wide table, which may lead to the problem of non-convergence or imbalance of feature weights in the subsequent training classification model, thereby affecting the quality of the generated classification model, before dividing the feature wide table into a training set and a test set, the feature values ​​in the feature wide table are preprocessed with one or more of the following: correlation test, One-Hot encoding, feature value dimension unification, and feature value normalization. Among them, the correlation test refers to determining whether different features are related and the degree of correlation, such as judging the correlation between different features by drawing a correlation matrix heat map to determine whether some features need to be deleted. One-Hot encoding is also called one-bit valid encoding, and its method is to use an n-bit state register to encode n states, each state has its own independent register bit, and only one of them is valid at any time; in this way, after One-Hot encoding discrete features such as city names and school names, the encoded features have continuity. Feature value normalization refers to mapping feature values ​​to the range of 0-1. The dimensional unification of eigenvalues ​​means using the same dimension to eliminate the influence of the dimension on the value, such as 180cm and 1.8m are unified as 1.8m or 180cm.

[0078] In addition, since different classification algorithms or algorithm frameworks are applicable to different data formats, after preprocessing the feature wide table, the feature values ​​and corresponding label information in the feature wide table need to be converted to a format so that the format of the converted feature values ​​and label information is applicable to the classification algorithm. For example, taking the commonly used NumPy framework of Python as an example, the format of the feature values ​​and corresponding label information can be converted to DataFrame format, which is a tabular data structure.

[0079] Step S103, based on the pre-constructed knowledge graph, according to the current target scenario and the data size of the feature wide table, determine the division ratio corresponding to the feature wide table to divide the feature wide table into a training set and a test set. Specifically, taking the training set obtained based on the knowledge graph: test set = 1:1 as an example, it is necessary to divide the samples in the feature wide table shown in Table 1 into two parts, one part is used as a training set, and the other part is used as a test set.

[0080] The knowledge graph is composed of one or more nodes and one or more edges connected to the nodes; wherein the node indicates any of the following: target scenario, data scale, classification problem, classification algorithm, parameters corresponding to the classification algorithm, and data set division ratio; the edge indicates any of the following: preferred, alternative, not recommended, configuration, belonging. It can be understood that the knowledge graph is established based on past experience, and different knowledge graphs can be established according to actual needs, such as establishing different knowledge graphs according to different target scenarios, such as knowledge graphs for predicting user age, knowledge graphs for predicting user gender, etc. Therefore, before determining the division ratio of the feature wide table according to the knowledge graph, it is necessary to determine the corresponding pre-built knowledge graph according to the target scenario, and then determine the division ratio based on the knowledge graph to adopt strategies such as random division and sorting division to generate training sets and test sets that meet the needs. In the case of insufficient data set size, each data set is also divided by cross combination. It is worth noting that in addition to dividing the feature wide table into training set and test set, the feature wide table can also be divided into training set, test set, and verification set according to actual needs.

[0081] like Figure 2 The knowledge graph shown in the figure is applicable to the target scenario of predicting whether a user will buy a certain product. The classification problem involved is a binary classification problem, and the data scale is in the tens of millions. The classification algorithms that can be used include GBDT (GradientBoostingDecisionTree) algorithm, RandomForest algorithm, XGBoost (eXtreme GradientBoosting) algorithm, etc., and the ratio of the training set to the test set corresponding to the RandomForest algorithm or the XGBoost algorithm is 1:1. Among them, different classification algorithms have different corresponding general parameters, such as the general parameter corresponding to the GBDT algorithm is the tree depth and the preferred value is 3, while the general parameter of the XGBoost algorithm is the number of iterations and the preferred value is 10000. It can be understood that the general parameters of the classification algorithm refer to the parameters such as the tree depth and the number of iterations determined before the classification algorithm is used to train the classification model, rather than the learning target parameters that can only be determined after the classification algorithm is used to train the classification model, such as the loss function, softmax cross entropy, etc.

[0082] Step S104, based on the knowledge graph, according to the current target scenario and the current classification problem, determine the classification algorithm and one or more common parameters corresponding to the classification algorithm.

[0083] Still see Figure 2, then the preferred classification algorithm is the XGBoost algorithm, and the preferred value of the number of iterations of the general parameter corresponding to the XGBoost algorithm is 10000. Based on this, the XGBoost algorithm can be used to train the divided training set, and the test set can be used for optimization to generate a classification model. In addition, based on the general parameters determined based on the knowledge graph, a manual correction mode can also be provided to adjust the general parameters given by the knowledge graph. In this way, on the basis of improving the generation of the classification model, personalized needs can be taken into account to improve the scope of application of the generated classification model.

[0084] Step S105, using the classification algorithm to perform training based on the training set and the test set to generate a classification model.

[0085] Specifically, the training using the classification algorithm to generate a classification model based on the training set and the test set includes: loading a Docker image pre-encapsulated with the classification algorithm to start one or more Docker instances; if the classification algorithm supports distributed training, inputting the training set and the test set into the distributed computing cluster corresponding to the classification algorithm to generate the classification model; if the classification algorithm does not support distributed training, dividing the training set and the test set according to the number of the Docker instances, and executing the classification algorithm based on the divided training set and the test set to generate one or more sub-classification models, and integrating the one or more sub-classification models to generate the classification model. In this way, the quality and generation efficiency of the classification model can be improved by means of distributed training or integrated algorithms. The so-called Docker refers to an open source application container engine that allows developers to package their applications and dependent packages into a portable image, and then publish them to any popular Linux or Windows machine, and can also achieve virtualization.

[0086] Furthermore, any of the following integrated algorithms can be used to integrate the one or more sub-classification models to generate a classification model: bagging algorithm, boosting algorithm, stacking algorithm. It is understandable that when using integrated algorithms such as bagging algorithm, boosting algorithm, stacking algorithm, etc. to train the classification model, any of the following methods can be selected to generate the classification model according to actual needs: (1) dividing the training set and the test set into multiple different training subsets and test subsets, using the same classification algorithm to train different training subsets and using corresponding test subsets for verification to generate multiple sub-classification models, and integrating the sub-classification models to generate the classification model; (2) using different classification algorithms to train the same training set and using the test set for verification to generate multiple sub-classification models, integrating the sub-classification models corresponding to different classification algorithms to generate the classification model. After the classification model is generated, the classification model is stored in the Hadoop distributed file system (HDFS) so that the classification model can be loaded from the Hadoop distributed file system and deployed online.

[0087] On this basis, after generating the classification model, it also includes: starting one or more Docker containers with the same configuration as the Docker image; deploying a corresponding agent program in each of the Docker containers, so that the agent program loads the classification model stored in the Hadoop distributed file system to the local computer, and upon receiving a classification request sent by the client, calls the classification model to predict the classification result of the data indicated in the classification request. It can be understood that when the agent program in the Docker container receives the classification request from the client, it can convert the format of the data indicated in the classification request so that the data format is suitable for the classification model, and input the converted data into the classification model to predict the classification result, thereby realizing the online deployment of the classification model and providing classification prediction services to the client.

[0088] It is understandable that as the number of classification requests sent by the client increases, when the number of classification requests is too large or there are high concurrent calls to the classification model, directly sending the classification request to the agent corresponding to the Docker container may cause waste of Docker container resources or crash. Therefore, when receiving the classification request, it is necessary to load balance the classification request to the agent corresponding to one or more Docker containers to improve the processing efficiency of the classification request.

[0089] In an optional implementation, it also includes: when receiving a classification request sent by a client, distributing the classification request to one or more proxy programs corresponding to the Docker containers through Nginx; or when receiving a classification request sent by a client, distributing the classification request to one or more proxy programs corresponding to the Docker containers through Dubbo middleware and Hessian protocol. Nginx refers to a high-performance HTTP and reverse proxy web server, and also provides IMAP / POP3 / SMTP services. Hessian is a remote communication library based on binary-RPC provided by caucho, which supports multiple languages ​​such as Java, Flash, Flex, python, c++, Ruby, ObjectC, etc., and can be used to achieve cross-language communication and interaction. Dubbo middleware is a modern distributed service framework that uses Java's Interface as a service contract, completes service registration and discovery through a registration center, and the details of remote communication are also shielded by proxy classes.

[0090] Specifically, in the case of providing a classification model call service based on the HTTP protocol, when receiving a classification request sent by a client, the classification request can be polled to the proxy programs of one or more Docker containers in a Round-Robin manner based on the reverse proxy function of Nginx, so that the proxy service calls the classification model and returns the classification result of the data indicated by the classification request. In this way, load balancing of classification requests is achieved through polling.

[0091] In the case of providing classification model call service based on Socket, a layer of Server program based on Hessian protocol is encapsulated for the execution program of the classification model in Python environment, so that the Server program can directly call the classification model for classification prediction; at the same time, based on Dubbo middleware, a Client program is created for the agent program in Java environment, so that the Client program can call the Server program through Hessian protocol and obtain the classification results predicted by the returned classification model, and a Provider program is started for the Client program and registered in the service center Registry, so that one or more external clients can call one or more Provider programs registered in the service center. In this way, when a classification request sent by the client is received, the classification request is distributed to the agent programs corresponding to one or more Docker containers through the selective call of the client to one or more Provider programs registered in the service center, and the selective call of the Client program to the Server program implemented by the Hessian protocol.

[0092] It is worth noting that in the process of distributing classification requests, the Hessian protocol is also used to implement the call of the classification model built in Python by the agent program written in Java, which supports cross-language interaction while ensuring good communication performance.

[0093] Based on the above embodiments, the data set is automatically divided based on the knowledge graph, and the classification algorithm and the general parameters of the classification algorithm are selected, and the divided data set is trained with the selected classification algorithm to generate a classification model, thereby improving the generation efficiency of the classification model; in addition, in the process of training the classification model, the training efficiency and training effect of the classification model are further improved by using distributed offline training or integrated learning algorithms such as bagging algorithm and stacking algorithm; on this basis, the rapid online deployment of the classification model is realized based on Docker container technology, so as to predict the classification result based on the classification model when the classification request from the client is received; further, the distribution of classification requests to multiple Docker containers containing agent programs is realized through Nginx or Dubbo middleware, thereby improving the application efficiency of the classification model.

[0094] See also Figure 3 Based on the above embodiment, the embodiment of the present invention provides another method for generating a classification model, which may specifically include the following steps:

[0095] Step S301: Acquire a first data set for training.

[0096] Step S302: construct a feature wide table according to the first data set, wherein the feature wide table indicates one or more feature values ​​and label information corresponding to one or more samples.

[0097] Step S303, preprocessing the eigenvalues ​​in the feature width table. The preprocessing includes one or more of the following: correlation test, One-Hot encoding, eigenvalue dimension unification, and eigenvalue normalization.

[0098] Step S304: converting the format of the preprocessed feature values ​​and the corresponding label information in the feature width table so that the formats of the converted feature values ​​and the label information are suitable for the classification algorithm.

[0099] Step S305, based on the pre-constructed knowledge graph, according to the current target scenario and the data size of the feature wide table, determine the division ratio corresponding to the feature wide table, so as to divide the feature wide table into a training set and a test set. In other words, the feature wide table that has been pre-processed and format-converted is divided into a training set and a test set according to the division ratio.

[0100] Step S306, based on the knowledge graph, according to the current target scenario and the current classification problem, determine the classification algorithm and one or more general parameters corresponding to the classification algorithm.

[0101] Step S307: Perform training using the classification algorithm based on the training set and the test set to generate a classification model.

[0102] See also Figure 4 Based on the above embodiment, the present invention provides a classification model training method, which may specifically include the following steps:

[0103] Step S401, loading a Docker image pre-packaged with the classification algorithm to start one or more Docker instances.

[0104] Step S402, determining whether the classification algorithm supports distributed training; if the classification algorithm supports distributed training, continue to execute the following step S403; if the classification algorithm does not support distributed training, continue to execute the following step S404.

[0105] Step S403: input the training set and the test set into the distributed computing cluster corresponding to the classification algorithm to generate the classification model.

[0106] Step S404, dividing the training set and the test set according to the number of the Docker instances. Specifically, taking the number of Docker instances as 10 as an example, the training set and the test set are correspondingly divided into 10 training subsets and 10 test subsets corresponding to the training subsets (see Table 2).

[0107] Table 2 Examples of training subsets and test subsets after division

[0108] Training subset 1 Test subset 1 Training subset 2 Test subset 2 Training subset 3 Test subset 3 Training subset 4 Test subset 4 Training subset 5 Test subset 5 Training subset 6 Test subset 6 Training subset 7 Test subset 7 Training subset 8 Test subset 8 Training subset 9 Test subset 9 Training subset 10 Test subset 10

[0109] Step S405, executing the classification algorithm based on the divided training set and test set to generate one or more sub-classification models. Still referring to Table 2, in the process of training and generating sub-classification models, a Docker instance executes a classification algorithm based on its training subset 1 and test subset 1 to generate a sub-classification model, and a Docker instance executes a classification algorithm based on its training subset 2 and test subset 2 to generate a sub-classification model, and so on, 10 Docker instances can generate 10 sub-classification models, and then the integration algorithm is used to integrate the 10 sub-classification models into one classification model.

[0110] Step S406: Integrate the one or more sub-classification models to generate a classification model.

[0111] See also Figure 5 Based on the above embodiment, an embodiment of the present invention provides a method for deploying a classification model, which may specifically include the following steps:

[0112] Step S501, start one or more Docker containers with the same configuration as the Docker image.

[0113] Step S502: deploy a corresponding agent program in each of the Docker containers, so that the agent program loads the classification model stored in the Hadoop distributed file system to the local computer.

[0114] Step S503, when receiving a classification request sent by the client, distribute the classification request to the agent programs corresponding to one or more of the Docker containers through Nginx or Dubbo middleware and Hessian protocol to call the classification model to predict the classification result of the data indicated in the classification request.

[0115] See also Figure 6Based on the above embodiments, the embodiment of the present invention provides a device for generating a classification model, including: a data set acquisition module 601, a feature wide table construction module 602, a feature wide table division module 603, a classification algorithm determination module 604, and a classification model generation module 605; wherein,

[0116] The data set acquisition module 601 is used to acquire a first data set for training;

[0117] The feature wide table construction module 602 is used to construct a feature wide table according to the first data set, wherein the feature wide table indicates one or more feature values ​​and label information corresponding to one or more samples;

[0118] The feature wide table partitioning module 603 is used to determine the partitioning ratio corresponding to the feature wide table based on the pre-built knowledge graph, according to the current target scenario and the data scale of the feature wide table, so as to divide the feature wide table into a training set and a test set;

[0119] The classification algorithm determination module 604 is used to determine the classification algorithm and one or more general parameters corresponding to the classification algorithm based on the knowledge graph, according to the current target scenario and the current classification problem;

[0120] The classification model generation module 605 is used to generate the classification model by training using the classification algorithm according to the training set and the test set.

[0121] In an optional implementation, the knowledge graph is composed of one or more nodes and one or more edges connected to the nodes; wherein,

[0122] The node indicates any one of the following: target scenario, data scale, classification problem, classification algorithm, parameters corresponding to the classification algorithm, and data set division ratio;

[0123] The edge indicates any of the following: preferred, alternative, not recommended, configured, belongs to.

[0124] In an optional implementation, the feature width table partitioning module 603 is further configured to:

[0125] Before dividing the feature wide table into a training set and a test set, one or more of the following preprocessing is performed on the feature values ​​in the feature wide table: correlation test, One-Hot encoding, feature value dimension unification, and feature value normalization.

[0126] In an optional implementation, the feature width table partitioning module 603 is further configured to:

[0127] The format of the feature values ​​and the corresponding label information in the preprocessed feature width table is converted so that the formats of the converted feature values ​​and the label information are suitable for the classification algorithm.

[0128] In an optional implementation, the training using the classification algorithm to generate the classification model based on the training set and the test set includes:

[0129] Loading a Docker image pre-packaged with the classification algorithm to start one or more Docker instances;

[0130] In the case where the classification algorithm supports distributed training, the training set and the test set are input into a distributed computing cluster corresponding to the classification algorithm to generate the classification model;

[0131] When the classification algorithm does not support distributed training, the training set and the test set are divided according to the number of the Docker instances, and the classification algorithm is executed based on the divided training set and the test set to generate one or more sub-classification models, and the one or more sub-classification models are integrated to generate a classification model.

[0132] In an optional implementation, the system further includes: a classification model deployment module 606; wherein the classification model deployment module 606 is used to:

[0133] Start one or more Docker containers with the same configuration as the Docker image;

[0134] A corresponding agent program is deployed in each of the Docker containers, so that the agent program loads the classification model stored in the Hadoop distributed file system locally, and upon receiving a classification request sent by a client, calls the classification model to predict the classification result of the data indicated in the classification request.

[0135] In an optional implementation, the system further includes: a classification request distribution module 607; wherein the classification request distribution module 607 is used to:

[0136] When receiving a classification request sent by a client, distribute the classification request to one or more proxy programs corresponding to the Docker containers through Nginx;

[0137] Or when receiving a classification request sent by a client, the classification request is load balanced to one or more proxy programs corresponding to the Docker containers through Dubbo middleware and Hessian protocol.

[0138] In an optional implementation, the classification model generation module 605 is used to integrate the one or more sub-classification models to generate a classification model using any one of the following integration algorithms: bagging algorithm, boosting algorithm, stacking algorithm.

[0139] Figure 7 An exemplary system architecture 700 is shown to which the method for generating a classification model or the apparatus for generating a classification model according to the embodiments of the present invention can be applied.

[0140] like Figure 7 As shown, system architecture 700 may include terminal devices 701, 702, 703, network 704 and server 705. Network 704 is used to provide a medium for communication links between terminal devices 701, 702, 703 and server 705. Network 704 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0141] Users can use terminal devices 701, 702, and 703 to interact with server 705 through network 704 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 701, 702, and 703, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0142] The terminal devices 701 , 702 , and 703 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.

[0143] Server 705 may be a server that provides various services, such as a backend management server that provides support for shopping websites browsed by users using terminal devices 701, 702, and 703. The backend management server may analyze and process received data such as product information query requests, and feed back the processing results to the terminal device.

[0144] It should be noted that the method for generating a classification model provided in the embodiment of the present invention is generally executed by the server 705 , and accordingly, the device for generating a classification model is generally arranged in the server 705 .

[0145] It should be understood that Figure 7 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 implementation requirements.

[0146] Reference below Figure 8 , which shows a schematic diagram of the structure of a computer system 800 of a terminal device suitable for implementing an embodiment of the present invention. Figure 8The terminal device 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.

[0147] like Figure 8 As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage part 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the system 800 are also stored. The CPU 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

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

[0149] 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 809, and / or installed from the removable medium 811. When the computer program is executed by the central processing unit (CPU) 801, the above-mentioned functions defined in the system of the present invention are executed.

[0150] 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.

[0151] 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.

[0152] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may be arranged in a processor, for example, may be described as: a processor including a data set acquisition module, a feature wide table construction module, a feature wide table partitioning module, a classification algorithm determination module, and a classification model generation module. The names of these modules do not, in some cases, constitute limitations on the modules themselves, for example, the data set acquisition module may also be described as a "module for acquiring a first data set for training".

[0153] 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 and not be 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 first data set for training; constructing a feature width table according to the first data set, the feature width table indicating one or more feature values ​​and label information corresponding to one or more samples; based on the pre-constructed knowledge graph, according to the current target scenario and the data scale of the feature width table, determining the division ratio corresponding to the feature width table to divide the feature width table into a training set and a test set; based on the knowledge graph, according to the current target scenario and the current classification problem, determining a classification algorithm and one or more general parameters corresponding to the classification algorithm; according to the training set and the test set, using the classification algorithm for training to generate a classification model.

[0154] According to the technical solution of the embodiment of the present invention, the data set is automatically divided and the classification algorithm and the general parameters of the classification algorithm are selected based on the knowledge graph, and the divided data set is trained with the selected classification algorithm to generate a classification model, thereby improving the generation efficiency of the classification model; in addition, in the process of training the classification model, the training efficiency and training effect of the classification model are further improved by using distributed offline training or integrated learning algorithms such as bagging algorithm and stacking algorithm; on this basis, the rapid online deployment of the classification model is realized based on Docker container technology, so as to predict the classification result based on the classification model when the classification request from the client is received; further, the distribution of classification requests to multiple Docker containers containing agent programs is realized through Nginx or Dubbo middleware, thereby improving the application efficiency of the classification model.

[0155] 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 classification model, characterized in that: include: Obtaining a first data set for training; Constructing a feature wide table according to the first data set, wherein the feature wide table indicates one or more feature values ​​and label information corresponding to one or more samples; Based on the pre-built knowledge graph, according to the current target scenario and the data scale of the feature wide table, determine the division ratio corresponding to the feature wide table, so as to divide the feature wide table into a training set and a test set; Based on the knowledge graph, according to the current target scenario and the current classification problem, determine a classification algorithm and one or more general parameters corresponding to the classification algorithm; According to the training set and the test set, the classification algorithm is used to perform training to generate a classification model; specifically comprising: loading a Docker image pre-packaged with the classification algorithm to start one or more Docker instances; When the classification algorithm supports distributed training, the training set and the test set are input into the distributed computing cluster corresponding to the classification algorithm to generate the classification model; when the classification algorithm does not support distributed training, the training set and the test set are divided according to the number of the Docker instances, and the classification algorithm is executed based on the divided training set and the test set to generate one or more sub-classification models, and the one or more sub-classification models are integrated to generate a classification model.

2. The method for generating a classification model according to claim 1, characterized in that: The knowledge graph is composed of one or more nodes and one or more edges connected to the nodes; wherein, The node indicates any one of the following: target scenario, data scale, classification problem, classification algorithm, parameters corresponding to the classification algorithm, and data set division ratio; The edge indicates any of the following: preferred, alternative, not recommended, configured, belongs to.

3. The method for generating a classification model according to claim 1, characterized in that: Also includes: Before dividing the feature wide table into a training set and a test set, one or more of the following preprocessing is performed on the feature values ​​in the feature wide table: correlation test, One-Hot encoding, feature value dimension unification, and feature value normalization.

4. The method for generating a classification model according to claim 3, characterized in that: Also includes: The format of the feature values ​​and the corresponding label information in the preprocessed feature width table is converted so that the formats of the converted feature values ​​and the label information are suitable for the classification algorithm.

5. The method for generating a classification model according to claim 1, characterized in that: Also includes: Start one or more Docker containers with the same configuration as the Docker image; A corresponding agent program is deployed in each of the Docker containers, so that the agent program loads the classification model stored in the Hadoop distributed file system locally, and upon receiving a classification request sent by a client, calls the classification model to predict the classification result of the data indicated in the classification request.

6. The method for generating a classification model according to claim 5, characterized in that: Also includes: When receiving a classification request sent by a client, distribute the classification request to one or more proxy programs corresponding to the Docker containers through Nginx; Or when receiving a classification request sent by the client, the classification request is distributed to the agent programs corresponding to one or more of the Docker containers through the Dubbo middleware and the Hessian protocol.

7. The method for generating a classification model according to claim 1, characterized in that: The one or more sub-classification models are integrated to generate a classification model using any of the following integration algorithms: bagging algorithm, boosting algorithm, stacking algorithm.

8. A device for generating a classification model, characterized in that: include: Data set acquisition module, feature wide table construction module, feature wide table partitioning module, classification algorithm determination module, classification model generation module; among them, The data set acquisition module is used to acquire a first data set for training; The feature wide table construction module is used to construct a feature wide table according to the first data set, wherein the feature wide table indicates one or more feature values ​​and label information corresponding to one or more samples; The feature wide table partitioning module is used to determine the partitioning ratio corresponding to the feature wide table based on the pre-built knowledge graph, according to the current target scenario and the data scale of the feature wide table, so as to divide the feature wide table into a training set and a test set; The classification algorithm determination module is used to determine the classification algorithm and one or more general parameters corresponding to the classification algorithm based on the knowledge graph, according to the current target scenario and the current classification problem; The classification model generation module is used to train the classification algorithm according to the training set and the test set to generate the classification model; specifically, it is used to: load a Docker image pre-packaged with the classification algorithm to start one or more Docker instances; if the classification algorithm supports distributed training, input the training set and the test set into the distributed computing cluster corresponding to the classification algorithm to generate the classification model; if the classification algorithm does not support distributed training, divide the training set and the test set according to the number of the Docker instances, and execute the classification algorithm based on the divided training set and the test set to generate one or more sub-classification models, and integrate the one or more sub-classification models to generate a classification model.

9. An electronic device for generating a classification model, 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 according to any one of claims 1 to 7.

10. 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 to 7 is implemented.

Citation Information

Patent Citations

  • Data sensing-based Spark configuration parameter automatic optimization method

    CN106648654A

  • Text data classification method and server

    CN107346433A

  • Brain-like system and method based on machine learning, apparatus and storage medium

    CN109033277A

  • A method and apparatus for training a model

    CN109325541A

  • Node classification method, model training method and device

    CN109460793A