Is there any method to convert directly the decision tree from Classification Tree Viewer to If-Else rules ?

댓글 수: 1

Mario Buser
Mario Buser 2019년 7월 9일
Would be interested in a solution as well. WEKA, for example, is able to export if/else statements.

댓글을 달려면 로그인하십시오.

답변 (1개)

Koorosh Aslansefat
Koorosh Aslansefat 2020년 5월 20일

0 개 추천

I am not sure what exactly you want but the following code can be useful considering that you saved the decision tree as "tc".
CP = tc.CutPoint;
NC = tc.NodeClass;
for ii = 1:size(CP,1)
if ~isnan(CP(ii))
fprintf('if x%d < %f then node %d elseif x%d >= %f then node %d else %d \n',str2num(NC{ii}),CP(ii),ii+1,str2num(NC{ii}),CP(ii), ii+2,ii)
elseif isnan(CP(ii))
fprintf('Class = %d \n',str2num(NC{ii}))
end
end
This equal to veiw(tc)

카테고리

도움말 센터File Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

질문:

2019년 3월 6일

답변:

2020년 5월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by