Created
May 29, 2022 18:16
-
-
Save NickyAlan/0cfa98ddcd3132a2f86f5b6233d50abf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot_decision_boundaries(clusterer, X, resolution=500, show_centroids=True, | |
show_xlabels=True, show_ylabels=True): | |
mins = X.min(axis=0) - 0.1 | |
maxs = X.max(axis=0) + 0.1 | |
xx, yy = np.meshgrid(np.linspace(mins[0], maxs[0], resolution), | |
np.linspace(mins[1], maxs[1], resolution)) | |
Z = clusterer.predict(np.c_[xx.ravel(), yy.ravel()]) | |
Z = Z.reshape(xx.shape) | |
#cmap | |
plt.contourf(Z, extent=(mins[0], maxs[0], mins[1], maxs[1]), | |
cmap="Pastel2") | |
#boundaries | |
plt.contour(Z, extent=(mins[0], maxs[0], mins[1], maxs[1]), | |
linewidths=.5, colors='k') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment