Encode Values

Encodes values in a column through a variety of methods:

Label Encoding: Encode target labels with value between 0 and n_classes-1. See scikit-learn's LabelEncoder for full documentation.

Target Encoding: Encode a categorical column with the average value of a target column for the corresponding value of the categorical column. See scikit-learn's TargetEncoder for full documentation.

One Hot Encoding: Encode a categorical column as a 0 or 1 for each possible category, each of which will be it's own row.

Parameters

Name
Type
Description
Is Optional

method

string

Encoding method which will be used ('label', 'target', or 'oh')

column

column

Column name to label encode

target

column

Required if method = 'target'. Numeric target column to use to create averages

True

Example

ds = rasgo.get.dataset(id)

ds2 = ds.label_encode(column='WEATHER_DESCRIPTION', method='oh')
ds2.preview()

ds3 = ds.target_encode(column='WEATHER_DESCRIPTION', target='DAILY_HIGH_TEMP')
ds3.preview()

Source Code

Last updated