A code generation method, device, equipment and storage medium

By obtaining the training parameters of the machine learning model and generating code segments, the prediction inaccuracy caused by data changes during cross-platform deployment is solved, and the rapid generation and flexibility of model training code is achieved, and the accuracy of prediction is improved.

CN110795089BActive Publication Date: 2025-05-13CHINA CONSTRUCTION BANK
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201911037981.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-10-29
Publication Date
2025-05-13
Estimated Expiration
2039-10-29

AI Technical Summary

Technical Problem

When the existing technology deploys machine learning models across platforms, data changes lead to inaccurate prediction results, and the PMML language cannot obtain training code, which makes it less flexible.

Method used

By obtaining training parameters in the initial model file, generate code segments based on these parameters and pre-configured code templates, and connect these code segments through associated parameters to generate target training code.

Benefits of technology

It realizes the rapid generation and flexibility of machine learning model training code, adapts to changes in training data sets, and improves the accuracy of model prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110795089B_ABST
    Figure CN110795089B_ABST
Patent Text Reader

Abstract

The present invention discloses a code generation method, device, equipment and storage medium. The method comprises: obtaining each training parameter in an initial model file; generating a code segment according to each training parameter and a pre-configured code template; determining the association parameters between each code segment, and connecting each code segment based on the association parameters to generate a target training code. The technical solution of the embodiment of the present invention realizes the rapid generation of machine learning model training code by automatically parsing the initial model file to generate the target training code, and improves the flexibility of the machine learning model training code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of computer application technology, and in particular to a code generation method, apparatus, device and storage medium. Background Art

[0002] Cross-platform issues are often encountered in machine learning products. For example, when a machine learning model is trained using the Python language and deployed across platforms to other production environments, the production environment needs to be modified in order to use the machine learning model. Obviously, modifying the production environment to use the machine learning model is not worth the cost. For this reason, people have agreed on the Predictive Model Markup Language (PMML) to achieve cross-platform machine learning model deployment.

[0003] However, machine learning models are strongly related to training data. Different data will train different models. When using PMML to deploy machine learning models to other platforms, if the data changes and adjusts, the prediction results produced by the machine learning model will be inaccurate. The machine learning model needs to be fine-tuned to adapt to the changes in data. However, PMML only describes the machine learning model and cannot obtain the training code of the machine learning model. The machine learning model can only be retrained on the original platform, which is less flexible. Summary of the invention

[0004] The present invention provides a code generation method, apparatus, device and storage medium to achieve flexible generation of machine learning model training code under cross-platform, which can enhance the accuracy of prediction results of machine learning modules.

[0005] In a first aspect, an embodiment of the present invention provides a code generation method, the method comprising:

[0006] Get the training parameters in the initial model file;

[0007] Generate a code segment according to each of the training parameters and a pre-configured code template;

[0008] Association parameters between the code segments are determined, and the code segments are connected based on the association parameters to generate target training code.

[0009] In a second aspect, an embodiment of the present invention further provides a code generation device, characterized in that the device comprises:

[0010] File analysis module, used to obtain various training parameters in the initial model file;

[0011] A code segment module, used to generate a code segment according to each of the training parameters and a pre-configured code template;

[0012] The code generation module is used to determine the association parameters between the code segments and connect the code segments based on the association parameters to generate the target training code.

[0013] In a third aspect, an embodiment of the present invention further provides a device, the device comprising:

[0014] one or more processors;

[0015] A memory for storing one or more programs;

