File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ # This code is supporting material for the book
2+ # Building Machine Learning Systems with Python
3+ # by Willi Richert and Luis Pedro Coelho
4+ # published by PACKT Publishing
5+ #
6+ # It is made available under the MIT License
7+
8+
9+ # This script plots prediction-vs-actual on training set for the Boston dataset
10+ # using OLS regression
11+
12+ from sklearn .linear_model import LinearRegression
13+ from sklearn .datasets import load_boston
14+ import pylab as plt
15+
16+ boston = load_boston ()
17+
18+ x = boston .data
19+ y = boston .target
20+
21+ lr = LinearRegression ()
22+ lr .fit (x , y )
23+ p = lr .predict (x )
24+ plt .scatter (p , y )
25+ plt .xlabel ('Predicted price' )
26+ plt .ylabel ('Actual price' )
27+ plt .plot ([y .min (), y .max ()], [y .min (), y .max ()])
28+
29+ plt .savefig ('Figure4.png' , dpi = 150 )
You can’t perform that action at this time.
0 commit comments