Normalize
Use Normalize seed with --minMax. Normalize one or more columns using a min max scaler
Examples
Example 1 - Normalize Entire Dataframe with Min-Max Scaling
In many modeling tasks, it’s important to normalize all numeric values so they are on the same scale. This example normalizes every numeric column in the dataframe using min-max scaling, which scales values to fall between 0 and 1.
#> Normalize --all --minMax
AFLEFT
minMaxScaler = MinMaxScaler()
for column in appleStockDf.columns:
if is_numeric_dtype(appleStockDf[column]):
appleStockDf[column] = minMaxScaler.fit_transform(appleStockDf[ [column] ]) AFRIGHT
Example 2 - Normalize Selected Columns with Min-Max Scaling
Rather than normalizing every column, you can choose specific columns to scale. In this case, we normalize only the High and Low columns using min-max scaling, which helps maintain focus on features of interest.
#> Normalize --columns High Low --minMax
AFLEFT
scaleColumn = appleStockDf[ ['High', 'Low'] ]
scaleColumn = minMaxScaler.fit_transform(scaleColumn)
appleStockDf[ ['High', 'Low'] ] = scaleColumn AFRIGHT
Example 3 - Normalize Columns Conditionally
Sometimes normalization should only apply to a subset of the data. This example applies min-max scaling to the Open column, but only for rows where the value in the High column is greater than 100. All other rows remain unchanged.
#> Normalize --columns Open --minMax --where High > 100
AFLEFT
scaleColumn = appleStockDf[ ['Open'] ][appleStockDf['High'] > 100]
scaleColumn = minMaxScaler.fit_transform(scaleColumn)
appleStockDf.loc[appleStockDf['High'] > 100,'Open'] = scaleColumn AFRIGHT