[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the code generation method as described in any one of the embodiments of the present invention.

[0017] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a code generation method as described in any one of the embodiments of the present invention.

[0018] The technical solution of the embodiment of the present invention obtains the training parameters in the initial model code file, generates code segments according to the training parameters and pre-configured code templates, and connects the code segments according to the associated parameters between the code segments to generate target training codes, thereby realizing rapid generation of model training codes, improving the flexibility of machine learning model training codes, adapting to changes in training data sets, and improving the accuracy of pre-stored machine learning models. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 is a flowchart of a code generation method provided by Embodiment 1 of the present invention;

[0020] Figure 2 is a flowchart of a code generation method provided by Embodiment 2 of the present invention;

[0021] Figure 3 is a schematic diagram of the structure of a code generating device provided in Embodiment 3 of the present invention;

[0022] Figure 4 It is a structural schematic diagram of a device provided in Embodiment 4 of the present invention. DETAILED DESCRIPTION

[0023] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention are shown in the accompanying drawings, rather than all structures. In addition, the embodiments of the present invention and the features in the embodiments may be combined with each other without conflict.

[0024] Embodiment 1

[0025] Figure 1 is a flowchart of a code generation method provided in Embodiment 1 of the present invention. This embodiment is applicable to the case where training code is inversely generated according to a machine learning model. The method can be executed by a code generation device, which can be implemented in hardware and / or software. Figure 1 The method of the embodiment of the present invention specifically includes the following steps:

[0026] Step 101: Obtain various training parameters in the initial model file.

[0027] Among them, the initial model file can be a file storing a machine learning model, specifically a Predictive Model Markup Language (PMML) file, and can be a machine learning model generated by a unified XML format description. The initial model file can describe and define the data dictionary, mining architecture, data conversion, model definition, output, target, model interpretation and model validation of the machine learning model. The initial model file can be used for data prediction; the training parameters can be parameters defined in the initial model file for describing the machine learning model, such as the training model used in the training process, etc. The training parameters can reflect the parameter information required for training the machine learning model.

[0028] Specifically, the initial model file can be analyzed to obtain the training parameters in the initial model file. For example, the initial model file can be analyzed according to the tags in the initial model file to obtain the parameters in each tag. The obtained parameters can be used as training parameters. Part of the content in a PMML file is as follows:

[0029]

[0030] The DataField name tag and Value tag in the initial model code file can be analyzed to obtain the content in the tag, the label column y and the input feature columns x1, x2, x3 and x4, and the value of the label column is (0, 1, 2). The obtained label column y, the input feature columns x1, x2, x3 and x4 and the label column value (0, 1, 2) can be used as training parameters.

[0031] Step 102: Generate a code segment according to the training parameters and the pre-configured code template.

[0032] Among them, the code template can be a code template pre-stored at each platform, which can be used to train the machine learning model. The code template can be the same as the language of each platform. For example, if the platform is an R language platform, correspondingly, the R language code template can be stored. The code template can be divided according to function, and different functions can correspond to different code templates. For example, data mining can correspond to code template A, and data conversion can correspond to code template B; the code segment can be a code generated according to the training parameters and the code template, and the code segment can be specifically a machine learning model training code to implement different functions.

[0033] In an embodiment of the present invention, a corresponding code template can be obtained according to the type of training parameters, and the training parameters can be filled into the code template to generate a code segment. For example, the training parameters are label columns and feature columns, and a code template of a training model can be obtained. The number of label columns and feature columns can be filled into the corresponding positions of the code template. The code template after filling in the training parameters can be used as a code segment, and different training parameters can correspond to the same code segment.

[0034] Step 103: Determine association parameters between the code segments, and connect the code segments based on the association parameters to generate target training code.

[0035] Among them, the associated parameter can be an intermediate parameter connecting each code segment, which can be used to connect the code segments into the target training code. For example, code segment A outputs parameter α, and code segment B inputs parameter α. Parameter α can be an associated parameter between code segment A and code segment B. The output parameter output by code segment A can be used as an input parameter input by code segment B. The target training code can be a machine learning model training code generated according to the initial model file. After running, the target training code can be trained to generate the machine learning model in the initial model file. The coding language of the target training code can be multiple, such as python, scikit-learn, R, SparkML, XGBoost, LightGBM or Tensorflow.

[0036] Specifically, the relationship between the code segments can be obtained by analyzing the initial model file, so as to determine the association parameters between the code segments as connections, obtain the association parameters between the code segments to be coded, and connect the code segments based on the association parameters so that the code segments constitute the target training code. It can be understood that the code segments can specifically be machine learning model training codes to implement different functions. After connecting the code segments, the complete training process of the machine learning model can be completed.

[0037] The technical solution of the embodiment of the present invention obtains training parameters by analyzing the initial model file, generates code segments according to the training parameters and code templates, and connects the code segments into target training codes according to the associated parameters between the code segments, thereby realizing reverse acquisition of model training codes according to machine learning model files, improving training code generation under cross-language platforms, using code segments as code templates, reducing code redundancy, and reducing the storage space of code templates. Each code template can be freely matched according to needs, which can improve the flexibility of machine learning model training code generation.

[0038] Embodiment 2

[0039] Figure 2 is a flowchart of a code generation method provided by Embodiment 2 of the present invention. The embodiment of the present invention is a specific implementation based on the above embodiment. Figure 2 , the code generation method provided by the embodiment of the present invention includes:

[0040] Step 201: Obtain text labels in the initial model file.

[0041] The text label may be a label in the initial model file that describes the machine learning model, and the text label may include a label name and label content.

[0042] Specifically, the initial model file may be a PMML markup language file, which includes a variety of text tags, for example, <datadictionary> 、 <miningschema>and <localtransformations>Different text tags can describe different machine learning model contents. Regular matching can be performed on the text tags in the initial model file. When the content is matched in the initial model file, it can be considered that the corresponding text tag is obtained.

[0043] Step 202: If the text label is a preset label, obtain the training parameters corresponding to the text label in the initial model file; wherein the training parameters include training input parameters, training output parameters, training model parameters, data conversion parameters and / or data mining parameters.

[0044] Among them, the preset tags can be matching tags for obtaining training parameters, which can be used to match text tags in the initial model file. The preset tags can be pre-stored as needed. By analyzing the PMML standard, it is found that the PMML markup language file can include several types of text tags such as data dictionary, mining architecture, data conversion, model definition, output, target, model interpretation and model validation. Among them, the text tags related to training machine learning models can include data dictionary, mining architecture, data conversion, model definition and model interpretation. Text tags such as data dictionary, mining architecture, data conversion, model definition and model interpretation related to machine learning model training can be preset as preset tags.

[0045] Specifically, the obtained text label can be compared with the preset label. If the text label is a label in the preset label, it can be determined that the text label is related to the machine learning model training, and the training parameters corresponding to the text label in the initial model file can be obtained. For example, when the text label matches the preset label, the label content of the text label in the initial model file can be obtained, and the obtained label content can be used as training parameters. The training parameters can be divided into training input parameters, training output parameters, training model parameters, data conversion parameters, and data mining parameters, etc. according to different text labels. The training parameters can be used to fill in the code template to generate code for training the machine learning model.

[0046] Optionally, the preset tags include data dictionary tags, mining architecture tags, data transformation tags, model definition tags and / or model interpretation tags.

[0047] In an embodiment of the present invention, the pre-label can be divided into data dictionary labels, mining framework labels, data conversion labels, model definition labels and model explanation labels according to the text labels corresponding to the training parameters. The preset labels can be stored in advance and can be one or more of the data dictionary labels, mining framework labels, data conversion labels, model definition labels and model explanation labels. The training parameters corresponding to the data dictionary labels can identify and define which input data fields are most useful for solving the current problem, including numerical, sequence and category fields, etc. The training parameters corresponding to the mining framework labels can be strategies for processing missing values ​​and outliers. The training parameters corresponding to the data conversion labels can be the calculations required to pre-process the original input data to the derived fields. The derived fields merge or modify the input data to obtain more valuable fields. The training parameters corresponding to the model definition labels can define the structure and parameters of the model, such as association rule models, Bayesian network models, clustering models, baseline models, Gaussian processing models, naive Bayes models, nearest neighbor models, neural network models, regression models, rule set models, sequence models, scorecard models, support vector machine models, text models, time series models and tree models. The training parameters corresponding to the model explanation label may define the model metrics calculated when the test data is passed to the model for prediction, such as confusion matrix, rate of change (ROC), and accuracy.

[0048] Step 203: Obtain a pre-configured code template according to the training parameters.

[0049] Among them, code templates can be used to generate codes for training machine learning models. Code templates can be divided according to the functions of training machine learning models. Different functions can correspond to different code templates. For example, code template A is used for data mining, and code template B is used for data conversion. The coding language of the code template can correspond to the coding language of the platform running the machine learning model.

[0050] In an embodiment of the present invention, the training parameters can be obtained to obtain the corresponding code template. If the training parameters are data mining parameters, a code template with data mining function can be obtained. If the training parameters are data conversion parameters, a code template with data conversion function can be obtained. It can be understood that the code template can be pre-stored in the machine learning model operation platform. Exemplarily, the training parameter is logit, and the training model of logistic regression can be obtained. In PMML, the training model can include an association rule model, a Bayesian network model, a clustering model, a baseline model, a Gaussian processing model, a naive Bayes model, a nearest neighbor model, a neural network model, a regression model, a rule set model, a sequence model, a scoring card model, a support vector machine model, a text model, a time series model, and a tree model, etc., and different code templates of training models can be obtained according to different training parameter contents.

[0051] Step 204: Fill the training parameters into the corresponding to-be-filled positions of the code template to generate a code segment.

[0052] The position to be filled may be a position reserved in the code template for filling in training parameters.

[0053] Specifically, the position to be filled in the code template may be obtained, the training parameters may be filled into the position to be filled according to the type of the training parameters, and the code template whose position to be filled has been filled with the training parameters may be used as a code segment.

[0054] Step 205: Determine the order in which the training parameters appear in the initial model file as the connection order relationship of each code segment.

[0055] Among them, the order of appearance can be the order of the training parameters in the initial model file. The training parameters describing the machine learning model in the initial model file can appear in the order of machine learning model training. The training parameters that appear first in the initial model file need to be used first when training the machine learning model. The code segments corresponding to the training parameters can appear in the code for training the machine learning model before other code segments.

[0056] Specifically, the order of appearance of the training parameters in the initial model file can be determined from the head to the tail of the initial model file, and the training parameters can be used as the connection order relationship of the corresponding code segments according to the order of appearance. For example, the data dictionary parameters in the training parameters appear before the mining architecture parameters. Accordingly, the code segment corresponding to the data dictionary used for data analysis in the code for training the machine learning model can appear before the code segment of the mining architecture for data mining.

[0057] Step 206: Generate association parameters according to the incoming parameters, outgoing parameters and connection order relationship of each code segment.

[0058] Among them, the incoming parameters can be the input data required by the code segment to implement the corresponding machine learning model training function, and the outgoing parameters can be the output data required by the code segment to implement the corresponding machine learning model training function.

[0059] Specifically, the code segment can be analyzed to obtain the incoming parameters and outgoing parameters. The code segment can have multiple incoming parameters and outgoing parameters. According to the connection order relationship between the code segments, if the outgoing parameter of the previous code segment is the same as the incoming parameter of the next code segment, the parameter can be used as an association parameter connecting the previous code segment and the next code segment.

[0060] Step 207: Generate target training code by connecting the code segments through associated parameters.

[0061] Specifically, after determining the association parameters between the code segments, the association parameters can be generated to transfer data between the code segments, and each code segment with the association parameters can be used as a target training code.

[0062] Step 208: Adjust the target training code according to the user's adjustment parameters.

[0063] Among them, the adjustment parameter can be a parameter for adjusting the target training code, and the adjustment parameter can be generated according to the change of the data set of the machine learning model.

[0064] In an embodiment of the present invention, when the data set used for machine learning model training changes, adjustment parameters can be generated to adjust the target training code. For example, the adjustment parameters may include adjusting the number of label columns and increasing the dimension of feature columns, etc. By adjusting the target training code, the adaptability to the data set is enhanced, and the machine learning model prediction generated by the target training code is more accurate.

[0065] The technical solution of the embodiment of the present invention obtains the text label in the initial model file. If the text label is a preset label, the corresponding training parameters in the initial model file are obtained, and the code template is obtained according to the training parameters. The code template filled with the training parameters is used as a code segment, and the association parameters between the code segments are determined. The code segments are connected by the association parameters to generate target training codes, and the target training codes are adjusted according to the user's adjustment parameters. The model training codes are reversely obtained according to the machine learning model files, and the training code generation under the cross-language platform is improved. The training codes are adjusted to facilitate the retraining of the machine learning model, which can improve the accuracy of the prediction.

[0066] Further, on the basis of the above-mentioned embodiments of the invention, associated parameters are generated according to the incoming parameters, outgoing parameters and connection order relationship of each code segment, including: obtaining a second code segment connected to the first code segment in the code segment according to the connection order relationship, wherein the first code segment is located at the starting position of the connection order relationship; if the first outgoing parameter of the first code segment is the same as the second incoming parameter of the second code segment, then determining the first outgoing parameter as the associated parameter; determining the second code segment as a new first code segment, and returning the second code segment connected to the first code segment in the code segment obtained according to the connection order relationship.

[0067] In an embodiment of the present invention, code segments can be obtained according to a connection order relationship, and the previous code segment obtained can be used as the first code segment, and the code segment following the code segment can be used as the second code segment. If the outgoing parameter of the first code segment is the same as the incoming parameter of the second code segment, the outgoing parameter of the first code segment can be used as the association parameter of the first code segment and the second code segment. The association parameters between the code segments can be determined according to the connection order relationship according to the above steps.

[0068] Embodiment 3

[0069] Figure 3 301 is a schematic diagram of the structure of a code generation device provided in the third embodiment of the present invention. The code generation device provided in the embodiment of the present invention can execute the code generation method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. The device can be implemented by software and / or hardware, and specifically includes: a file analysis module 301, a code segment module 302 and a code generation module 303.

[0070] The file analysis module 301 is used to obtain various training parameters in the initial model file.

[0071] The code segment module 302 is used to generate a code segment according to the training parameters and the pre-configured code template.

[0072] The code generation module 303 is used to determine the association parameters between the code segments, and connect the code segments based on the association parameters to generate the target training code.

[0073] The technical solution of the embodiment of the present invention obtains the training parameters in the initial model code file through the file analysis module, the code segment module generates code segments according to the training parameters and the pre-configured code template, and the code generation module connects the code segments according to the associated parameters between the code segments to generate the target training code, thereby realizing the rapid generation of model training code, improving the flexibility of the machine learning model training code, adapting to the changes in the training data set, and improving the accuracy of the pre-stored machine learning model.

[0074] Further, based on the above-mentioned embodiment of the invention, the file analysis module includes:

[0075] The label acquisition unit is used to obtain the text labels in the initial model file.

[0076] A parameter acquisition unit is used to obtain the training parameters corresponding to the text label in the initial model file if the text label is a preset label; wherein the training parameters include training input parameters, training output parameters, training model parameters, data conversion parameters and / or data mining parameters.

[0077] Further, based on the above-mentioned embodiments of the invention, the preset tags in the parameter acquisition unit include data dictionary tags, mining architecture tags, data conversion tags, model definition tags and / or model interpretation tags.

[0078] Further, based on the above-mentioned embodiment of the invention, the code segment module includes:

[0079] The template acquisition unit is used to acquire a pre-configured code template according to the training parameters.

[0080] The template filling unit is used to fill the training parameters into the corresponding to-be-filled positions of the code template to generate a code segment.

[0081] Further, based on the above-mentioned embodiment of the invention, the code generation module includes:

[0082] The sequence determination unit is used to determine the appearance order of the training parameters in the initial model file as the connection sequence relationship of each code segment.

[0083] The associated parameter generating unit is used to generate associated parameters according to the incoming parameters, outgoing parameters and connection sequence relationship of each code segment.

[0084] The code segment connection unit is used to connect the code segments through associated parameters to generate target training code.

[0085] Further, based on the above-mentioned embodiments of the invention, the association parameter generation unit is specifically used to: obtain a second code segment connected to the first code segment in the code segment according to a connection order relationship, wherein the first code segment is located at the starting position of the connection order relationship; if a first outgoing parameter of the first code segment is the same as a second incoming parameter of the second code segment, then determine the first outgoing parameter as an association parameter; determine the second code segment as a new first code segment, and return the second code segment connected to the first code segment in the code segment obtained according to the connection order relationship.

[0086] Furthermore, based on the above-mentioned embodiments of the invention, the present invention further includes:

[0087] The code adjustment module is used to adjust the target training code according to the user's adjustment parameters.

[0088] Embodiment 4

[0089] Figure 4 is a schematic diagram of the structure of a device provided by Embodiment 4 of the present invention, such as Figure 4 As shown, the device includes a processor 40, a memory 41, an input device 42 and an output device 43; the number of processors 40 in the device can be one or more. Figure 4 A processor 40 is taken as an example; the processor 40, memory 41, input device 42 and output device 43 in the device can be connected by a bus or other means. Figure 4 The example of connecting through bus is taken in the following.

[0090] The memory 41, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as a program module corresponding to a code generation method in an embodiment of the present invention (for example, a file analysis module 301, a code segment module 302 and a code generation module 303 in a code generation device). The processor 40 executes various functional applications and data processing of the device by running the software programs, instructions and modules stored in the memory 41, that is, implements the above-mentioned code generation method.

[0091] The memory 41 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 41 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 41 may further include a memory remotely arranged relative to the processor 40, and these remote memories may be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0092] The input device 42 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the device. The output device 43 may include a display device such as a display screen.

