Matlab 如何在分类决策树中获得特定类类型的决策路径

Matlab 如何在分类决策树中获得特定类类型的决策路径,matlab,classification,instantiation,decision-tree,data-generation,Matlab,Classification,Instantiation,Decision Tree,Data Generation,假设我创建了一个分类决策树,如下所示: HP(1:size(HP),end)=0;LP(1:尺寸(LP),末端)=1; %dt的输入和目标pop x=[HP(:,1:end-1);LP(:,1:end-1)];t=[HP(:,end);LP(:,end)]; dt=fitcree(x,t); 视图(dt) 视图(dt,‘模式’、‘图形’); 其结果如下: 1 if x2<-21.4866 then node 2 elseif x2>=-21.4866 then node 3 el

假设我创建了一个分类决策树,如下所示:

HP(1:size(HP),end)=0;LP(1:尺寸(LP),末端)=1;
%dt的输入和目标pop
x=[HP(:,1:end-1);LP(:,1:end-1)];t=[HP(:,end);LP(:,end)];
dt=fitcree(x,t);
视图(dt)
视图(dt,‘模式’、‘图形’);
其结果如下:

1  if x2<-21.4866 then node 2 elseif x2>=-21.4866 then node 3 else 1
2  class = 1
3  if x2<20.093 then node 4 elseif x2>=20.093 then node 5 else 0
4  if x1<27.8438 then node 6 elseif x1>=27.8438 then node 7 else 0
5  if x2<39.6866 then node 8 elseif x2>=39.6866 then node 9 else 1
6  if x1<-33.7504 then node 10 elseif x1>=-33.7504 then node 11 else 0
7  class = 1
8  class = 1
9  class = 0
10  class = 1
11  if x2<1.53772 then node 12 elseif x2>=1.53772 then node 13 else 0
12  if x2<-2.50063 then node 14 elseif x2>=-2.50063 then node 15 else 0
13  class = 0
14  if x1<14.2153 then node 16 elseif x1>=14.2153 then node 17 else 0
15  class = 1
16  class = 0
17  class = 1
1如果x2=-21.4866,则节点3其他1
2类=1类
3如果x2=20.093,则节点5否则为0
4如果x1=27.8438,则节点7否则为0
5如果x2=39.6866,则节点9其他1
6如果x1=-33.7504,则节点11否则为0
7类=1
8类=1
9类=0
10类=1
11如果x2=1.53772,则节点13其他0
12如果x2=-2.50063,则节点15其他0
13类=0
14如果x1=14.2153,则节点17为0
15类=1
16类=0
17类=1

问题: 1) 如何获取指向值为“0”的叶的所有路径


2) 是否有任何方法可以基于决策树创建新实例(除了随机生成实例和循环,直到获得所需的输出)?例如,我想创建一个随机实例,上面的树将其分类为“0”

如果您知道决策的结束节点,您可以找到路径。您可以从
[lable,score,node,cusum]=predict(mdl,x)中获取结束节点号。如果您想从Treebagger获取每个树的节点,则需要在每个树的循环中运行相同的节点<代码>[lable,score,node,cusum]=mdl.Trees{i}.predict(x)