我有一个决策树graphviz文件,我通过使用ScikitLearn的export_graphviz函数获得。为了简单起见,我将深度限制为3,所以我得到了这个输出:
digraph Tree {
node [shape=box] ;
0 [label="userAcceleration-magnitude-mean <= 0.973\ngini = 0.875\nsamples = 3878\nvalue = [471, 467, 485, 484, 486, 486, 513, 486]\nclass = Walking"] ;
1 [label="userAcceleration-x-IQR <= 0.073\ngini = 0.834\nsamples = 2881\nvalue = [471, 443, 476, 484, 9, 486, 512, 0]\nclass = Walking"] ;
0 -> 1 [labeldistance=2.5, labelangle=45, headlabel="True"] ;
2 [label="rotationRate-z-IQR <= 0.396\ngini = 0.606\nsamples = 1020\nvalue = [466, 80, 43, 2, 0, 429, 0, 0]\nclass = Push-ups"] ;
1 -> 2 ;
3 [label="gini = 0.355\nsamples = 515\nvalue = [5, 74, 28, 2, 0, 406, 0, 0]\nclass = Resting"] ;
2 -> 3 ;
4 [label="gini = 0.164\nsamples = 505\nvalue = [461, 6, 15, 0, 0, 23, 0, 0]\nclass = Push-ups"] ;
2 -> 4 ;
5 [label="rotationRate-magnitude-median <= 0.844\ngini = 0.764\nsamples = 1861\nvalue = [5, 363, 433, 482, 9, 57, 512, 0]\nclass = Walking"] ;
1 -> 5 ;
6 [label="gini = 0.596\nsamples = 974\nvalue = [2, 73, 388, 476, 0, 23, 12, 0]\nclass = Lunges"] ;
5 -> 6 ;
7 [label="gini = 0.571\nsamples = 887\nvalue = [3, 290, 45, 6, 9, 34, 500, 0]\nclass = Walking"] ;
5 -> 7 ;
8 [label="userAcceleration-y-max <= 2.702\ngini = 0.533\nsamples = 997\nvalue = [0, 24, 9, 0, 477, 0, 1, 486]\nclass = Running"] ;
0 -> 8 [labeldistance=2.5, labelangle=-45, headlabel="False"] ;
9 [label="rotationRate-z-IQR <= 2.4\ngini = 0.236\nsamples = 536\nvalue = [0, 22, 6, 0, 466, 0, 1, 41]\nclass = Jump Rope"] ;
8 -> 9 ;
10 [label="gini = 0.553\nsamples = 53\nvalue = [0, 11, 6, 0, 3, 0, 0, 33]\nclass = Running"] ;
9 -> 10 ;
11 [label="gini = 0.08\nsamples = 483\nvalue = [0, 11, 0, 0, 463, 0, 1, 8]\nclass = Jump Rope"] ;
9 -> 11 ;
12 [label="altitude-median <= 5.0\ngini = 0.068\nsamples = 461\nvalue = [0, 2, 3, 0, 11, 0, 0, 445]\nclass = Running"] ;
8 -> 12 ;
13 [label="gini = 0.0\nsamples = 445\nvalue = [0, 0, 0, 0, 0, 0, 0, 445]\nclass = Running"] ;
12 -> 13 ;
14 [label="gini = 0.477\nsamples = 16\nvalue = [0, 2, 3, 0, 11, 0, 0, 0]\nclass = Jump Rope"] ;
12 -> 14 ;
}
让我们专注于前两个节点:
0 [label="userAcceleration-magnitude-mean <= 0.973\ngini = 0.875\nsamples = 3878\nvalue = [471, 467, 485, 484, 486, 486, 513, 486]\nclass = Walking"] ;
1 [label="userAcceleration-x-IQR <= 0.073\ngini = 0.834\nsamples = 2881\nvalue = [471, 443, 476, 484, 9, 486, 512, 0]\nclass = Walking"] ;
0 -> 1 [labeldistance=2.5, labelangle=45, headlabel="True"] ;
2 [label="rotationRate-z-IQR <= 0.396\ngini = 0.606\nsamples = 1020\nvalue = [466, 80, 43, 2, 0, 429, 0, 0]\nclass = Push-ups"] ;
1 -> 2 ;
这是我不明白的地方:
答案 0 :(得分:0)
1:如果user-acceleration-magnitude-mean小于或等于0.973,请按True。 (这继续向下进入树。)
2:我搜索了一下,发现了基尼系数:一组数值中表示的变异程度的统计指标,特别用于分析收入不平等和#34;。我认为它已经脱离了经济背景,但我不确定是否是这种情况。
3:
这有一个潜在的结构。 samples
是适用于该节点的样本数量。根部有3878个样本,左侧儿童为2881个,右侧儿童为997个。自2881 + 997 = 3878以来,我认为2881个样本user-acceleration-magnitude-mean <= 0.973
为真。其他997个样本分别为False。
价值观也有某种潜在的结构。 value
列表中每个值的总和等于该节点中samples
的数量。