Learn practical skills, build real-world projects, and advance your career
Created 4 years ago
scikit-learn-linear-reg
Credits: Forked from PyCon 2015 Scikit-learn Tutorial by Jake VanderPlas
- Linear Regression
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import seaborn;
from sklearn.linear_model import LinearRegression
import pylab as pl
seaborn.set()
Linear Regression
Linear Regression is a supervised learning algorithm that models the relationship between a scalar dependent variable y and one or more explanatory variables (or independent variable) denoted X.
Generate some data:
# Create some simple data
import numpy as np
np.random.seed(0)
X = np.random.random(size=(20, 1))
y = 3 * X.squeeze() + 2 + np.random.randn(20)
plt.plot(X.squeeze(), y, 'o');