Skip to content

OneHotEncoder - add option for 1 of k-1 encoding #6488

@benrifkind

Description

@benrifkind

Like the title says. Would it be possible to add an option, say "independent = True" to OneHotEncoder that would return a 1 of k-1 encoding instead of a 1 of k encoding. This would be very useful to me when I am encoding categorical variables since the 1 of k encoding adds an extra (non-independent) degree of freedom to the model. It would also be nice if I could specify which category to keep as the baseline.

Something like:

X = np.array([12,24,36]).reshape(-1,1)  
OneHotEncoder(sparse=False, independent=True, baseline=24).fit_transform(X)  
Output: array([[ 1., 0.],
       [ 0., 0.],
       [ 0., 1.]])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions