K-Means

class breze.learn.kmeans.GainShapeKMeans(n_component, zscores=False, whiten=False, c_zca=1e-08, max_iter=10, random_state=None)

GainShapeKMeans class to perform K-means clustering for feature learning as described in [LFRKM].

Parameters:

n_components : integer

Number of features to learn.

zscores : boolean, optional, default: False

Flag indicating whether the data should be normalized to zero mean and unit variance before training and transformation.

whiten : boolean, optional, default: False

Flag indicating whether the data should be whitened before training and transformation.

c_zca : float, optional, default: 1e-8

Small number that is added to each singular value during ZCA.

max_iter : integer, optional

Maximum number of iterations to perform.

random_state : None, integer or numpy.RandomState, optional, default: None

Generator to initialize the dictionary. If None, the numpy singleton generator is used.

References

[LFRKM](1, 2) Learning Feature Representations with K-means, Adam Coates (2012)

Attributes

activation: {‘identity’, ‘omp-1’, ‘soft-threshold’}, optional, default: None Activation to for transformation. ‘identity’ does not alter the output. ‘omp-1’ only retains the component with the largest absolute value. ‘soft-threshold’ only sets components below a certain threshold to zero, but separates positive and negative parts.
threshold (scalar,) Threshold used for soft-thresholding activation. Ignored if another activation is used.

Methods

fit(X) Fit the parameters of the model.
iter_fit(X)
normalize_dict() Normalize the columns of the dictionary to unit length.
prepare(n_inpt) Initialize the models internal structures.
transform(X[, activation]) Transform the data according to the dictionary.
fit(X)

Fit the parameters of the model.

Parameters:

X : array_like

Array of shape (n_samples, n_inpt) used for training.

transform(X, activation=None)

Transform the data according to the dictionary.

Parameters:

X : array_like

Input data of shape (n_samples, n_inpt).

activation: {‘identity’, ‘omp-1’}, optional, default: None

Activation to use. ‘linear’ does not alter the output. ‘omp-1’ only retains the component with the largest absolute value. ‘soft-threshold’ only sets components below a certain threshold to zero, but separates positive and negative parts. If None, .activation is used.