minmax
minmax ¶
Module for dataframe normalization functions
Classes¶
Functions¶
denormalize_column ¶
The denormalize_column function takes a norm_info
of data and denormalizes it.
Parameters:
-
norm_info
(NormalizationInfo
) –NormalizationInfo: Specify the type of normalization used
-
data
(DataFrame
) –pd.DataFrame: Pass in the dataframe that is being normalized
Returns:
-
DataFrame
–A pandas dataframe with the column denormalized
Source code in niceml/data/normalization/minmax.py
normalize_binary_column ¶
The normalize_binary_column function takes a dataframe and the key of a column in that dataframe.It then checks to make sure that there are only two unique values in the column, and if so, it replaces those values with 0s and 1s. It returns both the normalized dataframe and an object containing information about how the normalization was performed.
Parameters:
-
dataframe
(DataFrame
) –Pass in the dataframe that we want to normalize
-
column_key
(str
) –Specify the column that we want to normalize
Returns:
-
DataFrame
–A tuple of the dataframe with the normalized column (
column_key
) -
BinaryNormalizationInfo
–and a
BinaryNormalizationInfo
object
Source code in niceml/data/normalization/minmax.py
normalize_categorical_column ¶
Normalizes a categorical column in the given DataFrame.
This function takes a dataframe
and a `column_key´ representing a categorical
column. It replaces the categorical values with their corresponding indices
in a sorted order. The normalization information is also returned.
Parameters:
-
dataframe
(DataFrame
) –The DataFrame containing the categorical column.
-
column_key
(str
) –The column key of the categorical column to be normalized.
Returns:
-
DataFrame
–A tuple containing DataFrame with the normalized column (
column_key
) and a -
CategoricalNormalizationInfo
–CategoricalNormalizationInfo object.
Source code in niceml/data/normalization/minmax.py
normalize_scalar_column ¶
The normalize_scalar_col function takes a dataframe and a column key as input. It returns the normalized dataframe and the normalization information for that column. The normalization is done by subtracting the minimum value from each element in that column, and then dividing by (max - min). The offset is equal to min_val, and divisor = max_val - min_val.
Parameters:
-
dataframe
(DataFrame
) –pd.DataFrame: Pass in the dataframe to be normalized
-
column_key
–Specify which column to normalize
Returns:
-
DataFrame
–A tuple of the dataframe with the normalized column (
column_key
) -
ScalarNormalizationInfo
–and a
ScalarNormalizationInfo
object