Question
Confirm or disconfirm the idea that pocket accuracy increases with NN by extending the plot to have a domain from 0 to 1500. def get_data_nonlin(N,line_coef=(-1,0.9,1),seed=42):
Confirm or disconfirm the idea that pocket accuracy increases with NN by extending the plot to have a domain from 0 to 1500.
def get_data_nonlin(N,line_coef=(-1,0.9,1),seed=42): np.random.seed(seed) # So that everyone has the same "random" points points = np.zeros(3*N).reshape(N,3) points[:,1] = np.random.rand(N) #random x-coordinates points[:,2] = np.random.rand(N) #random y-coordinates points[:,0] = np.ones(N) #bias column
line_coef = (-1,0.9,1) #this line will define whether a point is a positive or negative example pos = points.dot(line_coef) >= 0 # positive examples are above the line for i in range(N//10): # Now we flip about 10% of the data (could be less b/c collisions) r = np.random.randint(len(pos)) pos[r] = ~pos[r] return points,pos
_N = np.arange(35,1001,1) _L = np.zeros(1001-35) for i,n in enumerate(_N): X,pos = get_data_nonlin(n) y = 2*pos -1 w=Pocket_Algorithm(X,y) _L[i] = E_in(X,w,y)
plt.scatter(_N,_L,alpha=0.2) plt.xlabel("Data size") plt.ylabel(r"Pocket $E_{in}$") plt.title("Pocket algorithm performance (2000 iterations)") 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