Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GraphLearner should implement custom $configure() and Graph should also implement $configure() #888

Open
sebffischer opened this issue Mar 21, 2025 · 2 comments
Labels

Comments

@sebffischer
Copy link
Member

mlr3's $configure() allows to set both hyperparameters and fields.
It would be nice if GraphLearner provided its own $configure() method that also allows to set fields of PipeOps, something like

graph = po("pca") %>>% lrn("classif.rpart")
glrn = as_learner(graph)

glrn$configure(
  classif.rpart.predict_type = "prob"
) 

Currently this does not work, because glrn does neither have a field nor parameter called classif.rpart.predict_type.

Analogously, it would be nice if the same was possible for Graphs, which currently don't have a $configure() method.

@sebffischer sebffischer changed the title GraphLearner should implement custom $configure() and Graph should also implement $configre() GraphLearner should implement custom $configure() and Graph should also implement $configure() Mar 21, 2025
@mb706
Copy link
Collaborator

mb706 commented Mar 21, 2025

We could set up $configure so that it tries to call $configure() in contained objects whenever it does not find a field or hyperparameter in the class itself. So GraphLearner calls Graph's $configure() (to be implemented), Graph$configure() strips off a PipeOp id prefix and calls the corresponding PipeOp, PipeOpLearner delegates to the Learner etc

@mb706
Copy link
Collaborator

mb706 commented Mar 21, 2025

From our internal discussion: The predict_type example actually already works, since GraphLearner's predict_type is already delegated through the active binding:

graph = po("pca") %>>% lrn("classif.rpart")
glrn = as_learner(graph)

glrn$configure(predict_type = "prob") 
glrn$graph$pipeops$classif.rpart$learner
#> <LearnerClassifRpart:classif.rpart>: Classification Tree
#> * Model: -
#> * Parameters: xval=0
#> * Packages: mlr3, rpart
#> * Predict Types:  response, [prob]
#> * Feature Types: logical, integer, numeric, factor, ordered
#> * Properties: importance, missings, multiclass, selected_features,
#>   twoclass, weights

but there may be other fields for which this does not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants