mlrCPO icon indicating copy to clipboard operation
mlrCPO copied to clipboard

cpoSelect with statements

Open jakob-r opened this issue 7 years ago • 3 comments

Is there a CPO where I can just write something like cpoSelect(sel.statement = function(x) is.numeric(x) && !any(is.na(x))) and sel.statement just gets lapplied on the columns?

jakob-r avatar May 18 '18 12:05 jakob-r

Currently the way to select columns is only via cpoSelect(type = "numeric"); dropping columns with missing values is not supported right now. I will try to make this nicer, probably together with "slices" (see #38)

mb706 avatar May 23 '18 08:05 mb706

In the mean time, a quick and dirty implementation of this would be

library("BBmisc")
cpoSelectFunctional = makeCPO("select.functional",
  pSS(selector: funct),
  dataformat = "df.features",
  properties.adding = c("numerics.sometimes", "factors.sometimes",
    "ordered.sometimes", "missings.sometimes"),
  cpo.train = {
    vlapply(data, selector)
  },
  cpo.retrafo = {
    data[control]
  })

mb706 avatar May 23 '18 08:05 mb706

Thanks. That's a nice start. If you want, you can close this issue.

jakob-r avatar May 28 '18 09:05 jakob-r