mlr-org / mlr

Machine Learning in R
https://mlr.mlr-org.com
Other
1.64k stars 404 forks source link

How to handle "ineligible" learner parameters? #1637

Closed MariaErdmann closed 4 years ago

MariaErdmann commented 7 years ago

RWeka's J48, for example, has a parameter "output-debug-info". Hyphens are not allowed in R. This causes problems when using generateDesignOfDefaults:

ps = getParamSet("classif.J48")

# Modify so that ps has finite box constraints
ps.def = filterParams(ps, ids = names(getDefaults(ps)))
finite.constraints = lapply(ps.def$pars, function(p) {
  if (p$type %in% c("integer", "numeric")) {
    p$upper = ifelse(p$upper == Inf, p$default, p$upper)
    p$lower = ifelse(p$lower == -Inf, p$default, p$lower)
  }
  return(p)
})

ps.finite.constraints = do.call(makeParamSet, finite.constraints)
generateDesignOfDefaults(ps.finite.constraints)
mb706 commented 7 years ago

This is a bug in ParamHelpers, you should report it there...

By default, invalid parts of a variable name should be replaced by dots, so in the design data frame, the column should be named output.debug.info.

A workaround seems to be to remove the parameter from the param set to generate the default dataframe, and then to add the parameter manually:

ps.finite.constraints2 <- ps.finite.constraints
ps.finite.constraints2$pars[['output-debug-info']] <- NULL
desi = generateDesignOfDefaults(ps.finite.constraints2)
desi$output.debug.info=getDefaults(ps.finite.constraints)[['output-debug-info']]
ctrl4 <- makeTuneControlDesign(design=desi)
tuneParams("classif.J48", pid.task, resampling=cv3, control=ctrl4, par.set=ps.finite.constraints, show.info=TRUE)
stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.