Main Content

코드 생성

Statistics and Machine Learning Toolbox™ 함수에 대한 C/C++ 코드 및 MEX 함수 생성

MATLAB® Coder™는 코드 생성을 지원하는 Statistics and Machine Learning Toolbox 함수에서, 읽을 수 있고 이식 가능한 C 및 C++ 코드를 생성합니다. 예를 들어, 코드 생성을 사용하여 MATLAB을 실행할 수 없는 하드웨어 장치에 훈련된 서포트 벡터 머신(SVM) 분류 모델을 배포해 이 장치에서 새 관측값을 분류할 수 있습니다.

여러 가지 방법으로 다음 함수에 대한 C/C++ 코드를 생성할 수 있습니다.

  • 머신러닝 모델의 객체 함수에 대해서는 saveLearnerForCoder, loadLearnerForCoder, codegen (MATLAB Coder)을 사용합니다.

  • 머신러닝 모델의 predictupdate 객체 함수에 대해서는 learnerCoderConfigurer로 생성된 코더 구성기를 사용합니다. 이 구성기를 사용하여 코드 생성 옵션을 구성하고 생성된 코드에서 모델 파라미터를 업데이트하십시오.

  • 코드 생성을 지원하는 다른 함수에 대해서는 codegen을 사용합니다.

일부 머신러닝 모델의 예측을 위해 고정소수점 C/C++ 코드를 생성할 수도 있습니다. 이 유형의 코드를 생성하려면 Fixed-Point Designer™가 필요합니다.

머신러닝 모델의 예측을 Simulink®에 통합하려면 Statistics and Machine Learning Toolbox 라이브러리에서 MATLAB Function 블록이나 Simulink 블록을 사용하십시오.

코드 생성에 대해 알아보려면 Introduction to Code Generation 항목을 참조하십시오.

코드 생성을 지원하는 함수 목록은 함수 목록(C/C++ 코드 생성)을 참조하십시오.

함수

모두 확장

saveLearnerForCoderSave model object in file for code generation
loadLearnerForCoderReconstruct model object from saved model for code generation
generateLearnerDataTypeFcnGenerate function that defines data types for fixed-point code generation

코더 구성기 객체 생성

learnerCoderConfigurerCreate coder configurer of machine learning model

코더 구성기 객체 사용

generateCodeGenerate C/C++ code using coder configurer
generateFilesGenerate MATLAB files for code generation using coder configurer
validatedUpdateInputsValidate and extract machine learning model parameters to update
updateUpdate model parameters for code generation

객체

모두 확장

ClassificationTreeCoderConfigurerCoder configurer of binary decision tree model for multiclass classification
ClassificationSVMCoderConfigurerCoder configurer for support vector machine (SVM) for one-class and binary classification
ClassificationLinearCoderConfigurerCoder configurer for linear binary classification of high-dimensional data
ClassificationECOCCoderConfigurerCoder configurer for multiclass model using binary learners
RegressionTreeCoderConfigurerCoder configurer of binary decision tree model for regression
RegressionSVMCoderConfigurerCoder configurer for support vector machine (SVM) regression model
RegressionLinearCoderConfigurerCoder configurer for linear regression model with high-dimensional data

블록

ClassificationSVM PredictClassify observations using support vector machine (SVM) classifier for one-class and binary classification
RegressionSVM PredictPredict responses using support vector machine (SVM) regression model

도움말 항목

코드 생성 워크플로

Introduction to Code Generation

Learn how to generate C/C++ code for Statistics and Machine Learning Toolbox functions.

General Code Generation Workflow

Generate code for Statistics and Machine Learning Toolbox functions that do not use machine learning model objects.

Code Generation for Prediction of Machine Learning Model at Command Line

Generate code for the prediction of a classification or regression model at the command line.

Code Generation for Prediction of Machine Learning Model Using MATLAB Coder App

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.

Code Generation and Classification Learner App

Train a classification model using the Classification Learner app, and generate C/C++ code for prediction.

Code Generation for Nearest Neighbor Searcher

Generate code for finding nearest neighbors using a nearest neighbor searcher model.

Specify Variable-Size Arguments for Code Generation

Generate code that accepts input arguments whose size might change at run time.

Train SVM Classifier with Categorical Predictors and Generate C/C++ Code

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.

Code Generation for Probability Distribution Objects

Generate code that fits a probability distribution object to sample data and evaluates the fitted distribution object.

Generate Code to Classify Numeric Data in Table

Generate code for classifying numeric data in a table using a binary decision tree.

코드 생성 응용 사례

Predict Responses Using RegressionSVM Predict Block

This example shows how to train a support vector machine (SVM) regression model using the Regression Learner app, and then use the RegressionSVM Predict block for response prediction in Simulink®.

Predict Class Labels Using ClassificationSVM Predict Block

This example shows how to use the ClassificationSVM Predict block for label 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.

추천 예제