Skip to content

Commit

Permalink
Correction BA + remove parallellogger
Browse files Browse the repository at this point in the history
  • Loading branch information
AniekMarkus committed Sep 4, 2023
1 parent dacf8ee commit 93b5aef
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 7 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Imports:
farff,
Rcpp (>= 1.0.5),
RcppParallel,
stringr
stringr,
caret
Encoding: UTF-8
LinkingTo: Rcpp, BH (>= 1.51.0), RcppParallel
RoxygenNote: 7.2.3
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export(trainExplore)
import(Rcpp)
import(checkmate)
importFrom(RcppParallel,RcppParallelLibs)
importFrom(caret,confusionMatrix)
importFrom(farff,writeARFF)
importFrom(stringr,str_extract)
importFrom(stringr,str_replace_all)
Expand Down
14 changes: 8 additions & 6 deletions R/MainFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ trainExplore <- function(train_data = NULL,
Subsumption = TRUE,
BranchBound = TRUE,
Parallel = FALSE) {

if (!dir.exists(output_path)) {
dir.create(output_path, recursive = TRUE)
}

}
# Create output folder
if(!endsWith(output_path, "/")) {
warning("Output path should end with /, add this")
Expand Down Expand Up @@ -363,10 +363,11 @@ modelsCurveExplore <- function(train_data = NULL,
PrintSettings = PrintSettings, PrintPerformance = PrintPerformance,
Subsumption = Subsumption, BranchBound = BranchBound,
Parallel = Parallel)

return(model)
})
},
finally = ParallelLogger::logInfo('No model for specificity.')
finally = warning("No model for specificity.")
)

return(modelsCurve)
Expand All @@ -377,14 +378,15 @@ modelsCurveExplore <- function(train_data = NULL,
#'
#' @return auc value for EXPLORE
#' @export
#' @importFrom caret confusionMatrix
rocCurveExplore <- function(modelsCurve, data, labels) { # labels <- cohort$outcomeCount

# TODO: input checks?

# Combine all these results
curve_TPR <- c(1,0)
curve_FPR <- c(1,0)

for (c in length(modelsCurve):1) {
model <- modelsCurve[c]

Expand All @@ -394,7 +396,7 @@ rocCurveExplore <- function(modelsCurve, data, labels) { # labels <- cohort$outc
# Compute metrics
conf_matrix <- table(factor(predict, levels = c(0,1)), factor(labels, levels = c(0,1))) # binary prediction
performance <- caret::confusionMatrix(conf_matrix, positive = '1')

curve_TPR[c+2] <- performance$byClass['Sensitivity']
curve_FPR[c+2] <- 1 - performance$byClass['Specificity']
}
Expand Down
1 change: 1 addition & 0 deletions inst/examples/iris.project
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ FeatureRule=
[Constraints]
Maximize=ACCURACY
Accuracy=
BalancedAccuracy=
Specificity=
[Output]
OutputMethod=BEST
Expand Down
1 change: 1 addition & 0 deletions inst/settings/template.project
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ FeatureRule=
[Constraints]
Maximize=ACCURACY
Accuracy=
BalancedAccuracy=
Specificity=
[Output]
OutputMethod=BEST
Expand Down
1 change: 1 addition & 0 deletions man/modelsCurveExplore.Rd

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

1 change: 1 addition & 0 deletions man/settingsExplore.Rd

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

3 changes: 3 additions & 0 deletions man/trainExplore.Rd

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

0 comments on commit 93b5aef

Please sign in to comment.