Method, device, equipment and storage medium for generating model
By obtaining and screening factors to determine target model features, the complexity of feature engineering and screening in the logistic regression model generation process is solved, improving efficiency and reducing costs.
Patent Information
- Application Number
- CN202011530270.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-22
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2040-12-22
AI Technical Summary
When using a logistic regression model to generate a target model, you need to rely on a large amount of feature engineering and feature screening, resulting in increased time and manpower consumption.
By obtaining the sample resource characteristics and sample labels, the first and second screening factors are determined, and based on these factors, the characteristics of the target model are determined from the sample resource characteristics, and then the machine learning model is trained, reducing the dependence on feature engineering and feature screening.
It reduces time and manpower consumption, improves the efficiency of target model generation, and avoids complex processing of the features of the logistic regression model.
Smart Images

Figure CN112561082B
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, specifically to the field of artificial intelligence technology such as machine learning and big data processing, and more particularly to a method, apparatus, device and storage medium for generating a model. Background Art
[0002] In recent years, as the most basic algorithm of machine learning, the logistic regression (LR) model plays an important role in the process of establishing the target model.
[0003] At present, LR selects input features for the target model based on feature engineering and feature screening, and then generates the target model based on the input features training. Summary of the invention
[0004] The embodiments of the present application provide a method, apparatus, device and storage medium for generating a model.
[0005] In a first aspect, an embodiment of the present application proposes a method for generating a model, including: obtaining sample resource characteristics and sample labels corresponding to the sample resource characteristics; determining a first filtering factor based on the sample resource characteristics and the sample labels, and determining a first resource characteristic from the sample resource characteristics based on the first filtering factor; determining a second filtering factor based on parameters associated with a pre-trained logistic regression LR model, and determining a second resource characteristic from the first resource characteristic based on the second filtering factor, and obtaining characteristics of a target model based on the second resource characteristic; using the characteristics of the target model as the input of the target model, using the sample labels corresponding to the characteristics of the target model as the output of the target model, training a machine learning model, and obtaining a target model.
[0006] In the second aspect, an embodiment of the present application proposes a device for generating a model, comprising: a sample acquisition module, configured to acquire sample resource characteristics and sample labels corresponding to the sample resource characteristics; a first determination module, configured to determine a first filtering factor based on the sample resource characteristics and the sample labels, and to determine a first resource characteristic from the sample resource characteristics based on the first filtering factor; a second determination module, configured to determine a second filtering factor based on parameters associated with a pre-trained logistic regression LR model, and to determine a second resource characteristic from the first resource characteristic based on the second filtering factor, and to obtain characteristics of a target model based on the second resource characteristic; a model training module, configured to use the characteristics of the target model as the input of the target model, and use the sample labels corresponding to the characteristics of the target model as the output of the target model, to train a machine learning model, and to obtain a target model.
[0007] In a third aspect, an embodiment of the present application proposes an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described in the first aspect.
[0008] In a fourth aspect, an embodiment of the present application proposes a non-transitory computer-readable storage medium storing computer instructions, where the computer instructions are used to enable a computer to execute the method described in the first aspect.
[0009] In a fifth aspect, an embodiment of the present application proposes a computer program product, including a computer program, which implements the method described in the first aspect when executed by a processor.
[0010] The method, apparatus, device and storage medium for generating a model provided in the embodiment of the present application first obtain sample resource features and sample labels corresponding to the sample resource features; then determine a first screening factor based on the sample resource features and the sample labels, and determine a first resource feature from the sample resource features based on the first screening factor; then determine a second screening factor based on the parameters associated with the pre-trained logistic regression LR model, and determine a second resource feature from the first resource feature based on the second screening factor, and obtain the features of the target model based on the second resource feature; finally, use the features of the target model as the input of the target model, use the sample labels corresponding to the features of the target model as the output of the target model, train the machine learning model, and obtain the target model. This avoids the need to rely on a large amount of feature engineering, feature screening and model interpretability when determining the input features of the target model based on the LR model, thereby reducing time and manpower consumption.
[0011] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Other features, purposes and advantages of the present application will become more apparent by reading the detailed description of the non-limiting embodiments made with reference to the following drawings. The drawings are used to better understand the present solution and do not constitute a limitation of the present application. Among them:
[0013] Figure 1 is an exemplary system architecture in which the present application may be applied;
[0014] Figure 2 is a flowchart of an embodiment of a method for generating a model according to the present application;
[0015] Figure 3 is a flowchart of another embodiment of a method for generating a model according to the present application;
[0016] Figure 4 is a flowchart of another embodiment of a method for generating a model according to the present application;
[0017] Figure 5 It is a scene graph that can implement the method of generating a model in the embodiment of the present application;
[0018] Figure 6 is a structural schematic diagram of an embodiment of a device for generating a model according to the present application;
[0019] Figure 7 It is a block diagram of an electronic device used to implement the method for generating a model in an embodiment of the present application. DETAILED DESCRIPTION
[0020] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application 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 can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0021] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0022] Figure 1 An exemplary system architecture 100 is shown to which an embodiment of the method for generating a model or the apparatus for generating a model of the present application can be applied.
[0023] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0024] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various applications can be installed on terminal devices 101, 102, 103, such as various client applications, multi-party interaction applications, artificial intelligence applications, etc.
[0025] The terminal devices 101, 102, 103 may be hardware or software. When the terminal devices 101, 102, 103 are hardware, they may be various electronic devices that support document processing applications, including but not limited to smart terminals, tablet computers, laptop computers, desktop computers, etc. When the terminal devices 101, 102, 103 are software, they may be installed in the electronic devices listed above. They may be implemented as multiple software or software modules for providing distributed services, or as a single software or software module. No specific limitation is made here.
[0026] The server 105 may be a server that provides various services, such as a background server that provides support for the terminal devices 101, 102, and 103. The background server may analyze and process the received request and other data, and feed back the processing results to the terminal device.
[0027] It should be noted that the server can be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of multiple servers, or it can be implemented as a single server. When the server is software, it can be implemented as multiple software or software modules for providing distributed services, or it can be implemented as a single software or software module. No specific limitation is made here.
[0028] In practice, the method for training a label generation model or the method for determining a business label provided in the embodiments of the present application can be executed by the terminal device 101, 102, 103 or the server 105, and the device for training a label generation model or the device for determining a business label can also be set in the terminal device 101, 102, 103 or the server 105.
[0029] It should be understood that Figure 1 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.
[0030] Continue to refer Figure 2 , which shows a process 200 of an embodiment of a method for generating a model according to the present application. The method for generating a model comprises the following steps:
[0031] Step 201: Obtain sample resource features and sample labels corresponding to the sample resource features.
[0032] In this embodiment, the execution subject of the method for generating a model (eg Figure 1 The server 105 shown in the figure) can be accessed from a local or terminal device (e.g. Figure 1The terminal devices 101, 102, 103 shown in the figure obtain multiple sample resource features and multiple sample tags corresponding to the sample resource features, and each sample resource feature corresponds to a sample tag. The above-mentioned sample resource features can be resource-related features. For example: resource exchange frequency features, transaction resource features; resource utilization rate (number of times a given resource is used / total number of times a given resource is received); payment features extracted through payment information, such as payment amount features, payment frequency, etc.; user preference features for resources, user operation resource features (click, follow, purchase, etc.), user information features (age, gender, etc.).
[0033] The above sample labels can be obtained by manual labeling, rule labeling, and cluster labeling. Among them, rule labeling is: by setting some filtering conditions (rules), labeling part of the data to obtain a training set. Cluster labeling is: after feature engineering, different categories of labels are obtained by clustering.
[0034] It should be noted that this embodiment can be applied to "two-classification" application scenarios. For example, for loans, the user's income, deposits, occupation, age and other factors can be analyzed to determine whether to borrow; for emails, the email content can be used to determine whether the email is spam. For product or advertisement recommendation, products or advertisements can be recommended to users based on the user's preference for the product or advertisement, the user's operation on the product or advertisement, user information and the like.
[0035] Step 202: determine a first screening factor according to the sample resource feature and the sample tag, and determine a first resource feature from the sample resource features according to the first screening factor.
[0036] In this embodiment, the execution subject may match the corresponding screening factor according to the sample resource feature and / or the sample label; or may determine the first screening factor by training a model using the sample resource feature and the sample label and by using the associated parameters involved in the model process. The first screening factor may be used to screen the first resource feature from multiple sample resource features.
[0037] Before matching corresponding screening factors according to sample resource characteristics and / or sample labels, the method for generating a model may further include: pre-establishing screening factors having corresponding relationships with sample resource characteristics and / or sample labels.
[0038] In this embodiment, the above-mentioned execution entity can filter out the first resource feature from multiple sample resource features according to the first filtering factor; or, the above-mentioned execution entity can sort the multiple sample resource features, and then filter out the first resource feature from a preset number of sample resource features in the sorted multiple sample resource features.
[0039] Step 203, determining a second screening factor according to parameters associated with a pre-trained logistic regression LR model; and, based on the second screening factor, determining a second resource feature from the first resource feature, and obtaining features of a target model based on the second resource feature.
[0040] In this embodiment, the execution subject may determine the second screening factor according to the parameters associated with the pre-trained logistic regression LR model; and, based on the second screening factor, determine the second resource feature from the first resource feature, and obtain the feature of the target model based on the second resource feature. The parameters associated with the pre-trained LR model may be parameters involved in the pre-training LR model process, such as variable coefficients, information value, model stability evaluation index, and variance inflation factor.
[0041] In this embodiment, the execution subject may filter out the second resource feature from the first resource feature according to the second filter factor. The second filter factor may be used to filter out the second resource feature from the first resource feature.
[0042] In this embodiment, the above-mentioned execution entity can use the second resource feature as the feature of the target model; or, process the second resource feature to obtain the processed resource feature; then, use the processed resource feature as the feature of the target model, for example, bin the second resource feature to obtain the binned feature.
[0043] Step 204, using the characteristics of the target model as the input of the target model, using the sample labels corresponding to the characteristics of the target model as the output of the target model, training the machine learning model, and obtaining the target model.
[0044] In this embodiment, after obtaining the characteristics of the target model and the sample labels corresponding to the characteristics of the target model, the above-mentioned execution subject can use the characteristics of the target model and the sample labels corresponding to the characteristics of the target model to train the machine learning model to obtain the target model. During training, the execution subject can use the characteristics of the target model as the input of the target model, and use the sample labels corresponding to the characteristics of the target model as the expected output to obtain the target model. The above-mentioned machine learning model can be a probability model, classification model or other classifier in the existing technology or future development technology. For example, the machine learning model can include any of the following: decision tree model (XGBoost), logistic regression model (LR), deep neural network model (DNN), gradient boosting decision tree model (Gradient Boosting DecisionTree, GBDT).
[0045] The method for generating a model provided in an embodiment of the present application first obtains sample resource features and sample labels corresponding to the sample resource features; then, according to the sample resource features and the sample labels, a first screening factor is determined, and according to the first screening factor, a first resource feature is determined from the sample resource features; then, according to the parameters associated with the pre-trained logistic regression LR model, a second screening factor is determined, and based on the second screening factor, a second resource feature is determined from the first resource feature, and the features of the target model are obtained based on the second resource feature; finally, the features of the target model are used as the input of the target model, and the sample labels corresponding to the features of the target model are used as the output of the target model, and the machine learning model is trained to obtain the target model. This avoids the need to rely on a large amount of feature engineering, feature screening, and model interpretability when determining the input features of the target model according to the LR model, thereby reducing time and manpower consumption.
[0046] In some optional implementations of this embodiment, a first screening factor is determined based on sample resource characteristics and sample labels, including: training a decision tree XGBoost model based on the sample resource characteristics and sample labels corresponding to the sample resource characteristics to obtain an XGBoost model; and determining the first screening factor based on parameters associated with the XGBoost model.
[0047] In this implementation, the execution subject may determine the first screening factor according to the sample resource characteristics and the sample labels in the process of training the decision tree (XGBoost) model. The parameters associated with the XGBoost model may be parameters involved in the process of training the XGBoost model, such as coverage, correlation coefficient, etc.
[0048] In this implementation, after obtaining the sample resource features and the sample labels corresponding to the sample resource features, the execution subject can train the XGBoost model using the sample resource features and the sample labels corresponding to the sample resource features to obtain the XGBoost model. During training, the execution subject can use the sample resource features as the input of the XGBoost model, and use the sample labels corresponding to the input sample resource features as the expected output to obtain the XGBoost model.
[0049] In this implementation, the first screening factor is determined through the sample resource characteristics and the associated parameters involved in the training of the XGBoost model.
[0050] In some optional implementations of this embodiment, the parameters associated with the pre-trained XGBoost model include: coverage and correlation coefficient; and determining the first filtering factor based on the parameters associated with the pre-trained XGBoost model includes: determining the first filtering factor according to the coverage and / or correlation coefficient.
[0051] In this implementation, the execution subject may determine the first screening factor based on coverage and correlation coefficient; or, the execution subject may determine the first screening factor based on coverage; or, the execution subject may determine the first screening factor based on correlation coefficient. The coverage = (number of samples - number of samples with missing features) / number of samples, where the number of samples may be the number of all samples involved in the training of the XGBoost model, and the number of samples with missing features may be the number of samples with missing features in all samples. The correlation may be the correlation coefficient between the sample resource feature and the corresponding sample label.
[0052] It should be noted that when determining the first screening factor based on the coverage and the correlation coefficient, the user can also set the weights corresponding to the coverage and the correlation coefficient according to the feature screening requirements, and then perform weighted summation to obtain the first screening factor.
[0053] In this implementation, the first screening factor is determined by coverage and / or correlation coefficient (cor).
[0054] In some optional implementations of this embodiment, the method for generating a model also includes: sorting the sample resource features to obtain sorted sample resource features; determining the first resource feature from the sample resource features, including: determining the first resource feature from a preset number of sample resource features in the sorted sample resource features according to a first screening factor.
[0055] In this implementation, the execution subject may also sort the multiple sample resource features, for example, by feature importance, before determining the first resource feature from the multiple sample resource features; then, determine the first resource feature from a preset number of sample resource features of the sorted multiple sample resource features. The first resource feature may be a portion of the sample resource features selected from the sample resource features based on the first screening factor. The preset number of sample resource features may be set according to the performance of the target model or may be set by the user. For example, the sample resource features ranked in the top 10.
[0056] In this implementation, the first resource feature may be determined from a preset number of sample resource features among the sorted sample resource features based on the first screening factor.
[0057] In some optional implementations of this embodiment, sorting the sample resource features to obtain sorted sample resource features includes: sorting the sample resource features according to feature importance of the sample resource features to obtain sorted sample resource features.
[0058] In this implementation, the feature importance of each of the multiple sample resource features may be calculated first, and then the multiple sample resource features may be ranked based on the feature importance of each sample resource feature. The feature importance may be calculated by weight*gain.
[0059] In a specific example, according to weight*gain>10, coverage>5%, and cor<0.7, the first resource feature is screened out from multiple sample resource features.
[0060] In this implementation, the sample resource features are sorted according to their feature importance, and a preset number of sample resource features among the sorted sample resource features are used as candidate features for the first resource feature.
[0061] In some optional implementations of this embodiment, before determining the second screening factor based on the parameters associated with the pre-trained logistic regression LR model, the method for generating a model also includes: training the logistic regression LR model based on the first resource feature and the sample label corresponding to the first resource feature to obtain the LR model.
[0062] In this implementation, after obtaining the first resource feature and the sample label corresponding to the first resource feature, the execution subject can train the LR model using the first resource feature and the sample label corresponding to the first resource feature to obtain the LR model. During training, the execution subject can use the first resource feature as the input of the LR model, and use the sample label corresponding to the first resource feature as the expected output to obtain the LR model.
[0063] In this implementation, the LR model can be obtained by training the first resource feature and the sample label corresponding to the first resource feature.
[0064] In some optional implementations of this embodiment, the parameters associated with the LR model include at least one of the following: coefficient of variation (coef), P value, information value (IV), population stability index (PSI), and variance inflation factor (VIF), wherein the P value is a parameter for determining the test result of the pre-trained LR model.
[0065] In this implementation, the execution entity may determine the second screening factor based on the parameters associated with the LR model, including at least one of the following: coefficient of variation (coef), P value, information value (IV), population stability index (PSI), variance inflation factor (VIF), wherein the P value is a parameter for determining the test result of the pre-trained LR model. The PSI may be used to measure the distribution difference between the scores of the test samples and the model development samples. The VIF may be used to measure the severity of complex (multi) collinearity in the multivariate linear LR model. The IV may be used to measure the predictive power of the independent variable; the value screening range of the IV may be based on experience or may be set by the user as required.
[0066] In a specific example, the second screening factor is determined according to coef>0, P value<0.05, IV>0.5, PSI<0.05, and VIF<5.
[0067] In this implementation, the second screening factor may be determined based on parameters associated with the LR model.
[0068] In some optional implementations of this embodiment, the method for generating a model further includes: adjusting the hyperparameters of the target model according to one of the following items: grid search, random search, Bayesian optimization.
[0069] The above-mentioned hyperparameters may be parameters set before training the target model based on the machine learning model. The hyperparameters are not parameters obtained during the process of training the target model based on the machine learning model.
[0070] In this implementation, the hyperparameters are optimized through grid search, random search or Bayesian optimization, and a set of optimal hyperparameters are selected to improve the iteration efficiency of the target model.
[0071] In some optional implementations of this embodiment, the sample resource feature includes one of the following items: a sample image feature, a sample text feature, and a sample voice feature.
[0072] In this implementation, the sample resource feature may include any one of a sample image feature, a sample text feature, or a sample voice feature. The sample image feature may be a sample resource feature presented in the form of an image. The sample text feature may be a sample resource feature presented in the form of a text. The sample voice feature may be a sample resource feature presented in the form of a voice.
[0073] In this implementation, corresponding sample resource features can be obtained from the perspectives of image, text, voice, etc., so that the obtained target model can accurately predict sample image features, sample text features, and sample voice features.
[0074] Please refer to Figure 3 , which shows a process 300 of another embodiment of a method for generating a model according to the present application. The method for generating a model comprises the following steps:
[0075] Step 301: Obtain sample resource features and sample labels corresponding to the sample resource features.
[0076] In this embodiment, the specific operation of step 301 is already Figure 2 In the illustrated embodiment, step 201 is introduced in detail and will not be repeated here.
[0077] Step 302: Train the decision tree XGBoost model based on the sample resource features and the sample labels corresponding to the sample resource features to obtain an XGBoost model.
[0078] In this implementation, the execution subject of the method for generating the model (eg Figure 1 After obtaining the sample resource features and the sample labels corresponding to the sample resource features, the server 105 in the example can train the XGBoost model using the sample resource features and the sample labels corresponding to the sample resource features to obtain the XGBoost model. During training, the execution subject can use the sample resource features as the input of the XGBoost model, and use the sample labels corresponding to the input sample resource features as the expected output to obtain the XGBoost model.
[0079] Step 303: determine a first screening factor based on the parameters associated with the XGBoost model; and determine a first resource feature from the sample resource features according to the first screening factor.
[0080] In this embodiment, the specific operation of step 303 is already Figure 2 Step 202 is described in detail in the illustrated embodiment and will not be described again here.
[0081] Step 304: Train the logistic regression (LR) model based on the first resource feature and the sample label corresponding to the first resource feature to obtain the LR model.
[0082] In this embodiment, after obtaining the first resource feature and the sample label corresponding to the first resource feature, the execution subject can train the LR model using the first resource feature and the sample label corresponding to the first resource feature to obtain the LR model. During training, the execution subject can use the first resource feature as the input of the LR model, and use the sample label corresponding to the first resource feature as the expected output to obtain the LR model.
[0083] Step 305, determining a second screening factor based on the parameters associated with the LR model; and determining a second resource feature from the first resource feature based on the second screening factor, and obtaining the feature of the target model based on the second resource feature.
[0084] In this embodiment, the specific operation of step 305 is already Figure 2 Step 203 is described in detail in the illustrated embodiment and will not be described again here.
[0085] Step 306, taking the characteristics of the target model as the input of the target model, taking the sample labels corresponding to the characteristics of the target model as the output of the target model, training the machine learning, and obtaining the target model.
[0086] In this embodiment, the specific operation of step 306 is already in Figure 2 Step 204 is described in detail in the illustrated embodiment and will not be described again here.
[0087] from Figure 3 It can be seen that Figure 2 Compared with the corresponding embodiment, the process 300 of the method for generating a model in this embodiment highlights the steps of determining the first screening factor and the second screening factor. Therefore, the solution described in this embodiment improves the accuracy of the features of the target model, thereby improving the accuracy of the target model.
[0088] In some optional implementations of this embodiment, the parameters associated with the pre-trained XGBoost model include: coverage and correlation coefficient; and determining the first filtering factor based on the parameters associated with the pre-trained XGBoost model includes: determining the first filtering factor according to the coverage and / or correlation coefficient.
[0089] In this implementation, the execution subject may determine the first screening factor based on coverage and correlation coefficient; or, the execution subject may determine the first screening factor based on coverage; or, the execution subject may determine the first screening factor based on correlation coefficient. The coverage = (number of samples - number of samples with missing features) / number of samples, where the number of samples may be the number of all samples involved in the training of the XGBoost model, and the number of samples with missing features may be the number of samples with missing features in all samples. The correlation may be the correlation coefficient between the sample resource feature and the corresponding sample label.
[0090] It should be noted that when determining the first screening factor based on the coverage and the correlation coefficient, the user can also set the weights corresponding to the coverage and the correlation coefficient according to the feature screening requirements, and then perform weighted summation to obtain the first screening factor.
[0091] In this implementation, the first screening factor is determined by coverage and / or correlation coefficient (cor).
[0092] In some optional implementations of this embodiment, the parameters associated with the LR model include at least one of the following: coefficient of variation (coef), P value, information value (IV), population stability index (PSI), and variance inflation factor (VIF), wherein the P value is a parameter for determining the test result of the pre-trained LR model.
[0093] In this implementation, the execution entity may determine the second screening factor based on the parameters associated with the LR model, including at least one of the following: coefficient of variation (coef), P value, information value (IV), population stability index (PSI), variance inflation factor (VIF), wherein the P value is a parameter for determining the test result of the pre-trained LR model. The PSI may be used to measure the distribution difference between the scores of the test samples and the model development samples. The VIF may be used to measure the severity of complex (multi) collinearity in the multivariate linear LR model. The IV may be used to measure the predictive power of the independent variable; the value screening range of the IV may be based on experience or may be set by the user as required.
[0094] In a specific example, the second screening factor is determined according to coef sign>0, P value<0.05, IV>0.5, PSI<0.05, VIF<5. The value ranges of the coef sign, P value, IV, PSI and VIF can be set by the recognition accuracy of the target model to be trained.
[0095] In this implementation, the second screening factor may be determined using parameters associated with the LR model.
[0096] Please refer to Figure 4 , which shows a process 400 of another embodiment of a method for generating a model according to the present application. The method for generating a model comprises the following steps:
[0097] Step 401: Obtain sample resource features and sample labels corresponding to the sample resource features.
[0098] Step 402: Train the decision tree XGBoost model based on the sample resource features and the sample labels corresponding to the sample resource features to obtain an XGBoost model.
[0099] Step 403, determining a first screening factor based on the parameters associated with the XGBoost model; and determining a first resource feature from the sample resource features according to the first screening factor.
[0100] Step 404: Train the logistic regression (LR) model based on the first resource feature and the sample label corresponding to the first resource feature to obtain the LR model.
[0101] Step 405: determine a second screening factor based on the parameters associated with the LR model; and determine a second resource feature from the first resource features based on the second screening factor.
[0102] In this embodiment, the specific operations of steps 401-405 are already Figure 3 In the illustrated embodiment, steps 301 - 305 are described in detail and will not be repeated here.
[0103] Step 406: bin the second resource feature to obtain binned resource features, and determine the evidence weights corresponding to the binned resource features.
[0104] In this embodiment, the execution subject of the method for generating a model (eg Figure 1 The server 105 shown in the figure can bin the second resource feature to obtain binned resource features; then, the evidence weight corresponding to each binned resource feature is calculated. The above binning can include one of the following items: equal frequency binning, equal distance binning, and chi-square binning.
[0105] The weight of evidence (WOE) can be a method to measure the difference between the distribution of normal samples (Good) and bad samples (abnormal samples) (Bad). The WOE can be determined by the following formula:
[0106] WOE=ln(Distr Good / Distr Bad)
[0107] Among them, Distr Good is a normal sample, and Distr Bad is a bad sample.
[0108] It should be noted that in the process of building the model, the continuous variables (i.e., the second resource characteristics) need to be discretized; then, the model is trained through the discretized characteristics to obtain a trained model. The performance of the trained model will be more stable and the risk of overfitting of the trained model will be reduced.
[0109] Step 407 , in response to the fact that the variation rule of the evidence weights corresponding to all the binned resource features conforms to the preset rule, the binned resource features are used as the features of the target model.
[0110] In this embodiment, when the change rule of the evidence weight corresponding to all binned resource features meets the preset rule, the execution subject can use the binned resource features as the features of the target model. The change rule can be that the evidence weight corresponding to all binned features increases, decreases, increases first and then decreases, decreases first and then increases, increases first and then decreases and then increases, decreases first and then increases and then decreases, etc.
[0111] Step 408, using the characteristics of the target model as the input of the target model, using the sample labels corresponding to the characteristics of the target model as the output of the target model, training the machine learning, and obtaining the target model.
[0112] In this embodiment, the specific operation of step 408 is already Figure 3 Step 306 is described in detail in the illustrated embodiment and will not be described again here.
[0113] from Figure 4 It can be seen that Figure 3 Compared with the corresponding embodiment, the process 400 of the method for generating a model in this embodiment highlights the step of binning the second resource feature. Therefore, the solution described in this embodiment improves the monotonicity of the second resource feature, thereby making the performance of the target model more stable and reducing the risk of overfitting of the target model.
[0114] In some optional implementations of the present embodiment, the method for generating a model also includes: in response to the fact that the changing pattern of the evidence weights corresponding to all the binned resource features does not conform to a preset pattern, merging the binned resource features and calculating the evidence weights of the merged resource features; in response to the fact that the changing pattern of the evidence weights corresponding to all the binned resource features conforms to a preset pattern, taking the binned resource features as features of the target model, including: in response to the fact that the changing pattern of the evidence weights of the merged resource features conforms to a preset pattern, taking the merged resource features as features of the target model.
[0115] In this implementation, when the changing pattern of the evidence weights corresponding to all the binned resource features does not conform to the preset pattern, the binned resource features can be merged; then, it is judged whether the evidence weights corresponding to the merged resource features conform to the preset pattern. If they still do not conform to the preset pattern, it is necessary to merge the binned resource features again, and judge again whether the evidence weights corresponding to the merged resource features conform to the preset pattern, until the merged resource features are used as the features of the target model; otherwise, the binned resource features are merged again.
[0116] In a specific example, binning the second resource feature may include the following steps: (1) binning with equal frequency, for example, into 5-8 bins. (2) Calculating the WOE of each bin. (3) If the WOE value conforms to a preset rule, for example, increasing, feature encoding is completed, and the resource feature of each bin is used as the feature of the target model. (4) If the WOE value does not conform to the preset rule, bin merging is performed, for example, merging the age groups 15-24 and 24-30 into 15-30, and then executing (2) and (3).
[0117] In this implementation, the features of the target model can be selected by binning the second resource features and calculating the evidence weights corresponding to the binned resource features, which can improve the monotonicity of the features of the target model.
[0118] In some optional implementations of this embodiment, the preset rule includes one of the following items: increasing weight of evidence, decreasing weight of evidence, increasing weight of evidence first and then decreasing, or decreasing weight of evidence first and then increasing.
[0119] In this implementation, the preset rule includes any one of increasing evidence weight, decreasing evidence weight, increasing evidence weight first and then decreasing evidence weight, and decreasing evidence weight first and then increasing evidence weight. The above-mentioned increasing evidence weight may be that the evidence weights corresponding to all binned resource features are increased in sequence.
[0120] In this implementation, the features of the target model can be selected according to the above-mentioned preset rules, and the uniqueness of the features of the target model is improved.
[0121] For ease of understanding, the following provides an application scenario in which the method for generating a model in the embodiment of the present application can be implemented. Figure 5 As shown, the server 502 obtains sample resource features and sample labels corresponding to the sample resource features from the terminal device 501 (step 503); then, the server 502 determines a first screening factor based on the sample resource features and the sample labels, and determines a first resource feature from the sample resource features based on the first screening factor (step 504); then, the server 502 determines a second screening factor based on parameters associated with a pre-trained logistic regression LR model, and determines a second resource feature from the first resource feature based on the second screening factor, and obtains the features of the target model based on the second resource feature (step 505); finally, the server 502 uses the features of the target model as the input of the target model, and uses the sample labels corresponding to the features of the target model as the output of the target model, trains the machine learning model, and obtains the target model (step 506).
[0122] Further references Figure 6 As an implementation of the methods shown in the above figures, the present application provides an embodiment of a device for generating a model, and the device embodiment is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0123] like Figure 6 As shown, the device 600 for generating a model in this embodiment may include: a sample acquisition module 601, a first determination module 602, a second determination module 603 and a model training module 604. The sample acquisition module 601 is configured to acquire sample resource features and sample labels corresponding to the sample resource features; the first determination module 602 is configured to determine a first screening factor according to the sample resource features and the sample labels, and to determine a first resource feature from the sample resource features according to the first screening factor; the second determination module 603 is configured to determine a second screening factor according to a parameter associated with a pre-trained logistic regression LR model, and to determine a second resource feature from the first resource feature based on the second screening factor, and to obtain the features of the target model based on the second resource feature; the model training module 604 is configured to use the features of the target model as the input of the target model, and use the sample labels corresponding to the features of the target model as the output of the target model, to train the machine learning model, and to obtain the target model.
[0124] In the device 600 for generating a model in this embodiment, the specific processing of the sample acquisition module 601, the first determination module 602, the second determination module 603 and the model training module 604 and the technical effects thereof can be referred to respectively. Figure 2 The relevant descriptions of steps 201 - 204 in the corresponding embodiment are not repeated here.
[0125] In some optional implementations of this embodiment, the first determination module 602 includes: a model acquisition unit (not shown in the figure), configured to train the decision tree XGBoost model based on sample resource characteristics and sample labels corresponding to the sample resource characteristics to obtain the XGBoost model; a factor determination unit (not shown in the figure), configured to determine the first screening factor based on parameters associated with the XGBoost model.
[0126] In some optional implementations of this embodiment, the parameters associated with the pre-trained XGBoost model include: coverage and correlation coefficient; and the factor determination unit is further configured to: determine the first screening factor based on the coverage and / or correlation coefficient.
[0127] In some optional implementations of this embodiment, the device for generating the model also includes: a feature sorting module (not shown in the figure), configured to sort the sample resource features to obtain sorted sample resource features; a first determination module 602, further configured to: determine the first resource feature from a preset number of sample resource features in the sorted sample resource features according to the first screening factor.
[0128] In some optional implementations of this embodiment, the feature sorting module is further configured to sort the sample resource features according to the feature importance of the sample resource features to obtain sorted sample resource features.
[0129] In some optional implementations of this embodiment, before determining the second screening factor based on the parameters associated with the pre-trained logistic regression LR model, the device for generating the model also includes: a model acquisition module (not shown in the figure), which is configured to train the logistic regression LR model based on the first resource feature and the sample label corresponding to the first resource feature to obtain the LR model.
[0130] In some optional implementations of this embodiment, the parameters associated with the LR model include at least one of the following: variable coefficient, P value, information value, model stability evaluation index, variance inflation coefficient, wherein the P value is a parameter for determining the test results of the pre-trained LR model.
[0131] In some optional implementations of the present embodiment, the device for generating a model also includes: a first processing module (not shown in the figure), configured to bin the second resource feature, obtain the binned resource feature, and determine the evidence weight corresponding to the binned resource feature; a model as a module (not shown in the figure), configured to respond to the fact that the change pattern of the evidence weight corresponding to all the binned resource features conforms to a preset pattern, and use the binned resource features as the features of the target model.
[0132] In some optional implementations of the present embodiment, the device for generating a model also includes: a second processing module (not shown in the figure), configured to merge the binned resource features in response to the fact that the change pattern of the evidence weights corresponding to all the binned resource features does not conform to a preset pattern, and calculate the evidence weights of the merged resource features; the first as module is further configured to: in response to the fact that the change pattern of the evidence weights of the merged resource features conforms to a preset pattern, use the merged resource features as the features of the target model.
[0133] In some optional implementations of this embodiment, the preset rule includes one of the following items: increasing weight of evidence, decreasing weight of evidence, increasing weight of evidence first and then decreasing, or decreasing weight of evidence first and then increasing.
[0134] In some optional implementations of this embodiment, the device for generating a model also includes: a parameter adjustment module (not shown in the figure), which is configured to adjust the hyperparameters of the target model according to one of the following items: grid search, random search, Bayesian optimization.
[0135] In some optional implementations of this embodiment, the sample resource feature includes one of the following items: a sample image feature, a sample text feature, and a sample voice feature.
[0136] According to an embodiment of the present application, the present application also provides an electronic device, a readable storage medium and a computer program product.
[0137] Figure 7 A schematic block diagram of an example electronic device 700 that can be used to implement an embodiment of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present application described and / or required herein.
[0138] like Figure 7As shown, the device 700 includes a computing unit 701, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 702 or a computer program loaded from a storage unit 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the device 700 can also be stored. The computing unit 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0139] A number of components in the device 700 are connected to the I / O interface 705, including: an input unit 706, such as a keyboard, a mouse, etc.; an output unit 707, such as various types of displays, speakers, etc.; a storage unit 708, such as a disk, an optical disk, etc.; and a communication unit 709, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 709 allows the device 700 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0140] The computing unit 701 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 701 performs the various methods and processes described above, such as a method for generating a model. For example, in some embodiments, the method for generating a model may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 708. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 700 via ROM 702 and / or communication unit 709. When the computer program is loaded into RAM 703 and executed by the computing unit 701, one or more steps of the method for generating a model described above may be performed. Alternatively, in other embodiments, the computing unit 701 may be configured to perform a method for generating a model in any other appropriate manner (e.g., by means of firmware).
[0141] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0142] The program code for implementing the method of the present application can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, implements the functions / operations specified in the flow chart and / or block diagram. The program code can be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0143] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, 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 foregoing.
[0144] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0145] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0146] A computer system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.
[0147] Artificial intelligence is a discipline that studies computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, planning, etc.). It includes both hardware-level and software-level technologies. Artificial intelligence hardware technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, and big data processing; artificial intelligence software technologies mainly include computer vision technology, speech recognition technology, natural speech processing technology, as well as machine learning / deep learning, big data processing technology, knowledge graph technology, and other major directions.
[0148] According to the technical solution of the present application, firstly, sample resource features and sample labels corresponding to the sample resource features are obtained; then, a first screening factor is determined according to the sample resource features and the sample labels, and a first resource feature is determined from the sample resource features according to the first screening factor; then, a second screening factor is determined according to the parameters associated with the pre-trained logistic regression LR model, and a second resource feature is determined from the first resource feature based on the second screening factor, and the features of the target model are obtained based on the second resource feature; finally, the features of the target model are used as the input of the target model, and the sample labels corresponding to the features of the target model are used as the output of the target model, and the machine learning model is trained to obtain the target model. This avoids the need to rely on a large amount of feature engineering, feature screening, and model interpretability when determining the input features of the target model according to the LR model, thereby reducing time and manpower consumption.
[0149] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution disclosed in this application can be achieved, and this document is not limited here.
[0150] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.
Claims
1. A method for generating a model, comprising: Based on the acquired sample resource features and the sample labels corresponding to the sample resource features, the decision tree XGBoost model is trained to obtain the XGBoost model, wherein the sample resource features include one of the following items: sample image features, sample text features, and sample voice features; Determining the feature importance of the sample resource features, and sorting the sample resource features according to the feature importance to obtain sorted sample resource features; Determining a first screening factor based on a parameter associated with the XGBoost model, and determining a first resource feature from a preset number of sample resource features that are ranked first according to the first screening factor; Determining a second screening factor according to a parameter associated with a pre-trained logistic regression LR model, determining a second resource feature from the first resource features based on the second screening factor, and obtaining features of a target model based on the second resource feature; The characteristics of the target model are used as the input of the target model, and the sample labels corresponding to the characteristics of the target model are used as the output of the target model to train the machine learning model to obtain the target model.
2. The method according to claim 1, wherein: The parameters associated with the pre-trained XGBoost model include: coverage and correlation coefficient; and Determining the first screening factor based on the parameters associated with the pre-trained XGBoost model includes: The first screening factor is determined according to the coverage and / or the correlation coefficient.
3. The method according to claim 1, wherein: The determining the feature importance of the sample resource feature includes: Determining the feature importance of the sample resource feature based on the weight and gain of the sample resource feature; The sample resource features are sorted according to their feature importance to obtain sorted sample resource features.
4. The method according to claim 1, wherein: Before determining the second screening factor according to the parameters associated with the pre-trained logistic regression LR model, the method further includes: A logistic regression (LR) model is trained based on the first resource feature and a sample label corresponding to the first resource feature to obtain an LR model.
5. The method according to claim 1, wherein: The parameters associated with the LR model include at least one of the following: Variable coefficient, P value, information value, model stability evaluation index, variance inflation coefficient, wherein the P value is a parameter for determining the test result of the pre-trained LR model.
6. The method according to claim 1, further comprising: Binning the second resource feature to obtain binned resource features, and determining the evidence weights corresponding to the binned resource features; In response to the fact that the variation rule of the evidence weights corresponding to all the binned resource features conforms to a preset rule, the binned resource features are used as the features of the target model.
7. The method according to claim 6, further comprising: In response to the fact that the change rule of the evidence weights corresponding to all the binned resource features does not conform to the preset rule, the binned resource features are merged, and the evidence weights of the merged resource features are calculated; In response to the fact that the change rule of the evidence weights corresponding to all the binned resource features conforms to the preset rule, the binned resource features are used as the features of the target model, including: In response to the fact that the variation rule of the evidence weight of the combined resource feature complies with the preset rule, the combined resource feature is used as the feature of the target model.
8. The method according to claim 6 or 7, wherein: The preset rule includes one of the following items: The weight of evidence increases, the weight of evidence decreases, the weight of evidence increases first and then decreases, and the weight of evidence decreases first and then increases.
9. The method according to claim 1, further comprising: Tune hyperparameters of the target model according to one of the following: grid search, random search, Bayesian optimization.
10. A device for generating a model, comprising: A sample acquisition module is configured to train a decision tree XGBoost model based on the acquired sample resource features and sample labels corresponding to the sample resource features to obtain an XGBoost model, wherein the sample resource features include one of the following items: sample image features, sample text features, and sample voice features; a feature sorting module configured to determine the feature importance of the sample resource features, sort the sample resource features according to the feature importance, and obtain sorted sample resource features; a first determination module configured to determine a first screening factor based on a parameter associated with the XGBoost model, and determine a first resource feature from a preset number of sample resource features that are sorted first according to the first screening factor; The second determination module is configured to determine a second screening factor according to parameters associated with a pre-trained logistic regression (LR) model, and to determine a second resource feature from the first resource feature based on the second screening factor, and to obtain the features of the target model based on the second resource feature; the model training module is configured to use the features of the target model as the input of the target model, and use the sample labels corresponding to the features of the target model as the output of the target model, to train the machine learning model and obtain the target model.
11. The device according to claim 10, wherein: The parameters associated with the pre-trained XGBoost model include: coverage and correlation coefficient; and The factor determination unit is further configured to: The first screening factor is determined according to the coverage and / or the correlation coefficient.
12. The device according to claim 10, wherein: The feature sorting module is further configured to: Based on the weight and gain of the sample resource feature, the feature importance of the sample resource feature is determined.
13. The device according to claim 10, wherein: Before determining the second screening factor according to the parameters associated with the pre-trained logistic regression LR model, the method further includes: The model acquisition module is configured to train a logistic regression (LR) model based on the first resource feature and a sample label corresponding to the first resource feature to obtain an LR model.
14. The device according to claim 13, wherein: The parameters associated with the LR model include at least one of the following: Variable coefficient, P value, information value, model stability evaluation index, variance inflation coefficient, wherein the P value is a parameter for determining the test result of the pre-trained LR model.
15. The apparatus according to claim 10, further comprising: A first processing module is configured to bin the second resource feature to obtain binned resource features, and determine the evidence weights corresponding to the binned resource features; The model is configured as a module to respond to the fact that the change rules of the evidence weights corresponding to all the binned resource features conform to the preset rules, and use the binned resource features as the features of the target model.
16. The apparatus according to claim 15, further comprising: The second processing module is configured to merge the resource features after the binning in response to the fact that the change rule of the evidence weights corresponding to all the resource features after the binning does not conform to the preset rule, and calculate the evidence weights of the merged resource features; The first module is further configured as: In response to the fact that the variation rule of the evidence weight of the combined resource feature complies with the preset rule, the combined resource feature is used as the feature of the target model.
17. The device according to claim 15 or 16, wherein: The preset rule includes one of the following items: The weight of evidence increases, the weight of evidence decreases, the weight of evidence increases first and then decreases, and the weight of evidence decreases first and then increases.
18. The apparatus according to claim 10, further comprising: The parameter adjustment module is configured to adjust the hyperparameters of the target model according to one of the following items: grid search, random search, and Bayesian optimization.
19. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 9.
20. A non-transitory computer-readable storage medium storing computer instructions, the computer instructions being used to cause the computer to execute the method of any one of claims 1-9.
21. A computer program product comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 9.
