Skip to content

Commit

Permalink
Updates parameters in .project file + added test mandatory feature an…
Browse files Browse the repository at this point in the history
…d BA constraint
  • Loading branch information
AniekMarkus committed Sep 3, 2024
1 parent fae9e6e commit 4969782
Show file tree
Hide file tree
Showing 15 changed files with 111 additions and 47 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Imports:
pracma
Encoding: UTF-8
LinkingTo: Rcpp, BH (>= 1.51.0), RcppParallel
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
Suggests:
testthat (>= 3.0.0),
knitr,
Expand Down
9 changes: 4 additions & 5 deletions inst/examples/complexity/binary_10.project
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ IncrementalOutputFile=false
[Setup]
PartitionMethod=RESUBSTITUTION
Randomize=no
StartRulelength=3
StartRulelength=1
EndRulelength=3
LearnRatio=0.8
NumberofPartitions=1
Expand All @@ -34,17 +34,16 @@ PrintCutoffMethod=no
PrintCutoffValues=no
PrintOperatorMethod=no
PrintOperatorValues=no
PrintCombinations=yes
PrintFeatureSets=yes
PrintCombinations=no
PrintFeatureSets=no
PrintCutoffSets=no
PrintCutOffsetsBestLength=no
PrintPerformance=yes
PrintSets=no
SavePartitions=no
[Run]
Subsumption=no
BranchBound=no
Parallel=no
ParallelMethod=ONE
ParallelMethod=TWO
BinaryReduction=no

7 changes: 3 additions & 4 deletions inst/examples/complexity/binary_3.project
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ PrintCutoffMethod=no
PrintCutoffValues=no
PrintOperatorMethod=no
PrintOperatorValues=no
PrintCombinations=yes
PrintFeatureSets=yes
PrintCombinations=no
PrintFeatureSets=no
PrintCutoffSets=no
PrintCutOffsetsBestLength=no
PrintPerformance=yes
PrintSets=no
SavePartitions=no
[Run]
Subsumption=no
BranchBound=no
Parallel=no
ParallelMethod=ONE
ParallelMethod=TWO
BinaryReduction=no

9 changes: 4 additions & 5 deletions inst/examples/complexity/categorical_4.project
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ PrintCutoffMethod=no
PrintCutoffValues=no
PrintOperatorMethod=no
PrintOperatorValues=no
PrintCombinations=yes
PrintFeatureSets=yes
PrintCutoffSets=yes
PrintCutOffsetsBestLength=no
PrintCombinations=no
PrintFeatureSets=no
PrintCutoffSets=no
PrintPerformance=yes
PrintSets=no
SavePartitions=no
[Run]
Subsumption=no
BranchBound=no
Parallel=no
ParallelMethod=ONE
ParallelMethod=TWO
BinaryReduction=no

9 changes: 4 additions & 5 deletions inst/examples/complexity/continuous_4.project
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,16 @@ PrintCutoffMethod=no
PrintCutoffValues=no
PrintOperatorMethod=no
PrintOperatorValues=no
PrintCombinations=yes
PrintFeatureSets=yes
PrintCutoffSets=yes
PrintCutOffsetsBestLength=no
PrintCombinations=no
PrintFeatureSets=no
PrintCutoffSets=no
PrintPerformance=yes
PrintSets=no
SavePartitions=no
[Run]
Subsumption=no
BranchBound=no
Parallel=no
ParallelMethod=ONE
ParallelMethod=TWO
BinaryReduction=no

11 changes: 6 additions & 5 deletions inst/examples/complexity/mix_4.project
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,27 @@ FeatureRule=
Maximize=BALANCEDACCURACY
Accuracy=
Specificity=
BalancedAccuracy=0.6268
[Output]
OutputMethod=BEST
OutputMethod=EVERY
PrintSettings=yes
PrintPartitions=no
PrintFeatureOperators=no
PrintCutoffMethod=no
PrintCutoffValues=no
PrintOperatorMethod=no
PrintOperatorValues=no
PrintCombinations=yes
PrintFeatureSets=yes
PrintCombinations=no
PrintFeatureSets=no
PrintCutoffSets=no
PrintCutOffsetsBestLength=no
PrintPerformance=yes
PrintPerformance=no
PrintSets=no
SavePartitions=no
[Run]
Subsumption=no
BranchBound=no
Parallel=no
ParallelMethod=ONE
ParallelMethod=TWO
BinaryReduction=no

