# Linear Regression
import numpy as np
from sklearn.linear_model import LinearRegression
from numpy.linalg import inv

X = np.array([[1, 1], [1, 3], [1, 5], [1, 7]])
y = np.array([6, 8, 9, 11])
y = np.reshape(y,(4,1))

# Analytical solution using normal equation to find thetas
mul1 = np.dot(X.T, X)
mul2 = np.dot(X.T, y)
thetas = np.dot(inv(mul1), mul2)

# Find thetas using Linear Regression model
reg = LinearRegression().fit(X, y)
reg.coef_
reg.intercept_


# Polynomial regression
import numpy as np
from sklearn.linear_model import LinearRegression
from numpy.linalg import inv

X = np.array([[1, 1, 1], [1, 1, 2], [1, 2, 2], [1, 2, 3]])
y = np.array([6, 8, 9, 11])

# Analytical solution using normal equation to find thetas
mul1 = np.dot(X.T, X)
mul2 = np.dot(X.T, y)
thetas = np.dot(inv(mul1), mul2)

# Find thetas using Linear Regression model
reg = LinearRegression().fit(X, y)
reg.coef_
reg.intercept_
