linear regression
TOC
Linear Regression
- An approach for modeling the relationship between a scalare dependent variable y and one or more explanatory variables denoted X. - Wiki
Image 1. Linear regression
Linear Regression in Machine Learning
- Hypothesis of Linear Regression
$$ H(x) = W * x + b $$
* x: input
* H(x): output
* W: Weight, tuning parameter
* b: bias, tuning parameter
- Machine learning is a nice technique to find the best parameters for the hypothesis fitting the input and output.
import matplotlib.pyplot as plt
num_points = 10
# Set test input & output data
x = [i for i in range(num_points + 1)]
y = [i for i in range(num_points + 1)]
# Draw input and output
plt.plot(x, y,'ro')
# Set test parameters
params = [[2, 3], [3, -5], [1, 0]]
# Apply test parameters and draw it
for W, b in params:
hypo = [W * _x + b for _x in x]
plt.plot(x, hypo, label="W={0}, b={1}".format(W, b))
plt.xlabel("x")
plt.ylabel("y")
plt.ylim(0, 15)
plt.grid()
plt.legend()
plt.show()
Image 2. Optimization for W and b
COMMENTS