Description Usage Arguments Details Examples
Parametertuning
1 2 |
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. |
Parametrtuning for custom models.
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"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.