fitensemble cross-validation error

8 views (last 30 days)
Abhinav
Abhinav on 17 Oct 2015
Edited: Abhinav on 17 Oct 2015
I want to to find out optimal number of splits and learning rate for LSBoost. I followed the procedure mentioned in fitensemble documentation. However, I am getting an error at the end of the code. Code is as follows
Ntrees=250;
n=size(X,1);
m = floor(log2(n - 1));
lr = [0.01 0.05 0.1 0.25 0.5 1];
maxNumSplits = 2.^(0:m);
Mdl = cell(numel(maxNumSplits),numel(lr));
for k = 1:numel(lr);
for j = 1:numel(maxNumSplits);
templ = templateTree('MaxNumSplits',maxNumSplits(j));
Mdl{j,k} = fitensemble(xc,yc,'LSBoost',Ntrees,templ,...
'Type','regression','KFold',5,'LearnRate',lr(k));
end;
end;
kflAll = @(xc)kfoldLoss(xc,'Mode','cumulative');
errorCell = cellfun(kflAll,Mdl,'Uniform',false);
I got an error inh last line of code, which is as follows
Operands to the || and && operators must be convertible to logical scalar values.
Error in classreg.learning.partition.PartitionedEnsemble/checkEnsembleFoldArgs (line 112)
if ~isnumeric(folds) || ~isvector(folds) || min(folds)<=0 || max(folds)>kfold
Error in classreg.learning.partition.RegressionPartitionedEnsemble/kfoldLoss (line 133)
[mode,folds,partArgs] = checkEnsembleFoldArgs(this,extraArgs{:});
Error in @(xc)kfoldLoss(xc,'Mode','cumulative')
Can anyone please help me figure out the problem and how to correct it?
Also, I don't really understand last two lines of the code, it would be great help if someone can help me to figure that out.

Answers (0)

Community Treasure Hunt

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

Start Hunting!