.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/dimension_reduction/diffusion_maps/dmaps_swiss_role.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_auto_examples_dimension_reduction_diffusion_maps_dmaps_swiss_role.py: S-Curve ===================== This example shows how to use the :class:`.DiffusionMaps` class to reveal the embedded structure of S-Curve data. .. GENERATED FROM PYTHON SOURCE LINES 10-17 .. code-block:: default import numpy as np import matplotlib.pyplot as plt from UQpy.utilities.kernels.GaussianKernel import GaussianKernel from UQpy.dimension_reduction.diffusion_maps.DiffusionMaps import DiffusionMaps from sklearn.datasets import make_swiss_roll, make_s_curve .. GENERATED FROM PYTHON SOURCE LINES 18-19 Sample points randomly following a parametric curve and plot the 3D graphic. .. GENERATED FROM PYTHON SOURCE LINES 22-29 .. code-block:: default n = 4000 # number of samples # generate point cloud # X, X_color = make_s_curve(n, random_state=3, noise=0) X, X_color = make_s_curve(n, random_state=3, noise=0) .. GENERATED FROM PYTHON SOURCE LINES 30-31 plot the point cloud .. GENERATED FROM PYTHON SOURCE LINES 31-40 .. code-block:: default fig = plt.figure(figsize=(8, 8)) ax = fig.add_subplot(111, projection="3d") ax.scatter(X[:, 0], X[:, 1], X[:, 2], c=X_color, cmap=plt.cm.Spectral) ax.set_xlabel("x") ax.set_ylabel("y") ax.set_zlabel("z") ax.set_title("S-curve data") ax.view_init(10, 70) .. GENERATED FROM PYTHON SOURCE LINES 41-42 Case 1: Find the optimal parameter of the Gaussian kernel scale epsilon .. GENERATED FROM PYTHON SOURCE LINES 43-52 .. code-block:: default kernel = GaussianKernel(epsilon=0.65) dmaps_object = DiffusionMaps(data=X, alpha=1.0, n_eigenvectors=9, is_sparse=True, n_neighbors=100, kernel=kernel) .. GENERATED FROM PYTHON SOURCE LINES 53-55 Find the parsimonious representation of the eigenvectors. Identify the two most informative eigenvectors. .. GENERATED FROM PYTHON SOURCE LINES 56-61 .. code-block:: default dmaps_object.parsimonious(dim=2) print('most informative eigenvectors:', dmaps_object.parsimonious_indices) .. GENERATED FROM PYTHON SOURCE LINES 62-63 Plot the diffusion coordinates .. GENERATED FROM PYTHON SOURCE LINES 64-68 .. code-block:: default DiffusionMaps._plot_eigen_pairs(dmaps_object.eigenvectors, pair_indices=dmaps_object.parsimonious_indices, color=X_color, figure_size=[12, 12]) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_dimension_reduction_diffusion_maps_dmaps_swiss_role.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/SURGroup/UQpy/master?urlpath=lab/tree/notebooks/auto_examples/dimension_reduction/diffusion_maps/dmaps_swiss_role.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: dmaps_swiss_role.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: dmaps_swiss_role.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_