python - Accessing Clustering Feature Tree in Birch -
i have data set, has n_samples=200, n_features=22.
how can access clustering feature tree in birch?
for example, how many clusters there in hierarchy under root node , data samples in cluster?
can them separately 3 trees?
i appreciate if answer me. thanks.
best.
**birch implementation code** sklearn.cluster import birch sklearn.externals import joblib import numpy np import matplotlib.pyplot plt time import time sklearn.datasets.samples_generator import make_blobs x=np.loadtxt(open("c:\dataset.txt", "rb"), delimiter=";") brc = birch(branching_factor=50, n_clusters=none, threshold=0.5,compute_labels=true,copy=true) brc.fit(x) birch_predict=brc.predict(x) print ("\nclustering_result:\n") print (birch_predict) np.savetxt('birch_predict_class_0.csv', birch_predict,fmt="%i", delimiter=',') myroot = brc.root_ centroids = brc.subcluster_centers_ plt.plot(x[:,0], x[:,1], '+') plt.plot(centroids[:,0], centroids[:,1], 'o') plt.show() labels = brc.subcluster_labels_ n_clusters = np.unique(labels).size print("n_clusters : %d" % n_clusters + "\n")
Comments
Post a Comment