Question
Hello, consider # first class np.random.seed(17) train_data = np.random.normal(size=(100, 2)) train_labels = np.zeros(100) # adding second class train_data = np.r_[train_data, np.random.normal(size=(100, 2), loc=2)] train_labels =
Hello,
consider
# first class np.random.seed(17) train_data = np.random.normal(size=(100, 2)) train_labels = np.zeros(100)
# adding second class train_data = np.r_[train_data, np.random.normal(size=(100, 2), loc=2)] train_labels = np.r_[train_labels, np.ones(100)]
THENNN,
plt.scatter( train_data[:,0], train_data[:,1], c=train_labels, s=100, cmap="autumn", edgecolors="black", linewidth=1.5) plt.plot(range(-2, 5), range(4, -3, -1))
QUESTIONS:
What is this doing? It seems like it's plotting the first column of train data against the second column. but because of the concatenation we have 200 rows in train data.
Since the seed was set, shouldn't the two sets of 100 each be the same? When I print it out they seem to be different. why? Also how does c= train_labels work in general and in this case in particular. It looks as if train_labels has nothinggg to do with the training data. whats going on there?
and finally what's up with plt.plot(range(-2, 5), range(4, -3, -1)) why the -1 and why don't we need to do 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