# FeatureSelector in MLJ Learning Networks

**URL:** <https://discourse.julialang.org/t/featureselector-in-mlj-learning-networks/29591>\
**Category:** General Usage\
**Tags:** question\
**Created:** [October 7, 2019, 1:52pm UTC](https://discourse.julialang.org/t/featureselector-in-mlj-learning-networks/29591 "2019-10-07T13:52:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![petrost](https://avatars.discourse-cdn.com/v4/letter/p/6bbea6/32.png) [@petrost](https://discourse.julialang.org/u/petrost)\
**Post date:** [October 7, 2019, 1:52pm UTC](https://discourse.julialang.org/t/featureselector-in-mlj-learning-networks/29591/1 "2019-10-07T13:52:30Z")

</div>

I am trying to build a simple learning network using MLJ, but the FeatureSelector() is not recognized as a valid model used on a node. Is there any alternative to that?  
In general, is there a way I can perform column-wise operations with nodes (e.g. remove or select columns) just as you can do with rows?

---

<div class="post-metadata">

**Author:** ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Post date:** [October 7, 2019, 2:11pm UTC](https://discourse.julialang.org/t/featureselector-in-mlj-learning-networks/29591/2 "2019-10-07T14:11:58Z")

</div>

Hello @petrost could you quote the versions of the various `MLJ*` packages you’re using?

Unless I misunderstand your question, with MLJ 0.4 and MLJModels 0.4, this should work fine:

```julia
using MLJ, DataFrames
X = DataFrame(a=[1,2,3],b=[3,4,5],c=["a","a","b"])
fs = FeatureSelector(features=[:a,:b])
m = machine(fs, X)
fit!(m)
Xb = transform(m, X)

```

---

<div class="post-metadata">

**Author:** ![petrost](https://avatars.discourse-cdn.com/v4/letter/p/6bbea6/32.png) [@petrost](https://discourse.julialang.org/u/petrost)\
**Post date:** [October 7, 2019, 2:36pm UTC](https://discourse.julialang.org/t/featureselector-in-mlj-learning-networks/29591/3 "2019-10-07T14:36:59Z")

</div>

Thanks for the reply @tlienart! I have the latest versions of MLJ\* packages and the FeatureSelector is working just fine when used with dataframes, just like your example.

However, if you use it with an input of type ‘Node’ it doesn’t work. For example:

```julia
using MLJ, DataFrames
X = DataFrame(a=[1,2,3],b=[3,4,5],c=["a","a","b"])
Xs = source(X)

stand_model = Standardizer()
stand = machine(stand_model, Xs)
W = transform(stand, Xs)

fs = FeatureSelector(features=[:a])
m = machine(fs, W)
W1 = transform(fs, W)

```

In the above example, W is already of type ‘Node’ and when I run it I get

```julia
ERROR: LoadError: MethodError: no method matching transform(::FeatureSelector, ::Node{NodalMachine{Standardizer}})

```

---

<div class="post-metadata">

**Author:** ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Post date:** [October 7, 2019, 3:01pm UTC](https://discourse.julialang.org/t/featureselector-in-mlj-learning-networks/29591/4 "2019-10-07T15:01:56Z")

</div>

Thanks for taking the time to detail the question, I’ve opened an issue ([https://github.com/alan-turing-institute/MLJ.jl/issues/254](https://github.com/alan-turing-institute/MLJ.jl/issues/254)) as this should work.

---

<div class="post-metadata">

**Author:** ![ablaom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ablaom/32/4889_2.png) [@ablaom](https://discourse.julialang.org/u/ablaom)\
**Post date:** [October 8, 2019, 6:21am UTC](https://discourse.julialang.org/t/featureselector-in-mlj-learning-networks/29591/5 "2019-10-08T06:21:01Z")

</div>

See the issue just cited for what I am confident is the resolution to the problem - a usage error not a bug. Feel free to re-open the issue if this is not resolved.

Thanks for posting!
