简体   繁体   中英

Matlab TreeBagger: Table variable is not a valid predictor

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 from an example, using my own data:

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!

The use of tables for the Machine Learning toolbox was introduced in R2016a. For previous versions, the data could only be passed to the fit* functions or TreeBagger as arrays.

The behavior changed from R2015(a,b) to R2016a.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM