Add regr.fuser learner (fused Lasso regression)#555
Open
EngineerDanny wants to merge 3 commits intomlr-org:mainfrom
Open
Add regr.fuser learner (fused Lasso regression)#555EngineerDanny wants to merge 3 commits intomlr-org:mainfrom
EngineerDanny wants to merge 3 commits intomlr-org:mainfrom
Conversation
be-marc
requested changes
Mar 20, 2026
Member
be-marc
left a comment
There was a problem hiding this comment.
Hey, thanks for contributing. Lot of unnecessary checks. Otherwise, looks good to me. You need to release your fuser fork on r-universe; gh remotes do not work well for us.
| x = as_numeric_matrix(task$data(cols = feature_names)) | ||
| y = as.numeric(task$truth()) | ||
|
|
||
| if (length(y) != nrow(x)) { |
Member
There was a problem hiding this comment.
This check is superfluous. mlr3 guarantees this.
| stopf("Target length (%i) must match the number of rows (%i).", | ||
| length(y), nrow(x)) | ||
| } | ||
| if (anyNA(x) || anyNA(y)) { |
Member
There was a problem hiding this comment.
This is also unnecessary. We check this in mlr3 when the learner does not have the property "missings".
| groups = as.character(groups) | ||
| } | ||
| groups = as.vector(groups) | ||
| if (length(groups) != nrow(x)) { |
| stopf("Grouping column length (%i) must match the number of rows (%i).", | ||
| length(groups), nrow(x)) | ||
| } | ||
| if (anyNA(groups)) { |
| } | ||
|
|
||
| pv = self$param_set$get_values(tags = "train") | ||
| if (!is.null(pv$lambda) && (!is.numeric(pv$lambda) || length(pv$lambda) != 1L)) { |
Member
There was a problem hiding this comment.
Guaranteed by the parameter set
| if (!is.null(pv$lambda) && (!is.numeric(pv$lambda) || length(pv$lambda) != 1L)) { | ||
| stopf("Parameter 'lambda' must be a numeric scalar or NULL.") | ||
| } | ||
| if (!is.numeric(pv$gamma) || length(pv$gamma) != 1L) { |
| stopf("Grouping column length (%i) must match the number of rows (%i).", | ||
| length(groups), nrow(x)) | ||
| } | ||
| if (anyNA(x)) { |
| } | ||
|
|
||
| x = as_numeric_matrix(task$data(cols = self$model$feature_names)) | ||
| if (length(groups) != nrow(x)) { |
Contributor
|
I would suggest changing role name from group to subset.
|
e0d78c9 to
18bf58b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new regression learner
regr.fuserthat wraps the fused Lasso model fromfuserand requires a single grouping column via thegrouprole.Implementation Details
LearnerRegrFuserfuser::fusedL2DescentGLMNet(X, y, groups, lambda, G, gamma, scaling)grouprolelambda = NULL,gamma = 1,scaling = FALSE,G = NULL(defaults to all-ones K×K)lambda,gamma, andGdimensionsExample
Tests
Rscript -e 'testthat::test_file("tests/testthat/test_fuser_regr_fuser.R")'Notes
fuser(GitHub fork):remotes::install_github("EngineerDanny/fuser")Closes #426