tests/testthat/test-iris2_ModelPerformance.R

x=get(load(file="data_iris2/x.rda"))
y=get(load(file="data_iris2/y.rda"))

data=get(load(file="data_iris2/iris2.rda"))
cl=1
# -------------------------------------

cost=1

test_that("fast_ModelPerformance", {

feature.ranking = get(load('data_iris2/feature.ranking.rda'))
best.feature.nb=2
selected.features = as.character(feature.ranking$FeatureName[1:best.feature.nb])
x = x[,selected.features]
modelperf.obj <- ModelPerformance$new(x = x, y = y)

testthat::expect_equal(modelperf.obj$auc, 1, tolerance=1e-2)
testthat::expect_equal(as.numeric(modelperf.obj$cv.probs.labels$probs[1,1]), 0.9788528, tolerance=1e-5)

cv.probs.labels <- evaluateModelPerformance(data = data, cl = 1, cost=cost)
testthat::expect_equal(as.numeric(cv.probs.labels$probs[1,1]), 0.9989729, tolerance=1e-3)
}
)

test_that("fast_ModelPerformance", {

# --------------------------
feature.ranking = get(load('data_iris2/feature.ranking.rda'))
best.feature.nb=2
selected.features = as.character(feature.ranking$FeatureName[1:best.feature.nb])
x = x[,selected.features]
modelperf.obj <- ModelPerformance$new(x = x, y = y, cost=cost)

testthat::expect_equal(modelperf.obj$auc, 1, tolerance=1e-2)
testthat::expect_equal(as.numeric(modelperf.obj$cv.probs.labels$probs[1,1]), 0.9994173, tolerance=1e-5)

cv.probs.labels <- evaluateModelPerformance(data = data, cl = 1, cost=cost)
testthat::expect_equal(as.numeric(cv.probs.labels$probs[1,1]), 0.9989729, tolerance=1e-3)
}
)

Try the LedPred package in your browser

Any scripts or data that you put into this service are public.

LedPred documentation built on Nov. 8, 2020, 8 p.m.