Fashion-MNIST - Category Confusion Analysis
70,000 imagesMLcomputer-visioncosine
A TMAP of the full Fashion-MNIST dataset (70,000 clothing images, 784-dimensional pixel vectors) using cosine metric. The tree reveals which categories are structurally similar: Shirt and T-shirt/top share 1,844 boundary edges, Coat and Pullover share 1,584, and Pullover and Shirt share 1,315. Overall, 14.3% of tree edges cross category boundaries, with mean subtree purity of 0.82. Image tooltips show the actual clothing items at each node. Hover over boundary edges to see why the model considers two items from different categories to be neighbors.
This demo is hosted externally
The dataset is too large to embed inline. Opens in a new tab.
Open Interactive DemoHow it was made
generate.pypython
from sklearn.datasets import fetch_openml
from tmap import TMAP
from tmap.graph.analysis import boundary_edges, confusion_matrix_from_tree
fmnist = fetch_openml("Fashion-MNIST", version=1, as_frame=False)
X = fmnist.data.astype(np.float32)
labels = fmnist.target.astype(int)
model = TMAP(metric="cosine", n_neighbors=20, seed=42).fit(X)
# Category confusion analysis
label_names = [LABELS[i] for i in labels]
be = boundary_edges(model.tree_, np.array(label_names))
cmat, classes = confusion_matrix_from_tree(model.tree_, np.array(label_names))
print(f"Boundary edges: {len(be)} / {len(model.tree_.edges)}")
# Add image tooltips
viz = model.to_tmapviz()
viz.add_images(image_uris, tooltip_size=56)
viz.add_color_layout("category", label_names, categorical=True, color="tab10")
viz.write_html("fashion_mnist.html")