Producing an error vector with a loop

1 回表示 (過去 30 日間)
Tamir Basin
Tamir Basin 2015 年 1 月 1 日
コメント済み: Tamir Basin 2015 年 1 月 1 日
I need a loop that varies the 'MinLeaf' value from 200-2000 in steps of 10. All errors should go into one vector called 'LogLike_Error_Vector". Thanks Tamir
Num = xlsread('Data_Class_2015_Student_13.xlsx');
Y = Num(:,end); Y(1)=[];
X = Num(:,1:end-1); X(1,:)=[];
ly = length(Y);
i0 = Y==0;
i1 = Y==1;
im = Y<0;
rand('seed',123)
rnd = rand(ly,1);
iData=rnd>=0 & ~im;
XX = X;
t4=fitrtree(XX(iData,:),Y(iData),'MinLeaf',400);
view(t4,'mode','graph')
t2=prune(t4,'level', 15);
DT = predict(t2,XX);
LogLike_DT_Data = LogLikelihood(DT(iData),Y(iData))/sum(iData)

採用された回答

Shoaibur Rahman
Shoaibur Rahman 2015 年 1 月 1 日
Where is your LogLike_Error_Vector? Is it LogLike_DT_Data? If so, you can try using a for loop:
indx = 0;
for MinLeaf = 200:10:2000
indx = indx + 1;
t4=fitrtree(XX(iData,:),Y(iData),'MinLeaf', MinLeaf );
view(t4,'mode','graph') % you can skip this, if not needed
t2=prune(t4,'level', 15);
DT = predict(t2,XX);
LogLike_DT_Data(indx) = LogLikelihood(DT(iData),Y(iData))/sum(iData)
end
  1 件のコメント
Tamir Basin
Tamir Basin 2015 年 1 月 1 日
Thank you :-) Tamir

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeExtend Modeling Environment についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by