我正在尝试使用TreeBagger构建基于UCI糖尿病130-US数据库http://archive.ics.uci.edu/ml/datasets/Diabetes+130-US+hospitals+for+years+1999-2008的分类器。
我已将数据导入为表格(让Matlab决定数据类型),并对数据进行了一些清理。我从一个例子中调用分类器,使用我自己的数据:
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';
我收到以下错误:
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.
我想知道分类器无法处理某些数据类型。
感谢您的帮助!
答案 0 :(得分:1)
R2016a中引入了机器学习工具箱表的使用。对于以前的版本,数据只能作为数组传递给fit *函数或TreeBagger。
行为从R2015(a,b)变为R2016a。