erdogant/clusteval

AttributeError: 'clusteval' object has no attribute 'results'

nitinvinayak opened this issue · 3 comments

image
[clusteval] >Fit using agglomerative with metric: euclidean, and linkage: ward

AttributeError Traceback (most recent call last)
in
6
7 # Fit to find optimal number of clusters using dbscan
----> 8 results= ce.fit(X)
9
10 # Make plot of the cluster evaluation

~\anaconda3\lib\site-packages\clusteval\clusteval.py in fit(self, X)
167
168 # Compute the dendrogram threshold
--> 169 if (self.cluster!='kmeans') and (len(np.unique(self.results['labx']))>1):
170 # print(self.results['labx'])
171 max_d, max_d_lower, max_d_upper = _compute_dendrogram_threshold(self.Z, self.results['labx'], verbose=self.verbose)

AttributeError: 'clusteval' object has no attribute 'results'

Well this is unexpected to see. I see that you specify 'dbscan' as a method but the output prints agglomerative with metric: euclidean, and linkage: ward.

Can you maybe first check the version you are using? The latest one is 2.0.0

import clusteval
print(clusteval.__version__)

If you run the underneath example, what does it say?

from clusteval import clusteval
ce = clusteval(cluster='dbscan')
X, labels_true = make_blobs(n_samples=50, centers=[[1, 1], [-1, -1], [1, -1]], cluster_std=0.4,random_state=0)
results = ce.fit(X)
ce.plot()
ce.scatter(X)
cluster_labels = results['labx']

I may have found a bug that points to the usage of "_compute_dendrogram_threshold" with empty labels.
Can you update the library and try again?

pip install -U clusteval

import clusteval
print(clusteval.__version__)

Version should be >= 2.0.1

Hi
The code is working after the update. Thanks a lot!!!