msmbuilder.preprocessing.Normalizer

class msmbuilder.preprocessing.Normalizer(norm='l2', copy=True)

Normalize samples individually to 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 or l2) equals one.

This transformer is able to work both with dense numpy arrays and scipy.sparse matrix (use CSR format if you want to avoid the burden of a copy / conversion).

Scaling inputs to unit norms is a common operation for text classification or clustering for instance. For instance the dot product of two l2-normalized TF-IDF vectors is the cosine similarity of the vectors and is the base similarity metric for the Vector Space Model commonly used by the Information Retrieval community.

Read more in the User Guide.

Parameters:
norm : ‘l1’, ‘l2’, or ‘max’, optional (‘l2’ by default)

The norm to use to normalize each non zero sample.

copy : boolean, optional, default True

set to False to perform inplace row normalization and avoid a copy (if the input is already a numpy array or a scipy.sparse CSR matrix).

See also

normalize
Equivalent function without the estimator API.

Notes

This estimator is stateless (besides constructor parameters), the fit method does nothing but is useful when used in a pipeline.

For a comparison of the different scalers, transformers, and normalizers, see examples/preprocessing/plot_all_scaling.py.

Methods

fit(X[, y]) Fit Preprocessing to X.
fit_transform(sequences[, y]) Fit the model and apply preprocessing
get_params([deep]) Get parameters for this estimator.
partial_fit(sequence[, y]) Fit Preprocessing to X.
partial_transform(sequence) Apply preprocessing to single sequence
set_params(**params) Set the parameters of this estimator.
summarize() Return some diagnostic summary statistics about this Markov model
transform(sequences) Apply preprocessing to sequences
__init__(norm='l2', copy=True)

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__([norm, copy]) Initialize self.
fit(X[, y]) Fit Preprocessing to X.
fit_transform(sequences[, y]) Fit the model and apply preprocessing
get_params([deep]) Get parameters for this estimator.
partial_fit(sequence[, y]) Fit Preprocessing to X.
partial_transform(sequence) Apply preprocessing to single sequence
set_params(**params) Set the parameters of this estimator.
summarize() Return some diagnostic summary statistics about this Markov model
transform(sequences) Apply preprocessing to sequences
fit(X, y=None)

Fit Preprocessing to X.

Parameters:
sequence : array-like, [sequence_length, n_features]

A multivariate timeseries.

y : None

Ignored

Returns:
self
fit_transform(sequences, y=None)

Fit the model and apply preprocessing

Parameters:
sequences: list of array-like, each of shape (n_samples_i, n_features)

Training data, where n_samples_i in the number of samples in sequence i and n_features is the number of features.

y : None

Ignored

Returns:
sequence_new : list of array-like, each of shape (n_samples_i, n_components)
get_params(deep=True)

Get parameters for this estimator.

Parameters:
deep : boolean, optional

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
params : mapping of string to any

Parameter names mapped to their values.

partial_fit(sequence, y=None)

Fit Preprocessing to X. Parameters ———- sequence : array-like, [sequence_length, n_features]

A multivariate timeseries.
y : None
Ignored

self

partial_transform(sequence)

Apply preprocessing to single sequence

Parameters:
sequence: array like, shape (n_samples, n_features)

A single sequence to transform

Returns:
out : array like, shape (n_samples, n_features)
set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Returns:
self
summarize()

Return some diagnostic summary statistics about this Markov model

transform(sequences)

Apply preprocessing to sequences

Parameters:
sequences: list of array-like, each of shape (n_samples_i, n_features)

Sequence data to transform, where n_samples_i in the number of samples in sequence i and n_features is the number of features.

Returns:
sequence_new : list of array-like, each of shape (n_samples_i, n_components)