class_docstr: The Silhouette Visualizer displays the silhouette coefficient for each
  sample on a per-cluster basis, visually evaluating the density and
  separation between clusters. The score is calculated by averaging the
  silhouette coefficient for each sample, computed as the difference
  between the average intra-cluster distance and the mean nearest-cluster
  distance for each sample, normalized by the maximum value. This produces a
  score between -1 and +1, where scores near +1 indicate high separation
  and scores near -1 indicate that the samples may have been assigned to
  the wrong cluster.
  
  In SilhouetteVisualizer plots, clusters with higher scores have wider
  silhouettes, but clusters that are less cohesive will fall short of the
  average score across all clusters, which is plotted as a vertical dotted
  red line.
  
  This is particularly useful for determining cluster imbalance, or for
  selecting a value for K by comparing multiple visualizers.
  
  Parameters
  ----------
  estimator : a Scikit-Learn clusterer
      Should be an instance of a centroidal clustering algorithm (``KMeans``
      or ``MiniBatchKMeans``). If the estimator is not fitted, it is fit when
      the visualizer is fitted, unless otherwise specified by ``is_fitted``.
  
  ax : matplotlib Axes, default: None
      The axes to plot the figure on. If None is passed in the current axes
      will be used (or generated if required).
  
  colors : iterable or string, default: None
      A collection of colors to use for each cluster group. If there are
      fewer colors than cluster groups, colors will repeat. May also be a
      Yellowbrick or matplotlib colormap string.
  
  is_fitted : bool or str, default='auto'
      Specify if the wrapped estimator is already fitted. If False, the
      estimator will be fit when the visualizer is fit, otherwise, the
      estimator will not be modified. If 'auto' (default), a helper method
      will check if the estimator is fitted before fitting it again.
  
  kwargs : dict
      Keyword arguments that are passed to the base class and may influence
      the visualization as defined in other Visualizers.
  
  Attributes
  ----------
  silhouette_score_ : float
      Mean Silhouette Coefficient for all samples. Computed via scikit-learn
      `sklearn.metrics.silhouette_score`.
  
  silhouette_samples_ : array, shape = [n_samples]
      Silhouette Coefficient for each samples. Computed via scikit-learn
      `sklearn.metrics.silhouette_samples`.
  
  n_samples_ : integer
      Number of total samples in the dataset (X.shape[0])
  
  n_clusters_ : integer
      Number of clusters (e.g. n_clusters or k value) passed to internal
      scikit-learn model.
  
  y_tick_pos_ : array of shape (n_clusters,)
      The computed center positions of each cluster on the y-axis
  
  Examples
  --------
  
  >>> from yellowbrick.cluster import SilhouetteVisualizer
  >>> from sklearn.cluster import KMeans
  >>> model = SilhouetteVisualizer(KMeans(10))
  >>> model.fit(X)
  >>> model.show()
