caretEnsemble

caret models all the way down :turtle:

https://github.com/zachmayer/caretensemble

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.0%) to scientific vocabulary

Keywords from Contributors

distributed
Last synced: 10 months ago · JSON representation

Repository

caret models all the way down :turtle:

Basic Info
Statistics
  • Stars: 227
  • Watchers: 24
  • Forks: 75
  • Open Issues: 7
  • Releases: 7
Created over 13 years ago · Last pushed 10 months ago
Metadata Files
Readme Changelog Contributing Funding License

README.md

caretEnsemble

CRAN
version CRAN
status CRAN
Downloads R-CMD-check Tests Code
Coverage CodeFactor r-universe status
badge Code
Size License Discord <!-- badges: end -->

caretEnsemble is a framework for stacking models fit with the caret package.

Use caretList to fit multiple models, and then use caretStack to stack them with another caret model.

First, use caretList to fit many models to the same data:

``` r set.seed(42L) data(diamonds, package = "ggplot2") dat <- data.table::data.table(diamonds) dat <- dat[sample.int(nrow(diamonds), 500L), ] models <- caretEnsemble::caretList( price ~ ., data = dat, methodList = c("rf", "glmnet") ) print(summary(models))

> The following models were ensembled: rf, glmnet

>

> Model accuracy:

> model_name metric value sd

>

> 1: rf RMSE 1076.492 215.4737

> 2: glmnet RMSE 1142.082 105.6022

```

Then, use caretEnsemble to make a greedy ensemble of these models

``` r greedystack <- caretEnsemble::caretEnsemble(models) print(greedystack)

> The following models were ensembled: rf, glmnet

>

> caret::train model:

> Greedy Mean Squared Error Optimizer

>

> No pre-processing

> Resampling: Cross-Validated (5 fold)

> Summary of sample sizes: 400, 400, 400, 400, 400

> Resampling results:

>

> RMSE Rsquared MAE

> 969.2517 0.9406218 557.1987

>

> Tuning parameter 'max_iter' was held constant at a value of 100

>

> Final model:

> Greedy MSE

> RMSE: 989.2085

> Weights:

> [,1]

> rf 0.55

> glmnet 0.45

```

You can also use caretStack to make a non-linear ensemble

``` r rf_stack <- caretEnsemble::caretStack(models, method = "rf")

> note: only 1 unique complexity parameters in default grid. Truncating the grid to 1 .

print(rf_stack)

> The following models were ensembled: rf, glmnet

>

> caret::train model:

> Random Forest

>

> No pre-processing

> Resampling: Cross-Validated (5 fold)

> Summary of sample sizes: 400, 400, 400, 400, 400

> Resampling results:

>

> RMSE Rsquared MAE

> 1081.425 0.930012 540.3294

>

> Tuning parameter 'mtry' was held constant at a value of 2

>

> Final model:

>

> Call:

> randomForest(x = x, y = y, mtry = param$mtry)

> Type of random forest: regression

> Number of trees: 500

> No. of variables tried at each split: 2

>

> Mean of squared residuals: 925377

> % Var explained: 93.95

```

Use autoplot from ggplot2 to plot ensemble diagnostics:

r ggplot2::autoplot(greedy_stack, training_data = dat, xvars = c("carat", "table"))

6 panel plot of an ensemble of models fit to the diamonds dataset. The RF model is the best and has the highest weight. The residual plots look good. RMSE is about `r round(min(greedy_stack$ens_model$results$RMSE))`.

r ggplot2::autoplot(rf_stack, training_data = dat, xvars = c("carat", "table"))

6 panel plot of an ensemble of models fit to the diamonds dataset. The RF model is the best and has the highest weight. The residual plots look good. RMSE is about `r round(min(rf_stack$ens_model$results$RMSE))`.

Installation

Install the stable version from CRAN:

r install.packages("caretEnsemble")

Install the dev version from github:

r devtools::install_github("zachmayer/caretEnsemble")

There are also tagged versions of caretEnsemble on github you can install via devtools. For example, to install the previous release of caretEnsemble use:

r devtools::install_github("zachmayer/caretEnsemble@2.0.3")

This is useful if the latest release breaks some aspect of your workflow. caretEnsemble is pure R with no compilation, so this command will work in a variety of environments.

Package development

This package uses a Makefile. Use make help to see the supported options.

Use make fix-style to fix simple linting errors.

For iterating while writing code, run make dev. This runs just make clean fix-style document lint spell test, for a quicker local dev loop. Please still run make all before making a PR.

Use make all before making a pull request, which will also run R CMD CHECK and a code coverage check. This runs make clean fix-style document install build-readme build-vignettes lint spell test check coverage preview-site.

First time dev setup:

run make install from the git repository to install the dev version of caretEnsemble, along with the necessary package dependencies. # Inspiration and similar packages: caretEnsemble was inspired by medley, which in turn was inspired by Caruana et. al.’s (2004) paper Ensemble Selection from Libraries of Models.

If you want to do something similar in python, check out vecstack.

Code of Conduct:

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Owner

  • Name: Zach Deane-Mayer
  • Login: zachmayer
  • Kind: user
  • Location: Boston, MA
  • Company: DataRobot

https://www.datacamp.com/courses/advanced-deep-learning-with-keras-in-python https://www.datacamp.com/courses/machine-learning-toolbox

GitHub Events

Total
  • Issues event: 9
  • Watch event: 2
  • Delete event: 25
  • Issue comment event: 118
  • Push event: 91
  • Pull request review comment event: 57
  • Pull request review event: 56
  • Pull request event: 62
  • Fork event: 2
  • Create event: 29
Last Year
  • Issues event: 9
  • Watch event: 2
  • Delete event: 25
  • Issue comment event: 118
  • Push event: 91
  • Pull request review comment event: 57
  • Pull request review event: 56
  • Pull request event: 62
  • Fork event: 2
  • Create event: 29

Committers

Last synced: over 2 years ago

All Time
  • Total Commits: 407
  • Total Committers: 11
  • Avg Commits per committer: 37.0
  • Development Distribution Score (DDS): 0.337
Past Year
  • Commits: 3
  • Committers: 2
  • Avg Commits per committer: 1.5
  • Development Distribution Score (DDS): 0.333
Top Committers
Name Email Commits
Zach Mayer z****r@g****m 270
Jared Knowles j****s@g****m 119
Eric Czech e****h@g****m 7
Zach Deane-Mayer 5****r 3
Jason Cohen J****C@g****m 2
terrytangyuan t****n@g****m 1
rlesca01 r****u@g****m 1
topazand 4****d 1
Graeme g****0@g****m 1
Matt w****e 1
Shyam Saladi s****i 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 139
  • Total pull requests: 110
  • Average time to close issues: almost 4 years
  • Average time to close pull requests: about 1 month
  • Total issue authors: 50
  • Total pull request authors: 13
  • Average comments per issue: 3.54
  • Average comments per pull request: 2.95
  • Merged pull requests: 89
  • Bot issues: 0
  • Bot pull requests: 7
Past Year
  • Issues: 21
  • Pull requests: 77
  • Average time to close issues: 14 days
  • Average time to close pull requests: about 13 hours
  • Issue authors: 3
  • Pull request authors: 5
  • Average comments per issue: 2.71
  • Average comments per pull request: 1.58
  • Merged pull requests: 66
  • Bot issues: 0
  • Bot pull requests: 7
Top Authors
Issue Authors
  • zachmayer (69)
  • sparcycram (9)
  • jknowles (5)
  • farbodr (3)
  • lsemployeeoftheyear (2)
  • Mosquito00 (2)
  • brent-halen (2)
  • hadley (2)
  • topepo (2)
  • iamdeit (2)
  • univ12 (2)
  • JasonCEC (2)
  • drag05 (1)
  • achekroud (1)
  • pglez82 (1)
Pull Request Authors
  • zachmayer (145)
  • antongomez (9)
  • dependabot[bot] (7)
  • eric-czech (4)
  • github-actions[bot] (3)
  • washcycle (3)
  • devloai[bot] (2)
  • smsaladi (1)
  • the-tourist- (1)
  • terrytangyuan (1)
  • Malhadas (1)
  • JasonCEC (1)
  • topazand (1)
Top Labels
Issue Labels
enhancement (36) 1.3 (15) 4.0 (10) 1.1 (9) 1.2 (6) bug (5) 4.1 (3) fix-me (3) needs-minimal-reproducible-example (1)
Pull Request Labels
dependencies (7) github_actions (1)

Packages

  • Total packages: 2
  • Total downloads:
    • cran 1,715 last-month
  • Total docker downloads: 2,071
  • Total dependent packages: 2
    (may contain duplicates)
  • Total dependent repositories: 6
    (may contain duplicates)
  • Total versions: 8
  • Total maintainers: 1
cran.r-project.org: caretEnsemble

Ensembles of Caret Models

  • Versions: 7
  • Dependent Packages: 2
  • Dependent Repositories: 6
  • Downloads: 1,715 Last month
  • Docker Downloads: 2,071
Rankings
Forks count: 0.9%
Stargazers count: 1.9%
Downloads: 8.6%
Average: 10.0%
Dependent repos count: 11.9%
Dependent packages count: 13.7%
Docker downloads count: 23.2%
Maintainers (1)
Last synced: 11 months ago
conda-forge.org: r-caretensemble
  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Forks count: 18.9%
Stargazers count: 23.0%
Average: 31.8%
Dependent repos count: 34.0%
Dependent packages count: 51.2%
Last synced: 10 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.2.0 depends
  • caret * imports
  • data.table * imports
  • digest * imports
  • ggplot2 * imports
  • gridExtra * imports
  • lattice * imports
  • methods * imports
  • pbapply * imports
  • plyr * imports
  • MASS * suggests
  • caTools * suggests
  • e1071 * suggests
  • gbm * suggests
  • glmnet * suggests
  • ipred * suggests
  • kernlab * suggests
  • klaR * suggests
  • knitr * suggests
  • lintr * suggests
  • mlbench * suggests
  • nnet * suggests
  • pROC * suggests
  • randomForest * suggests
  • rmarkdown * suggests
  • rpart * suggests
  • testthat * suggests