trainOwl: Train a owl model

Description Usage Arguments Details Value See Also Examples

View source: R/trainOwl.R

Description

This function trains a model fit by owl() by tuning its parameters through cross-validation.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
trainOwl(
  x,
  y,
  q = 0.2,
  number = 10,
  repeats = 1,
  measure = c("mse", "mae", "deviance", "missclass", "auc"),
  cl = NULL,
  ...
)

Arguments

x

the feature matrix, which can be either a dense matrix of the standard matrix class, or a sparse matrix inheriting from Matrix::sparseMatrix Data frames will be converted to matrices internally.

y

the response. For Gaussian models this must be numeric; for binomial models, it can be a factor.

q

shape of lambda sequence

number

number of folds (cross-validation)

repeats

number of repeats for each fold (for repeated k-fold cross validation)

measure

measure to try to optimize; note that you may supply multiple values here and that, by default, all the possible measures for the given model will be used.

cl

cluster if parallel fitting is desired. Can be any cluster accepted by parallel::parLapply().

...

other arguments to pass on to owl()

Details

Note that by default this method matches all of the available metrics for the given model family against those provided in the argument measure. Collecting these measures is not particularly demanding computationally so it is almost always best to leave this argument as it is and then choose which argument to focus on in the call to plot.TrainedOwl().

Value

An object of class "TrainedOwl", with the following slots:

summary

a summary of the results with means, standard errors, and 0.95 confidence levels

data

the raw data from the model training

optima

a data.frame of the best (mean) values for the different metrics and their corresponding parameter values

measure

a data.frame listing the used metrics and their labels

model

the model fit to the entire data set

call

the call

See Also

parallel::parallel, plot.TrainedOwl()

Examples

1
2
3
4
5
6
# 8-fold cross-validation repeated 5 times
tune <- trainOwl(subset(mtcars, select = c("mpg", "drat", "wt")),
                 mtcars$hp,
                 q = c(0.1, 0.2),
                 number = 8,
                 repeats = 5)

jolars/prague documentation built on March 4, 2020, 7:13 p.m.