class_docstr_tok: ["The","Silhouette","Visualizer","displays","the","silhouette","coefficient","for","each","sample","on","a","per-cluster","basis",",","visually","evaluating","the","density","and","separation","between","clusters",".","The","score","is","calculated","by","averaging","the","silhouette","coefficient","for","each","sample",",","computed","as","the","difference","between","the","average","intra-cluster","distance","and","the","mean","nearest-cluster","distance","for","each","sample",",","normalized","by","the","maximum","value",".","This","produces","a","score","between","-1","and","+1",",","where","scores","near","+1","indicate","high","separation","and","scores","near","-1","indicate","that","the","samples","may","have","been","assigned","to","the","wrong","cluster",".","In","SilhouetteVisualizer","plots",",","clusters","with","higher","scores","have","wider","silhouettes",",","but","clusters","that","are","less","cohesive","will","fall","short","of","the","average","score","across","all","clusters",",","which","is","plotted","as","a","vertical","dotted","red","line",".","This","is","particularly","useful","for","determining","cluster","imbalance",",","or","for","selecting","a","value","for","K","by","comparing","multiple","visualizers",".","Parameters","--","--","--","--","--","estimator",":","a","Scikit-Learn","clusterer","Should","be","an","instance","of","a","centroidal","clustering","algorithm","(","``","KMeans","``","or","``","MiniBatchKMeans","``",")",".","If","the","estimator","is","not","fitted",",","it","is","fit","when","the","visualizer","is","fitted",",","unless","otherwise","specified","by","``","is_fitted","``",".","ax",":","matplotlib","Axes",",","default",":","None","The","axes","to","plot","the","figure","on",".","If","None","is","passed","in","the","current","axes","will","be","used","(","or","generated","if","required",")",".","colors",":","iterable","or","string",",","default",":","None","A","collection","of","colors","to","use","for","each","cluster","group",".","If","there","are","fewer","colors","than","cluster","groups",",","colors","will","repeat",".","May","also","be","a","Yellowbrick","or","matplotlib","colormap","string",".","is_fitted",":","bool","or","str",",","default='auto'","Specify","if","the","wrapped","estimator","is","already","fitted",".","If","False",",","the","estimator","will","be","fit","when","the","visualizer","is","fit",",","otherwise",",","the","estimator","will","not","be","modified",".","If","'auto","'","(","default",")",",","a","helper","method","will","check","if","the","estimator","is","fitted","before","fitting","it","again",".","kwargs",":","dict","Keyword","arguments","that","are","passed","to","the","base","class","and","may","influence","the","visualization","as","defined","in","other","Visualizers",".","Attributes","--","--","--","--","--","silhouette_score_",":","float","Mean","Silhouette","Coefficient","for","all","samples",".","Computed","via","scikit-learn","`","sklearn.metrics.silhouette_score","`",".","silhouette_samples_",":","array",",","shape","=","[","n_samples","]","Silhouette","Coefficient","for","each","samples",".","Computed","via","scikit-learn","`","sklearn.metrics.silhouette_samples","`",".","n_samples_",":","integer","Number","of","total","samples","in","the","dataset","(","X.shape","[","0","]",")","n_clusters_",":","integer","Number","of","clusters","(","e.g",".","n_clusters","or","k","value",")","passed","to","internal","scikit-learn","model",".","y_tick_pos_",":","array","of","shape","(","n_clusters",",",")","The","computed","center","positions","of","each","cluster","on","the","y-axis","Examples","--","--","--","--",">",">",">","from","yellowbrick.cluster","import","SilhouetteVisualizer",">",">",">","from","sklearn.cluster","import","KMeans",">",">",">","model","=","SilhouetteVisualizer","(","KMeans","(","10",")",")",">",">",">","model.fit","(","X",")",">",">",">","model.show","(",")"]
docstr: Prepare the figure for rendering by setting the title and adjusting
  the limits on the axes, adding labels and a legend.
docstr_tok: ["Prepare","the","figure","for","rendering","by","setting","the","title","and","adjusting","the","limits","on","the","axes",",","adding","labels","and","a","legend","."]
code: def finalize(self):
      """
      Prepare the figure for rendering by setting the title and adjusting
      the limits on the axes, adding labels and a legend.
      """
  
      # Set the title
      self.set_title(
          (
              "Silhouette Plot of {} Clustering for {} Samples in {} Centers"
          ).format(self.name, self.n_samples_, self.n_clusters_)
      )
  
      # Set the X and Y limits
      # The silhouette coefficient can range from -1, 1;
      # but here we scale the plot according to our visualizations
  
      # l_xlim and u_xlim are lower and upper limits of the x-axis,
      # set according to our calculated max and min score with necessary padding
      l_xlim = max(
          -1, min(-0.1, round(min(self.silhouette_samples_) - 0.1, 1))
      )
      u_xlim = min(1, round(max(self.silhouette_samples_) + 0.1, 1))
      self.ax.set_xlim([l_xlim, u_xlim])
  
      # The (n_clusters_+1)*10 is for inserting blank space between
      # silhouette plots of individual clusters, to demarcate them clearly.
      self.ax.set_ylim(
          [0, self.n_samples_ + (self.n_clusters_ + 1) * 10]
      )
  
      # Set the x and y labels
      self.ax.set_xlabel("silhouette coefficient values")
      self.ax.set_ylabel("cluster label")
  
      # Set the ticks on the axis object.
      self.ax.set_yticks(self.y_tick_pos_)
      self.ax.set_yticklabels(
          str(idx) for idx in range(self.n_clusters_)
      )
      # Set the ticks at multiples of 0.1
      self.ax.xaxis.set_major_locator(ticker.MultipleLocator(0.1))
  
      # Show legend (Average Silhouette Score axis)
      self.ax.legend(loc="best")
  
file_path: yellowbrick/yellowbrick/cluster/silhouette.py
imports: import numpy
  import matplotlib.ticker
  from sklearn.metrics import silhouette_score, silhouette_samples
  from yellowbrick.utils import check_fitted
  from yellowbrick.style import resolve_colors
  from yellowbrick.cluster.base import ClusteringScoreVisualizer
label_desc: Use image node_id 4 for calling the SilhouetteVisualizer obj's underlying member method code with example usage: obj.finalize() without return types