Skip to content

Commit

Permalink
Merge 52fce53 into c96fa7f
Browse files Browse the repository at this point in the history
  • Loading branch information
zachmayer committed May 23, 2015
2 parents c96fa7f + 52fce53 commit 095e83b
Show file tree
Hide file tree
Showing 18 changed files with 598 additions and 519 deletions.
66 changes: 36 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,52 @@
# Sample .travis.yml for R projects from https://github.com/craigcitro/r-travis

language: c
language: r
warnings_are_errors: false
sudo: required

env:
global:
- WARNINGS_ARE_ERRORS=1
- R_BUILD_ARGS=" "
- R_CHECK_ARGS="--as-cran"
- BOOTSTRAP_LATEX="1"
- CRAN: http://cran.rstudio.com
- R_BUILD_ARGS="--no-build-vignettes --no-manual --no-examples"
- R_CHECK_ARGS="--no-build-vignettes --no-manuall --no-examples --as-cran"
matrix:
- NOT_CRAN="true"
- NOT_CRAN="false"

before_install:
- cd pkg/caret
- curl -OL http://raw.github.com/craigcitro/r-travis/master/scripts/travis-tool.sh
- chmod 755 ./travis-tool.sh
- ./travis-tool.sh bootstrap

install:
- ./travis-tool.sh install_deps
- sudo add-apt-repository -y ppa:texlive-backports/ppa
- sudo add-apt-repository ppa:texlive-backports/ppa -y
- sudo apt-get -qq update
- ./travis-tool.sh aptget_install texlive-base
- ./travis-tool.sh aptget_install biblatex
- ./travis-tool.sh aptget_install texlive-latex-base
- ./travis-tool.sh aptget_install texlive-latex-recommended
- ./travis-tool.sh aptget_install texlive-latex-extra
- ./travis-tool.sh aptget_install texlive-fonts-recommended
- ./travis-tool.sh aptget_install texlive-fonts-extra
- ./travis-tool.sh aptget_install texlive-science
- ./travis-tool.sh github_package jimhester/covr

script: ./travis-tool.sh run_tests

on_failure:
- ./travis-tool.sh dump_logs

after_success:
- Rscript -e 'library(covr);coveralls()'
apt_packages:
- texlive-base
- biblatex
- texlive-latex-base
- texlive-latex-recommended
- texlive-latex-extra
- texlive-fonts-recommended
- texlive-fonts-extra
- texlive-science

r_binary_packages:
- arm
- glmnet
- rpart
- C50
- ipred
- plyr
- earth
- kknn

r_github_packages:
- jimhester/covr

notifications:
email:
on_success: change
on_failure: change

after_script:
- Rscript -e 'library(devtools);test()'
- dump_logs

