Exercise 2.6

Answers

(a)
Apply the error bar in (2.1), i.e. Eout(g) Ein(g) + 1 2N ln 2M δ .
The following calculation shows that error on Ein(g) = 0.1151 and error on Etest(g) = 0.096. So the error bar on in-sample error is higher than the error bar from test error.
(b)
If we reserve more examples for testing, then we’ll have less samples for training. We may end up with a hypothesis that is not as good as we could have arrived if using more training samples. So Etest(g) might be way too off even the error bar on it is small.
import numpy as np 
epsilon = 0.05 
 
= 200 
# test bound 
print('test bound: ', np.sqrt(np.log(2/epsilon)/2/N)) 
 
# train bound 
= 1000 
= 400 
print('train bound: ', np.sqrt(np.log(2*M/epsilon)/2/N))
test bound:  0.09603227913199208
train bound:  0.11509037065006825

User profile picture
2021-12-07 22:06
Comments