How to get the out degree of trees?
1 次查看(过去 30 天)
显示 更早的评论
tree = [0 1 2 2 2 2 2 1 8 8 1 11 11 1 14];
C=children(tree);
treeplot(tree);
count = size(tree,2);
[x,y] = treelayout(tree);
x = x';
y = y';
name1 = cellstr(num2str((1:count)'));
text(x(:,1), y(:,1), name1, 'VerticalAlignment','bottom','HorizontalAlignment','right');
title({'Level Lines'},'FontSize',12,'FontName','Times New Roman');
why the one in bold doesn't work?
0 个评论
回答(1 个)
Walter Roberson
2012-2-26
Your "tree" variable is not a classregtree as is required for the children() function. See http://www.mathworks.com/help/toolbox/stats/classregtree.children.html
3 个评论
Walter Roberson
2012-2-26
Once the tree is a classregtree, then
C = children(TheClassRegTree);
outdegree = sum(C~=0,2);
and outdegree for node #3 would be outdegree(3) with the children of node #3 being C(3,:)
In order to create a classregtree you need both a predictor and a response. You appear to be missing one of those two.
http://www.mathworks.com/help/toolbox/stats/classregtree.html
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!