필터 지우기
필터 지우기

Check for missing argument or incorrect argument data type in call to function 'predict'.

조회 수: 5 (최근 30일)
I am trying to predict values of cross-validated model using training data.But I am getting this error -
Check for missing argument or incorrect argument data type in call to function 'predict'.
The code I am using is as below -
mdlCv= fitctree(bank_Train,'y','KFold',10); %bank_Train is the training data
[label,scores] = predict(mdlCv,bank_Test); %bank_Test is the testing data
If I try to use below code then also I am getting the error
[label,scores] = predict(mdlCv.Trained{1},bank_Test);
Error using classreg.learning.internal.table2PredictMatrix>makeXMatrix (line 97)
Table variable job is not a valid predictor.
Error in classreg.learning.internal.table2PredictMatrix (line 47)
Xout = makeXMatrix(X,CategoricalPredictors,vrange,pnames);
Error in classreg.learning.classif.CompactClassificationTree/predict (line 894)
X = classreg.learning.internal.table2PredictMatrix(X,[],[],...

채택된 답변

Walter Roberson
Walter Roberson 2020년 12월 6일
편집: Walter Roberson 2020년 12월 6일
You are using 'KFold' so you are creating a classification partitioned object and need to use kfoldPredict() instead of predict()
  댓글 수: 1
Tejal Mehta
Tejal Mehta 2020년 12월 6일
Thanks .
If I want to predict using test data then do I have to create model on test data and then use kfoldPredict ?
I cannot directly use predict function with test_data?
Like I saw somewhere this below code works if all columns are numeric -
[label,scores] = predict(mdlCv.Trained{1},bank_Test); %bank_Test is the testing data
for me this is not working as I have got few categorical columns as well and it is throwing error stating
Error using classreg.learning.internal.table2PredictMatrix>makeXMatrix (line 97)
Table variable job is not a valid predictor.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

제품

Community Treasure Hunt

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

Start Hunting!

Translated by