TreeBagger: Table variable is not a valid predictor.

10 visualizzazioni (ultimi 30 giorni)
I'm trying to use TreeBagger to build a classifier based on the UCI Diabetes 130-US database, http://archive.ics.uci.edu/ml/datasets/Diabetes+130-US+hospitals+for+years+1999-2008.
I have imported the data as a table (letting Matlab decide on the data types), and have done some cleaning on the data. I'm calling the classifier as:
num_trees = 50;
B = TreeBagger(num_trees, train, train.readmitted,...
'OOBPrediction','On',...
'Method','classification');
oobErrorBaggedEnsemble = oobError(B);
plot(oobErrorBaggedEnsemble)
xlabel 'Number of grown trees';
ylabel 'Out-of-bag classification error';
I get the following error:
Error using classreg.learning.internal.table2PredictMatrix>makeXMatrix (line 100) Table variable is not a valid predictor.
Error in classreg.learning.internal.table2PredictMatrix (line 57)
Xout = makeXMatrix(X,CategoricalPredictors,vrange,pnames);
Error in classreg.learning.classif.CompactClassificationTree/predict (line 639)
X = classreg.learning.internal.table2PredictMatrix(X,[],[],...
Error in CompactTreeBagger/treeEval (line 1083)
[labels,~,nodes] = predict(tree,x);
Error in CompactTreeBagger/predictAccum (line 1414)
thisR = treeEval(bagger,it,thisX,doclassregtree);
Error in CompactTreeBagger/error (line 470)
predictAccum(bagger,X,'useifort',useIforT,...
Error in TreeBagger/oobError (line 1479)
err = error(bagger.Compact,bagger.X,bagger.Y,...
train is a table, and table.readmitted is a cell retrieved from the table. Most of the rows are cells, as most of the data in this dataset is categorical.
I'm wondering is there are certain datatypes that the classifier can't handle.
Thanks for any help!
  4 Commenti
Ridwan Alam
Ridwan Alam il 26 Nov 2019
Hi Karel, has this question been answered already then?
Karel Mundnich
Karel Mundnich il 26 Nov 2019
Yes. Just posted the comment above as an answer and accepted it, so others can see that there's an answer.

Accedi per commentare.

Risposta accettata

Karel Mundnich
Karel Mundnich il 26 Nov 2019
In my problem, the input to the function was a table, for a MATLAB version that was not able to parse the input as a table. Check that the version of MATLAB that you're using is compatible with the code that you're running.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by