NeuralClassificationTransformer

class proglearn.NeuralClassificationTransformer(network, euclidean_layer_idx, optimizer, loss='categorical_crossentropy', pretrained=False, compile_kwargs={'metrics': ['acc']}, fit_kwargs={'callbacks': [<keras.callbacks.EarlyStopping object>], 'epochs': 100, 'validation_split': 0.33, 'verbose': False})[source]

A class used to transform data from a category to a specialized representation.

Parameters

network : object

A neural network used in the classification transformer.

euclidean_layer_idx : int

An integer to represent the final layer of the transformer.

optimizer : str or keras.optimizers instance

An optimizer used when compiling the neural network.

loss : str, default="categorical_crossentropy"

A loss function used when compiling the neural network.

pretrained : bool, default=False

A boolean used to identify if the network is pretrained.

compile_kwargs : dict, default={"metrics": ["acc"]}

A dictionary containing metrics for judging network performance.

fit_kwargs : dict, default={

"epochs": 100, "callbacks": [keras.callbacks.EarlyStopping(patience=5, monitor="val_acc")], "verbose": False, "validation_split": 0.33,

},

A dictionary to hold epochs, callbacks, verbose, and validation split for the network.

Attributes

encoder_

(object) A Keras model with inputs and outputs based on the network attribute. Output layers are determined by the euclidean_layer_idx parameter.

fitted_

(boolean) A boolean flag initialized after the model is fitted.

Methods Summary

NeuralClassificationTransformer.fit(X, y)

Fits the transformer to data X with labels y.

NeuralClassificationTransformer.fit_transform(X)

Fit to data, then transform it.

NeuralClassificationTransformer.get_params([deep])

Get parameters for this estimator.

NeuralClassificationTransformer.set_params(...)

Set the parameters of this estimator.

NeuralClassificationTransformer.transform(X)

Performs inference using the transformer.


NeuralClassificationTransformer.fit(X, y)[source]

Fits the transformer to data X with labels y.

Parameters

X : ndarray

Input data matrix.

y : ndarray

Output (i.e. response data matrix).

Returns

self : NeuralClassificationTransformer

The object itself.

NeuralClassificationTransformer.fit_transform(X, y=None, **fit_params)

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters

X : array-like of shape (n_samples, n_features)

Input samples.

y : array-like of shape (n_samples,) or (n_samples, n_outputs), default=None

Target values (None for unsupervised transformations).

**fit_params : dict

Additional fit parameters.

Returns

X_new : ndarray array of shape (n_samples, n_features_new)

Transformed array.

NeuralClassificationTransformer.get_params(deep=True)

Get parameters for this estimator.

Parameters

deep : bool, default=True

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

Returns

params : dict

Parameter names mapped to their values.

NeuralClassificationTransformer.set_params(**params)

Set the parameters of this estimator.

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

Parameters

**params : dict

Estimator parameters.

Returns

self : estimator instance

Estimator instance.

NeuralClassificationTransformer.transform(X)[source]

Performs inference using the transformer.

Parameters

X : ndarray

Input data matrix.

Returns

X_transformed : ndarray

The transformed input.

Raises

NotFittedError

When the model is not fitted.