mealy.preprocessing

Classes

class mealy.preprocessing.DummyPipelinePreprocessor(model_performance_predictor_features)[source]
transform(x)[source]
Parameters

x (array-like or dataframe of shape (number of samples, number of features)) – input feature values.

Returns

ndarray

class mealy.preprocessing.FeatureNameTransformer(original_features, preprocessed_features)[source]

Transformer of feature names and indices.

A FeatureNameTransformer parses an input Pipeline preprocessor and generate a mapping between the input unprocessed feature names/indices and the output preprocessed feature names/indices.

Parameters
original_feature_names

list of original unpreprocessed feature names.

Type

list

preprocessed_feature_names

list of preprocessed feature names.

Type

list

class mealy.preprocessing.PipelinePreprocessor(ct_preprocessor, original_features=None)[source]

Transformer of feature values from the original values to preprocessed ones.

A PipelinePreprocessor parses an input Pipeline preprocessor and generate a mapping between the input unprocessed feature values and the output preprocessed feature values.

Parameters
inverse_transform(preprocessed_x)[source]

Invert the preprocessing pipeline and inverse transform feature values.

Parameters

preprocessed_x (numpy.ndarray or scipy sparse matrix) – preprocessed feature values.

Returns

feature values without preprocessing.

Return type

numpy.ndarray

inverse_transform_feature_id(index)[source]

Undo preprocessing of feature name.

Transform the preprocessed feature name at given index back into the original unprocessed feature index.

Parameters

index (int) – feature index.

Returns

index of the unprocessed feature corresponding to the input preprocessed feature index.

Return type

int

is_categorical(index=None, name=None)[source]

Check whether an unprocessed feature at a given index or with a given name is categorical.

Parameters
  • index (int) – feature index.

  • name (str) – feature name.

Returns

True if the input feature is categorical, else False. If both index and name are provided, the index

is retained.

Return type

bool

transform(x)[source]

Transform the input feature values according to the preprocessing pipeline.

Parameters

x (array-like or dataframe of shape (number of samples, number of features)) – input feature values.

Returns

transformed feature values.

Return type

numpy.ndarray