I am trying to visualize the silhouette score for the fuzzy c-means clustering method using yellowbrick's silhouette visualizer. This same code works perfectly fine for k-means clustering. However, it provides the following error for the fuzzy c-means clustering method.
import matplotlib.pyplot as plt
from fcmeans import FCM
from yellowbrick.cluster import SilhouetteVisualizer
model = FCM(n_clusters=5, random_state=0)
visualizer = SilhouetteVisualizer(model, colors='yellowbrick')
visualizer.fit(X)
visualizer.show()
error:
YellowbrickTypeError Traceback (most recent call last)
Input In [24], in <cell line: 6>()
3 from yellowbrick.cluster import SilhouetteVisualizer
5 model = FCM(n_clusters=5, random_state=0)
----> 6 visualizer = SilhouetteVisualizer(model, colors='yellowbrick')
8 visualizer.fit(X)
9 visualizer.show()
File C:\ProgramData\Anaconda3\lib\site-packages\yellowbrick\cluster\silhouette.py:118, in SilhouetteVisualizer.__init__(self, estimator, ax, colors, is_fitted, **kwargs)
115 def __init__(self, estimator, ax=None, colors=None, is_fitted="auto", **kwargs):
116
117 # Initialize the visualizer bases
--> 118 super(SilhouetteVisualizer, self).__init__(estimator, ax=ax, **kwargs)
120 # Visual Properties
121 # Use colors if it is given, otherwise attempt to use colormap which
122 # which will override colors. If neither is found, default to None.
123 # The colormap may yet still be found in resolve_colors
124 self.colors = colors
File C:\ProgramData\Anaconda3\lib\site-packages\yellowbrick\cluster\base.py:45, in
ClusteringScoreVisualizer.__init__(self, estimator, ax, fig, force_model, **kwargs)
43 def __init__(self, estimator, ax=None, fig=None, force_model=False, **kwargs):
44 if not force_model and not isclusterer(estimator):
---> 45 raise YellowbrickTypeError(
46 "The supplied model is not a clustering estimator; try a "
47 "classifier or regression score visualizer instead!"
48 )
49 self.force_model = force_model
50 super(ClusteringScoreVisualizer, self).__init__(
51 estimator, ax=ax, fig=fig, **kwargs
52 )
YellowbrickTypeError: The supplied model is not a clustering estimator; try a classifier or regression score visualizer instead! Kindly help me in solving this issue.