class_docstr: Silhouette Visualizer Tests
class_docstr_tok: ["Silhouette","Visualizer","Tests"]
docstr: Test that visualizer properly handles an already-fitted model
docstr_tok: ["Test","that","visualizer","properly","handles","an","already-fitted","model"]
code: def test_with_fitted(self):
      """
      Test that visualizer properly handles an already-fitted model
      """
      X, y = make_blobs(
          n_samples=100,
          n_features=5,
          centers=3,
          shuffle=False,
          random_state=112,
      )
      model = MiniBatchKMeans().fit(X)
      labels = model.predict(X)
  
      with mock.patch.object(model, "fit") as mockfit:
          oz = SilhouetteVisualizer(model)
          oz.fit(X)
          mockfit.assert_not_called()
  
      with mock.patch.object(model, "fit") as mockfit:
          oz = SilhouetteVisualizer(model, is_fitted=True)
          oz.fit(X)
          mockfit.assert_not_called()
  
      with mock.patch.object(
          model, "fit_predict", return_value=labels
      ) as mockfit:
          oz = SilhouetteVisualizer(model, is_fitted=False)
          oz.fit(X)
          mockfit.assert_called_once_with(X, None)
  
imports: import sys
  import pytest
  import matplotlib.pyplot
  import numpy
  from sklearn.datasets import make_blobs
  from sklearn.cluster import KMeans, MiniBatchKMeans
  from sklearn.cluster import SpectralClustering, AgglomerativeClustering
  from unittest import mock
  from tests.base import VisualTestCase
  from yellowbrick.cluster.silhouette import SilhouetteVisualizer, silhouette_visualizer
label_desc: Use image node_id 8 for calling the TestSilhouetteVisualizer obj's underlying member method code with example usage: obj.test_with_fitted() without return types