Created
February 11, 2019 09:48
-
-
Save nithyadurai87/c57ac1197368249f015ed4d1dba029f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
x = [1, 2, 3] | |
y = [1, 2, 3] | |
plt.figure() | |
plt.title('Data - X and Y') | |
plt.plot(x,y,'*') | |
plt.xticks([0,1,2,3]) | |
plt.yticks([0,1,2,3]) | |
plt.show() | |
def linear_regression(theta0,theta1): | |
predicted_y = [] | |
for i in x: | |
predicted_y.append((theta0+(theta1*i))) | |
plt.figure() | |
plt.title('Predictions') | |
plt.plot(x,predicted_y,'.') | |
plt.xticks([0,1,2,3]) | |
plt.yticks([0,1,2,3]) | |
plt.show() | |
theta0 = 1.5 | |
theta1 = 0 | |
linear_regression(theta0,theta1) | |
theta0a = 0 | |
theta1a = 1.5 | |
linear_regression(theta0a,theta1a) | |
theta0b = 1 | |
theta1b = 0.5 | |
linear_regression(theta0b,theta1b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment