Skip to content

Commit

Permalink
check target classPos
Browse files Browse the repository at this point in the history
  • Loading branch information
aruaud committed Jan 20, 2025
1 parent 7c3cc0f commit 6c77e7e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/model2DE.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ model2DE <- function(model, model_type, data, target,


# define classPos if it has not been passed
if (is.character(target) && is.null(classPos) == TRUE) {
if (!is.numeric(target) && is.null(classPos) == TRUE) {
classPos <- names(which.max(table(target)))
cat("Positive class:", classPos, "\n")
}
Expand Down
2 changes: 1 addition & 1 deletion R/model2DE_resampling.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ model2DE_resampling <- function(model, model_type, data, target, classPos = NULL

### Get a network for each subset
# define classPos if it has not been passed
if (is.character(target) && is.null(classPos) == TRUE) {
if (!is.numeric(target) && is.null(classPos) == TRUE) {
classPos <- names(which.max(table(target)))
cat("Positive class:", classPos, "\n")
}
Expand Down
3 changes: 3 additions & 0 deletions R/preCluster.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ preCluster <- function(model, model_type, data, target,

#### Create the data partition
if (length(sample_weight) == 2) {
if (is.null(classPos)) {
stop("classPos must be provided when using sample_weight = c(classPos weight, other classes weight).")
}
sample_weight <- ifelse(target == classPos, sample_weight[1], sample_weight[2])
} else if (is.null(sample_weight)) {
sample_weight <- rep(1, length(target))
Expand Down

0 comments on commit 6c77e7e

Please sign in to comment.