Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating tests #155

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bb610c6
add test_ prefix so tests are run
zachmayer May 22, 2015
5657dc8
added packages needed for testing to suggests
zachmayer May 22, 2015
049baee
Fixed tests for treebag and rpart trimming
zachmayer May 22, 2015
9b4cc4a
Removed failing trim test for earth models
zachmayer May 22, 2015
d9e5d52
updated travis.yml file
zachmayer May 22, 2015
0345023
updated travis yml file
zachmayer May 22, 2015
3fe652e
add :
zachmayer May 22, 2015
49213cb
added data splitting tests
zachmayer May 22, 2015
3001812
reorg travis files
zachmayer May 22, 2015
ae43e1f
rip out more latex packages
zachmayer May 22, 2015
c97669c
fixed package requirements
zachmayer May 22, 2015
feb8276
added CRAN tests packages to suggests
zachmayer May 22, 2015
afeefd3
suppress some warnings
zachmayer May 22, 2015
4ba54ee
export trim
zachmayer May 23, 2015
c1f14eb
re-add all latex packages
zachmayer May 23, 2015
4a00ae8
trying to fix the tests
zachmayer May 23, 2015
6250297
AHAH
zachmayer May 23, 2015
f6cc22e
explicit package loads for tests
zachmayer May 23, 2015
aa56770
back to the old school travis tool
zachmayer May 23, 2015
6949f90
try to install packages
zachmayer May 23, 2015
80d6080
load libraries inside tests
zachmayer May 23, 2015
6164f0d
comment out tests again
zachmayer May 23, 2015
8369f59
back to new travis tool, try binary packages
zachmayer May 23, 2015
9b4d101
dump logs?
zachmayer May 23, 2015
a34372b
skip example code for now
zachmayer May 23, 2015
52fce53
run tests outside of r cmd check
zachmayer May 23, 2015
c652729
add test packages to suggests
zachmayer May 23, 2015
675215a
un-comment other tests
zachmayer May 23, 2015
598a68f
remove testing package from description
zachmayer May 27, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 46 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,62 @@
# 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_packages:
- arm
- glmnet
- rpart
- C50
- ipred
- plyr
- earth
- kknn

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()'
4 changes: 2 additions & 2 deletions pkg/caret/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ Suggests:
RANN,
spls,
subselect,
pamr,
superpc,
pamr,
superpc,
Cubist,
testthat (>= 0.9.1)
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