2011-12-30 26 views

回答

11

的ctree對象是S4對象至少在頂部,樹信息是在「樹」插槽。 「樹插槽,可與@運營商訪問ED如果你把在幫助(ctree)頁的第一個例子,你可以得到一個圖形顯示:

plot(airct) 

enter image description here

然後您就可以看起來與列表操作遍歷是樹的樹枝的樹的「葉子」的節點的後代與「終端」 == TRUE:

> [email protected]$right$terminal 
[1] FALSE 
> [email protected]$left$terminal 
[1] FALSE 
> [email protected]$right$right$terminal 
[1] TRUE 
> [email protected]$right$left$terminal 
[1] TRUE 
> [email protected]$left$left$terminal 
[1] TRUE 
> [email protected]$left$right$terminal 
[1] FALSE 

在上面的葉子節點的信息也可以恢復:

> [email protected]$left$right 
4) Temp <= 77; criterion = 0.997, statistic = 11.599 
    5)* weights = 48 
4) Temp > 77 
    6)* weights = 21 

這是相同的信息,如果你知道了某個節點的數量nodes功能將恢復:

> nodes(airct,4) 
[[1]] 
4) Temp <= 77; criterion = 0.997, statistic = 11.599 
    5)* weights = 48 
4) Temp > 77 
    6)* weights = 21 
+0

感謝您對S4對象工作的深入瞭解。 – user1122211 2011-12-30 11:45:52

+0

@ user1122211 - 爲了表明迪文回答了您的問題 - 我會說很好 - 並且作爲對他的另一種表示方式,您可以通過直接在其左側點擊複選標記來「接受」它。謝謝。 – 2011-12-31 05:50:21

1

mlmeta [R包裝ctree模型轉換爲SAS代碼。它可以很容易地適應其他語言,並且通常對對象的內部有指導意義。