You are viewing documentation about an older version (1.0.12). View latest version

snowflake.ml.modeling.preprocessing.NormalizerΒΆ

class snowflake.ml.modeling.preprocessing.Normalizer(*, norm: str = 'l2', input_cols: Optional[Union[str, Iterable[str]]] = None, output_cols: Optional[Union[str, Iterable[str]]] = None, drop_input_cols: Optional[bool] = False)ΒΆ

Bases: BaseTransformer

Normalize samples individually to each row’s unit norm.

Each sample (i.e. each row of the data matrix) with at least one non-zero component is rescaled independently of other samples so that its norm (l1, l2 or inf) equals one.

Args:
norm: str, default=”l2”

The norm to use to normalize each non-zero sample. If norm=’max’ is used, values will be rescaled by the maximum of the absolute values. It must be one of β€˜l1’, β€˜l2’, or β€˜max’.

input_cols: Optional[Union[str, List[str]]]

Columns to use as inputs during transform.

output_cols: Optional[Union[str, List[str]]]

A string or list of strings representing column names that will store the output of transform operation. The length of output_cols must equal the length of input_cols.

drop_input_cols: bool, default=False

Remove input columns from output if set True.

Methods

fit(dataset)

Does nothing, because the normalizer is a stateless transformer.

transform(dataset)

Scale each non-zero row of the input dataset to the unit norm.