簡體   English   中英

如何讀取graphviz決策樹?

[英]How to read a graphviz decision tree?

我有一個決策樹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 ;

這是我不明白的:

  1. 如果user-acceleration-magnitude-mean小於或等於0.973,則該類為“正在行走”,否則我跳到節點1,對嗎? 還是相反?
  2. 如何閱讀以“ gini = 0.596”開頭的標簽? 基尼不是我的決策樹的功能,這是什么意思?
  3. 其他值,例如nsamples和nvalue呢? 它們代表什么?

1:如果用戶加速度幅度平均值小於或等於0.973,請遵循True。 (這繼續向下進入樹中。)

2:我用Google搜索了一下,發現“基尼系數:用一組值表示的變化程度的統計量度,尤其用於分析收入不平等”。 我認為這已經脫離了經濟背景,但我不確定情況是否如此。

3:其中包含一個基礎結構。 samples是適用於該節點的樣本數量。 根有3878個樣本,左子樣本有2881個樣本,右子樣本有997個樣本。 由於2881 + 997 = 3878,因此我相信對於2881個樣本, user-acceleration-magnitude-mean <= 0.973為True。 其他997個樣本分別為False。

這些值還具有某種底層結構。 value列表中每個值的總和等於該節點中的samples數量。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM