we start by using scikit-learn' methods to load the dataset this is one of the built-in datasets that scikit-learn comes withso it is very easyfrom sklearn datasets import load_boston boston load_boston(the boston object is composite object with several attributesin particularboston data and boston target will be of interest to us we will start with simple one-dimensional regressiontrying to regress the price on single attribute according to the average number of rooms per dwellingwhich is stored at position (you can consult boston descr and boston feature_names for detailed information on the data)from matplotlib import pyplot as plt plt scatter(boston data[:, ]boston targetcolor=' 'the boston target attribute contains the average house price (our target variablewe can use the standard least squares regression you probably first saw in high school our first attempt looks like thisimport numpy as np we import numpyas this basic package is all we need we will use functions from the np linalg submodulewhich performs basic linear algebra operationsx boston data[:, np array([[vfor in ]this may seem strangebut we want to be two dimensionalthe first dimension is the different exampleswhile the second dimension is the attributes in our casewe have single attributethe mean number of rooms per dwellingso the second dimension is boston target slope, , , np linalg lstsq( ,yfinallywe use least squares regression to obtain the slope of the regression the np linalg lstsq function also returns some internal information on how well the regression fits the datawhich we will ignore for the moment