Skip to content

Programmatic creation of pipelines #594

@CameronBieganek

Description

@CameronBieganek

Consider the following code:

julia> using MLJ

julia> function make_pipeline(model, name::AbstractString; drop_last=false)
           @pipeline(
               OneHotEncoder(drop_last=drop_last),
               model,
               name=name
           )
       end
ERROR: LoadError: UndefVarError: drop_last not defined
Stacktrace:
 [1] top-level scope at REPL[5]:1
 [2] eval at ./boot.jl:331 [inlined]
 [3] eval(::Expr) at ./client.jl:449
 [4] pipeline_preprocess(::Module, ::Expr, ::Vararg{Any,N} where N) at /Users/bieganek/.julia/packages/MLJBase/2UxSl/src/composition/models/pipelines.jl:310
 [5] pipeline_(::Module, ::Expr, ::Vararg{Any,N} where N) at /Users/bieganek/.julia/packages/MLJBase/2UxSl/src/composition/models/pipelines.jl:439
 [6] @pipeline(::LineNumberNode, ::Module, ::Vararg{Any,N} where N) at /Users/bieganek/.julia/packages/MLJBase/2UxSl/src/composition/models/pipelines.jl:562
in expression starting at REPL[5]:2

I'm not sure precisely what's going on here, but it looks like @pipeline was only designed to be called at the top-level, which makes it more laborious to create a bunch of related pipelines that use different supervised ML models for the target prediction.

I'm not sure how feasible this is, but it would be nice if there were a simple interface for creating pipelines without using a macro (in the spirit of this Discourse comment).

Version Info:

(@v1.4) pkg> status MLJ MLJBase MLJModels MLJLinearModels
Status `~/.julia/environments/v1.4/Project.toml`
  [add582a8] MLJ v0.12.0
  [a7f614a8] MLJBase v0.14.2
  [6ee0df7b] MLJLinearModels v0.5.0
  [d491faf4] MLJModels v0.11.0
julia> versioninfo()
Julia Version 1.4.0
Commit b8e9a9ecc6 (2020-03-21 16:36 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.6.0)
  CPU: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-8.0.1 (ORCJIT, skylake)
Environment:
  JULIA_EDITOR = vim

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions