watex.view.biPlot#
- watex.view.biPlot(self, Xr, components, y, classes=None, markers=None, colors=None)[source]#
The biplot is the best way to visualize all-in-one following a PCA analysis.
There is an implementation in R but there is no standard implementation in Python.
- Parameters:
self (
watex.property.BasePlot.) –Matplotlib property from BasePlot instances. Default BasePlot instance is given as a pobj instance and can be loaded for plotting purpose as:
>>> from watex.view import pobj
To change some default plot properties like line width or style, both can be set before running the script as follow
>>> pobj.lw = 2. ; pobj.ls=':' # and so on
Xr (NDArray of transformed X.) – the PCA projected data scores on n-given components.The reduced dimension of train set ‘X’ with maximum ratio as sorted eigenvectors from first to the last component.
components (NDArray, shape (n_components, n_eigenvectors ),) – the eigenvectors of the PCA. The shape in axis must much the number of component computed using PCA. If the Xr shape 1 equals to the shape 0 of the component matrix components, it will be transposed to fit Xr shape 1.
y (Array-like,) – the target composing the class labels.
classes (list or int,) – class categories or class labels
markers (str,) – Matplotlib list of markers for plotting classes.
colors (str,) – Matplotlib list of colors to customize plots
Examples
>>> from watex.analysis import nPCA >>> from watex.datasets import fetch_data >>> from watex.view import biPlot, pobj # pobj is Baseplot instance >>> X, y = fetch_data ('bagoue pca' ) # fetch pca data >>> pca= nPCA (X, n_components= 2 , return_X= False ) # return PCA object >>> components = pca.components_ [:2, :] # for two components >>> biPlot (pobj, pca.X, components , y ) # pca.X is the reduced dim X >>> # to change for instance line width (lw) or style (ls) >>> # just use the baseplotobject (pobj)
References
Originally written by Serafeim Loukas, serafeim.loukas@epfl.ch and was edited to fit the watex package API.