[R] #library("CHAID") - Cross validation for chaid

Rodica Coderie rodikgeorgiana at yahoo.com
Wed Jan 7 15:29:46 CET 2015


So, if I understood correctly, the mod$finalModel should be the resulted tree after cross-validation, right?
It's the same as the original one.

names(mod) 
mod$finalModel 
chaidUS

Thanks!
Rodica


----- Original Message -----
From: Rodica Coderie <rodikgeorgiana at yahoo.com>
To: Max Kuhn <mxkuhn at gmail.com>
Cc: "r-help at r-project.org" <r-help at r-project.org>
Sent: Wednesday, January 7, 2015 1:32 PM
Subject: Re: [R] #library("CHAID") - Cross validation for chaid



Thanks Max!

You are right! I used the train function below and no model was built.
Do you know what can I use instead?

library(caret)
mod <- train(x = USvoteS[,-1], y = USvoteS$vote3, 
method = modelInfo, 
trControl = trainControl(method = "cv"))

Thanks!
Rodica




________________________________

From: Max Kuhn <mxkuhn at gmail.com>

Cc: "r-help at r-project.org" <r-help at r-project.org> 
Sent: Monday, January 5, 2015 6:56 PM
Subject: Re: [R] #library("CHAID") - Cross validation for chaid


You can create your own:

  http://topepo.github.io/caret/custom_models.html

I put a prototype together. Source this file:

  https://github.com/topepo/caret/blob/master/models/files/chaid.R

then try this:

library("CHAID")

### fit tree to subsample
set.seed(290875)
USvoteS <- USvote[sample(1:nrow(USvote), 1000),]


## You probably don't want to use `train.formula` as
## it will convert the factors to dummy variables
mod <- train(x = USvoteS[,-1], y = USvoteS$vote3,
             method = modelInfo,
             trControl = trainControl(method = "cv"))

Max




On Mon, Jan 5, 2015 at 7:11 AM, Rodica Coderie via R-help
<r-help at r-project.org> wrote:
> Hello,
>
> Is there an option of cross validation for CHAID decision tree? An example of CHAID is below:
> library("CHAID")
> example("chaid", package = "CHAID")
>
> How can I use a 10 fold cross-validation for CHAID?
> I've read that caret package is to cross-validate on many times of models, but model CHAID is not in caret's built-in library.
>
> library(caret)
> model <- train(vote3 ~., data = USvoteS, method='CHAID', tuneLength=10,trControl=trainControl(method='cv', number=10, classProbs=TRUE, summaryFunction=twoClassSummary))
>
> Thanks,
> Rodica
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list