Deploy classification learner model

1 回表示 (過去 30 日間)
Ganesalingam Narenthiran
Ganesalingam Narenthiran 2020 年 7 月 19 日
回答済み: Divya Gaddipati 2020 年 7 月 23 日
Hello,
Using 'Claassification Trainer', I crated a model called 'trainedModel'
I want to predict survival 'c' for the data on the file 'for_prediction.xlsx'
I wrote the following code:
T = readtable('for_prediction.xlsxv');
predictions = trainedModel.predictFcn(T);
T.predictions = predictions;
However, I am getting errors.
I also tried:
>> % This function takes "ValidationData" as an input from Excel and
% returns "yfit" which a prediction based on the "trainedModel" from "model.mat"
function yfit = runModelFromMATLAB(ValidationData)
%#function ClassificationTree % declares which "predict" function to use
load trainedModel.mat; % trained model from Classification Learners App
for_prediction.xlsx = ValidationData;
% convert data to table
ModTableData = cell2table(for_prediction.xlsx, 'VariableNames',...
{'PCLASS','AGE','SIBSP','PARCH',...
'FARE'});
% get classification tree from the model and call predict using this tree
ModelClassTree = trainedModel.ClassificationTree;
yfit = predict(ModelClassTree, ModTableData);
yfit = {char(yfit)};
function yfit = runModelFromMATLAB(ValidationData)
Error: Function definition not supported in this context. Create functions in code file.
Would appreciate any advice. Thanks in advance!

回答 (1 件)

Divya Gaddipati
Divya Gaddipati 2020 年 7 月 23 日
Refer to the following link on how to use your model on new data

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by