Loading...

verticapy.machine_learning.memmodel.preprocessing.OneHotEncoder.transform#

OneHotEncoder.transform(X: list | ndarray) ndarray#

Transforms and applies the OneHotEncoder model to the input matrix.

Parameters#

X: ArrayLike

The data on which to make the transformation.

Returns#

numpy.array

Transformed values.

Examples#

Import the required module.

from verticapy.machine_learning.memmodel.preprocessing import OneHotEncoder

Let’s create a model.

model_ohe = OneHotEncoder(
    categories = [["male", "female"], [1, 2, 3]],
    drop_first = False,
    column_naming = None,
)

Create a dataset.

data = [["male", 1], ["female", 3]]

Transform the data.

model_ohe.transform(data)
Out[4]: 
array([[1, 0, 1, 0, 0],
       [0, 1, 0, 0, 1]])

Note

Refer to OneHotEncoder for more information about the different methods and usages.