Matlab or fitensemble strange behaviour!

1 vue (au cours des 30 derniers jours)
Louis
Louis le 2 Mar 2016
Modifié(e) : Louis le 2 Mar 2016
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 commentaires
Jan
Jan le 2 Mar 2016
Modifié(e) : Jan le 2 Mar 2016
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 le 2 Mar 2016
Thank you, Jan. I updated the code. This is a working code that replicates the problem.

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by