2016-08-09 34 views
-2

我使用虹膜數據R.,使用R

我寫這樣的代碼是什麼決策樹平均Y:

irisctree<-ctree(Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width) 
plot(itisctree,type="simple") 

,並導致看見我這個樣子: enter image description here

這是什麼意思?

Y =(1,0,0)和y =(0,0.939,0.061),Y =(0,0.031,0.969)

+0

你需要統計教育。這不是真正的SO任務。 –

回答

1

如果您在iris看物種(您的響應變量)數據集,你會看到,它與3級水平的因素:

> unique(iris$Species) 
[1] setosa  versicolor virginica 
Levels: setosa versicolor virginica 

鑑於該水平出現在上面的順序:setosa,雲芝,錦葵,決策樹的輸出爲每一種的概率水平,並且概率總和爲1.

要驗證這一點,請查看您的t的左側分割稀土元素。它分裂在Petal.Length <= 1.9。當Petal.Length <= 1.9時物種的分佈是什麼?

prop.table(table(iris[iris$Petal.Length <= 1.9,]$Species)) 

setosa versicolor virginica 
    1   0   0 

在上面的代碼中,我子集上Petal.Length <= 1.9,然後看物種(因此prop.table(table(...)))的分佈。 100%是Setosa。

另一個例子:右分割(Petal.Length > 1.9)和左分割(Petal.Width <= 1.6)。結果是:

prop.table(table(iris[iris$Petal.Length > 1.9 & iris$Petal.Width <= 1.6,]$Species)) 

setosa versicolor virginica 
0.00000000 0.92307692 0.07692308 

我在這裏的號碼與您的不匹配。我相信你有100行的訓練集,而我正在使用整個數據集。這可能是差異的原因。糾正我,如果我錯了。

1

這些是目標變量Species的三個類別中每一個的概率,對於位於每個葉節點中的實例。

因此,例如,在您的中葉,Species == setosa的概率爲0,Species == versicolor爲0.939,Species == virginica的概率爲0.061。