preprocessing Package

preprocessing Package

normalizer Module

class pypr.preprocessing.normalizer.Normalizer(X, handleStd0=True)

Rescale and shift each feature individually, so that it gets a mean of zero, and a unity standard deviation. The scaling and shifting are based upon X

Parameters :

X : np array

An array with samples row wise and features/inputs column wise.

handleStd0 : bool, optional

True (default) or False. If true, the standard deviation is set to 1.0 if it is found to be 0, otherwise an exception is thrown in this case.

Methods

invtransform
transform
invtransform(iX)

Find the inverse transformation.

Parameters :

iX : np array

An array with normalized samples row wise and features/inputs column wise.

Returns :

X : np array

The inverse transformation of the values given in iX.

transform(X)

Find the normalized values for the samples in X, so that each input will have zero mean and unit standard deviation.

Parameters :

X : np array

An array with samples row wise and features/inputs column wise.

Returns :

——- :

iX : np arrray

Normalized version of X

pca Module

class pypr.preprocessing.pca.PCA(X, normalize=True, whitening=False, **kwargs)

Bases: pypr.preprocessing.normalizer.Normalizer

Principal Component Analysis (PCA)

Parameters :

X : np array

Expects an array X with samples row wise and features column wise. The eigen values and normalization used by the PCA are based upon X.

normalize : bool, optional

Optional input normalize specifies if the input data X should be normalized before the PCA transform.

whitening : bool, optional

If whitening is true, then the outputs are scaled so that they have zero mean and unity standard deviation. (NOT IMPLEMENTED)

Methods

get_eig
invtransform
transform
get_eig()

Eigen values.

Returns :

w : np array

Eigenvalues (length equal to number of inputs in X, D)

v : np array

Eigenvectors in a DxD sized matrix. Vectors a columns.

The eigenvectors (columns) are sorted after eigenvalues in descending order.

invtransform(Z, skipnormalization=False)

Returns Z projected back in to the original vector space.

Parameters :

Z : np array

Projected data. Samples row-wise.

Returns :

X : np array

Z transformed to original vector space.

transform(X, dim=0, skipnormalization=False)

Projects X into the new vector space found by the PCA.

Parameters :

X : np array

Samples to be projected by PCA. Samples row-wise, inputs column- wise.

dim : int, optional

The number of most significant dimensions to return. If dim is zero, then all dimensions are returned.

Returns :

Z : np array

Returns new projection of data. Samples row-wise, and dim columns.

Table Of Contents

Previous topic

optimization Package

This Page