Description Usage Arguments Details Value Author(s) Examples
Calculates the impurity of a node.
1 2 3 | node.impurity(
class.probabilities,
impurity.measure = c("deviance","gini"))
|
class.probabilities |
A vector of observed class probabilities. |
impurity.measure |
Impurity criterion to use. |
Where p_i are observed class probabilities, “Gini Impurity” is calculated as
i(p) = ∑_{i!=j} p_i p_j = 1-∑_i p_i^2.
The “deviance” measure is calculated as
i(p) = -2 ∑_i p_i \log(p_i)
to allow for internal compatibility. Note: 0 \log(0) = 0.
A value for node impurity is returned.
A. Truong
1 2 3 4 5 6 7 8 9 | #A node only has observations of one type
oblique.tree:::node.impurity(
class.probabilities = c(1,0,0,0),
impurity.measure = "deviance")
#Another node has equal numbers of observations of each type
oblique.tree:::node.impurity(
class.probabilities = c(0.25,0.25,0.25,0.25),
impurity.measure = "deviance")
|
Loading required package: tree
Loading required package: glmnet
Loading required package: Matrix
Loading required package: foreach
Loaded glmnet 2.0-12
[1] 0
[1] 2.772589
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.