Skip to content

Commit

Permalink
stop if multiclass
Browse files Browse the repository at this point in the history
  • Loading branch information
egenn committed Jul 1, 2024
1 parent 9cf09e3 commit e0f7f91
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions R/s_LightRuleFit.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ s_LightRuleFit <- function(x, y = NULL,
xnames <- dt$xnames
type <- dt$type
checkType(type, c("Classification", "Regression"), mod.name)
# Currently only supports binary classification
if (type == "Classification" && length(levels(y)) > 2) {
stop("Only binary classification is currently supported")
}
# if (any(sapply(x, is.factor))) {
# factor_index <- names(x)[which(sapply(x, is.factor))]
# xp <- preprocess(x,
Expand Down Expand Up @@ -286,6 +290,8 @@ s_LightRuleFit <- function(x, y = NULL,
n.cores = n.cores
)
mod_glmnet_select <- do.call(s_GLMNET, glmnet_select_args)
# binary classification: coef(mod_glmnet_select$mod) is n x 1 sparse Matrix of class "dgCMatrix"
# multiclass classification
rule_coefs <- data.matrix(coef(mod_glmnet_select$mod))
intercept_coef <- rule_coefs[1, , drop = FALSE]
colnames(intercept_coef) <- "Coefficient"
Expand Down

0 comments on commit e0f7f91

Please sign in to comment.