sklearn.cluster.ward_tree:
sklearn.cluster.ward_tree?
AgglomerativeClustering , children_. AgglomerativeClustering. (node_id, left_child, right_child) node .
import numpy as np
from sklearn.cluster import AgglomerativeClustering
import itertools
X = np.concatenate([np.random.randn(3, 10), np.random.randn(2, 10) + 100])
model = AgglomerativeClustering(linkage="average", affinity="cosine")
model.fit(X)
ii = itertools.count(X.shape[0])
[{'node_id': next(ii), 'left': x[0], 'right':x[1]} for x in model.children_]
fooobar.com/questions/698191/...