I have the following Daru Data Frame with a categorical variable called search_term
:
home,search_term,bought
0,php,1
0,java,1
1,php,1
...
I want to convert it to a Daru Data Frame with binary columns, something like:
home,php,java,bought
0,1,0,1
0,0,1,1
1,1,0,1
...
I can't find a way to achieve it. I know it's possible in Python's Panda but I want to use Ruby with the Darus gem.
Thanks.
According to a blog post written by Yoshoku, the author of Rumale machine learning library, you can do it like:
Rumale's label encoder is also useful for the categorical variable.
Rumale::Preprocessing::OneHotEncoder
But, conversion of Daru::Vector and Numo::NArray needs to use
to_a
.