tweakr: tweakr

Description Usage Arguments Details Examples

View source: R/twk.tweakr.R

Description

Parametertuning

Usage

1
2
tweakr(train_set, params, func_train, k = 5, folds = NULL,
  save_path = NULL, save_freq = 10, twk_object = NULL, ...)

Arguments

train_set

Training data.

params

List of parameters.

func_train

Function to train a model. The arguments must be 'param', 'train' and 'test' and return the fitted object.

k

Number of folds (Default: 5).

folds

custom folds (Default: NULL).

save_path

The path where the model are stored (Default: NULL).

save_freq

The frequence of model saving. (Defaut: 10)

twk_object

tweakr object to continue training (Default: NULL).

...

Additional arguments for tweakr functions.

Details

Parametrtuning for custom models.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
library(rpart)
set.seed(123)

twk <- tweakr(train_set = iris,
params = list(cp=c(.01,.05)),
k = 10,
func_train = function(param, train, test) {
  model <- rpart(Species~. , train, control = rpart.control(cp = param$cp))
  pred <- predict(model, test, type = "class")
  error <- sum(pred == test$Species) / nrow(test)
  list(fit=model, pred=pred, eval=error)
})

prediction <- predict(twk,
                      iris,
                      func_predict = function(fit, test) predict(fit, test, type = "prob"))

illoRocks/tweakr documentation built on July 23, 2019, 3:54 p.m.