Combine several fitted models in a multimodel
models.Rd
The function models()
is a more general version of c.model()
.
While the latter expects arguments inheriting of classes “model” or “multimodel”
in its “...” arguments, the former also accepts fitted models (e.g. an “lm”).
Usage
models(..., .env = parent.frame())
Value
A multimodel.
Examples
mm <- models(
lm = lm(Sepal.Length ~ ., iris),
rpart = model(rpart::rpart(Sepal.Length ~ ., iris)),
xgboost = tune(fm_xgb(Sepal.Length ~ ., iris))
)
#> set_pref_iter(), model ‘model’, modifications made in call:
#> pref_iter=14, nrounds=14, early_stopping_rounds=NULL
mm
#> --- A “multimodel” object containing 3 models ---
#>
#> ‘lm’:
#> model class: lm
#> formula: Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width +
#> Species
#> data: data.frame [150 x 5],
#> input as: ‘data = iris’
#> call: lm(formula = Sepal.Length ~ ., data = data)
#>
#> ‘rpart’:
#> model class: rpart
#> formula: Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width +
#> Species
#> data: data.frame [150 x 5],
#> input as: ‘data = iris’
#> call: rpart::rpart(formula = Sepal.Length ~ ., data = data)
#>
#> ‘xgboost’:
#> model class: fm_xgb
#> formula: Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width +
#> Species - 1
#> data: data.frame [150 x 5],
#> input as: ‘data = iris’
#> call: fm_xgb(formula = Sepal.Length ~ ., data = data,
#> nrounds = 14L, early_stopping_rounds = NULL,
#> pref_iter = 14L)
cv_performance(mm)
#> --- Performance table ---
#> Metric: rmse
#> train_rmse test_rmse iteration time_cv
#> lm 0.29963 0.31478 NA 0.016
#> rpart 0.31432 0.39094 NA 0.029
#> xgboost 0.18173 0.32602 14 0.064