Loading Classification Model in Simulink created using MATLAB Classification Learner App

14 ビュー (過去 30 日間)
Burhan Hyder
Burhan Hyder 2021 年 7 月 1 日
回答済み: Drew 2023 年 11 月 3 日
I have trained a classification model using Matlab's Classification Learner App. I have exported it to the workspace and also saved it as a .mat file.
I need to embed it in a Simulink model to make predictions at every time step during simulation. I've tried multiple things like:
  1. Using a From File block to load the classification model from the .mat file and then using mdl.predictFcn(myInputData) to make a prediction on new data.
  2. Pre-loading the model in workspace and then accessing it using a Matlab Function
However, both of these methods do not work. The first method gives me an error stating that the .mat file can only have timeseries data (which it doesn't as it is a classification model) and the second method is not able to identify the pre-loaded model in the workspace.
Can someone guide me in solving this issue. Thanks

回答 (1 件)

Drew
Drew 2023 年 11 月 3 日
MathWorks provides Simulink blocks for machine learning model prediction. So, you can use the native Simulink block designed for model prediction with your machine learning model. Check the "Blocks" section of the doc page https://www.mathworks.com/help/stats/code-generation.html
For example, from that doc page, here are Simulink blocks currently available for prediction with different types of ML Classifiers:
ClassificationECOC Predict Classify observations using error-correcting output codes (ECOC) classification model (Since R2023a)
ClassificationEnsemble Predict Classify observations using ensemble of decision trees (Since R2021a)
ClassificationKNN Predict Classify observations using nearest neighbor classification model (Since R2022b)
ClassificationLinear Predict Classify observations using linear classification model (Since R2023a)
ClassificationNaiveBayes Predict Classify observations using naive Bayes model (Since R2023b)
ClassificationNeuralNetwork Predict Classify observations using neural network classification model (Since R2021b)
ClassificationSVM Predict Classify observations using support vector machine (SVM) classifier for one-class and binary classification (Since R2020b)
ClassificationTree Predict Classify observations using decision tree classifier (Since R2021a)
if this answer helps you, please remember to accept the answer.

カテゴリ

Help Center および File ExchangeClassification Learner App についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by