Loading Classification Model in Simulink created using MATLAB Classification Learner App
조회 수: 14 (최근 30일)
이전 댓글 표시
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:
- 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.
- 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
댓글 수: 0
답변 (1개)
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)
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)
if this answer helps you, please remember to accept the answer.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Classification Learner App에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!