[0093] Embodiment 5

[0094] Embodiment D of the present invention further provides a storage medium comprising computer executable instructions, wherein the computer executable instructions are used to execute a code generation method when executed by a computer processor, the method comprising:

[0095] Get the training parameters in the initial model file;

[0096] Generate a code segment according to each of the training parameters and a pre-configured code template;

[0097] Association parameters between the code segments are determined, and the code segments are connected based on the association parameters to generate target training code.

[0098] Of course, the computer executable instructions of a storage medium containing computer executable instructions provided by an embodiment of the present invention are not limited to the operations of the method described above, and can also execute related operations in a code generation method provided by any embodiment of the present invention.

[0099] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0100] It is worth noting that in the embodiment of the above-mentioned code generation device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be realized; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.

[0101] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.< / localtransformations> < / miningschema> < / datadictionary>

Claims

1. A code generation method, characterized in that: include: Obtain each training parameter in the initial model file; the training parameters reflect parameter information required for training the machine learning model; Generate a code segment according to each of the training parameters and a pre-configured code template; The code segments are connected to complete the complete training process of the machine learning model; Determining association parameters between the code segments, and connecting the code segments based on the association parameters to generate target training code; Get the text labels in the initial model file; If the text label is a preset label related to the machine learning model training, obtain the training parameters corresponding to the text label in the initial model file; Wherein, the training parameters include training input parameters, training output parameters, training model parameters, data conversion parameters and / or data mining parameters; Wherein, the initial model file is a model markup language file; the pre-configured code template is the same as the language of each platform; the target training code is a machine learning model training code generated according to the initial model file, and the machine learning model in the initial model file is generated after running and training; The step of determining association parameters between the code segments and connecting the code segments based on the association parameters to generate target training code includes: The order in which the training parameters appear in the initial model file is determined as the connection order relationship of each code segment; Generate associated parameters according to the incoming parameters, outgoing parameters and connection order relationship of each code segment; Connecting the code segments by associating parameters to generate target training code; Among them, the order of appearance is the order of the training parameters in the initial model file. The training parameters describing the machine learning model in the initial model file appear in the order of machine learning model training. The training parameters that appear first in the initial model file need to be used first when training the machine learning model, and the code segments corresponding to the training parameters appear in the code for training the machine learning model before other code segments.

