Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Performance Engineering 10th European Workshop Epew 2013 Venice Italy September 17 2013 Proceedings

Authors: Maria Simonetta Balsamo ,William Knottenbelt ,Andrea Marin

2013 Edition

3642407242, 978-3642407246

More Books

Students also viewed these Programming questions

Question

=+1. Which of the given are Actions and which are States of Nature?

Answered: 1 week ago