msmbuilder.preprocessing.Imputer

class msmbuilder.preprocessing.Imputer(missing_values='NaN', strategy='mean', axis=0, verbose=0, copy=True)

Imputation transformer for completing missing values.

Read more in the User Guide.

Parameters:

missing_values : integer or “NaN”, optional (default=”NaN”)

The placeholder for the missing values. All occurrences of missing_values will be imputed. For missing values encoded as np.nan, use the string value “NaN”.

strategy : string, optional (default=”mean”)

The imputation strategy.

  • If “mean”, then replace missing values using the mean along the axis.
  • If “median”, then replace missing values using the median along the axis.
  • If “most_frequent”, then replace missing using the most frequent value along the axis.

axis : integer, optional (default=0)

The axis along which to impute.

  • If axis=0, then impute along columns.
  • If axis=1, then impute along rows.

verbose : integer, optional (default=0)

Controls the verbosity of the imputer.

copy : boolean, optional (default=True)

If True, a copy of X will be created. If False, imputation will be done in-place whenever possible. Note that, in the following cases, a new copy will always be made, even if copy=False:

  • If X is not an array of floating values;
  • If X is sparse and missing_values=0;
  • If axis=0 and X is encoded as a CSR matrix;
  • If axis=1 and X is encoded as a CSC matrix.

Notes

  • When axis=0, columns which only contained missing values at fit are discarded upon transform.
  • When axis=1, an exception is raised if there are rows for which it is not possible to fill in the missing values (e.g., because they only contain missing values).

Attributes

statistics_ (array of shape (n_features,)) The imputation fill value for each feature if axis == 0.

Methods

fit(sequences[, 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__(missing_values='NaN', strategy='mean', axis=0, verbose=0, copy=True)

Methods

__init__([missing_values, strategy, axis, ...])
fit(sequences[, 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(sequences, y=None)

Fit Preprocessing to X.

Parameters:

sequences : list of array-like, each of shape [sequence_length, n_features]

A list of multivariate timeseries. Each sequence may have a different length, but they all must have the same number of features.

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

Returns:

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)