Question: python error code: TypeError: 'numpy.ndarray' object is notcallable Code: data = sns.load_dataset('iris', delimiter= ',') data = pd.DataFrame({A: [1, 2], B: [3.0, 4.5]}) data.to_numpy() X1 =

python error code: TypeError: 'numpy.ndarray' object is notcallable

Code:

data = sns.load_dataset('iris', delimiter= ',')
data = pd.DataFrame({"A": [1, 2], "B": [3.0, 4.5]})
data.to_numpy()
X1 = np.random.normal(size=1000, loc=1,scale=1)
Y1 = np.random.normal(size=1000, loc=1,scale=1)
X2 = np.random.normal(size=1000, loc=4,scale=1)
Y2 = np.random.normal(size=1000, loc=4,scale=1)

X= np.concatenate([X1,X2])
Y = np.concatenate([Y1, Y2])
XY = np.vstack([X,Y]).T

plt.scatter(X,Y)
plt.axis('equal')
plt.show()
km= KMeans(n_clusters=3)
km.fit(XY)
cluster_labels = km.predict(XY)
colors = ('red', 'blue', 'green')
plt.scatter(X,Y,c=cluster_labels,cmap=matplotlib.colors.ListedColormap(colors))
print(km.cluster_centers_)
plt.scatter(km.cluster_centers_[:,0],km.cluster_centers_[:,1],c='black',marker='x')
plt.axis('equal')
plt.show()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!