.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/05_assessment/plot_01_vat_ivat.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_05_assessment_plot_01_vat_ivat.py: VAT and iVAT images =================== VAT reorders a dissimilarity matrix in the order in which Prim's algorithm grows the minimal spanning tree, so samples of one cluster become consecutive and appear as a dark block on the diagonal. iVAT replaces every dissimilarity by the largest edge on the tree path between the two samples (the minimax distance); the blocks become crisp for elongated clusters, where plain VAT shows only faint structure. Minimax distances are single-linkage distances, however, so groups joined by a chain still form one block. .. GENERATED FROM PYTHON SOURCE LINES 13-34 .. image-sg:: /auto_examples/05_assessment/images/sphx_glr_plot_01_vat_ivat_001.png :alt: ChainLink, VAT, iVAT, Curves, VAT, iVAT :srcset: /auto_examples/05_assessment/images/sphx_glr_plot_01_vat_ivat_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from graphclust.datasets import make_chainlink, make_curves from graphclust.plotting import plot_partition, plot_vat from graphclust.vat import ivat, vat fig, axes = plt.subplots(2, 3, figsize=(11, 7.4)) for row, (X, y, name) in enumerate([(*make_chainlink(), "ChainLink"), (*make_curves(), "Curves")]): D = np.linalg.norm(X[:, None] - X[None], axis=-1) # [snippet:vat] R, order = vat(D) R_i, _ = ivat(D) # [/snippet:vat] plot_partition(X, y, ax=axes[row, 0], markers=False, title=name) axes[row, 0].set_xticks([]) axes[row, 0].set_yticks([]) plot_vat(R, ax=axes[row, 1], title="VAT") plot_vat(R_i, ax=axes[row, 2], title="iVAT") plt.tight_layout() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.087 seconds) .. _sphx_glr_download_auto_examples_05_assessment_plot_01_vat_ivat.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/05_assessment/plot_01_vat_ivat.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_vat_ivat.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_vat_ivat.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_vat_ivat.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_