Skip to content

Commit c725a97

Browse files
committed
DOC Add explanatory comments. Save plot as PNG
1 parent 857cbf0 commit c725a97

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ch07/boston1.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
x = boston.data
2020
y = boston.target
2121

22+
# Fitting a model is trivial: call the ``fit`` method in LinearRegression:
2223
lr = LinearRegression()
2324
lr.fit(x, y)
2425

@@ -27,10 +28,10 @@
2728
print('RMSE: {}'.format(rmse))
2829

2930
# Plot the prediction versus real:
30-
plt.plot(lr.predict(x), boston.target, 'ro')
31+
plt.scatter(lr.predict(x), boston.target)
3132

3233
# Plot a diagonal (for reference):
33-
plt.plot([0, 50], [0, 50], 'g-')
34+
plt.plot([0, 50], [0, 50], '-', color=(.9,.3,.3), lw=4)
3435
plt.xlabel('predicted')
3536
plt.ylabel('real')
36-
plt.show()
37+
plt.savefig('Figure_07_08.png')

0 commit comments

Comments
 (0)