Answered step by step
Verified Expert Solution
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
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 separatorStep 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