The chapter "Normalized Information Distance", visualizes a hierarchical clustering as a tree of nodes with labels:
Unfortunately I cannot find out how to replicate this visualization, maybe they did it in a manual way with Tikz? How can I achieve this effect automatically in Python, preferably with Scikit-Learn? I only found the Dendogram, which looks nothing like the effect I want to replicate:
Result (thanks at @andy-w):
model = AgglomerativeClustering(linkage="average", n_clusters=N_CLUSTERS, compute_distances=True, affinity="l1")
model.fit(data)
no_of_observations = np.arange(2, model.children_.shape[0]+2)
linkage_matrix = np.column_stack([model.children_, model.distances_, no_of_observations]).astype(float)
G = nx.Graph()
n = len(linkage_matrix)
for i in range(n):
row = linkage_matrix[i]
G.add_edge(label(int(row[0])),label(n+i+1),len=1+0.1*(math.log(1+row[2])))
G.add_edge(label(int(row[1])),label(n+i+1),len=1+0.1*(math.log(1+row[2])))
dot = nx.nx_pydot.to_pydot(G).to_string()
dot = graphviz.Source(dot, engine='neato')
dot.render(format='pdf',filename='tree')