How can I use a model exported from classification learner to make a prediction?
조회 수: 1 (최근 30일)
이전 댓글 표시
So I've trained a model and exported it to my workspace however i get an error when i try to use it to make a prediction. I've tried two forms, one as instructed by matlab, and the 2nd according to this answer
first attempt: my code is
m1.predictFcn(featureVec)
and i get an error
Error using array2table (line 62)
The VariableNames property must contain one name for each variable in the table.
Error in mlearnapp.internal.model.DatasetSpecification>@(x)array2table(x','VariableNames',this.PredictorNames)
Error in mlearnapp.internal.model.DatasetSpecification>@(x)exportableClassifier.predictFcn(predictorExtractionFcn(x)) (line 138)
newExportableClassifier.predictFcn = @(x) exportableClassifier.predictFcn(predictorExtractionFcn(x));
2nd attempt
VarNames = arrayfun(@(N) sprintf('VarName%d',N), 1:4, 'Uniform', 0);
FV_table = array2table( featureVector, 'VariableNames', {'a','b','c','d'});
yfit = m1.predictFcn(featureVector)
and this time the error is
Error using array2table (line 62)
The VariableNames property must contain one name for each variable in the table.
Error in mlearnapp.internal.model.DatasetSpecification>@(x)array2table(x','VariableNames',this.PredictorNames)
Error in mlearnapp.internal.model.DatasetSpecification>@(x)exportableClassifier.predictFcn(predictorExtractionFcn(x)) (line 138)
newExportableClassifier.predictFcn = @(x) exportableClassifier.predictFcn(predictorExtractionFcn(x));
답변 (1개)
Billy Ram
2022년 3월 15일
I might be very late in answering this question. I had the same problem and was looking for answers. Make sure that you don't have the supervised class column in your test data.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Classification Ensembles에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!