June 2018
Intermediate to advanced
248 pages
5h 27m
English
You have already seen how to code a linear regression algorithm from scratch with NumPy. The Scipy.stats module has a linregress function to calculate the slope, intercept, correlation coefficient (r-value), two-sided p-value, and standard error of the estimate, as shown here:
from sklearn import datasets %matplotlib inline import matplotlib.pyplot as plt # Boston House Prices dataset boston = datasets.load_boston() x = boston.data y = boston.target boston.feature_names array(['CRIM', 'ZN', 'INDUS', 'CHAS', 'NOX', 'RM', 'AGE', 'DIS', 'RAD', 'TAX', 'PTRATIO', 'B', 'LSTAT'], dtype='<U7') x.shape (506, 13) y.shape (506,) # We will consider "lower status of population" as independent variable for its importance ...