フィルターのクリア

Machine Learning with MATLAB 4.7, Further Practice

2 ビュー (過去 30 日間)
Drilon Ferra
Drilon Ferra 2021 年 2 月 27 日
回答済み: Vishesh 2023 年 9 月 21 日
The question is to find a confusion chart. Before that, there were two tasks to complete.
Pre-existing code:
rng(0)
load creditData
creditRatings
mdlFull
fullLoss = kfoldLoss(mdlFull)
Construct a tree model for Task 1:
tModel = fitctree(creditRatings, "Rating")
p = predictorImportance(tModel)
bar(p)
xticklabels(creditRatings.Properties.VariableNames(1:end-1))
xtickangle(60)
[~,iSorted] = sort(p)
selected = [iSorted(1:3) width(creditRatings)]
mdl = fitctree(creditRatings(:,selected), "Rating", "KFold", 7)
mdlLoss = kfoldLoss(mdl)
Task 2 (which I don't think is relevant to the Further Practice) was to construct an ensemble model:
mdlEns = fitcensemble(creditRatings(:, selected), "Rating", "Method", "Bag", "Learners", "tree", "NumLearningCycles", 50, "KFold", 7)
lossEns = kfoldLoss(mdlEns)
For the further practice, I attempted to get a prediction (there is no dataTest/dataTrain presented) but kep getting the error "Check for missing argument or incorrect argument data type in call to function 'predict'". The following lines each gave the error.
prediction = predict(mdl, creditRatings)
prediction = predict(mdl, creditRatings.Rating)
%confusionchart(creditRatings.Rating, prediction)
Perhaps the data needs to be divided by the user? I read that either the model type isn't "ClassificationTree", or the data should be a table. double or single. As far as I can tell, I have used a tree model, and creditRatings is a table.
anonfun = @(XTrain,yTrain,XTest,yTest) nnz(yTest ~= predict(fitfunction(XTrain,yTrain),XTest))
Am unsure how to call yTrain though from this function.

回答 (1 件)

Vishesh
Vishesh 2023 年 9 月 21 日
I understand that you are getting following error when calling "predict" function in your script:
Check for missing argument or incorrect argument data type in call to function 'predict'
Please refer to the following MATLAB answer for a solution to resolve this error:
Also, please refer to the following MATLAB answer for guidance to split your data into training and testing data:

カテゴリ

Help Center および File ExchangeGaussian Process Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by