Skip to content

Commit

Permalink
Use inherits (#247)
Browse files Browse the repository at this point in the history
* use inherits

* oopsie

* fix tests:

* UTF-8

* fix note

* fuckity shit

* lol

* i guess you dont need the vingettes

* ddddd

* bump version

* notes

* fix urls

* more fixes

* couple more fixes

* remove dead badges

* update news

* fix comment

* fix link

* copyright
  • Loading branch information
zachmayer authored Dec 13, 2019
1 parent 48e6ecd commit 8a6496f
Show file tree
Hide file tree
Showing 69 changed files with 43 additions and 1,060 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ inst/docs
inst/examples
travis_wait_*
.github/*
^doc$
^Meta$
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,5 @@ pip-log.txt
.RHistory
.Rproj.user
caretEnsemble_test_plots.png
doc
Meta
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Encoding: UTF-8
Package: caretEnsemble
Type: Package
Title: Ensembles of Caret Models
Version: 2.0.0
Date: 2016-02-06
Version: 2.0.1
Date: 2019-12-11
Authors@R: c(person(c("Zachary", "A."), "Deane-Mayer", role = c("aut", "cre"),
email = "[email protected]"),
person(c("Jared", "E."), "Knowles", role=c("aut"),
Expand Down Expand Up @@ -47,4 +48,4 @@ Imports:
caret
License: MIT + file LICENSE
VignetteBuilder: knitr
RoxygenNote: 5.0.1
RoxygenNote: 6.1.1
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
YEAR: 2013-2015
YEAR: 2013-2019
COPYRIGHT HOLDER: Zachary Albert Mayer
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ importFrom(stats,coef)
importFrom(stats,median)
importFrom(stats,model.frame)
importFrom(stats,model.response)
importFrom(stats,na.omit)
importFrom(stats,predict)
importFrom(stats,qnorm)
importFrom(stats,reshape)
Expand Down
7 changes: 4 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#NEWS

## caretEnsemble 2.0.1
- Minor fixes to support R 4.0

## caretEnsemble 2.0.0
- caretEnsemble now inherits from caretStack
- Removed the optimizers and now use a glm for caretEnsemble (optimizers will be added back ase caret.train models in a future release)
Expand All @@ -8,7 +11,6 @@
- Fixed the build on travis and locally

## caretEnsemble 1.0.5

- Change output for predict functions to better align with other predict methods
in R (predict.caretEnsemble and predict.caretStack)
- Update documentation for predict methods to better explain the model disagreement
Expand All @@ -18,5 +20,4 @@ calculation
calculation

## caretEnsemble 1.0 - First CRAN release

* caretEnsemble is a new package for making ensembles of [caret](http://cran.r-project.org/web/packages/caret/index.html) models.
- caretEnsemble is a new package for making ensembles of [caret](https://CRAN.R-project.org/package=caret/) models.
8 changes: 4 additions & 4 deletions R/S3GenericExtenstions.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
c.caretList <- function(...) {

new_model_list <- unlist(lapply(list(...), function(x) {
if(class(x)[1] != "caretList") {
if(class(x)[1] != "train") stop("class of modelList1 must be 'caretList' or 'train'")
if(! inherits(x, "caretList")) {
if(! inherits(x, "train")) stop("class of modelList1 must be 'caretList' or 'train'")

## assuming this is a single train object
x <- list(x)
Expand Down Expand Up @@ -81,8 +81,8 @@ c.caretList <- function(...) {
c.train <- function(...) {

new_model_list <- unlist(lapply(list(...), function(x) {
if(class(x)[1] != "caretList") {
if(class(x)[1] != "train") stop("class of modelList1 must be 'caretList' or 'train'")
if(! inherits(x, "caretList")) {
if(! inherits(x, "train")) stop("class of modelList1 must be 'caretList' or 'train'")

## assuming this is a single train object
x <- list(x)
Expand Down
1 change: 0 additions & 1 deletion R/caretEnsemble-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ NULL
#' @name Y.class
#' @docType data
#' @rdname data
#' @references \url{data_blah.com}
#' @keywords data
NULL

Expand Down
2 changes: 1 addition & 1 deletion R/caretEnsemble.R
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ multiResiduals <- function(object, ...){
fortify <- function(model, data = NULL, ...){
data <- extractModFrame(model)
data$y <- model$models[[1]]$trainingData$.outcome
if(class(data$y) != "numeric"){
if(!inherits(data$y, "numeric")){
data$y <- as.character(data$y)
z <- table(data$y)
prevOutcome <- names(z)[z == max(z)]
Expand Down
10 changes: 5 additions & 5 deletions R/caretList.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ methodCheck <- function(x){
"(e.g. getModelInfo(\"gbm\", regex=F))"))
}
})
models <- do.call(rbind, models)
models <- do.call(rbind, models) # Could use data.table to be more efficient with lots of models

# Ensure that all non-custom models are valid
native_models <- subset(models, type == "native")$model
native_models <- subset(models, get('type') == "native")$model
bad_models <- setdiff(native_models, supported_models)

if(length(bad_models)>0){
Expand Down Expand Up @@ -282,7 +282,7 @@ as.caretList.default <- function(object){
#' @export
#' @method as.caretList list
as.caretList.list <- function(object){
if(!(class(object) == "list")){
if(! inherits(object, "list")){
stop("object must be a list of caret models")
}
# Check that each element in the list is of class train
Expand Down Expand Up @@ -350,8 +350,8 @@ predict.caretList <- function(object, newdata = NULL, ..., verbose = FALSE){
stop(paste("Unknown model type:", type))
}
})
if(class(preds) != "matrix" & class(preds) != "data.frame"){
if(class(preds) == "character" | class(preds) == "factor"){
if(! inherits(preds, "matrix") & ! inherits(preds, "data.frame")){
if(inherits(preds, "character") | inherits(preds, "factor")){
preds <- as.character(preds) # drop factorization
}
preds <- as.matrix(t(preds))
Expand Down
3 changes: 2 additions & 1 deletion R/caretStack.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ predict.caretStack <- function(
if(type == "Classification"){
out <- predict(object$ens_model, newdata=preds, na.action=na.action, ...)
# Need a check here
if(class(out) %in% c("data.frame", "matrix")){
if(inherits(out, c("data.frame", "matrix"))){
# Return probability predictions for only one of the classes
# as determined by configured default response class level
est <- out[, getBinaryTargetLevel(), drop = TRUE]
Expand Down Expand Up @@ -157,6 +157,7 @@ summary.caretStack <- function(object, ...){
#' @description This is a function to print a caretStack.
#' @param x An object of class caretStack
#' @param ... ignored
#' @importFrom stats na.omit
#' @export
#' @examples
#' \dontrun{
Expand Down
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
[![Build Status](http://img.shields.io/travis/zachmayer/caretEnsemble.svg?style=flat)](https://travis-ci.org/zachmayer/caretEnsemble)
[![Coverage Status](http://img.shields.io/coveralls/zachmayer/caretEnsemble.svg?style=flat)](https://coveralls.io/r/zachmayer/caretEnsemble)
[![Github Issues](http://githubbadges.herokuapp.com/zachmayer/caretEnsemble/issues.svg)](https://github.com/zachmayer/caretEnsemble/issues)
[![Pending Pull-Requests](http://githubbadges.herokuapp.com/zachmayer/caretEnsemble/pulls.svg?style=flat)](https://github.com/zachmayer/caretEnsemble/pulls)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/caretEnsemble)](http://cran.r-project.org/web/packages/caretEnsemble)
[![Downloads](http://cranlogs.r-pkg.org/badges/caretEnsemble)](http://cran.rstudio.com/package=caretEnsemble)
[![License](http://img.shields.io/:license-mit-blue.svg?style=flat)](http://badges.mit-license.org)
[![Badges](http://img.shields.io/:badges-9/9-438cf0.svg?style=flat)](https://github.com/badges/badgerbadgerbadger)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/caretEnsemble)](https://CRAN.R-project.org/package=caretEnsemble/)
[![Downloads](http://cranlogs.r-pkg.org/badges/caretEnsemble)](https://CRAN.R-project.org/package=caretEnsemble/)
[![License](http://img.shields.io/:license-mit-blue.svg?style=flat)](https://badges.mit-license.org)
[![Badges](http://img.shields.io/:badges-7/7-438cf0.svg?style=flat)](https://github.com/badges/badgerbadgerbadger)
[![Join the chat at https://gitter.im/zachmayer/caretEnsemble](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/zachmayer/caretEnsemble?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

# caretEnsemble: [(Read the vignette!)](https://htmlpreview.github.io/?https://github.com/zachmayer/caretEnsemble/blob/master/inst/doc/caretEnsemble-intro.html)
Expand All @@ -14,7 +12,7 @@ Framework for fitting multiple [caret models](https://github.com/topepo/caret) u

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)

# Install the stable version from [CRAN](http://cran.r-project.org/web/packages/caretEnsemble/):
# Install the stable version from [CRAN](https://CRAN.R-project.org/package=caretEnsemble/):
```{R}
install.packages('caretEnsemble')
```
Expand All @@ -30,4 +28,4 @@ devtools::install_github('zachmayer/[email protected]')
```

# Code of Conduct:
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.
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.
15 changes: 4 additions & 11 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
## Test environments
* local OS X install, R 3.1.2
* ubuntu 12.04 (on travis-ci), R 3.1.2
* win-builder (devel and release)
* local OS X install, R 3.6.1
* ubuntu 16.04, R 3.6.0
* win-builder (R-release, R-devel, R-devel ATC, R-oldrelease)

## R CMD check results
There were no ERRORs, WARNINGs, or NOTES.

## Downstream dependencies
I have also run R CMD check on downstream dependencies of caretEnsemble
(https://github.com/wch/checkresults/blob/master/httr/r-release). All packages
that I could install passed except:

* XYZ:...
There were no ERRORs, WARNINGs, or NOTEs
135 changes: 0 additions & 135 deletions inst/doc/caretEnsemble-intro.R

This file was deleted.

Loading

0 comments on commit 8a6496f

Please sign in to comment.