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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started