Matlab or fitensemble strange behaviour!

조회 수: 3 (최근 30일)
Louis
Louis 2016년 3월 2일
편집: Louis 2016년 3월 2일
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