.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "glr_examples/view/plot_pca.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_glr_examples_view_plot_pca.py: ================================================= Plot robust principal components analysis (PCA) ================================================= visualizes the robust PCA component analysis from hydro-geological data .. GENERATED FROM PYTHON SOURCE LINES 8-11 .. code-block:: Python # Author: L.Kouadio # Licence: BSD-3-clause .. GENERATED FROM PYTHON SOURCE LINES 12-13 Visualize the first two components PC1 and PC2 .. GENERATED FROM PYTHON SOURCE LINES 13-30 .. code-block:: Python from watex.datasets import load_bagoue from watex.view.mlplot import EvalPlot X , y = load_bagoue(as_frame =True ) b=EvalPlot(tname ='flow', encode_labels=True , scale = True ) b.fit_transform (X, y) b.plotPCA (n_components= 2 ) # Note that pc1 and pc2 labels > n_components -> otherwise raises user warnings # Axis 1 and 2 is the default behaviour. # Runing the script below shows the same figure as the above. # b.plotPCA (n_components= 2 , biplot=False, pc1_label='Axis 1', # pc2_label='axis 2') # UserWarning: Number of components and axes might be consistent; # '2'and '4 are given; default two components are used. .. image-sg:: /glr_examples/view/images/sphx_glr_plot_pca_001.png :alt: PCA :srcset: /glr_examples/view/images/sphx_glr_plot_pca_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none EvalPlot(tname= flow, objective= None, scale= True, ... , sns_height= 4.0, sns_aspect= 0.7, verbose= 0) .. GENERATED FROM PYTHON SOURCE LINES 31-34 can visulizalise the other components axis in Axis 3 and 4. Note for PC1 and PC2 labels must be consistent with the number of components. .. GENERATED FROM PYTHON SOURCE LINES 34-37 .. code-block:: Python b.plotPCA (n_components= 8 , biplot=False, pc1_label='Axis3', pc2_label='axis4') # # works fine since n_components are greater to the number of axes .. image-sg:: /glr_examples/view/images/sphx_glr_plot_pca_002.png :alt: PCA :srcset: /glr_examples/view/images/sphx_glr_plot_pca_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none EvalPlot(tname= flow, objective= None, scale= True, ... , sns_height= 4.0, sns_aspect= 0.7, verbose= 0) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.829 seconds) .. _sphx_glr_download_glr_examples_view_plot_pca.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/watex/watex/0.3.X?urlpath=lab/tree/notebooks/glr_examples/view/plot_pca.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_pca.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_pca.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_