Matlab or fitensemble strange behaviour!

2 次查看(过去 30 天)
Hello, I am having this strange behaviour that I am trying to justify for more than a day now. Changing the value of an unused variable affects the results. Here is a snippet of the code:
a=Some vector
Number=50
mu=mean(a);
stds=std(a);
Covar=cov(a);
z=zeros(Number,100);
for ii=1:Number
z(ii,:)=mvnrnd(mu,Covar);
end
model =fitensemble(bagging classification);
My model changes if I change the variable Number! What's going on? Is it possible that changing Number is somehow affecting fitensemble initialization? Also, when a specific Number is used, then the model is consistent whenever that Number is used!
EDIT: Here is a working code. In my original code a and b are some data, but using randn could replicate the problem. Please notice that if Number is changed, the model is changed. Roughly, sum(model.UseObsForLearner(:)) changes accordingly.
rng(5)
temp=randn(100,200);
a=temp(1:50,:);
b=temp(51:end,:);
Number=10
means=mean(a);
stds=std(a);
mu=means;
Covar=cov(a);
z1=zeros(Number,200);
for ii=1:Number
z1(ii,:)=mvnrnd(mu,Covar);
end
classLabels=[ones(size(a,1),1);-1*ones(1*size(a,1),1)];
model =fitensemble([a;b],classLabels,'bag',50,'tree','type','classification');
sum(model.UseObsForLearner(:))
Many thanks
EDIT 2: I am getting closer. It has something to do with bagging. When I change from bagging to GentleBoost, the result is consistent and is not affected by the variable Number.
  2 个评论
Jan
Jan 2016-3-2
编辑:Jan 2016-3-2
Please post the original code. A rough paraphrased pseudo-code might reveal the actual problem, because you show us your intention - but the problem is, that the code does not do what you expect. If the code conatins a cause for a "strange" behavior, this detail is concealed yet.
Louis
Louis 2016-3-2
Thank you, Jan. I updated the code. This is a working code that replicates the problem.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Classification Ensembles 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by