watex.utils.plot_voronoi#

watex.utils.plot_voronoi(X, y, *, cluster_centers, ax=None, show_vertices=False, line_colors='k', line_width=1.0, line_alpha=1.0, fig_size=(7, 7), fig_title='')[source]#

Plots the Voronoi diagram of the k-means clusters overlaid with the data

Parameters:
  • X (NDarray, Arraylike 1d) – Data training X and y. Must have the same length

  • y (NDarray, Arraylike 1d) – Data training X and y. Must have the same length

  • cluster_center (int,) – Cluster center. Cluster center can be obtain withe KMeans algorithms

  • show_vertices (bool, optional) – Add the Voronoi vertices to the plot.

  • line_colors (string, optional) – Specifies the line color for polygon boundaries

  • line_width (float, optional) – Specifies the line width for polygon boundaries

  • line_alpha (float, optional) – Specifies the line alpha for polygon boundaries

  • point_size (float, optional) – Specifies the size of points

  • ax (Matplotlib.Axes) – Maplotlib axes. If None, a axis is created instead.

  • fig_size (tuple, default = (7, 7)) – Size of the figures.

Returns:

ax – Axes to support the figure

Return type:

Matplotlib.Axes

Examples

>>> from sklearn.datasets import make_moons
>>> from sklearn.cluster import KMeans
>>> from watex.utils.plotutils import plot_voronoi
>>> X, y = make_moons(n_samples=2000, noise=0.2)
>>> km = KMeans (n_init ='auto').fit(X, y )
>>> plot_voronoi ( X, y , cluster_centers = km.cluster_centers_)