-
Notifications
You must be signed in to change notification settings - Fork 632
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
397 additions
and
397 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,152 +1,152 @@ | ||
# | ||
# test_that('single tree', { | ||
# skip_on_cran() | ||
# library(caret) | ||
# library(C50) | ||
# | ||
# set.seed(1) | ||
# tr_dat <- twoClassSim(200) | ||
# te_dat <- twoClassSim(200) | ||
# | ||
# set.seed(2) | ||
# class_trim <- train(Class ~ ., data = tr_dat, | ||
# method = "C5.0", | ||
# tuneGrid = data.frame(trials = 1, | ||
# model = "tree", | ||
# winnow = FALSE), | ||
# trControl = trainControl(method = "none", | ||
# classProbs = TRUE, | ||
# trim = TRUE)) | ||
# | ||
# set.seed(2) | ||
# class_notrim <- train(Class ~ ., data = tr_dat, | ||
# method = "C5.0", | ||
# tuneGrid = data.frame(trials = 1, | ||
# model = "tree", | ||
# winnow = FALSE), | ||
# trControl = trainControl(method = "none", | ||
# classProbs = TRUE, | ||
# trim = FALSE)) | ||
# | ||
# expect_equal(predict(class_trim, te_dat), | ||
# predict(class_notrim, te_dat)) | ||
# | ||
# expect_equal(predict(class_trim, te_dat, type = "prob"), | ||
# predict(class_notrim, te_dat, type = "prob")) | ||
# | ||
# expect_less_than(object.size(class_trim)-object.size(class_notrim), 0) | ||
# }) | ||
# | ||
# test_that('single rule', { | ||
# skip_on_cran() | ||
# library(caret) | ||
# library(C50) | ||
# | ||
# set.seed(1) | ||
# tr_dat <- twoClassSim(200) | ||
# te_dat <- twoClassSim(200) | ||
# | ||
# set.seed(2) | ||
# class_trim <- train(Class ~ ., data = tr_dat, | ||
# method = "C5.0", | ||
# tuneGrid = data.frame(trials = 1, | ||
# model = "rules", | ||
# winnow = FALSE), | ||
# trControl = trainControl(method = "none", | ||
# classProbs = TRUE, | ||
# trim = TRUE)) | ||
# | ||
# set.seed(2) | ||
# class_notrim <- train(Class ~ ., data = tr_dat, | ||
# method = "C5.0", | ||
# tuneGrid = data.frame(trials = 1, | ||
# model = "rules", | ||
# winnow = FALSE), | ||
# trControl = trainControl(method = "none", | ||
# classProbs = TRUE, | ||
# trim = FALSE)) | ||
# | ||
# expect_equal(predict(class_trim, te_dat), | ||
# predict(class_notrim, te_dat)) | ||
# | ||
# expect_equal(predict(class_trim, te_dat, type = "prob"), | ||
# predict(class_notrim, te_dat, type = "prob")) | ||
# | ||
# expect_less_than(object.size(class_trim)-object.size(class_notrim), 0) | ||
# }) | ||
# | ||
# test_that('boosted tree', { | ||
# skip_on_cran() | ||
# library(caret) | ||
# library(C50) | ||
# | ||
# set.seed(1) | ||
# tr_dat <- twoClassSim(200) | ||
# te_dat <- twoClassSim(200) | ||
# | ||
# set.seed(2) | ||
# class_trim <- train(Class ~ ., data = tr_dat, | ||
# method = "C5.0", | ||
# tuneGrid = data.frame(trials = 5, | ||
# model = "tree", | ||
# winnow = FALSE), | ||
# trControl = trainControl(method = "none", | ||
# classProbs = TRUE, | ||
# trim = TRUE)) | ||
# | ||
# set.seed(2) | ||
# class_notrim <- train(Class ~ ., data = tr_dat, | ||
# method = "C5.0", | ||
# tuneGrid = data.frame(trials = 5, | ||
# model = "tree", | ||
# winnow = FALSE), | ||
# trControl = trainControl(method = "none", | ||
# classProbs = TRUE, | ||
# trim = FALSE)) | ||
# | ||
# expect_equal(predict(class_trim, te_dat), | ||
# predict(class_notrim, te_dat)) | ||
# | ||
# expect_equal(predict(class_trim, te_dat, type = "prob"), | ||
# predict(class_notrim, te_dat, type = "prob")) | ||
# | ||
# expect_less_than(object.size(class_trim)-object.size(class_notrim), 0) | ||
# }) | ||
# | ||
# test_that('boosted rule', { | ||
# skip_on_cran() | ||
# library(caret) | ||
# library(C50) | ||
# | ||
# set.seed(1) | ||
# tr_dat <- twoClassSim(200) | ||
# te_dat <- twoClassSim(200) | ||
# | ||
# set.seed(2) | ||
# class_trim <- train(Class ~ ., data = tr_dat, | ||
# method = "C5.0", | ||
# tuneGrid = data.frame(trials = 5, | ||
# model = "rules", | ||
# winnow = FALSE), | ||
# trControl = trainControl(method = "none", | ||
# classProbs = TRUE, | ||
# trim = TRUE)) | ||
# | ||
# set.seed(2) | ||
# class_notrim <- train(Class ~ ., data = tr_dat, | ||
# method = "C5.0", | ||
# tuneGrid = data.frame(trials = 5, | ||
# model = "rules", | ||
# winnow = FALSE), | ||
# trControl = trainControl(method = "none", | ||
# classProbs = TRUE, | ||
# trim = FALSE)) | ||
# | ||
# expect_equal(predict(class_trim, te_dat), | ||
# predict(class_notrim, te_dat)) | ||
# | ||
# expect_equal(predict(class_trim, te_dat, type = "prob"), | ||
# predict(class_notrim, te_dat, type = "prob")) | ||
# | ||
# expect_less_than(object.size(class_trim)-object.size(class_notrim), 0) | ||
# }) | ||
|
||
test_that('single tree', { | ||
skip_on_cran() | ||
library(caret) | ||
library(C50) | ||
|
||
set.seed(1) | ||
tr_dat <- twoClassSim(200) | ||
te_dat <- twoClassSim(200) | ||
|
||
set.seed(2) | ||
class_trim <- train(Class ~ ., data = tr_dat, | ||
method = "C5.0", | ||
tuneGrid = data.frame(trials = 1, | ||
model = "tree", | ||
winnow = FALSE), | ||
trControl = trainControl(method = "none", | ||
classProbs = TRUE, | ||
trim = TRUE)) | ||
|
||
set.seed(2) | ||
class_notrim <- train(Class ~ ., data = tr_dat, | ||
method = "C5.0", | ||
tuneGrid = data.frame(trials = 1, | ||
model = "tree", | ||
winnow = FALSE), | ||
trControl = trainControl(method = "none", | ||
classProbs = TRUE, | ||
trim = FALSE)) | ||
|
||
expect_equal(predict(class_trim, te_dat), | ||
predict(class_notrim, te_dat)) | ||
|
||
expect_equal(predict(class_trim, te_dat, type = "prob"), | ||
predict(class_notrim, te_dat, type = "prob")) | ||
|
||
expect_less_than(object.size(class_trim)-object.size(class_notrim), 0) | ||
}) | ||
|
||
test_that('single rule', { | ||
skip_on_cran() | ||
library(caret) | ||
library(C50) | ||
|
||
set.seed(1) | ||
tr_dat <- twoClassSim(200) | ||
te_dat <- twoClassSim(200) | ||
|
||
set.seed(2) | ||
class_trim <- train(Class ~ ., data = tr_dat, | ||
method = "C5.0", | ||
tuneGrid = data.frame(trials = 1, | ||
model = "rules", | ||
winnow = FALSE), | ||
trControl = trainControl(method = "none", | ||
classProbs = TRUE, | ||
trim = TRUE)) | ||
|
||
set.seed(2) | ||
class_notrim <- train(Class ~ ., data = tr_dat, | ||
method = "C5.0", | ||
tuneGrid = data.frame(trials = 1, | ||
model = "rules", | ||
winnow = FALSE), | ||
trControl = trainControl(method = "none", | ||
classProbs = TRUE, | ||
trim = FALSE)) | ||
|
||
expect_equal(predict(class_trim, te_dat), | ||
predict(class_notrim, te_dat)) | ||
|
||
expect_equal(predict(class_trim, te_dat, type = "prob"), | ||
predict(class_notrim, te_dat, type = "prob")) | ||
|
||
expect_less_than(object.size(class_trim)-object.size(class_notrim), 0) | ||
}) | ||
|
||
test_that('boosted tree', { | ||
skip_on_cran() | ||
library(caret) | ||
library(C50) | ||
|
||
set.seed(1) | ||
tr_dat <- twoClassSim(200) | ||
te_dat <- twoClassSim(200) | ||
|
||
set.seed(2) | ||
class_trim <- train(Class ~ ., data = tr_dat, | ||
method = "C5.0", | ||
tuneGrid = data.frame(trials = 5, | ||
model = "tree", | ||
winnow = FALSE), | ||
trControl = trainControl(method = "none", | ||
classProbs = TRUE, | ||
trim = TRUE)) | ||
|
||
set.seed(2) | ||
class_notrim <- train(Class ~ ., data = tr_dat, | ||
method = "C5.0", | ||
tuneGrid = data.frame(trials = 5, | ||
model = "tree", | ||
winnow = FALSE), | ||
trControl = trainControl(method = "none", | ||
classProbs = TRUE, | ||
trim = FALSE)) | ||
|
||
expect_equal(predict(class_trim, te_dat), | ||
predict(class_notrim, te_dat)) | ||
|
||
expect_equal(predict(class_trim, te_dat, type = "prob"), | ||
predict(class_notrim, te_dat, type = "prob")) | ||
|
||
expect_less_than(object.size(class_trim)-object.size(class_notrim), 0) | ||
}) | ||
|
||
test_that('boosted rule', { | ||
skip_on_cran() | ||
library(caret) | ||
library(C50) | ||
|
||
set.seed(1) | ||
tr_dat <- twoClassSim(200) | ||
te_dat <- twoClassSim(200) | ||
|
||
set.seed(2) | ||
class_trim <- train(Class ~ ., data = tr_dat, | ||
method = "C5.0", | ||
tuneGrid = data.frame(trials = 5, | ||
model = "rules", | ||
winnow = FALSE), | ||
trControl = trainControl(method = "none", | ||
classProbs = TRUE, | ||
trim = TRUE)) | ||
|
||
set.seed(2) | ||
class_notrim <- train(Class ~ ., data = tr_dat, | ||
method = "C5.0", | ||
tuneGrid = data.frame(trials = 5, | ||
model = "rules", | ||
winnow = FALSE), | ||
trControl = trainControl(method = "none", | ||
classProbs = TRUE, | ||
trim = FALSE)) | ||
|
||
expect_equal(predict(class_trim, te_dat), | ||
predict(class_notrim, te_dat)) | ||
|
||
expect_equal(predict(class_trim, te_dat, type = "prob"), | ||
predict(class_notrim, te_dat, type = "prob")) | ||
|
||
expect_less_than(object.size(class_trim)-object.size(class_notrim), 0) | ||
}) |
Oops, something went wrong.