after_success:
- Rscript -e 'library(covr);coveralls()'
7 changes: 4 additions & 3 deletions pkg/caret/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ Suggests:
RANN,
spls,
subselect,
pamr,
superpc,
pamr,
superpc,
Cubist,
testthat (>= 0.9.1)
testthat (>= 0.9.1),
kknn
License: GPL (>= 2)
24 changes: 12 additions & 12 deletions pkg/caret/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export(anovaScores,
gafs_spCrossover,
gafs_raMutation,
gafs,
gafs.default,
gafs.default,
gafsControl,
gamFormula,
gamFuncs,
Expand Down Expand Up @@ -122,7 +122,7 @@ export(anovaScores,
nullModel,
nullModel.default,
oneSE,
panel.calibration,
panel.calibration,
panel.lift,
panel.lift2,
panel.needle,
Expand Down Expand Up @@ -179,16 +179,16 @@ export(anovaScores,
rfeControl,
rfeIter,
rfFuncs,
rfGA,
rfGA,
rfSA,
rfSBF,
rfStats,
RMSE,
safs_initial,
safs_perturb,
safs_perturb,
safs_prob,
safs,
safs.default,
safs.default,
safsControl,
sbf,
sbf.default,
Expand Down Expand Up @@ -308,7 +308,7 @@ S3method(varImp, nnet)
S3method(varImp, glmnet)
S3method(varImp, gam)
S3method(varImp, gafs)
S3method(varImp, safs)
S3method(varImp, safs)

S3method(densityplot, train)
S3method(histogram, train)
Expand Down Expand Up @@ -346,7 +346,7 @@ S3method(plot, prcomp.resamples)
S3method(plot, lift)
S3method(plot, calibration)
S3method(plot, gafs)
S3method(plot, safs)
S3method(plot, safs)

S3method(confusionMatrix, train)
S3method(confusionMatrix, rfe)
Expand Down Expand Up @@ -387,7 +387,7 @@ S3method(print, lift)
S3method(print, calibration)
S3method(print, expoTrans)
S3method(print, gafs)
S3method(print, safs)
S3method(print, safs)

S3method(predict, plsda)
S3method(predict, splsda)
Expand All @@ -410,7 +410,7 @@ S3method(predict, dummyVars)
S3method(predict, BoxCoxTrans)
S3method(predict, expoTrans)
S3method(predict, gafs)
S3method(predict, safs)
S3method(predict, safs)

S3method(summary, bagEarth)
S3method(summary, bagFDA)
Expand All @@ -428,7 +428,7 @@ S3method(predictors, default)
S3method(predictors, rfe)
S3method(predictors, sbf)
S3method(predictors, gafs)
S3method(predictors, safs)
S3method(predictors, safs)

S3method(confusionMatrix, table)

Expand All @@ -455,7 +455,7 @@ S3method(summary, diff.resamples)
S3method(update, train)
S3method(update, rfe)
S3method(update, gafs)
S3method(update, safs)
S3method(update, safs)

S3method(fitted, train)
S3method(residuals, train)
Expand All @@ -471,7 +471,7 @@ S3method(oob_pred, sbf)
S3method(oob_pred, list)

S3method(gafs, default)
S3method(safs, default)
S3method(safs, default)

S3method(trim, train)

Expand Down
12 changes: 6 additions & 6 deletions pkg/caret/R/trim.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ trim.train <- function(object, ...) {
"perfNames", "maxmimize", "times")
for(i in removals)
if(i %in% names(object)) object[i] <- NULL
c_removals <- c('method', 'number', 'repeats', 'p', 'initialWindow',
'horizon', 'fixedWindow', 'verboseIter', 'returnData',
'returnResamp', 'savePredictions', 'summaryFunction',
'selectionFunction', 'index', 'indexOut', 'timingSamps',
c_removals <- c('method', 'number', 'repeats', 'p', 'initialWindow',
'horizon', 'fixedWindow', 'verboseIter', 'returnData',
'returnResamp', 'savePredictions', 'summaryFunction',
'selectionFunction', 'index', 'indexOut', 'timingSamps',
'trim', 'yLimits')
for(i in c_removals)
if(i %in% names(object$control)) object$control[i] <- NULL
if(i %in% names(object$control)) object$control[i] <- NULL
if(!is.null(object$modelInfo$trim))
object$finalModel <- object$modelInfo$trim(object$finalModel)
object
}
}
24 changes: 12 additions & 12 deletions pkg/caret/tests/testthat/test_confusionMatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ set.seed(442)

test_that("Confusion matrix works", {
library(caret)
train <- twoClassSim(n = 1000, intercept = -8, linearVars = 3,
train <- twoClassSim(n = 1000, intercept = -8, linearVars = 3,
noiseVars = 10, corrVars = 4, corrValue = 0.6)

ctrl <- trainControl(method = "cv", classProbs = TRUE)
fullModel <- train(Class ~ ., data = train,
method = "knn",
preProc = c("center", "scale"),
tuneLength = 4,

fullModel <- train(Class ~ ., data = train,
method = "knn",
preProc = c("center", "scale"),
tuneLength = 4,
trControl = ctrl)
dat <- train$Class
ref <- predict(fullModel)
Expand All @@ -26,10 +26,10 @@ test_that("Confusion matrix works", {
dat5 <- as.character(dat3)
dat5[200] <- "Class4"
dat5 <- factor(dat5, levels = c("Class1", "Class4"))
cm1 <- confusionMatrix(dat, ref)
cm2 <- confusionMatrix(dat2, ref2)
cm3 <- confusionMatrix(dat3, ref2)
cm4 <- confusionMatrix(dat4, ref2)
suppressWarnings(cm1 <- confusionMatrix(dat, ref))
suppressWarnings(cm2 <- confusionMatrix(dat2, ref2))
suppressWarnings(cm3 <- confusionMatrix(dat3, ref2))
suppressWarnings(cm4 <- confusionMatrix(dat4, ref2))
expect_true(class(cm1) == "confusionMatrix")
expect_true(class(cm2) == "confusionMatrix")
expect_true(class(cm3) == "confusionMatrix")
Expand All @@ -42,4 +42,4 @@ test_that("Confusion matrix works", {
expect_identical(cm4$overall, cm3$overall)
expect_true(identical(cm1, cm2))
expect_true(identical(cm3, cm4))
})
})
49 changes: 49 additions & 0 deletions pkg/caret/tests/testthat/test_create_folds.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
library(caret)
context('Test Data Splitting Functions')

test_that('createTimeSlices', {
set.seed(1)
y <- 1:10

s1 <- createTimeSlices(y, initialWindow=5, horizon=1, fixedWindow=TRUE)
expect_equal(length(s1$train), 5)
expect_equal(length(s1$test), 5)
expect_equal(s1$train$Training1, 1:5)
expect_equal(s1$train$Training2, 2:6)
expect_equal(s1$train$Training3, 3:7)
expect_equal(s1$train$Training4, 4:8)
expect_equal(s1$train$Training5, 5:9)
expect_equal(s1$test$Testing1, 6)
expect_equal(s1$test$Testing2, 7)
expect_equal(s1$test$Testing3, 8)
expect_equal(s1$test$Testing4, 9)
expect_equal(s1$test$Testing5, 10)

s2 <- createTimeSlices(y, initialWindow=5, horizon=1, fixedWindow=FALSE)
expect_equal(length(s2$train), 5)
expect_equal(length(s2$test), 5)
expect_equal(s2$train$Training1, 1:5)
expect_equal(s2$train$Training2, 1:6)
expect_equal(s2$train$Training3, 1:7)
expect_equal(s2$train$Training4, 1:8)
expect_equal(s2$train$Training5, 1:9)
expect_equal(s2$test$Testing1, 6)
expect_equal(s2$test$Testing2, 7)
expect_equal(s2$test$Testing3, 8)
expect_equal(s2$test$Testing4, 9)
expect_equal(s2$test$Testing5, 10)

s3 <- createTimeSlices(y, initialWindow=5, horizon=5, fixedWindow=TRUE)
expect_equal(length(s3$train), 1)
expect_equal(length(s3$test), 1)
expect_equal(s3$train$Training1, 1:5)
expect_equal(s3$test$Testing1, 6:10)

s4 <- createTimeSlices(y, initialWindow=5, horizon=5, fixedWindow=FALSE)
expect_equal(length(s3$train), 1)
expect_equal(length(s3$test), 1)
expect_equal(s3$train$Training1, 1:5)
expect_equal(s3$test$Testing1, 6:10)

expect_identical(s3, s4)
})
Loading

0 comments on commit 095e83b

Please sign in to comment.