Skip to content

Commit

Permalink
check changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cebarboza committed Jul 12, 2023
1 parent 6e1a016 commit 6fc7dfa
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 99 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ Suggests:
VignetteBuilder: knitr
Config/testthat/edition: 3
URL: https://cbarbozaerasmus.github.io/Explore/
SystemRequirements: GNU make
1 change: 0 additions & 1 deletion R/MainFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#' @param train_data Train data
#' @param output_path A string declaring the path to the settings
#' @param settings_path A string declaring the path to the settings
#' @param settings Settings parameter
#' @param output_path A string declaring the path to the settings
#' @param file_name A string declaring the the path to the file name
#' @param train_data Train data
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions man/trainExplore.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

192 changes: 96 additions & 96 deletions tests/testthat/test-MainFunctions.R
Original file line number Diff line number Diff line change
@@ -1,96 +1,96 @@
# # TODO: check differences variable names with / without ''
#
# test_that("option 1: fully pre-specified settings file works", {
# ### Tests for EXPLORE using iris dataset
# data_path <- system.file("examples", "iris.arff", package = "Explore")
# settings_path <- system.file("examples", "iris.project", package = "Explore")
# output_path <- system.file("examples", "output", package = "Explore")
# data <- farff::readARFF(data_path)
# # Required dependencies
# withr::local_package("farff")
# model <- Explore::trainExplore(output_path = output_path,
# file_name = "iris",
# train_data = data,
# ClassFeature = "'class'",
# PositiveClass = '"Iris-versicolor"')
# expect_equal(class(model), "character")
# # expect_true(is.na(model), info = "Test failed because model is NA")
# expect_equal(model, "'petallength'>2.45AND'petallength'<=4.95AND'petalwidth'<=1.65")
# })
#
# test_that("option 2: pre-specified settings file with input data works", {
#
# ### Tests for EXPLORE using iris dataset
# data_path <- system.file("examples", "iris.arff", package = "Explore")
# settings_path <- system.file("examples", "iris.project", package = "Explore")
# output_path <- system.file("examples", "output", package = "Explore")
# data <- farff::readARFF(data_path)
# # Required dependencies
# withr::local_package("farff")
# model <- Explore::trainExplore(output_path = output_path,
# train_data = data,
# settings_path = settings_path,
# ClassFeature = "'class'",
# PositiveClass = '"Iris-versicolor"')
# expect_equal(class(model), "character")
# expect_false(model == "NA", info = "Test failed because model is NA")
# expect_equal(model, "'petallength'>2.45AND'petallength'<=4.95AND'petalwidth'<=1.65") # OR "'sepallength'>4.85" ?
# })
#
# test_that("option 3: only input parameters (no settings file) works", {
# ### Tests for EXPLORE using iris dataset
# data_path <- system.file("examples", "iris.arff", package = "Explore")
# settings_path <- system.file("examples", "iris.project", package = "Explore")
# output_path <- system.file("examples", "output", package = "Explore")
# data <- farff::readARFF(data_path)
# # Required dependencies
# withr::local_package("farff")
# model <- Explore::trainExplore(output_path = output_path,
# file_name = "iris",
# train_data = data,
# ClassFeature = "'class'",
# PositiveClass = '"Iris-versicolor"')
# expect_equal(class(model), "character")
# expect_false(model == "NA", info = "Test failed because model is NA")
# expect_equal(model, "'petallength'>2.45AND'petallength'<=4.95AND'petalwidth'<=1.65")
# })
#
# test_that("prediction", {
# ### Tests for EXPLORE using iris dataset
# data_path <- system.file("examples", "iris.arff", package = "Explore")
# settings_path <- system.file("examples", "iris.project", package = "Explore")
# output_path <- system.file("examples", "output", package = "Explore")
# data <- farff::readARFF(data_path)
# # Required dependencies
# withr::local_package("farff")
# model <- Explore::trainExplore(output_path = output_path,
# train_data = data,
# settings_path = settings_path,
# ClassFeature = "'class'",
# PositiveClass = '"Iris-versicolor"')
# prediction <- Explore::predictExplore(model, test_data = data)
# expect_equal(class(prediction), "integer")
# expect_equal(length(prediction), nrow(data))
# expect_equal(sum(prediction %in% c(0,1) == FALSE),0)
# })
#
# test_that("compute AUC", {
# ### Tests for EXPLORE using iris dataset
# data_path <- system.file("examples", "iris.arff", package = "Explore")
# settings_path <- system.file("examples", "iris.project", package = "Explore")
# output_path <- system.file("examples", "output", package = "Explore")
# # output_path <- system.file("examples", "output//", package = "Explore")
# # output_path <- paste0(output_path, "//")
# data <- farff::readARFF(data_path)
#
# # Required dependencies
# withr::local_package("farff")
# auroc <- Explore::aurocEXPLORE(output_path = output_path,
# train_data = data,
# settings_path = settings_path,
# ClassFeature = "'class'",
# PositiveClass = '"Iris-versicolor"')
# expect_equal(class(auroc), "numeric")
# expect_true(auroc < 100)
# expect_true(auroc > 0)
# })
# TODO: check differences variable names with / without ''

