Displaying 1 result from an estimated 1 matches for "obs_0".
Did you mean:
obs30
2011 Jun 13
1
In rpart, how is "improve" calculated? (in the "class" case)
...# why is improve here 5.38 ?
# Here is what I thought it should have been:
# for "information"
entropy <- function(p) {
if(any(p==1)) return(0) # works for the case when y has only 0 and 1
categories...
-sum(p*log(p,2))
}
gini <- function(p) {sum(p*(1-p))}
obs_1 <- y[x>.5]
obs_0 <- y[x<.5]
n_l <- sum(x>.5)
n_R <- sum(x<.5)
n <- length(x)
# for entropy (information)
impurity_root <- entropy(prop.table(table(y)))
impurity_l <- entropy(prop.table(table(obs_0)))
impurity_R <-entropy(prop.table(table(obs_1)))
# shouldn't this have been "i...