Note
Go to the end to download the full example code or to run this example in your browser via Binder.
Biclusters of the manufacturing space#
Spectral co-clustering finds groups of resources that are used together by groups of activities. Outlined on the seriated incidence matrix (activities in rows, as in the figure of Nagy et al. 2022), the blocks correspond to the transport (AGV) activities, the crimping stations and the assembly stations. Vertex labels are colored by resource type.
import matplotlib.pyplot as plt
import hatvis as hv
from hatvis.plotting import plot_incidence
H = hv.datasets.load_wire_harness()
# [snippet:blocks]
blocks = hv.seriation.bicluster_blocks(H, n_clusters=6, random_state=0, min_density=0.3)
for b in blocks:
print(f"{len(b['nodes']):2d} resources x {len(b['edges']):2d} activities, density {b['density']:.2f}:",
", ".join(b["nodes"]))
order = hv.seriate(H, "correspondence")
# [/snippet:blocks]
2 resources x 7 activities, density 0.86: R2, M2
4 resources x 12 activities, density 0.83: O1, AGV, C8, S1
3 resources x 5 activities, density 0.67: O4, R3, D2
8 resources x 15 activities, density 0.42: O2, O5, R5, M1, M3, M4, C7, S3
14 resources x 15 activities, density 0.30: O3, O6, O7, R1, R4, R6, E1, E6, D1, D3, C1, C3, C6, S2
fig, ax = plt.subplots(figsize=(7, 12))
plot_incidence(H, order=order, ax=ax, transpose=True, biclusters=blocks, node_groups="type", label_size=6)
plt.tight_layout()

Total running time of the script: (0 minutes 0.541 seconds)