def fit(self, X, y=None, **kwargs):
"""
Fits the model and generates the the silhouette visualization.
TODO: decide to use this method or the score method to draw.
NOTE: Probably this would be better in score, but the standard score
is a little different and I'm not sure how it's used.
"""
# Fit the wrapped estimator
self.estimator.fit(X, y, **kwargs)
# Get the properties of the dataset
self.n_samples = X.shape[0]
self.n_clusters = self.estimator.n_clusters
# Compute the scores of the cluster
labels = self.estimator.predict(X)
self.silhouette_score_ = silhouette_score(X, labels)
self.silhouette_samples_ = silhouette_samples(X, labels)
# Draw the silhouette figure
self.draw(labels)
# Return the estimator
return self
评论列表
文章目录