[R] caret package: arguments passed to the classification or regression routine

Max Kuhn mxkuhn at gmail.com
Fri Sep 19 21:24:51 CEST 2008


Forgot to cc...

On Fri, Sep 19, 2008 at 3:22 PM, Max Kuhn <mxkuhn at gmail.com> wrote:
> A new version 3.41 is on
>
>   https://r-forge.r-project.org/projects/caret/
>
> Until later tonight, you will have to get it via
>
>   svn checkout svn://svn.r-forge.r-project.org/svnroot/caret
>
> and build it yourself.
>
> Usage examples:
>
>  library(caret)
>  library(mlbench)
>  data(BostonHousing)
>
>  gbm1 <- train(medv ~ .,
>                data = BostonHousing,
>                "gbm",
>                distribution = "laplace",
>                verbose = FALSE)
>
>  gbm2 <- train(medv ~ .,
>                data = BostonHousing,
>                "gbm",
>                verbose = FALSE)
>
>  gbm3 <- train(medv ~ .,
>                data = BostonHousing,
>                "gbm",
>                verbose = FALSE,
>                distribution = list(name="quantile",alpha=0.5))
>
> Max
>
>
> On Fri, Sep 19, 2008 at 2:49 PM, Max Kuhn <mxkuhn at gmail.com> wrote:
>> Peter,
>>
>> train looks at the class of the outcome variable to determine the type
>> of model (regression or classification). Rather than making everyone
>> specify the distribution in every case, it switches between
>> "bernoulli" and "gaussian".
>>
>> For other models, train looks at the parameters passed via ... and
>> will let those over-ride the automatically generated values. I can do
>> the same for gbm in this context (besides the tuning parameters, this
>> is the only argument that is automatically set for gbm).
>>
>> I'll make the changes and upload a new version to
>>
>>   https://r-forge.r-project.org/projects/caret/
>>
>> It will probably be version 3.41.
>>
>> One other thing - it is usually better to email the package
>> maintainers off-list for questions like this before emailing the list.
>>
>> Max
>>
>>
>> On Thu, Sep 18, 2008 at 2:22 PM, Peter Tait <petertait at sympatico.ca> wrote:
>>> Hi,
>>> I am having problems passing arguments to method="gbm" using the train()
>>> function.
>>>
>>> I would like to train gbm using the laplace distribution or the quantile
>>> distribution.
>>>
>>> here is the code I used and the error:
>>>
>>> gbm.test <- train(x.enet, y.matrix[,7],
>>>  method="gbm",
>>>  distribution=list(name="quantile",alpha=0.5), verbose=FALSE,
>>>  trControl=trainControl(method="cv",number=5),
>>>  tuneGrid=gbmGrid
>>> )
>>> Model 1: interaction.depth=1, shrinkage=0.1, n.trees=300
>>> collapsing over other values of n.trees
>>> Error in gbm.fit(trainX, modY, interaction.depth =
>>> tuneValue$.interaction.depth,  :
>>>  formal argument "distribution" matched by multiple actual arguments
>>>
>>> The same error occured with distribution="laplace".
>>>
>>> I also tried the following without and success :
>>>
>>> gbm.test <- train(x.enet, y.matrix[,7],
>>>  method="gbm",
>>>  list(distribution="laplace", verbose=FALSE),
>>>  trControl=trainControl(method="cv",number=2),
>>>  tuneGrid=gbmGrid
>>> )
>>> Model 1: interaction.depth=1, shrinkage=0.1, n.trees=300
>>> collapsing over other values of n.trees
>>> Error in if (is.null(offset) || (offset == 0)) { :
>>>  missing value where TRUE/FALSE needed
>>> In addition: Warning message:
>>> In gbm.fit(trainX, modY, interaction.depth = tuneValue$.interaction.depth,
>>>  :
>>>  NAs introduced by coercion
>>>
>>> Any help would be appreciated.
>>> Cheers
>>> Peter
>>>
>>> ______________________________________________
>>> R-help at r-project.org mailing list
>>> 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.
>>>
>>
>>
>>
>> --
>>
>> Max
>>
>
>
>
> --
>
> Max
>



-- 

Max



More information about the R-help mailing list