PCA model

class mpca.pcamodel.pcamodel[source]

Wrapper class for a 2-component PCA model.

PCA is performed using sklearn PCA.

The model is defined by the loadings and the scores.

Implements saving and loading from file.

define_PCA_model(X)[source]

Define a PCA model based on the data X.

Parameters:X (array, shape (n_samles x n_features)) – The data to define the PCA model on.
NOTE: X must be centered
since pmodel uses the scikit PCA model which automatically centers the input and the loadings need to be defined so that multiplication of new data with them is enough for a correct transform
load_from_h5(filename)[source]

Load scores and loadings from a h5 file.

Parameters:filename – Full filename to load from.
load_from_SMARTPCA(fileprefix)[source]

Load scores and loadings from SMARTPCA output.

Parameters:fileprefix – Path and filename (exluding ending) of files to read from.

Assumes fileprefix.evec and fileprefix.weights exists.

save_to_h5(filename)[source]

Save the PCA model (scores and loadings) to a h5 file.

Parameters:filename – full filename to write to