1 change: 0 additions & 1 deletion inst/examples/plp/test_plp.project
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ PrintOperatorValues=no
PrintCombinations=no
PrintFeatureSets=no
PrintCutoffSets=no
PrintCutOffsetsBestLength=no
PrintPerformance=yes
PrintSets=no
SavePartitions=no
Expand Down
1 change: 0 additions & 1 deletion inst/examples/test.project
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ PrintOperatorValues=no
PrintCombinations=no
PrintFeatureSets=no
PrintCutoffSets=no
PrintCutOffsetsBestLength=no
PrintPerformance=yes
PrintSets=no
SavePartitions=no
Expand Down
1 change: 0 additions & 1 deletion inst/examples/tests/iris.project
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ PrintOperatorValues=no
PrintCombinations=no
PrintFeatureSets=no
PrintCutoffSets=no
PrintCutOffsetsBestLength=no
PrintPerformance=yes
PrintSets=no
SavePartitions=no
Expand Down
1 change: 0 additions & 1 deletion inst/examples/train_data.project
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ PrintOperatorValues=no
PrintCombinations=no
PrintFeatureSets=no
PrintCutoffSets=no
PrintCutOffsetsBestLength=no
PrintPerformance=yes
PrintSets=no
SavePartitions=no
Expand Down
5 changes: 2 additions & 3 deletions inst/settings/template.project
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,12 @@ PrintOperatorValues=no
PrintCombinations=no
PrintFeatureSets=no
PrintCutoffSets=no
PrintCutOffsetsBestLength=no
PrintPerformance=yes
PrintPerformance=no
PrintSets=no
SavePartitions=no
[Run]
Subsumption=no
BranchBound=yes
Parallel=yes
ParallelMethod=ONE
ParallelMethod=TWO
BinaryReduction=no
14 changes: 9 additions & 5 deletions man/modelsCurveExplore.Rd

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

13 changes: 9 additions & 4 deletions man/settingsExplore.Rd

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

18 changes: 12 additions & 6 deletions man/trainExplore.Rd

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

57 changes: 57 additions & 0 deletions tests/testthat/test-MainFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,60 @@ test_that("compute AUC", {
expect_true(auroc < 100)
expect_true(auroc > 0)
})

test_that("mandatory features", {
### Tests for EXPLORE using iris dataset
data_path <- system.file("examples", "tests", "iris.arff", package = "Explore")
settings_path <- system.file("examples", "tests", "iris.project", package = "Explore")
output_path <- paste0(tempdir(), "/", "Test1")
dir.create(output_path)
if (.Platform$OS.type == "windows") {
output_path <- gsub("\\\\", "/", output_path)
}
output_path <- paste0(output_path, "/")
data <- farff::readARFF(data_path)
model <- Explore::trainExplore(output_path = output_path,
file_name = "iris",
train_data = data,
ClassFeature = "'class'",
PositiveClass = '"Iris-versicolor"',
FeatureInclude = "'sepalwidth';'sepallength'")
expect_equal(class(model), "character")
# expect_true(is.na(model), info = "Test failed because model is NA")
expect_equal(model, "'sepallength'>4.9AND'sepalwidth'<=3.2AND'petalwidth'<=1.7")
})

test_that("balanced accuracy constraint ", {
data_path <- system.file("examples", "complexity", "mix_4.arff", package = "Explore")
output_path <- paste0(getwd(), "/", "Test1")
dir.create(output_path)
if (.Platform$OS.type == "windows") {
output_path <- gsub("\\\\", "/", output_path)
}
output_path <- paste0(output_path, "/")

data <- farff::readARFF(data_path)
data <-as.data.frame(apply(data,2,as.numeric))

model_without <- Explore::trainExplore(output_path = output_path,
file_name = "mix_4",
train_data = data,
StartRulelength = 3,
ClassFeature = "'outcomeCount'",
PositiveClass = '"1"')
num_without <- Explore::candidatesExplore(paste0(output_path, "mix_4", ".result"))

model_with <- Explore::trainExplore(output_path = output_path,
file_name = "mix_4",
train_data = data,
StartRulelength = 3,
ClassFeature = "'outcomeCount'",
PositiveClass = '"1"',
BalancedAccuracy = 0.6,
OutputMethod = "EVERY",
Parallel = FALSE)
num_with <- Explore::candidatesExplore(paste0(output_path, "mix_4", ".result"))

expect_equal(num_without, 1940)
expect_equal(num_with, 36)
})

0 comments on commit 4969782

Please sign in to comment.