2. The method according to claim 1, characterized in that The preset tags include data dictionary tags, mining architecture tags, data conversion tags, model definition tags and / or model interpretation tags.

3. The method according to claim 1, characterized in that The generating of code segments according to the training parameters and the pre-configured code templates includes: Get pre-configured code templates based on training parameters; Fill the training parameters into the corresponding positions to be filled in the code template to generate a code snippet.

4. The method according to claim 1, characterized in that: The generating of the associated parameters according to the incoming parameters, outgoing parameters and connection order relationship of each code segment includes: Acquire a second code segment connected to the first code segment in the code segment according to the connection sequence relationship, wherein the first code segment is located at the beginning position of the connection sequence relationship; If the first outgoing parameter of the first code segment is the same as the second incoming parameter of the second code segment, determining the first outgoing parameter as the associated parameter; The second code segment is determined as a new first code segment, and the second code segment connected to the first code segment in the code segment is obtained according to the connection order relationship.

5. The method according to claim 1, characterized in that Also includes: The target training code is adjusted according to the user's adjustment parameters.

6. A code generating device, characterized in that: include: File analysis module, used to obtain various training parameters in the initial model file; The training parameters reflect parameter information required for training the machine learning model; A code segment module, used to generate a code segment according to each of the training parameters and a pre-configured code template; The code segments are connected to complete the complete training process of the machine learning model; A code generation module, used for determining association parameters between the code segments, and connecting the code segments based on the association parameters to generate a target training code; Wherein, the file analysis module includes: A label acquisition unit, used to acquire text labels in the initial model file; A parameter acquisition unit, used for acquiring a training parameter corresponding to the text label in the initial model file if the text label is a preset label related to the machine learning model training; Wherein, the training parameters include training input parameters, training output parameters, training model parameters, data conversion parameters and / or data mining parameters; Wherein, the initial model file is a model markup language file; the pre-configured code template is the same as the language of each platform; the target training code is a machine learning model training code generated according to the initial model file, and the machine learning model in the initial model file is generated after running and training; Wherein, the code generation module includes: A sequence determination unit, used to determine the order of appearance of the training parameters in the initial model file as the connection sequence relationship of each code segment; An associated parameter generating unit, used for generating associated parameters according to the incoming parameters, outgoing parameters and connection sequence relationship of each code segment; A code segment connection unit, used to connect the code segments through associated parameters to generate a target training code; Among them, the order of appearance is the order of the training parameters in the initial model file. The training parameters describing the machine learning model in the initial model file appear in the order of machine learning model training. The training parameters that appear first in the initial model file need to be used first when training the machine learning model, and the code segments corresponding to the training parameters appear in the code for training the machine learning model before other code segments.

7. A device, characterized in that: The device comprises: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the code generation method according to any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the code generation method as described in any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Code automatic generation method and device, computer equipment and memory medium

    CN108762764A

  • A method and device for generating code

    CN110083351A