# AutoMLPipeline.jl makes it easy to create complexed ML pipeline structures

**URL:** <https://discourse.julialang.org/t/automlpipeline-jl-makes-it-easy-to-create-complexed-ml-pipeline-structures/35308>\
**Category:** Package Announcements\
**Tags:** machine-learning\
**Created:** [February 28, 2020, 11:22pm UTC](https://discourse.julialang.org/t/automlpipeline-jl-makes-it-easy-to-create-complexed-ml-pipeline-structures/35308 "2020-02-28T23:22:10Z")\
**Posts on this page:** 4\
**Page:** 2

<div class="post-metadata">

**Author:** ![JP\_Nieto](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jp_nieto/32/10082_2.png) [@JP\_Nieto](https://discourse.julialang.org/u/JP_Nieto)\
**Post date:** [March 5, 2020, 3:09pm UTC](https://discourse.julialang.org/t/automlpipeline-jl-makes-it-easy-to-create-complexed-ml-pipeline-structures/35308/22 "2020-03-05T15:09:58Z")

</div>

Is there a way to automatically create a visual representation (flowchart) of the pipelines?

---

<div class="post-metadata">

**Author:** ![ppalmes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ppalmes/32/6838_2.png) [@ppalmes](https://discourse.julialang.org/u/ppalmes)\
**Post date:** [March 5, 2020, 3:42pm UTC](https://discourse.julialang.org/t/automlpipeline-jl-makes-it-easy-to-create-complexed-ml-pipeline-structures/35308/23 "2020-03-05T15:42:21Z")

</div>

i’m working on it. you can use @pipelinex instead of @pipeline for the expression. i know there is a package that can translate this into tree representation by passing this expression. I think you can try TreeView.jl if you like to see the tree structure of the expression.

---

<div class="post-metadata">

**Author:** ![ppalmes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ppalmes/32/6838_2.png) [@ppalmes](https://discourse.julialang.org/u/ppalmes)\
**Post date:** [March 5, 2020, 4:23pm UTC](https://discourse.julialang.org/t/automlpipeline-jl-makes-it-easy-to-create-complexed-ml-pipeline-structures/35308/25 "2020-03-05T16:23:25Z")

</div>

You can try this. Install AbstractTrees and use print\_tree:

using AbstractTrees  
using AutoMLPipeline

print\_tree(stdout,@pipelinex a |\> (b |\> d) + (c |\> e) |\> rf)  
:(Pipeline(Pipeline(a, ComboPipeline(Pipeline(b, d), Pipeline(c, e))), rf))  
├─ :Pipeline  
├─ :(Pipeline(a, ComboPipeline(Pipeline(b, d), Pipeline(c, e))))  
│ ├─ :Pipeline  
│ ├─ :a  
│ └─ :(ComboPipeline(Pipeline(b, d), Pipeline(c, e)))  
│ ├─ :ComboPipeline  
│ ├─ :(Pipeline(b, d))  
│ │ ├─ :Pipeline  
│ │ ├─ :b  
│ │ └─ :d  
│ └─ :(Pipeline(c, e))  
│ ├─ :Pipeline  
│ ├─ :c  
│ └─ :e  
└─ :rf

---

<div class="post-metadata">

**Author:** ![ppalmes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ppalmes/32/6838_2.png) [@ppalmes](https://discourse.julialang.org/u/ppalmes)\
**Post date:** [March 9, 2020, 10:19pm UTC](https://discourse.julialang.org/t/automlpipeline-jl-makes-it-easy-to-create-complexed-ml-pipeline-structures/35308/26 "2020-03-09T22:19:45Z")

</div>

Just an update of the latest feature in the @pipeline call of AutoMLPipeline. Aside from `|>` and `+` operators that are for `Linear` and `Combo Pipeline`, you can now use `*` to act as a `Selector Pipeline` to pick the best ML learner. Here’s an example:

```julia
julia> pcmc = @pipeline disc |> ((catf |> ohe) + (numf |> std)) |> (jrf * ada * sgd * tree * lsvc)
julia> crossvalidate(pcmc,X,Y,"accuracy_score",10)
(mean = 0.7276977412403225, std = 0.033181493759015454, folds = 10)

```

The `Selector Pipeline` performs internal cross-validation among the learners: jrf, ada, sgd, tree, lsvc. It will then use the best learner prediction as its final output.

The much longer typical workflow to pick the best learner and use its output will be:

```julia
julia> learners = DataFrame()
julia> for learner in [jrf,ada,sgd,tree,lsvc]
         pcmc = @pipeline disc |> ((catf |> ohe) + (numf |> std)) |> learner
         println(learner.name)
         mean,sd,_ = crossvalidate(pcmc,X,Y,"accuracy_score",10)
         global learners = vcat(learners,DataFrame(name=learner.name,mean=mean,sd=sd))
       end;
julia> @show learners;
learners = 5×3 DataFrame
│ Row │ name │ mean │ sd │
│ │ String │ Float64 │ Float64 │
├─────┼────────────────────────┼──────────┼───────────┤
│ 1 │ rf_k2d │ 0.684652 │ 0.0334061 │
│ 2 │ AdaBoostClassifier_1rk │ 0.698086 │ 0.0576059 │
│ 3 │ SGDClassifier_2xI │ 0.715688 │ 0.0452629 │
│ 4 │ prunetree_pSa │ 0.578826 │ 0.0459255 │
│ 5 │ LinearSVC_39A │ 0.730508 │ 0.0494756 │

```

Based on these results, Linear SVC will be chosen by the user because its performance is the best (73.00%). The `Selector Pipeline` also used Linear SVC to achieve almost similar performance (72.7%) in an automatic manner.

[Previous page](https://discourse.julialang.org/t/automlpipeline-jl-makes-it-easy-to-create-complexed-ml-pipeline-structures/35308.md?page=1)
