Skip to content

Commit

Permalink
Set self.n_clusters equal to n_components if estimator has it as an A…
Browse files Browse the repository at this point in the history
…ttribute
  • Loading branch information
lwgray committed Jul 29, 2023
1 parent e38d0e7 commit 9737dba
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions yellowbrick/cluster/silhouette.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ def fit(self, X, y=None, **kwargs):
# Compute the number of available clusters from the estimator
if hasattr(self.estimator, "n_clusters"):
self.n_clusters_ = self.estimator.n_clusters
elif hasattr(self.estimator, "n_components"):
self.n_clusters_ = self.estimator.n_components
else:
unique_labels = set(labels)
n_noise_clusters = 1 if -1 in unique_labels else 0
Expand Down

0 comments on commit 9737dba

Please sign in to comment.