Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE USE PYTHON Below we use the pocket algorithm to find a linear separator w for the breast cancer data and then output its E_in

PLEASE USE PYTHON

image text in transcribed

Below we use the pocket algorithm to find a linear separator w for the breast cancer data and then output its E_in What is the accuracy? That is, what percentage of the datapoints does the classifier w classify correctly? Change the code below so that the accuracy is printed as well as E_in. In [22]: xnp.ones (D.shape [0]*3).reshape(D. shape[01,3) X:,2-D,20] y- 2-malignant -1 # so that y in {-1,1), not {0,1} wPocket_Algorithm(x,y,2000) wp = w/w[-1] # dividing out c as described in comments to first code cell E in(X,W,y) Out[ 22) 0.1054481546572935 In the plot below we visualize the learned decision boundary. In [91: import numpy as np import matplotlib.pyplot as plt plt.scatter (xm,ym, label-"malignant",alpha-0.3) plt . scatter ( xb , , abel=" benign " , alpha-o . 3 ) plt.plot(x,yh, 'brown', 1abel-"learned plt.axis ([-0.05,0.5,0,.08]) plt.legend() plt.show) boundary") #plot linear separator Below we use the pocket algorithm to find a linear separator w for the breast cancer data and then output its E_in What is the accuracy? That is, what percentage of the datapoints does the classifier w classify correctly? Change the code below so that the accuracy is printed as well as E_in. In [22]: xnp.ones (D.shape [0]*3).reshape(D. shape[01,3) X:,2-D,20] y- 2-malignant -1 # so that y in {-1,1), not {0,1} wPocket_Algorithm(x,y,2000) wp = w/w[-1] # dividing out c as described in comments to first code cell E in(X,W,y) Out[ 22) 0.1054481546572935 In the plot below we visualize the learned decision boundary. In [91: import numpy as np import matplotlib.pyplot as plt plt.scatter (xm,ym, label-"malignant",alpha-0.3) plt . scatter ( xb , , abel=" benign " , alpha-o . 3 ) plt.plot(x,yh, 'brown', 1abel-"learned plt.axis ([-0.05,0.5,0,.08]) plt.legend() plt.show) boundary") #plot linear separator

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 Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions