代码生成 -凯发k8网页登录
为 statistics and machine learning toolbox™ 函数生成 c/c 代码和 mex 函数
matlab® coder™ 可从支持代码生成的 statistics and machine learning toolbox 函数中生成可读且可移植的 c 代码和 c 代码。例如,您可以利用代码生成,将经过训练的支持向量机 (svm) 分类模型部署到不能运行 matlab 的硬件设备上,在这些硬件设备上对新观测值进行分类。
您可以通过多种方式为这些函数生成 c/c 代码:
对机器学习模型的对象函数使用
savelearnerforcoder
、loadlearnerforcoder
和codegen
(matlab coder)。对机器学习模型的
predict
和update
对象函数使用由learnercoderconfigurer
创建的代码生成器配置器。使用配置器配置代码生成选项,并在生成代码中更新模型参数。对于支持代码生成的其他函数,使用
codegen
。
您还可以生成定点 c/c 代码,用于预测一些机器学习模型。这种类型的代码生成需要 fixed-point designer™。
要将机器学习模型的预测集成到 simulink® 中,请使用 statistics and machine learning toolbox 库中的 matlab function 模块或 simulink 模块。
要了解代码生成,请参阅introduction to code generation。
有关支持代码生成的函数的列表,请参阅。
函数
对象
模块
主题
代码生成工作流
- introduction to code generation
learn how to generate c/c code for statistics and machine learning toolbox functions.
generate code for statistics and machine learning toolbox functions that do not use machine learning model objects.
generate code for the prediction of a classification or regression model at the command line.
generate code that implements incremental learning for binary linear classification at the command line.
generate code for the prediction of a classification or regression model by using the matlab coder app.- code generation for prediction and update using coder configurer
generate code for the prediction of a model using a coder configurer, and update model parameters in the generated code.
generate code that accepts input arguments whose size might change at run time.
generate code for classifying data in a table containing numeric and categorical variables.
convert categorical predictors to numeric dummy variables before fitting an svm classifier and generating code.- fixed-point code generation for prediction of svm
generate fixed-point code for the prediction of an svm classification or regression model.
train a classification model using the classification learner app, and generate c/c code for prediction.
generate code for finding nearest neighbors using a nearest neighbor searcher model.
generate code that fits a probability distribution object to sample data and evaluates the fitted distribution object.
this example shows how to train a binary glm logistic regression model using classification learner, and then generate c code that predicts labels using the exported classification model.
generate single-precision code that detects anomalies in data using a trained isolation forest model or one-class svm.
分类和回归预测模块
- predict class labels using classificationsvm predict block
this example shows how to use the classificationsvm predict block for label prediction in simulink®.
train a classification decision tree model using the classification learner app, and then use the classificationtree predict block for label prediction.
this example shows how to use the classificationlinear predict block for label prediction in simulink®.
train an ecoc classification model, and then use the classificationecoc predict block for label prediction.
train a classification ensemble model with optimal hyperparameters, and then use the classificationensemble predict block for label prediction.
train a neural network classification model, and then use the classificationneuralnetwork predict block for label prediction.
train a nearest neighbor classification model, and then use the classificationknn predict block for label prediction.- predict responses using regressionsvm predict block
train a support vector machine (svm) regression model using the regression learner app, and then use the regressionsvm predict block for response prediction.
this example shows how to use the regressiontree predict block for response prediction in simulink®.
this example shows how to use the regressionlinear predict block for response prediction in simulink®.
train a regression ensemble model with optimal hyperparameters, and then use the regressionensemble predict block for response prediction.
train a neural network regression model, and then use the regressionneuralnetwork predict block for response prediction.
train a gaussian process (gp) regression model, and then use the regressiongp predict block for response prediction.
代码生成应用程序
- predict class labels using matlab function block
generate code from a simulink model that classifies data using an svm model. - system objects for classification and code generation
generate code from a system object™ for making predictions using a trained classification model, and use the system object in a simulink model. - predict class labels using stateflow
generate code from a stateflow® model that classifies data using a discriminant analysis classifier.
generate code from a classification simulink model prepared for fixed-point deployment.- (simulink support package for arduino hardware)
this example shows how to use the simulink® support package for arduino® hardware to identify punch and flex hand gestures using a machine learning algorithm.
predict in simulink using a neural network regression model, and deploy the simulink model to an fpga/asic platform by using hdl code generation.