test_that("option 1: fully pre-specified settings file works", {
### Tests for EXPLORE using iris dataset
data_path <- system.file("examples", "iris.arff", package = "Explore")
settings_path <- system.file("examples", "iris.project", package = "Explore")
output_path <- system.file("examples", "output", package = "Explore")
data <- farff::readARFF(data_path)
# Required dependencies
withr::local_package("farff")
model <- Explore::trainExplore(output_path = output_path,
file_name = "iris",
train_data = data,
ClassFeature = "'class'",
PositiveClass = '"Iris-versicolor"')
expect_equal(class(model), "character")
# expect_true(is.na(model), info = "Test failed because model is NA")
expect_equal(model, "'petallength'>2.45AND'petallength'<=4.95AND'petalwidth'<=1.65")
})

test_that("option 2: pre-specified settings file with input data works", {

### Tests for EXPLORE using iris dataset
data_path <- system.file("examples", "iris.arff", package = "Explore")
settings_path <- system.file("examples", "iris.project", package = "Explore")
output_path <- system.file("examples", "output", package = "Explore")
data <- farff::readARFF(data_path)
# Required dependencies
withr::local_package("farff")
model <- Explore::trainExplore(output_path = output_path,
train_data = data,
settings_path = settings_path,
ClassFeature = "'class'",
PositiveClass = '"Iris-versicolor"')
expect_equal(class(model), "character")
expect_false(model == "NA", info = "Test failed because model is NA")
expect_equal(model, "'petallength'>2.45AND'petallength'<=4.95AND'petalwidth'<=1.65") # OR "'sepallength'>4.85" ?
})

test_that("option 3: only input parameters (no settings file) works", {
### Tests for EXPLORE using iris dataset
data_path <- system.file("examples", "iris.arff", package = "Explore")
settings_path <- system.file("examples", "iris.project", package = "Explore")
output_path <- system.file("examples", "output", package = "Explore")
data <- farff::readARFF(data_path)
# Required dependencies
withr::local_package("farff")
model <- Explore::trainExplore(output_path = output_path,
file_name = "iris",
train_data = data,
ClassFeature = "'class'",
PositiveClass = '"Iris-versicolor"')
expect_equal(class(model), "character")
expect_false(model == "NA", info = "Test failed because model is NA")
expect_equal(model, "'petallength'>2.45AND'petallength'<=4.95AND'petalwidth'<=1.65")
})

test_that("prediction", {
### Tests for EXPLORE using iris dataset
data_path <- system.file("examples", "iris.arff", package = "Explore")
settings_path <- system.file("examples", "iris.project", package = "Explore")
output_path <- system.file("examples", "output", package = "Explore")
data <- farff::readARFF(data_path)
# Required dependencies
withr::local_package("farff")
model <- Explore::trainExplore(output_path = output_path,
train_data = data,
settings_path = settings_path,
ClassFeature = "'class'",
PositiveClass = '"Iris-versicolor"')
prediction <- Explore::predictExplore(model, test_data = data)
expect_equal(class(prediction), "integer")
expect_equal(length(prediction), nrow(data))
expect_equal(sum(prediction %in% c(0,1) == FALSE),0)
})

test_that("compute AUC", {
### Tests for EXPLORE using iris dataset
data_path <- system.file("examples", "iris.arff", package = "Explore")
settings_path <- system.file("examples", "iris.project", package = "Explore")
output_path <- system.file("examples", "output", package = "Explore")
# output_path <- system.file("examples", "output//", package = "Explore")
# output_path <- paste0(output_path, "//")
data <- farff::readARFF(data_path)

# Required dependencies
withr::local_package("farff")
auroc <- Explore::aurocEXPLORE(output_path = output_path,
train_data = data,
settings_path = settings_path,
ClassFeature = "'class'",
PositiveClass = '"Iris-versicolor"')
expect_equal(class(auroc), "numeric")
expect_true(auroc < 100)
expect_true(auroc > 0)
})

0 comments on commit 6fc7dfa

Please sign in to comment.