Linear regression with scikit-learn and higher dimensionality
The scikit-learn library offers the LinearRegression
class, which works with n-dimensional spaces. For this purpose, we're going to use the Boston dataset:
from sklearn.datasets import load_boston boston = load_boston() print(boston.data.shape) (506L, 13L) print(boston.target.shape) (506L,)
It has 506
samples with 13
input features and one output. In the following graph, there's a collection of the plots of the first 12 features:

The plot of the first 12 features of the Boston dataset
Note
When working with datasets, it's useful to have a tabular view to manipulate data. Pandas is a perfect framework for this task, and even though it's beyond the scope of this book, I suggest you create a data frame with the pandas.DataFrame(boston.data, columns=boston.feature_names)
command and use Jupyter to visualize it. For further information, refer to Learning pandas - Python Data Discovery and Analysis Made Easy, Heydt M., Packt Publishing...