Can you help me adjust this python code? I would like to make the…
Question Answered step-by-step Can you help me adjust this python code? I would like to make the… Can you help me adjust this python code? I would like to make the background of the plot black, and the connected points to be white, like the image below. But I am not sure how to change thisMy code currently:import matplotlib.pyplot as pltimport scipy.cluster.hierarchy as schfrom scipy.cluster.hierarchy import linkageimport numpy as npimport pandas as pdfrom sklearn.datasets import make_blobsfrom sklearn.cluster import KMeansfrom sklearn.cluster import AgglomerativeClustering# Setting seed to zeronp.random.seed(0)# Make blobsX, y = make_blobs(n_samples=200, centers=[[3,2], [6,4], [10,5]], cluster_std=0.9)# Kmeanskmeans = KMeans(init = “k-means++”, n_clusters = 3, n_init = 12).fit(X)# Aggromelative clusteringagglo = AgglomerativeClustering(n_clusters = 3, linkage = ‘average’).fit(X)# plot kmeanspred = kmeans.predict(X)for i in range(3): plt.plot(X[pred == i][:,0], X[pred == i][:,1])plt.title(‘KMeans’)plt.xticks([])plt.yticks([])plt.show() current plot output that has wrong colours: Computer Science Engineering & Technology Python Programming IT SIT384 Share QuestionEmailCopy link Comments (0)


