Skip to content

Commit

Permalink
rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
zachmayer committed Aug 13, 2024
1 parent 7149f29 commit 0630397
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 46 deletions.
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ Type: Package
Title: Ensembles of Caret Models
Version: 4.0.0
Date: 2024-08-12
Authors@R: c(person(c("Zachary", "A."), "Deane-Mayer", role = c("aut", "cre"),
email = "zach.mayer@gmail.com"),
person(c("Jared", "E."), "Knowles", role=c("aut"),
email="jknowles@gmail.com"))
Authors@R: c(person(c("Zachary", "A."), "Deane-Mayer", role = c("aut", "cre", "cph"), email = "zach.mayer@gmail.com"),
person(c("Jared", "E.", "Knowles", role="ctb", email="jknowles@gmail.com"),
person("Antón", "López", role="ctb", email="zach.mayer+get-correct-email@gmail.com")
)
URL: https://github.com/zachmayer/caretEnsemble
BugReports: https://github.com/zachmayer/caretEnsemble/issues
Description: Functions for creating ensembles of caret models: caretList()
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
YEAR: 2013-2024
COPYRIGHT HOLDER: Zachary Albert Mayer
COPYRIGHT HOLDER: Zachary Albert Mayer
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,24 @@ Size](https://img.shields.io/github/languages/code-size/zachmayer/caretEnsemble.
[![Discord](https://img.shields.io/discord/1255535052578619524)](https://discord.gg/zgPeSm8a3u)
<!-- badges: end -->

caretEnsemble is a framework for fitting multiple [caret
models](https://github.com/topepo/caret) using the same re-sampling
strategy as well as creating ensembles of such models. Use `caretList`
to fit multiple models, and then use `caretStack` to stack them using a
caret model.
caretEnsemble is a framework for
[stacking](https://en.wikipedia.org/wiki/Ensemble_learning#Stacking)
models fit with the [caret](https://topepo.github.io/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
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"))
models <- caretEnsemble::caretList(
price ~ .,
data = dat,
methodList = c("rf", "glmnet")
)
```

Then, use caretEnsemble to make a greedy ensemble of these models
Expand All @@ -51,21 +56,21 @@ print(greedy_stack)
#>
#> No pre-processing
#> Resampling: Cross-Validated (5 fold)
#> Summary of sample sizes: 400, 400, 400, 401, 399
#> Summary of sample sizes: 400, 400, 400, 400, 400
#> Resampling results:
#>
#> RMSE Rsquared MAE
#> 946.5929 0.9468516 506.8786
#> 1019.069 0.9401024 530.9788
#>
#> Tuning parameter 'max_iter' was held constant at a value of 100
#>
#> Final model:
#> Greedy MSE
#> RMSE: 963.298
#> RMSE: 1013.725
#> Weights:
#> [,1]
#> rf 0.7
#> glmnet 0.3
#> rf 0.9
#> glmnet 0.1
ggplot2::autoplot(greedy_stack, training_data = dat, xvars = c("carat", "table"))
```

Expand All @@ -84,11 +89,11 @@ print(rf_stack)
#>
#> No pre-processing
#> Resampling: Cross-Validated (5 fold)
#> Summary of sample sizes: 400, 401, 400, 400, 399
#> Summary of sample sizes: 400, 400, 400, 400, 400
#> Resampling results:
#>
#> RMSE Rsquared MAE
#> 968.4043 0.9467661 499.4089
#> 1076.369 0.9338026 531.9601
#>
#> Tuning parameter 'mtry' was held constant at a value of 2
#>
Expand All @@ -100,8 +105,8 @@ print(rf_stack)
#> Number of trees: 500
#> No. of variables tried at each split: 2
#>
#> Mean of squared residuals: 881047.1
#> % Var explained: 94.87
#> Mean of squared residuals: 1136154
#> % Var explained: 93.38
ggplot2::autoplot(rf_stack, training_data = dat, xvars = c("carat", "table"))
```

Expand All @@ -121,13 +126,9 @@ install.packages("caretEnsemble")
devtools::install_github("zachmayer/caretEnsemble")
```

There are also tagged versions of caretEnsemble on github you can
install via devtools. For example, to install the original draft of the
API:

There are also tagged versions of caretEnsemble on github you can
install via devtools. For example, to install the [previous release of
caretEnsemble](https://github.com/zachmayer/caretEnsemble/releases/tag/)
caretEnsemble](https://github.com/zachmayer/caretEnsemble/releases/)
use:

``` r
Expand All @@ -149,7 +150,7 @@ 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
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`.

Expand Down
14 changes: 8 additions & 6 deletions README.rmd
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ First, use caretList to fit many models to the same data:
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"))
models <- caretEnsemble::caretList(
price ~ .,
data = dat,
methodList = c("rf", "glmnet")
)
```

Then, use caretEnsemble to make a greedy ensemble of these models
Expand Down Expand Up @@ -67,9 +71,7 @@ install.packages("caretEnsemble")
devtools::install_github("zachmayer/caretEnsemble")
```

There are also tagged versions of caretEnsemble on github you can install via devtools. For example, to install the original draft of the API:

There are also tagged versions of caretEnsemble on github you can install via devtools. For example, to install the [previous release of caretEnsemble](https://github.com/zachmayer/caretEnsemble/releases/tag/) use:
There are also tagged versions of caretEnsemble on github you can install via devtools. For example, to install the [previous release of caretEnsemble](https://github.com/zachmayer/caretEnsemble/releases/) use:
```{r, eval=FALSE}
devtools::install_github("zachmayer/caretEnsemble@2.0.3")
```
Expand All @@ -82,15 +84,15 @@ 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`.
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](https://github.com/mewo2/medley), which in turn was inspired by Caruana et. al.'s (2004) paper [Ensemble Selection from Libraries of Models.](http://www.cs.cornell.edu/~caruana/ctp/ct.papers/caruana.icml04.icdm06long.pdf)

If you want to do something similar in python, check out [vecstack](https://github.com/vecxoz/vecstack)
If you want to do something similar in python, check out [vecstack](https://github.com/vecxoz/vecstack).

# Code of Conduct:
Please note that this project is released with a [Contributor Code of Conduct](https://github.com/zachmayer/caretEnsemble/blob/master/.github/CONTRIBUTING.md). By participating in this project you agree to abide by its terms.
21 changes: 11 additions & 10 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Caruana
classProbs
CMD
CodeFactor
codebase
coercible
Deane
defaultControl
Expand All @@ -27,8 +28,10 @@ importances
kable
knitr
Ksikes
linter
linters
Makefile
makefile
methodList
Mizil
modelInfo
Expand All @@ -41,30 +44,28 @@ Niculescu
nnet
observeds
optimizers
pkgdown
pred
preds
prob
probs
readme
resid
roxygen
rpart
's
savePredictions
scalability
scikit
SDs
trainControl
travis
tuneGrid
tuneList
un
unintuitive
varImp
vecstack
yhat
’s
codebase
linter
makefile
pkgdown
readme
scalability
un
Verions
verions
xvars
yhat
8 changes: 4 additions & 4 deletions man/caretEnsemble.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified man/figures/README-unnamed-chunk-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/README-unnamed-chunk-4-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0630397

Please sign in to comment.