|
| 1 | +# test permutation test class |
| 2 | +test_that('permutation test',{ |
| 3 | + set.seed('57475') |
| 4 | + # dataset |
| 5 | + D=iris_dataset() |
| 6 | + # iterator |
| 7 | + I = permutation_test(number_of_permutations=20)*(mean_centre()+PLSDA()) |
| 8 | + # metric |
| 9 | + B=balanced_accuracy() |
| 10 | + # run |
| 11 | + I=run(I,D,B) |
| 12 | + # calculate metric |
| 13 | + B=calculate(B,Yhat=output.value(I,'results.unpermuted')$predicted, |
| 14 | + Y=output.value(I,'results.unpermuted')$actual) |
| 15 | + expect_equal(value(B),0.50775) |
| 16 | +}) |
| 17 | + |
| 18 | +# permutation test box plot |
| 19 | +test_that('permutation test boxplot',{ |
| 20 | + set.seed('57475') |
| 21 | + # dataset |
| 22 | + D=iris_dataset() |
| 23 | + # iterator |
| 24 | + I = permutation_test(number_of_permutations=10)*kfold_xval(folds=3)*(mean_centre()+PLSDA()) |
| 25 | + # metric |
| 26 | + B=balanced_accuracy() |
| 27 | + # run |
| 28 | + I=run(I,D,B) |
| 29 | + # chart |
| 30 | + C=permutation_test.boxplot() |
| 31 | + gg=chart.plot(C,I) |
| 32 | + expect_true(is(gg,'ggplot')) |
| 33 | +}) |
| 34 | + |
| 35 | +# permutation test hist plot |
| 36 | +test_that('permutation test hist plot',{ |
| 37 | + set.seed('57475') |
| 38 | + # dataset |
| 39 | + D=iris_dataset() |
| 40 | + # iterator |
| 41 | + I = permutation_test(number_of_permutations=10)*kfold_xval(folds=3)*(mean_centre()+PLSDA()) |
| 42 | + # metric |
| 43 | + B=balanced_accuracy() |
| 44 | + # run |
| 45 | + I=run(I,D,B) |
| 46 | + # chart |
| 47 | + C=permutation_test.hist() |
| 48 | + gg=chart.plot(C,I) |
| 49 | + expect_true(is(gg,'ggplot')) |
| 50 | +}) |
| 51 | + |
| 52 | +# permutation test scatter plot |
| 53 | +test_that('permutation scatter hist plot',{ |
| 54 | + set.seed('57475') |
| 55 | + # dataset |
| 56 | + D=iris_dataset() |
| 57 | + # iterator |
| 58 | + I = permutation_test(number_of_permutations=10)*kfold_xval(folds=3)*(mean_centre()+PLSDA()) |
| 59 | + # metric |
| 60 | + B=balanced_accuracy() |
| 61 | + # run |
| 62 | + I=run(I,D,B) |
| 63 | + # chart |
| 64 | + C=permutation_test.scatter() |
| 65 | + gg=chart.plot(C,I) |
| 66 | + expect_true(is(gg,'ggplot')) |
| 67 | +}) |
| 68 | + |
| 69 | +# permutation test violin plot |
| 70 | +test_that('permutation violin hist plot',{ |
| 71 | + set.seed('57475') |
| 72 | + # dataset |
| 73 | + D=iris_dataset() |
| 74 | + # iterator |
| 75 | + I = permutation_test(number_of_permutations=10)*kfold_xval(folds=3)*(mean_centre()+PLSDA()) |
| 76 | + # metric |
| 77 | + B=balanced_accuracy() |
| 78 | + # run |
| 79 | + I=run(I,D,B) |
| 80 | + # chart |
| 81 | + C=permutation_test.violin() |
| 82 | + gg=chart.plot(C,I) |
| 83 | + expect_true(is(gg,'ggplot')) |
| 84 | +}) |
| 85 | + |
0 commit comments