library(otsad)
context("Dynamic Threshold Scorer")
test_that("DynamicThresholdScorer gives the correct result", {
a <- c(0.590, 0.157, 0.052, 1.027, 0.274, 0.357, 1.464, 1.797, 0.546, 0.749, 0.028, 1.449,
0.008, 2.520, 0.780, 1.180, 0.985, 1.919, 1.678, 1.046, 0.517, 0.375, 0.832, 0.376,
0.709, 0.046, 0.771, 0.286, 0.343, 0.378, 1.321, 1.404, 1.054, 0.662, 0.357, 0.283,
0.586, 2.577, 0.262, 0.208, 0.115, 1.387, 0.016, 1.649, 0.613, 0.362, 0.439, 0.202,
2.671, 0.334, 0.653, 0.248, 0.149, 0.808, 0.216, 0.319, 0.042, 3.356, 0.151, 1.901,
0.625, 0.592, 0.777, 6.000, 2.011, 0.957, 1.002, 1.311, 0.255, 1.043, 0.369, 1.177,
1.023, 0.118, 0.861, 1.176, 2.120, 1.332, 0.720, 0.052, 0.636, 1.173, 0.278, 0.037,
1.753, 0.493, 0.124, 0.064, 1.242, 0.196, 0.297, 0.471, 1.234, 1.544, 1.918, 0.716,
0.665, 1.496, 0.491, 0.816)
res <- c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
scorer <- DynamicThresholdScorer$new(3, l = 6)
scores <- round(sapply(a, function(x) {scorer$computeScore(x)}), 3)
expect_equal(scores, res)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.