.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/07_topology_maps/plot_01_isomap_isotop_cda.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_07_topology_maps_plot_01_isomap_isotop_cda.py: Isomap, Isotop and curvilinear distance analysis ================================================ Three ways to map geodesic distances: * Isomap embeds the graph distances of a kNN graph by classical MDS, a global eigenproblem; * Isotop lets the nodes self-organize like a SOM whose neighborhood is measured along the data graph; * CCA weights the distance errors by a function of the *map* distance so that only short distances are enforced; with geodesic input distances it becomes curvilinear distance analysis (CDA). On the swiss roll Isomap and CDA unroll the sheet, while CCA with Euclidean input distances tears it into pieces. Isotop unfolds most of the roll but its stochastic self-organization can leave folds, which is why its schedules need some care. .. GENERATED FROM PYTHON SOURCE LINES 20-41 .. image-sg:: /auto_examples/07_topology_maps/images/sphx_glr_plot_01_isomap_isotop_cda_001.png :alt: Isomap (samples), Isotop (nodes, samples at nearest node), CCA, Euclidean (nodes, samples at nearest node), CDA, geodesic (nodes, samples at nearest node) :srcset: /auto_examples/07_topology_maps/images/sphx_glr_plot_01_isomap_isotop_cda_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt from graphclust import CurvilinearComponentAnalysis, Isomap, Isotop from graphclust.datasets import make_swiss_roll from graphclust.plotting import plot_embedding X, t = make_swiss_roll(1500, random_state=0) # [snippet:geomaps] iso = Isomap(k=8).fit(X) itp = Isotop(n_nodes=250, k=6, random_state=0).fit(X) cca = CurvilinearComponentAnalysis(n_nodes=250, n_epochs=30, random_state=0).fit(X) cda = CurvilinearComponentAnalysis(geodesic=True, k=6, n_nodes=250, n_epochs=30, random_state=0).fit(X) # [/snippet:geomaps] fig, axes = plt.subplots(1, 4, figsize=(14, 3.5)) plot_embedding(iso.embedding_, t, ax=axes[0], s=5, title="Isomap (samples)") for ax, m, name in [(axes[1], itp, "Isotop"), (axes[2], cca, "CCA, Euclidean"), (axes[3], cda, "CDA, geodesic")]: plot_embedding(m.transform(X), t, ax=ax, s=5, title=f"{name} (nodes, samples at nearest node)") plt.tight_layout() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 3.404 seconds) .. _sphx_glr_download_auto_examples_07_topology_maps_plot_01_isomap_isotop_cda.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/ComplexSystemsIntelligence/graphclust/main?urlpath=lab/tree/notebooks/auto_examples/07_topology_maps/plot_01_isomap_isotop_cda.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_isomap_isotop_cda.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_isomap_isotop_cda.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_isomap_isotop_cda.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_