Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how should OneHotEncoding be used? #7

Open
flamz3d opened this issue Jul 22, 2020 · 1 comment
Open

how should OneHotEncoding be used? #7

flamz3d opened this issue Jul 22, 2020 · 1 comment

Comments

@flamz3d
Copy link

flamz3d commented Jul 22, 2020

hello, I'm trying to create a dataset and one feature I'd like to encode is WEEKDAY as a one-hot encoded vector

I tried:
engine.add(factors.filter.OneHotEncoder(factors.WEEKDAY), "weekday")
and
engine.add(factors.WEEKDAY.one_hot(), "weekday")
seems to be called and encoded properly, however I get an error saying factors cannot return multiple values.

What's the proper way to use the OneHotEncoder filter?

@Heerozh
Copy link
Owner

Heerozh commented Jul 22, 2020

OneHotEncoder factor returns multiple values by class, for example, if you encoding [1,2,2,3], it will return 3 values: [1, 0, 0, 0], [0, 1, 1, 0], [0, 0, 0, 1]

So just use slice []:

onehots = factors.WEEKDAY.one_hot()
for i in range(5):
    engine.add(onehots[i], "weekday{}".format(i+1))

btw: other factors such as RollingLinearRegression also return multiple values (slope and intercept)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants