Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 2 : In the class example, we apply logistic regression to build a linear classifier to distinguish the iris species setosa ( in blue

Problem 2: In the class example, we apply logistic regression to build a linear classifier
to distinguish the iris species setosa (in blue dots) and versicolor (in green dots), as
shown below. We also report the coefficients and the intercept for the linear classifier.
from sklearn.linear_model import LogisticRegression
model = LogisticRegression(random_state =0).f it (X_train.values, y_train)
print coefficients and the intercept
print (model.coef_)
print(model.intercept_)
4 visualize support vectors and the boundaries
ax = plt.gca()
xlim = ax.get_xlim()
ylim = ax.get_ylim()
plt.xlabel('petal_length')
plt.ylabel('petal_width')
=np.1 inspace (xlim?[0],xlim?[1],30)
yy = np.linspace (ylim?[0],ylim?[1],30)
YY,xx=np.meshgrid(Yy,xx
xy= np.vstack ([XX.ravel (), YY.ravel()]).T
z= model.decision_function(xy.reshape(XX.shape) # get f(x), i.e., the decision function
# plot the decision boundary f(x)=0, as well as references f(x)=-1 and f(x)=1.
ax.contour , colors='k', levels=[-1,0,1], alpha=0.5, linestyles=['--','-','--'])
plt.show ()
[2.31381394,0.90900393]
]
a) Write the decision boundary formula, i.e.,f(x).
b) If a new species has been discovered with petal length of 2.5 and petal width of
0.75, what is the probability that this species belongs to setosa? (The classes are
ordered as [setosa, versicolor].)
image text in transcribed

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

Step: 3

blur-text-image

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

Database Systems A Practical Approach To Design Implementation And Management

Authors: THOMAS CONNOLLY

6th Edition

9353438918, 978-9353438913

More Books

Students also viewed these Databases questions

Question

What are Measures in OLAP Cubes?

Answered: 1 week ago

Question

How do OLAP Databases provide for Drilling Down into data?

Answered: 1 week ago

Question

How are OLAP Cubes different from Production Relational Databases?

Answered: 1 week ago