November 2017
Intermediate to advanced
374 pages
10h 19m
English
One thing that's been glossed over a bit is the fact that coefficients themselves are random variables, therefore, they have a distribution. Let's use bootstrapping to look at the distribution of the coefficient for the crime rate. Bootstrapping is a very common technique to get an understanding of the uncertainty of an estimate:
n_bootstraps = 1000len_boston = len(boston.target)subsample_size = np.int(0.5*len_boston)subsample = lambda: np.random.choice(np.arange(0, len_boston),size=subsample_size)coefs = np.ones(n_bootstraps) #pre-allocate the space for the coefsfor i in range(n_bootstraps): subsample_idx = subsample() subsample_X = boston.data[subsample_idx] subsample_y = boston.target[subsample_idx] lr.fit(subsample_X, ...
Read now
Unlock full access