sksurv.preprocessing.OneHotEncoder

class sksurv.preprocessing.OneHotEncoder(allow_drop=True)

Encode categorical columns with M categories into M-1 columns according to the one-hot scheme.

The order of non-categorical columns is preserved, encoded columns are inserted inplace of the original column.

Parameters:

allow_drop : boolean, optional, default=True

Whether to allow dropping categorical columns that only consist of a single category.

Attributes

feature_names_ (pandas.Index) List of encoded columns.
categories_ (dict) Categories of encoded columns.
encoded_columns_ (list) Name of columns after encoding. Includes names of non-categorical columns.
__init__(allow_drop=True)

Methods

__init__([allow_drop])
fit(X) Retrieve categorical columns.
fit_transform(X[, y]) Convert categorical columns to numeric values.
transform(X) Convert categorical columns to numeric values.
fit(X)

Retrieve categorical columns.

Parameters:

X : pandas.DataFrame

Data to encode.

Returns:

self : object

Returns self

fit_transform(X, y=None, **fit_params)

Convert categorical columns to numeric values.

Parameters:

X : pandas.DataFrame

Data to encode.

y :

Ignored. For computability with TransformerMixin.

fit_params :

Ignored. For computability with TransformerMixin.

Returns:

Xt : pandas.DataFrame

Encoded data.

transform(X)

Convert categorical columns to numeric values.

Parameters:

X : pandas.DataFrame

Data to encode.

Returns:

Xt : pandas.DataFrame

Encoded data.