Skip to content

Commit 9aebc92

Browse files
committed
add tests for grid search
1 parent 927b960 commit 9aebc92

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

tests/testthat/test-gridsearch1d.R

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# test grid search
2+
test_that('grid_search',{
3+
set.seed('57475')
4+
# dataset
5+
D=iris_dataset()
6+
# iterator
7+
I = grid_search_1d(param_to_optimise='number_components',
8+
factor_name='Species',
9+
search_values=1:4,
10+
model_index=2,
11+
max_min='min')*
12+
kfold_xval(folds=5)*
13+
(mean_centre()+PLSDA())
14+
# metric
15+
B=balanced_accuracy()
16+
# run
17+
I=run(I,D,B)
18+
# calculate metric
19+
expect_equal(I$metric$value,0.3)
20+
})
21+
22+
# test grid search
23+
test_that('grid_search',{
24+
set.seed('57475')
25+
# dataset
26+
D=iris_dataset()
27+
# iterator
28+
I = grid_search_1d(param_to_optimise='number_components',
29+
factor_name='Species',
30+
search_values=1:4,
31+
model_index=2,
32+
max_min='min')*
33+
kfold_xval(folds=5)*
34+
(mean_centre()+PLSDA())
35+
# metric
36+
B=balanced_accuracy()
37+
# run
38+
I=run(I,D,B)
39+
# calculate metric
40+
C=gs_line()
41+
gg=chart.plot(C,I)
42+
expect_true(is(gg,'ggplot'))
43+
})

0 commit comments

Comments
 (0)