Skip to content

Commit

Permalink
Update one_hot.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxHalford committed Jun 5, 2023
1 parent b76a1a3 commit 7cd76f7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions river/preprocessing/one_hot.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,21 @@ class OneHotEncoder(base.MiniBatchTransformer):
2 i h
>>> oh = preprocessing.OneHotEncoder(drop_zeros=True)
>>> oh = oh.learn_many(X)
>>> df = oh.transform_many(X)
>>> df.sort_index(axis="columns")
c1_a c1_i c1_u c2_d c2_h c2_x
0 0 0 1 1 0 0
1 1 0 0 0 0 1
2 0 1 0 0 1 0
>>> oh = preprocessing.OneHotEncoder(drop_zeros=True, drop_first=True)
>>> df = oh.transform_many(X)
>>> df.sort_index(axis="columns")
c1_i c1_u c2_d c2_h c2_x
0 0 1 1 0 0
1 0 0 0 0 1
2 1 0 0 1 0
Here's an example where the zeros are kept:
>>> oh = preprocessing.OneHotEncoder(drop_zeros=False)
Expand Down

0 comments on commit 7cd76f7

Please sign in to comment.