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

Move pkg function calls within ParamSets to helper file #2730

Merged
merged 11 commits into from
Feb 26, 2020
Merged

Conversation

pat-s
Copy link
Member

@pat-s pat-s commented Feb 8, 2020

fixes #2729

We cannot have pkg::<fun> call within the ParamSets of learners as they will cause listLearners() to fail if the learner package is not installed.

@jakob-r
Copy link
Sponsor Member

jakob-r commented Feb 10, 2020

It looks a bit cumbersome.
I would avoid extra helper files for each learner
Can you just write function(...) mda::polyreg(...) directly inside the paramset?

@pat-s
Copy link
Member Author

pat-s commented Feb 10, 2020

Thanks. Seems to work.

@jakob-r
Copy link
Sponsor Member

jakob-r commented Feb 10, 2020

Sorry. This was a stupid suggestion. Now we will run into problems if we want to set e.g. method to mda::mars because the check will say that mda::mars is not a valid value.
I think here it is done correctly:

par.funs = learnerArgsToControl(list, metric, Ker)
par.funs = lapply(par.funs, function(x) getFromNamespace(x, "fda.usc"))

Otherwise just use makeUntypedLearnerParam I guess. Does not really hurt and allows the user to supply custom functions.

@pat-s
Copy link
Member Author

pat-s commented Feb 17, 2020

I think here it is done correctly:

This is within train() which is easier than in the ParamSet.

I will use the makeUntypedLearnerParam then.

@@ -21,7 +21,7 @@ makeRLearner.classif.mda = function() {
makeLogicalLearnerParam(id = "trace", default = FALSE, tunable = FALSE),
makeDiscreteLearnerParam(id = "start.method", default = "kmeans", values = c("kmeans", "lvq")),
makeIntegerLearnerParam(id = "tries", default = 5L, lower = 1L),
makeDiscreteLearnerParam(id = "criterion", default = "misclassification", values = c("misclassification", "deviance"))
makeDiscreteLearnerParam(id = "criterion", default = "misclassification", special.vals = c("misclassification", "deviance"))
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
makeDiscreteLearnerParam(id = "criterion", default = "misclassification", special.vals = c("misclassification", "deviance"))
makeDiscreteLearnerParam(id = "criterion", default = "misclassification", values = c("misclassification", "deviance"))

special.vals are meant for values that do not match the param type. It also does not make much sense to define a DiscreteParam without discrete values.

values = list(polyreg = mda::polyreg, mars = mda::mars, bruto = mda::bruto, gen.ridge = mda::gen.ridge)),
# see helpers_mda.R for objects
makeUntypedLearnerParam(id = "method", default = function(...) mda::polyreg(...),
values = list(polyreg = function(...) mda::polyreg(...),
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for an untyped Param you cannot set values.

@jakob-r
Copy link
Sponsor Member

jakob-r commented Feb 20, 2020

Now everyhting looks mixed up...

@mlr-org mlr-org deleted a comment from codecov bot Feb 20, 2020
@codecov
Copy link

codecov bot commented Feb 20, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@85c939b). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2730   +/-   ##
=========================================
  Coverage          ?   92.36%           
=========================================
  Files             ?      402           
  Lines             ?    14486           
  Branches          ?        0           
=========================================
  Hits              ?    13380           
  Misses            ?     1106           
  Partials          ?        0

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 85c939b...4db31b8. Read the comment docs.

@pat-s
Copy link
Member Author

pat-s commented Feb 24, 2020

@jakob-r approved?

Copy link
Sponsor Member

@jakob-r jakob-r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am on it

@jakob-r
Copy link
Sponsor Member

jakob-r commented Feb 26, 2020

Ok - i just did a commit how I would do it. If you dislike it feel free to revert to another solution

@pat-s
Copy link
Member Author

pat-s commented Feb 26, 2020

Thanks. I am not an expert in advanced Param specifications so I'll take whatever works :)

@pat-s pat-s merged commit 9933804 into master Feb 26, 2020
@pat-s pat-s deleted the fix-param-sets branch February 26, 2020 10:50
vrodriguezf pushed a commit to vrodriguezf/mlr that referenced this pull request Jan 16, 2021
* Refactor function calls from packages (`<pkg::fun>`) within ParamSets (mlr-org#2730)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

listLearners() fails if certain packages are not installed
2 participants