.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "glr_examples/analysis/plot_explained_variance_ratio.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_analysis_plot_explained_variance_ratio.py: ============================================== Explained variance ratio ============================================== visualizes the explained variance ratio using the test data looking at the steps behind the PCA .. GENERATED FROM PYTHON SOURCE LINES 9-12 .. code-block:: Python # Author: L.Kouadio # Licence: BSD-3-clause .. GENERATED FROM PYTHON SOURCE LINES 13-18 Call the test data: Bagoue datasets --------------------------------------- The first raw dataset is selected using `data=dfy1` passed to the get method see more in :class:`~watex.proerty.BagoueNotes`. .. GENERATED FROM PYTHON SOURCE LINES 18-31 .. code-block:: Python import matplotlib.pyplot as plt from watex.exlib.sklearn import SimpleImputer from watex.utils import selectfeatures from watex.datasets import fetch_data data= fetch_data("bagoue original").get('data=dfy1') # encoded flow categories y = data.flow ; X= data.drop(columns='flow') # select the numerical features X =selectfeatures(X, include ='number') # imputed the missing data X = SimpleImputer().fit_transform(X) .. GENERATED FROM PYTHON SOURCE LINES 32-34 Total variance ratio ------------------------- .. GENERATED FROM PYTHON SOURCE LINES 34-39 .. code-block:: Python from watex.analysis import total_variance_ratio # Use the X value in the example of `extract_pca` function total_variance_ratio(X, view=True) plt.show() .. image-sg:: /glr_examples/analysis/images/sphx_glr_plot_explained_variance_ratio_001.png :alt: plot explained variance ratio :srcset: /glr_examples/analysis/images/sphx_glr_plot_explained_variance_ratio_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.184 seconds) .. _sphx_glr_download_glr_examples_analysis_plot_explained_variance_ratio.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/analysis/plot_explained_variance_ratio.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_explained_variance_ratio.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_explained_variance_ratio.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_