Skip to content

Commit ef091c1

Browse files
authored
Update 22_linear_regression_direct_inverse.py
1 parent 45ba658 commit ef091c1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

03_linear_algebra/22_linear_regression_direct_inverse.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,15 @@
2121

2222
# Predict against the y-values
2323
y_predict = X_1.dot(b)
24+
25+
26+
# plot
27+
import matplotlib.pyplot as plt
28+
import numpy as np
29+
# show in chart
30+
X = np.array([p.x for p in df.itertuples()])
31+
Y = np.array([p.y for p in df.itertuples()])
32+
33+
plt.plot(X, Y, 'o') # scatterplot
34+
plt.plot(X, m*X+b) # line
35+
plt.show()

0 commit comments

Comments
 (0)