Skip to content
svgvat-heatmap

VAT image (cluster tendency)

Is there cluster structure before any clustering is run?

Demo data · seed 20261101 · 900 rows · default settings · 640 × 360SVG, lightSVG, darkDemo CSV

How to read it

  1. Read the diagonal: dark blocks along it are candidate clusters.
  2. Count the blocks and their sizes.
  3. No blocks suggests no clear structure.
  1. Callout 1: A dark block: a candidate cluster.
  2. Callout 2: Another block.
  3. Callout 3: A smaller block.

Watch out

  • It's a pre-check: an empty display doesn't rule out non-round clusters.

Defaults

No settings: the chart draws one way.

Pinned in the code

  • Draws the run's numbers as given (computed by the host's cs-ml evaluation or the Python/R engine); the chart computes nothing statistical.
  • Order: start at the row holding the largest distance, then repeatedly add the unvisited row nearest to the visited set (Bezdek & Hathaway's VAT).
  • Large tables are evenly sampled (≤ 500 rows) and averaged into at most 80 × 80 blocks; darker = closer.
# VAT image (cluster tendency) — Codesplash Chart Lab (recipe "vat-heatmap")
# controls: defaults
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

try:
    import codesplash as cs  # optional: the app's chart theme
except ImportError:
    cs = None
if cs:
    cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else plt.rcParams["axes.prop_cycle"].by_key()["color"]

df = pd.read_csv("vat-heatmap-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV

R = "row block"
C = "column block"
V = "mean distance"
m = df.pivot_table(index=R, columns=C, values=V, aggfunc="mean").sort_index().sort_index(axis=1)
fig, ax = plt.subplots(figsize=(6, 5))
im = ax.imshow(m.to_numpy(), cmap="Blues_r", aspect="equal", interpolation="nearest", extent=[m.columns.min() - 0.5, m.columns.max() + 0.5, m.index.max() + 0.5, m.index.min() - 0.5])
fig.colorbar(im, label=V, shrink=0.8)
ax.set_xlabel("block (VAT order)")
ax.set_ylabel("block (VAT order)")
plt.show()

Needs pandas, numpy, matplotlib · reads vat-heatmap-demo.csv · app theme from the optional codesplash helper