Method and apparatus for optimizing machine learning model, electronic device, and storage medium
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-22
- Publication Date
- 2026-08-11
AI Technical Summary
[0003]本申请实施例提供了一种机器学习模型的优化方法、装置、电子设备及存储介质,解决了现有技术中机器学习模型优化效率较低的问题
Smart Images

Figure CN117540826B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and in particular to a method, apparatus, electronic device and storage medium for optimizing a machine learning model. Background Technology
[0002] With the rapid development of artificial intelligence technologies, primarily machine learning, machine learning models are being applied in an increasing number of fields. Model optimization plays a crucial role in modeling, not only improving model performance and efficiency but also reducing resource consumption. Currently, common optimization methods include data preprocessing such as data cleaning, standardization, and normalization. However, these methods typically only select correctly predicted data for analysis and optimization, failing to comprehensively consider the impact of all predicted data on the machine learning model, thus resulting in relatively low optimization efficiency. Summary of the Invention
[0003] This application provides a method, apparatus, electronic device, and storage medium for optimizing machine learning models, which solves the problem of low optimization efficiency of machine learning models in the prior art.
[0004] To solve the above problems, this application is implemented as follows:
[0005] In a first aspect, embodiments of this application provide a method for optimizing a machine learning model, the method comprising:
[0006] Obtain first sample data and second sample data corresponding to the target machine learning model. The prediction results obtained by the target machine learning model based on the first sample data and the second sample data are different. The first sample data includes x first features, and the second sample data includes y second features, where x is a positive integer and y is a positive integer.
[0007] The contribution of each of the x first features and the y second features to the target machine learning model is calculated respectively to obtain z first contribution values. The contribution values are used to characterize the degree of influence of the corresponding features on the output of the target machine learning model. The z is the sum of the x and the y, and the z is a positive integer.
[0008] Determine at least one first target contribution from the z first contribution values;
[0009] The target machine learning model is optimized based on at least one feature corresponding to the at least one first target contribution, to obtain the optimized target machine learning model.
[0010] Optionally, obtaining the first sample data and the second sample data of the target machine learning model during the training process includes:
[0011] The types of the target machine learning models are determined, including machine learning models for classification tasks and machine learning models for regression tasks;
[0012] Based on the aforementioned categories, first sample data and second sample data are obtained during the training process of the target machine learning model. Wherein, if the category indicates that the target machine learning model is a machine learning model for the classification task, the first sample data consists of sample data where the target machine learning model predicts incorrectly, and the second sample data consists of sample data where the target machine learning model predicts correctly. Wherein, if the category indicates that the target machine learning model is a machine learning model for the regression task, the first sample data consists of sample data where the target machine learning model's prediction error is greater than a preset error, and the second sample data consists of sample data where the target machine learning model's prediction error is equal to or less than the preset error.
[0013] Optionally, the step of calculating the contribution of each of the x first features and the y second features to the target machine learning model to obtain z first contributions includes:
[0014] The contribution of each of the x first features and the y second features to the target machine learning model is calculated respectively to obtain z second contributions, which include the x second contributions corresponding to the x first features and the y second contributions corresponding to the y second features.
[0015] The x second contributions corresponding to the x first features are optimized to obtain x third contributions;
[0016] The z first contribution values include: the y second contribution values corresponding to the y second features, and the x third contribution values.
[0017] Optionally, optimizing the x contributions corresponding to the x first features to obtain x third contributions includes:
[0018] The contribution of each of the x first features to the target machine learning model is calculated to obtain x fourth contributions;
[0019] The x fourth contribution values are classified to obtain the x third contribution values, wherein the third contribution value includes a classification identifier, which is used to characterize whether the corresponding contribution value is a positive contribution value or a negative contribution value.
[0020] Optionally, determining at least one first target contribution among the z first contribution values includes:
[0021] Sort the z first contribution values in descending order to obtain a sorted set;
[0022] The sorted set is filtered according to a preset threshold to determine at least one first target contribution, wherein the first target contribution is greater than or equal to the preset threshold.
[0023] Optionally, optimizing the target machine learning model based on at least one feature corresponding to the at least one first target contribution to obtain the optimized target machine learning model includes:
[0024] Based on at least one target feature corresponding to the at least one target contribution, the at least one target contribution is updated to obtain at least one second target contribution, wherein the at least one first target contribution corresponds one-to-one with the at least one second target contribution;
[0025] The contribution of the at least one second objective is screened to determine the contribution of at least one third objective;
[0026] The target machine learning model is optimized based on at least one feature corresponding to the at least one third objective contribution, to obtain the optimized target machine learning model.
[0027] Optionally, optimizing the target machine learning model based on at least one feature corresponding to the at least one third objective contribution to obtain an optimized target machine learning model includes:
[0028] Optimization information is generated based on the contribution of at least one third objective.
[0029] The target machine learning model is optimized based on the optimization information to obtain the optimized target machine learning model;
[0030] The optimization information includes at least one of the following: adjusting the weight values corresponding to the target features in the target machine learning model, adding the first sample features of the target machine learning model, deleting the second sample features of the target machine learning model, and preprocessing the training samples of the target machine learning model.
[0031] Secondly, embodiments of this application also provide an optimization apparatus for a machine learning model, the apparatus comprising:
[0032] The acquisition module is used to acquire first sample data and second sample data corresponding to the target machine learning model. The prediction results obtained by the target machine learning model based on the first sample data and the second sample data are different. The first sample data includes x first features, and the second sample data includes y second features, where x is a positive integer and y is a positive integer.
[0033] The calculation module is used to calculate the contribution of each of the x first features and the y second features to the target machine learning model, respectively, to obtain z first contribution values. The contribution values are used to characterize the degree of influence of the corresponding features on the output of the target machine learning model, where z is the sum of x and y, and z is a positive integer.
[0034] The determining module is configured to determine at least one first target contribution among the z first contribution values;
[0035] An optimization module is used to optimize the target machine learning model based on at least one feature corresponding to the at least one first target contribution, so as to obtain an optimized target machine learning model.
[0036] Thirdly, embodiments of this application also provide an electronic device, including: a memory, a processor, and a program stored in the memory and executable on the processor; the processor is configured to read the program in the memory to implement the steps in the method described in the first aspect above.
[0037] Fourthly, embodiments of this application also provide a readable storage medium for storing a program, which, when executed by a processor, implements the steps of the method described in the first aspect above.
[0038] This application provides a method, apparatus, electronic device, and storage medium for optimizing a machine learning model. The method includes: acquiring first sample data and second sample data corresponding to a target machine learning model, wherein the prediction results obtained by the target machine learning model based on the first sample data and the second sample data are different; the first sample data includes x first features, and the second sample data includes y second features, where x is a positive integer and y is a positive integer; calculating the contribution of each of the x first features and the y second features to the target machine learning model, respectively, to obtain z first contribution values, wherein the contribution value is used to characterize the degree of influence of the corresponding feature on the output result of the target machine learning model, where z is the sum of x and y, and z is a positive integer; determining at least one first target contribution value from the z first contribution values; and optimizing the target machine learning model based on at least one feature corresponding to the at least one first target contribution value to obtain an optimized target machine learning model. This application obtains sample data with different prediction results during the training of the target machine learning model, obtains multiple features based on the sample data, calculates the degree of influence of different features on the target machine learning model, thereby determining at least one feature that has a significant impact on the target machine learning model, and optimizes the target machine learning model using this at least one feature, thereby improving the optimization efficiency of the machine learning model. Attached Figure Description
[0039] Figure 1 A flowchart illustrating a method for optimizing a machine learning model provided in an embodiment of this application;
[0040] Figure 2 A schematic diagram of the structure of an optimization device for a machine learning model provided in an embodiment of this application;
[0041] Figure 3 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0042] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0043] The terms "first," "second," etc., used in the embodiments of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products, or devices. Additionally, the use of "and / or" in this application indicates at least one of the connected objects, such as A and / or B and / or C, representing seven possibilities: including A alone, B alone, C alone, and the presence of both A and B, both B and C, both A and C, and the presence of A, B, and C.
[0044] See Figure 1 , Figure 1 This is a flowchart illustrating the optimization method for the machine learning model provided in the embodiments of this application.
[0045] Step 101: Obtain the first sample data and the second sample data corresponding to the target machine learning model. The prediction results obtained by the target machine learning model based on the first sample data and the second sample data are different. The first sample data includes x first features, and the second sample data includes y second features, where x is a positive integer and y is a positive integer.
[0046] In this embodiment, the method provided by this application is applied to a machine learning platform that can deploy multiple machine learning models and deep learning models. Deep learning is a subset of machine learning, and machine learning models include deep learning models. Generative AI models or Large Language Models (LLMs) belong to deep learning models and can use deep learning and other technologies to generate new content. The machine learning models in this embodiment are not limited to representational machine learning models, but also used to represent deep learning models, large language models, etc. The target machine learning model can be used, for example, to classify and regress structured or unstructured data (e.g., images, videos, documents, etc.). Training the target machine learning model can also achieve other functions, which are not specifically limited in this embodiment. During the training of the target machine learning model with sample data or the subsequent prediction process of the target machine learning model on the sample data (i.e., the model application process), different predicted results will be generated. Compared with the actual results corresponding to the first or second sample data, the predicted result may be an accurate prediction result (i.e., the predicted result is consistent with the actual result) or an inaccurate prediction result (i.e., the predicted result is inconsistent with the actual result). Specifically, for example, the classification of the resulting data can be either successful recognition or failure recognition. In this model, the first sample data consists of bad case data, while the second sample data consists of data that were predicted correctly or relatively accurately. Bad case data is defined as samples that the model or specific rules cannot predict well; it is determined by the samples that the model predicted incorrectly or with relatively inaccurate predictions. It should be noted that the division between the first and second sample data may differ in different types of machine learning models, and this embodiment does not impose a specific limitation.
[0047] Specifically, after acquiring first and second sample data during the training process of the target machine learning model, x first features are determined based on the first sample data, and y second features are determined based on the second sample data, where x and y are both positive integers. The first and second features represent the dimensions of the sample data. The x first features and y second features can be the same or different. For example, if the sample data is structured data, the first and second features can represent data format, data size, data length, etc., and different features have different degrees of influence on the machine learning model.
[0048] Step 102: Calculate the contribution of each of the x first features and the y second features to the target machine learning model to obtain z first contribution values. The contribution values are used to characterize the degree of influence of the corresponding features on the output of the target machine learning model. The z is the sum of the x and the y, and the z is a positive integer.
[0049] In this embodiment, the contribution of each first feature and each second feature to the target machine learning model can be calculated using the target algorithm. The contribution represents the degree of influence of the feature during the training or prediction process of the target machine learning model. In this embodiment, the target algorithm can be the Shapley Additive Explanations (SHAP) algorithm, a non-parametric machine learning technique used to identify and explain the influence of specific input features on the model output. The SHAP algorithm can calculate the SHAP value corresponding to each first feature and each second feature, i.e., z first contributions, where z is the sum of x and y, and z is a positive integer.
[0050] It should be noted that the first contribution is a specific numerical value, such as 70, 90, 95, etc. The larger the value, the greater the contribution of the feature to the target machine learning model, and the smaller the value, the smaller the contribution of the feature to the target machine learning model.
[0051] Step 103: Determine at least one first target contribution from the z first contribution values.
[0052] In this embodiment, after obtaining z first contribution values, these z first contribution values are filtered. The filtering condition can be to compare each of the z first contribution values with a target threshold. The first contribution value greater than the target threshold is determined as the first target contribution value. For example, when the first contribution values are 70, 90, and 95, the target threshold is set to 85 based on experience. In this case, the contributions of 90 and 95 can be determined as the first target contribution values, while the contribution of 70 is discarded. After comparing all the first contribution values, at least one first target contribution value is obtained. This first target contribution value indicates that it has a significant impact on the target machine learning model and needs to be considered when optimizing the target machine learning model.
[0053] Step 104: Optimize the target machine learning model based on at least one feature corresponding to the at least one first target contribution, to obtain the optimized target machine learning model.
[0054] In this embodiment, after obtaining at least one first target contribution, corresponding optimization measures can be generated based on the first target contribution. These optimization measures are then used to optimize the parameters or results in the target machine learning model, resulting in an optimized target machine learning model. This optimized model can be used for classification and regression of structured data, and its classification and regression operations on structured data are more accurate. By combining the contributions of the first and second sample data to the machine learning model, the problem of existing technologies failing to analyze the reasons for poor performance from the perspective of prediction bias and prediction errors after model training is addressed. Furthermore, by analyzing the feature importance of correctly predicted samples and incorrectly predicted samples, the contribution of features to the model's prediction results is analyzed, inferring which features are prone to causing prediction errors, indirectly reflecting the model's rationality, and providing measures for model optimization.
[0055] This application provides a method for optimizing a machine learning model. The method includes: acquiring first sample data and second sample data corresponding to a target machine learning model, wherein the prediction results obtained by the target machine learning model based on the first sample data and the second sample data are different; the first sample data includes x first features, and the second sample data includes y second features, where x and y are positive integers; calculating the contribution of each of the x first features and the y second features to the target machine learning model, respectively, to obtain z first contribution values, where the contribution value characterizes the degree of influence of the corresponding feature on the output result of the target machine learning model, and z is the sum of x and y, where z is a positive integer; determining at least one first target contribution value from the z first contribution values; and optimizing the target machine learning model based on at least one feature corresponding to the at least one first target contribution value to obtain an optimized target machine learning model. This application improves the optimization efficiency of the machine learning model by acquiring sample data with different prediction results during the training process of the target machine learning model, obtaining multiple features from the sample data, calculating the degree of influence of different features on the target machine learning model, thereby determining at least one feature with a significant impact on the target machine learning model, and optimizing the target machine learning model using this at least one feature.
[0056] In some feasible implementations, optionally, obtaining the first sample data and the second sample data of the target machine learning model during the training process includes:
[0057] The types of the target machine learning models are determined, including machine learning models for classification tasks and machine learning models for regression tasks;
[0058] Based on the aforementioned categories, first sample data and second sample data are obtained during the training process of the target machine learning model. Wherein, if the category indicates that the target machine learning model is a machine learning model for the classification task, the first sample data consists of sample data where the target machine learning model predicts incorrectly, and the second sample data consists of sample data where the target machine learning model predicts correctly. Wherein, if the category indicates that the target machine learning model is a machine learning model for the regression task, the first sample data consists of sample data where the target machine learning model's prediction error is greater than a preset error, and the second sample data consists of sample data where the target machine learning model's prediction error is equal to or less than the preset error.
[0059] In this embodiment, since the target machine learning models are of different types, the division of the first sample data and the second sample data is also different. Therefore, before optimizing the target machine learning model, it is necessary to determine the type of target machine learning model. In this embodiment, machine learning models for classification tasks and machine learning models for regression tasks are used as examples for explanation.
[0060] When the classification result of the target machine learning model indicates that the target machine learning model is a classification task, the prediction result of the sample data has only two possibilities. For example, when determining whether structured data is in JSON format, the target machine learning model predicts either yes or no. In this case, the first sample data is the sample data that the target machine learning model predicted incorrectly, while the second sample data is the sample data that the target machine learning model predicted correctly.
[0061] When the identification result of the target machine learning model represents the machine learning model for the regression task, the prediction result of the sample data is a numerical value. For example, when judging the similarity between structured data and preset data, the prediction result of the target machine learning model may be a percentage or a decimal, such as 50%, 80%, etc.
[0062] By accurately identifying the type of the target machine learning model before acquiring data, it is possible to obtain better first and second sample data, thereby ensuring the accuracy of contribution value calculation through features.
[0063] Optionally, the step of calculating the contribution of each of the x first features and the y second features to the target machine learning model to obtain z first contributions includes:
[0064] The contribution of each of the x first features and the y second features to the target machine learning model is calculated respectively to obtain z second contributions, which include the x second contributions corresponding to the x first features and the y second contributions corresponding to the y second features.
[0065] The x second contributions corresponding to the x first features are optimized to obtain x third contributions;
[0066] The z first contribution values include: the y second contribution values corresponding to the y second features, and the x third contribution values.
[0067] In this embodiment, a first algorithm can be used to calculate the contribution of each of the x first features and y second features to the target machine learning model. Specifically, the first algorithm is used to calculate the degree of influence of the input features on the target machine learning model. For example, the first algorithm can be the Shapley Additive Model Interpretation Algorithm, which calculates the contribution of each of the x first features and y second features to the target machine learning model, i.e., the SHAP value. It should be noted that SHAP is a solution for cooperative game theory, and the SHAP method generates a prediction value for each sample model. The SHAP value of the first sample data is the value assigned to each first feature in samples with incorrect or inaccurate predictions, used to characterize the contribution of the first feature to the incorrect inference of the incorrect data samples. The SHAP value of the second sample data is the data assigned to each second feature in samples with correct or relatively accurate predictions, used to characterize the contribution of the second feature to the inference of the correctly or relatively correctly predicted samples.
[0068] In this embodiment, a second algorithm can be used to optimize the x second contributions corresponding to the x first features to obtain x third contributions. Specifically, the second algorithm is used to filter among multiple input features and output features that meet preset requirements. For example, the second algorithm can be the Local Interpretable Model-agnostic Explanations (LIME) algorithm, which optimizes the x second contributions corresponding to the x first features to obtain x third contributions. LIME is a machine learning technique that aims to provide a global perspective on interpretable models. It explains the behavior of the trained model through interpretable local explanations, enabling users to understand the model's results. By optimizing the x contributions corresponding to the x first features using LIME to obtain x third contributions, z first contributions can be formed from the y second contributions corresponding to y second features and the x third contributions.
[0069] Optionally, optimizing the x contributions corresponding to the x first features to obtain x third contributions includes:
[0070] The contribution of each of the x first features to the target machine learning model is calculated to obtain x fourth contributions;
[0071] The x fourth contribution values are classified to obtain the x third contribution values, wherein the third contribution value includes a classification identifier, which is used to characterize whether the corresponding contribution value is a positive contribution value or a negative contribution value.
[0072] In this embodiment, the contribution of each of the x first features is first calculated using the Shapley additivity model interpretation algorithm to obtain x fourth contributions. Specifically, the Shapley Value, i.e., the marginal contribution, of each feature in each sample of the first sample data is calculated based on the SHAP method. The offset of the predicted value of the first sample data from the mean of predicted values is the sum of the contributions of all features of that sample. For the predicted value of each sample, the role of different features in the predicted value can be understood as the predicted value obtained after each feature has a positive or negative effect on the "mean of predicted values".
[0073] Secondly, the x fourth contributions are classified using a locally interpretable model-agnostic interpretation algorithm to obtain the x third contributions. Specifically, the classification includes a classification label, indicating whether the third contribution is a positive contribution (positive effect) or a negative contribution (negative effect). It should be noted that a positive effect means the feature has a positive impact on the model's predicted value, i.e., it increases the prediction probability. A negative effect means the feature has a negative impact on some predicted values, i.e., it decreases the prediction probability.
[0074] Therefore, by combining the SHAP and LIME algorithms to analyze individual samples, the importance of features in each sample and their positive or negative impact on the prediction results are visualized. By analyzing the contribution of features that lead to prediction errors in individual sample data, the limitations of the interpretability of a single model on the model itself can be compensated for.
[0075] Optionally, determining at least one first target contribution among the z first contribution values includes:
[0076] Sort the z first contribution values in descending order to obtain a sorted set;
[0077] The sorted set is filtered according to a preset threshold to determine at least one first target contribution, wherein the first target contribution is greater than or equal to the preset threshold.
[0078] In this embodiment, the z first contribution values are sorted in descending order to identify which important features' value ranges cause certain prediction results to be too high. It should be noted that the preset threshold can be set based on practical experience and is not specifically limited in this embodiment. By filtering out the first contribution values with a degree greater than or equal to the preset threshold, at least one first target contribution value is determined. Filtering the sorted set in descending order improves the filtering speed, thereby further improving the model's optimization efficiency.
[0079] Optionally, optimizing the target machine learning model based on at least one feature corresponding to the at least one first target contribution to obtain the optimized target machine learning model includes:
[0080] Based on at least one target feature corresponding to the at least one target contribution, the at least one target contribution is updated to obtain at least one second target contribution, wherein the at least one first target contribution corresponds one-to-one with the at least one second target contribution;
[0081] The contribution of the at least one second objective is screened to determine the contribution of at least one third objective;
[0082] The target machine learning model is optimized based on at least one feature corresponding to the at least one third objective contribution, to obtain the optimized target machine learning model.
[0083] In this embodiment, after determining at least one target feature corresponding to at least one first target contribution, the target contribution can be updated through statistical methods to obtain at least one second target contribution. For example, if a certain first target contribution is significantly larger than the values of other first target contributions, it indicates that the first target contribution may be an incorrect value, and therefore needs to be updated to meet the requirements. Thus, after filtering and updating all the first target contributions, at least one second target contribution is determined.
[0084] Furthermore, at least one third objective contribution is determined by screening the contribution of at least one second objective. This screening can be achieved through quantitative and qualitative analysis of the prediction results within different value ranges of the features using statistical methods. This analysis helps to understand the impact of feature intervals on the model output. It should be noted that quantitative and qualitative analysis can reveal the impact of data quality, missing values, anomalies in specific values, dispersion, central tendency, etc., on the model, thus avoiding unfavorable modeling results due to data distortion. Statistical methods are used to jointly analyze different target column ranges corresponding to different feature value ranges. This analysis helps to understand the impact of feature intervals and target columns on the model output, thereby identifying the target features with the greatest influence.
[0085] Optionally, optimizing the target machine learning model based on at least one feature corresponding to the at least one third objective contribution to obtain an optimized target machine learning model includes:
[0086] Optimization information is generated based on the contribution of at least one third objective.
[0087] The target machine learning model is optimized based on the optimization information to obtain the optimized target machine learning model;
[0088] The optimization information includes at least one of the following: adjusting the weight values corresponding to the target features in the target machine learning model, adding the first sample features of the target machine learning model, deleting the second sample features of the target machine learning model, and preprocessing the training samples of the target machine learning model.
[0089] In this embodiment, optimization information is generated based on the contribution of the third objective, and corresponding optimization measures are taken to improve the machine learning model based on the optimization information. These optimization measures may include adjusting the weights of features in the model, adding or deleting features, and improving data preprocessing. For example, feature distribution analysis of top-ranked features reveals data anomalies, and improvements to data preprocessing are suggested during the feedback optimization phase. Feature importance analysis and SHAP importance analysis of bad case data help infer which features are prone to causing model prediction errors, and features may be added or deleted before model training during the feedback optimization phase. Joint analysis of different target column ranges corresponding to different feature value ranges helps understand the impact of feature intervals and target columns on the model output. During the feedback optimization phase, it is suggested to change the sample weights of the training data for the corresponding feature intervals, forcing the model to focus on misclassified samples, thereby improving model performance.
[0090] This application obtains sample data with different prediction results during the training of the target machine learning model, obtains multiple features based on the sample data, calculates the degree of influence of different features on the target machine learning model, thereby determining at least one feature that has a significant impact on the target machine learning model, and optimizes the target machine learning model through at least one feature, thereby improving the optimization efficiency of the machine learning model.
[0091] See Figure 2 , Figure 2 This is a structural diagram of the optimization device for the machine learning model provided in an embodiment of this application. Figure 2 As shown, the optimization device 200 for the machine learning model includes:
[0092] The acquisition module 210 is used to acquire first sample data and second sample data corresponding to the target machine learning model. The prediction results obtained by the target machine learning model based on the first sample data and the second sample data are different. The first sample data includes x first features, and the second sample data includes y second features, where x is a positive integer and y is a positive integer.
[0093] The calculation module 220 is used to calculate the contribution of each of the x first features and the y second features to the target machine learning model, respectively, to obtain z first contribution values. The contribution values are used to characterize the degree of influence of the corresponding features on the output of the target machine learning model. The z is the sum of the x and the y, and the z is a positive integer.
[0094] Determining module 230 is used to determine at least one first target contribution among the z first contribution values;
[0095] The optimization module 240 is used to optimize the target machine learning model based on at least one feature corresponding to the at least one first target contribution, so as to obtain an optimized target machine learning model.
[0096] Optionally, the acquisition module 210 includes:
[0097] The classification determination submodule is used to determine the type of the target machine learning model, which includes machine learning models for classification tasks and machine learning models for regression tasks;
[0098] The classification acquisition submodule is used to acquire first sample data and second sample data of the target machine learning model during the training process based on the category. Wherein, if the category indicates that the target machine learning model is a machine learning model for the classification task, the first sample data consists of sample data where the target machine learning model predicts incorrectly, and the second sample data consists of sample data where the target machine learning model predicts correctly. If the category indicates that the target machine learning model is a machine learning model for the regression task, the first sample data consists of sample data where the prediction error of the target machine learning model is greater than a preset error, and the second sample data consists of sample data where the prediction error of the target machine learning model is equal to or less than the preset error.
[0099] Optionally, the computing module 220 includes:
[0100] The first calculation submodule is used to calculate the contribution of each of the x first features and the y second features to the target machine learning model, respectively, to obtain z second contributions, wherein the z second contributions include the x second contributions corresponding to the x first features and the y second contributions corresponding to the y second features;
[0101] The second calculation submodule is used to optimize the x second contribution values corresponding to the x first features to obtain x third contribution values;
[0102] The z first contribution values include: the y second contribution values corresponding to the y second features, and the x third contribution values.
[0103] Optionally, the second computational submodule includes:
[0104] A calculation unit is used to calculate the contribution of each of the x first features to the target machine learning model, and obtain x fourth contribution values.
[0105] A classification unit is used to classify the x fourth contribution degrees to obtain the x third contribution degrees, wherein the third contribution degree includes a classification identifier, which is used to characterize whether the corresponding contribution degree is a positive contribution degree or a negative contribution degree.
[0106] Optionally, the determining module 230 includes:
[0107] The sorting submodule is used to sort the z first contribution values in descending order to obtain a sorted set;
[0108] A determination submodule is used to filter the sorted set according to a preset threshold and determine at least one first target contribution, wherein the first target contribution is greater than or equal to the preset threshold.
[0109] Optionally, optimization module 240 includes:
[0110] An update submodule is used to update the at least one target contribution based on at least one target feature corresponding to the at least one target contribution, to obtain at least one second target contribution, wherein the at least one first target contribution corresponds one-to-one with the at least one second target contribution;
[0111] A filtering submodule is used to filter the contribution of the at least one second objective to determine the contribution of at least one third objective.
[0112] The optimization submodule is used to optimize the target machine learning model based on at least one feature corresponding to the at least one third objective contribution, so as to obtain the optimized target machine learning model.
[0113] Optional, optimized submodules include:
[0114] The generation unit is used to generate optimization information based on the contribution of the at least one third objective.
[0115] An optimization unit is used to optimize the target machine learning model based on the optimization information to obtain an optimized target machine learning model.
[0116] The optimization information includes at least one of the following: adjusting the weight values corresponding to the target features in the target machine learning model, adding the first sample features of the target machine learning model, deleting the second sample features of the target machine learning model, and preprocessing the training samples of the target machine learning model.
[0117] This application obtains sample data with different prediction results during the training of the target machine learning model, obtains multiple features based on the sample data, calculates the degree of influence of different features on the target machine learning model, thereby determining at least one feature that has a significant impact on the target machine learning model, and optimizes the target machine learning model using this at least one feature, thereby improving the optimization efficiency of the machine learning model.
[0118] This application also provides an electronic device. Please refer to [link to relevant documentation]. Figure 3 The electronic device may include a processor 301, a memory 302, and a program 3021 stored in the memory 302 and capable of running on the processor 301.
[0119] When program 3021 is executed by processor 301, it can achieve the following: Figure 1 Any step in the corresponding method embodiment:
[0120] Obtain first sample data and second sample data corresponding to the target machine learning model. The prediction results obtained by the target machine learning model based on the first sample data and the second sample data are different. The first sample data includes x first features, and the second sample data includes y second features, where x is a positive integer and y is a positive integer.
[0121] The contribution of each of the x first features and the y second features to the target machine learning model is calculated respectively to obtain z first contribution values. The contribution values are used to characterize the degree of influence of the corresponding features on the output of the target machine learning model. The z is the sum of the x and the y, and the z is a positive integer.
[0122] Determine at least one first target contribution from the z first contribution values;
[0123] The target machine learning model is optimized based on at least one feature corresponding to the at least one first target contribution, to obtain the optimized target machine learning model.
[0124] Optionally, obtaining the first sample data and the second sample data of the target machine learning model during the training process includes:
[0125] The types of the target machine learning models are determined, including machine learning models for classification tasks and machine learning models for regression tasks;
[0126] Based on the aforementioned categories, first sample data and second sample data are obtained during the training process of the target machine learning model. Wherein, if the category indicates that the target machine learning model is a machine learning model for the classification task, the first sample data consists of sample data where the target machine learning model predicts incorrectly, and the second sample data consists of sample data where the target machine learning model predicts correctly. Wherein, if the category indicates that the target machine learning model is a machine learning model for the regression task, the first sample data consists of sample data where the target machine learning model's prediction error is greater than a preset error, and the second sample data consists of sample data where the target machine learning model's prediction error is equal to or less than the preset error.
[0127] Optionally, the step of calculating the contribution of each of the x first features and the y second features to the target machine learning model to obtain z first contributions includes:
[0128] The contribution of each of the x first features and the y second features to the target machine learning model is calculated respectively to obtain z second contributions, which include the x second contributions corresponding to the x first features and the y second contributions corresponding to the y second features.
[0129] The x contribution values corresponding to the x first features are optimized to obtain x third contribution values;
[0130] The z first contribution values include: the y second contribution values corresponding to the y second features, and the x third contribution values.
[0131] Optionally, optimizing the x contributions corresponding to the x first features to obtain x third contributions includes:
[0132] The contribution of each of the x first features to the target machine learning model is calculated to obtain x fourth contributions;
[0133] The x fourth contribution values are classified to obtain the x third contribution values, wherein the third contribution value includes a classification identifier, which is used to characterize whether the corresponding contribution value is a positive contribution value or a negative contribution value.
[0134] Optionally, determining at least one first target contribution among the z first contribution values includes:
[0135] Sort the z first contribution values in descending order to obtain a sorted set;
[0136] The sorted set is filtered according to a preset threshold to determine at least one first target contribution, wherein the first target contribution is greater than or equal to the preset threshold.
[0137] Optionally, optimizing the target machine learning model based on at least one feature corresponding to the at least one first target contribution to obtain the optimized target machine learning model includes:
[0138] Based on at least one target feature corresponding to the at least one target contribution, the at least one target contribution is updated to obtain at least one second target contribution, wherein the at least one first target contribution corresponds one-to-one with the at least one second target contribution;
[0139] The contribution of the at least one second objective is screened to determine the contribution of at least one third objective;
[0140] The target machine learning model is optimized based on at least one feature corresponding to the at least one third objective contribution, to obtain the optimized target machine learning model.
[0141] Optionally, optimizing the target machine learning model based on at least one feature corresponding to the at least one third objective contribution to obtain an optimized target machine learning model includes:
[0142] Optimization information is generated based on the contribution of at least one third objective.
[0143] The target machine learning model is optimized based on the optimization information to obtain the optimized target machine learning model;
[0144] The optimization information includes at least one of the following: adjusting the weight values corresponding to the target features in the target machine learning model, adding the first sample features of the target machine learning model, deleting the second sample features of the target machine learning model, and preprocessing the training samples of the target machine learning model.
[0145] This application obtains sample data with different prediction results during the training of the target machine learning model, obtains multiple features based on the sample data, calculates the degree of influence of different features on the target machine learning model, thereby determining at least one feature that has a significant impact on the target machine learning model, and optimizes the target machine learning model using this at least one feature, thereby improving the optimization efficiency of the machine learning model.
[0146] This application also provides a computer-readable storage medium storing a computer program. When executed by a processor, this computer program implements the various processes of the optimization method embodiment of the above-described machine learning model and achieves the same technical effect. To avoid repetition, it will not be described again here. The computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0147] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0148] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0149] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A method for optimizing a machine learning model, characterized in that, The method includes: Obtain first sample data and second sample data corresponding to the target machine learning model. The prediction results obtained by the target machine learning model based on the first sample data and the second sample data are different. The first sample data includes x first features, and the second sample data includes y second features, where x is a positive integer and y is a positive integer. The contribution of each of the x first features and y second features to the target machine learning model is calculated to obtain z first contribution values. These contribution values characterize the influence of the corresponding feature on the output of the target machine learning model. Here, z is the sum of x and y, and z is a positive integer. The calculation of the contribution of each of the x first features and y second features to the target machine learning model to obtain z first contribution values includes: calculating the contribution of each of the x first features and y second features to the target machine learning model to obtain z second contribution values, where z second contribution values include the x second contribution values corresponding to the x first features and the y second contribution values corresponding to the y second features; and optimizing the x second contribution values corresponding to the x first features to obtain x third contribution values. The z first contribution values include the y second contribution values corresponding to the y second features and the x third contribution values. Determine at least one first target contribution from the z first contribution values; The target machine learning model is optimized based on at least one feature corresponding to the at least one first target contribution, to obtain the optimized target machine learning model.
2. The method according to claim 1, characterized in that, The acquisition of the first and second sample data of the target machine learning model during the training process includes: The types of the target machine learning models are determined, including machine learning models for classification tasks and machine learning models for regression tasks; Based on the aforementioned categories, first sample data and second sample data are obtained during the training process of the target machine learning model. Wherein, if the category indicates that the target machine learning model is a machine learning model for the classification task, the first sample data consists of sample data where the target machine learning model predicts incorrectly, and the second sample data consists of sample data where the target machine learning model predicts correctly. Wherein, if the category indicates that the target machine learning model is a machine learning model for the regression task, the first sample data consists of sample data where the target machine learning model's prediction error is greater than a preset error, and the second sample data consists of sample data where the target machine learning model's prediction error is equal to or less than the preset error.
3. The method according to claim 1, characterized in that, The optimization of the x contribution values corresponding to the x first features to obtain x third contribution values includes: The contribution of each of the x first features to the target machine learning model is calculated to obtain x fourth contributions; The x fourth contribution values are classified to obtain the x third contribution values, wherein the third contribution value includes a classification identifier, which is used to characterize whether the corresponding contribution value is a positive contribution value or a negative contribution value.
4. The method according to any one of claims 1 to 3, characterized in that, Determining at least one first target contribution among the z first contribution values includes: Sort the z first contribution values in descending order to obtain a sorted set; The sorted set is filtered according to a preset threshold to determine at least one first target contribution, wherein the first target contribution is greater than or equal to the preset threshold.
5. The method according to claim 1 or 4, characterized in that, The optimization of the target machine learning model based on at least one feature corresponding to the at least one first target contribution, to obtain the optimized target machine learning model, includes: Based on at least one target feature corresponding to the at least one target contribution, the at least one target contribution is updated to obtain at least one second target contribution, wherein the at least one first target contribution corresponds one-to-one with the at least one second target contribution; The contribution of the at least one second objective is screened to determine the contribution of at least one third objective; The target machine learning model is optimized based on at least one feature corresponding to the at least one third objective contribution, to obtain the optimized target machine learning model.
6. The method according to claim 5, characterized in that, The optimization of the target machine learning model based on at least one feature corresponding to the at least one third objective contribution to obtain an optimized target machine learning model includes: Optimization information is generated based on the contribution of at least one third objective. The target machine learning model is optimized based on the optimization information to obtain the optimized target machine learning model; The optimization information includes at least one of the following: adjusting the weight values corresponding to the target features in the target machine learning model, adding the first sample features of the target machine learning model, deleting the second sample features of the target machine learning model, and preprocessing the training samples of the target machine learning model.
7. An optimization device for a machine learning model, characterized in that, The device includes: The acquisition module is used to acquire first sample data and second sample data corresponding to the target machine learning model. The prediction results obtained by the target machine learning model based on the first sample data and the second sample data are different. The first sample data includes x first features, and the second sample data includes y second features, where x is a positive integer and y is a positive integer. A calculation module is used to calculate the contribution of each of the x first features and the y second features to the target machine learning model, respectively, to obtain z first contribution values. The contribution value characterizes the degree of influence of the corresponding feature on the output of the target machine learning model, where z is the sum of x and y, and z is a positive integer. The calculation module includes: a first calculation submodule, used to calculate the contribution of each of the x first features and the y second features to the target machine learning model, respectively, to obtain z second contribution values, where z second contribution values include x second contribution values corresponding to the x first features and y second contribution values corresponding to the y second features; and a second calculation submodule, used to optimize the x second contribution values corresponding to the x first features to obtain x third contribution values; wherein the z first contribution values include: y second contribution values corresponding to the y second features, and the x third contribution values. The determining module is configured to determine at least one first target contribution among the z first contribution values; An optimization module is used to optimize the target machine learning model based on at least one feature corresponding to the at least one first target contribution, so as to obtain an optimized target machine learning model.
8. An electronic device, comprising: A memory, a processor, and a program stored in the memory and executable on the processor; characterized in that the processor is configured to read the program from the memory to implement the steps in the method for optimizing a machine learning model as described in any one of claims 1 to 6.
9. A readable storage medium for storing a program, characterized in that, When the program is executed by the processor, it implements the steps in the optimization method of the machine learning model as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Method and device for determining feature contribution degree in federal learning, and electronic equipment
CN113657996A
Auxiliary diagnosis and prediction method, device and equipment for inherited metabolic disease and medium
CN116665879A