La traduction de cette page n'est pas à jour. Cliquez ici pour voir la dernière version en anglais.
Génération de code pour les fonctions statistiques et de Machine Learning
R2026aMATLAB® Coder™ génère du code C et C++ lisible et portable à partir des fonctions de Statistics and Machine Learning Toolbox qui supportent la génération de code. Par exemple, il est possible de classifier de nouvelles observations sur des équipements hardware qui ne peuvent pas exécuter MATLAB en déployant un modèle de classification par machine à vecteurs de support (SVM) entraîné sur l’équipement grâce à la génération de code.
Vous pouvez générer du code C/C++ pour ces fonctions de différentes manières :
Utilisez
saveLearnerForCoder,loadLearnerForCoderetcodegen(MATLAB Coder) pour une fonction d’objet d’un modèle de Machine Learning.Utilisez un configurateur de codeur créé par
learnerCoderConfigurerpour les fonctions d’objetpredictetupdated’un modèle de Machine Learning. Configurez les options de génération de code à l’aide du configurateur et mettez à jour les paramètres du modèle dans le code généré.Utilisez
codegenpour les autres fonctions qui supportent la génération de code.Entraînez un modèle de Machine Learning dans l’application Classification Learner ou Regression Learner et exportez-le vers MATLAB Coder.
Il est également possible de générer du code C/C++ en virgule fixe pour la prédiction de certains modèles de Machine Learning. Ce type de génération de code nécessite Fixed-Point Designer™.
Pour en savoir plus sur la génération de code, consultez Introduction to Code Generation for Statistics and Machine Learning Functions.
Pour une liste des fonctions qui supportent la génération de code, consultez Liste des fonctions (génération de code C/C++).
Fonctions
Objets
Rubriques
Workflows de génération de code
- Introduction to Code Generation for Statistics and Machine Learning Functions
Learn how to generate C/C++ code for Statistics and Machine Learning Toolbox functions. - Overview of Code Generation Using MATLAB Coder (MATLAB Coder)
The MATLAB Coder code generation workflow. - 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 Incremental Learning
Generate code that implements incremental learning for binary linear classification 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. - Specify Variable-Size Arguments for Code Generation of Machine Learning Models
Generate code that accepts input arguments whose size might change at run time. - Generate Code to Classify Data in Table
Generate code for classifying data in a table containing numeric and categorical variables. - Create Dummy Variables for 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 Nearest Neighbor Searcher
Generate code for finding nearest neighbors using a nearest neighbor searcher model. - Code Generation for Probability Distribution Objects
Generate code that fits a probability distribution object to sample data and evaluates the fitted distribution object. - Code Generation for Anomaly Detection
Generate single-precision code that detects anomalies in data using a trained isolation forest model or one-class SVM.
Workflows de génération de code dans les applications de Machine Learning
- Export Classification Model to MATLAB Coder to Generate C/C++ Code
After training a model in Classification Learner, export the model to MATLAB Coder to generate C/C++ code for prediction. - Export Regression Model to MATLAB Coder to Generate C/C++ Code
After training a model in Regression Learner, export the model to MATLAB Coder to generate C/C++ code for prediction. - Generate Code at Command Line Using Model Exported from Machine Learning App
Train a classification model using the Classification Learner app, and generate C/C++ code for prediction at the MATLAB command line. - Code Generation for Binary GLM Logistic Regression Model Trained in Classification Learner
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.
Applications de génération de code
- 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 MATLAB Function Block
Generate code from a Simulink model that classifies data using an SVM model. - Predict Class Labels Using Stateflow
Generate code from a Stateflow® model that classifies data using a discriminant analysis classifier.

