################################################################
# name:rpart_deviance_explained
rpart_deviance_explained <- function(model_fit)
{
estat <- print(model_fit)$frame[,c("var","n","dev","yval")]
null_deviance <- estat[1,"dev"]
residual_deviance <- sum(subset(estat, var == "<leaf>")$dev)
dev_explained <- (null_deviance - residual_deviance) / null_deviance
return(dev_explained)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.