如果我把這個問題作爲我對R和一般的統計分析非常陌生的話,我會提前道歉。用「print」顯示推理樹節點值
我使用party
庫生成了條件推理樹。
當我我plot(my_tree, type = "simple")
得到這樣一個結果:
當我print(my_tree)
我得到這樣一個結果:
1) SOME_VALUE <= 2.5; criterion = 1, statistic = 1306.478
2) SOME_VALUE <= -10.5; criterion = 1, statistic = 173.416
3) SOME_VALUE <= -16; criterion = 1, statistic = 19.385
4)* weights = 275
3) SOME_VALUE > -16
5)* weights = 261
2) SOME_VALUE > -10.5
6) SOME_VALUE <= -2.5; criterion = 1, statistic = 24.094
7) SOME_VALUE <= -6.5; criterion = 0.974, statistic = 4.989
8)* weights = 346
7) SOME_VALUE > -6.5
9)* weights = 563
6) SOME_VALUE > -2.5
10)* weights = 442
1) SOME_VALUE > 2.5
11) SOME_VALUE <= 10; criterion = 1, statistic = 225.148
12) SOME_VALUE <= 6.5; criterion = 1, statistic = 18.789
13)* weights = 648
12) SOME_VALUE > 6.5
14)* weights = 473
11) SOME_VALUE > 10
15) SOME_VALUE <= 16; criterion = 1, statistic = 51.729
16)* weights = 595
15) SOME_VALUE > 16
17) SOME_VALUE <= 23.5; criterion = 0.997, statistic = 8.931
18)* weights = 488
17) SOME_VALUE > 23.5
19)* weights = 365
我喜歡的print
輸出,但它似乎是缺少y = (0.96, 0.04)
值。
理想情況下,我想我的輸出是這個樣子:
1) SOME_VALUE <= 2.5; criterion = 1, statistic = 1306.478
2) SOME_VALUE <= -10.5; criterion = 1, statistic = 173.416
3) SOME_VALUE <= -16; criterion = 1, statistic = 19.385
4)* weights = 275; y = (0.96, 0.04)
3) SOME_VALUE > -16
5)* weights = 261; y = (0.831, 0.169)
2) SOME_VALUE > -10.5
...
我如何去實現呢?
它不會那麼容易,因爲所有'print.BinaryTree'方法基本上都是在打印'my_tree @ tree'的同時添加上面的註釋。 –
有沒有簡單提取這些值的方法?如果必須的話,我會很好的手動加入它。我只是尋找一些編程方法來獲得它們,而不是從一個繪圖手動複製。 –
是的,請參閱我的回答[here](http://stats.stackexchange.com/a/171317/42632),其中我準確地展示瞭如何實現這一目標。另請參閱軟件包創建者自己(Zeileis教授)就如何使用新的'partykit'軟件包來做到這一點的其他答案。 –