Model and Cost Function
2-1 Model Representation
Supervised Learning:
- Regression Problem, predict real-valued output
- Classification Problem, predict discrete-valued output
- Training set
- ( x , y ) (x,y) (x,y)–one training example
- ( x ( i ) , y ( i ) ) (x^{(i)},y^{(i)}) (x(i),y(i))– i t h i^{th} ith training example
- When the target variable to be predicted is continuous, we call the learning problem a r e g r e s s i o n p r o b l e m ‾ \underline{a \;regression \;problem} aregressionproblem. When y can take on only a small number of discrete values , we call it a c l a s s i f i c a t i o n p r o b l e m ‾ \underline{a\; classification\; problem} aclassificationproblem.
- Represent h (hypothesis)
Linear Regression
h θ ( x ) = θ 0 + θ 1 x h_\theta(x)=\theta_0+\theta_1x hθ(x)=θ0+θ1x
- Linear regression with one variable(x) : univariate linear regression
2-2 Cost Function (Squared Error Function )
- Choose parameter θ i ′ s \theta_i's θi′s for the function h θ ( x ) = θ 0 + θ 1 x h_\theta(x)=\theta_0+\theta_1x hθ(x)=θ0+θ1x
Idea: Choose θ 0 , θ 1 \theta_0,\theta_1 θ0,θ1 so that $h_\theta(x) $ is close to y y y for training examples ( x , y ) (x,y) (x,y).
-
Measure the accuracy of our hypothesis function by using a cost function
2-3 Cost Function Intuition I
The training data set is scatter on x-y plane and we trying to get a straight line that defined by h θ ( x ) h_\theta(x) hθ(x) ,so we need to minimize the cost function.
Set θ 0 = 0 \theta_0=0 θ0=0, get the simplified function J θ = θ 1 x J_\theta=\theta_1x Jθ=θ1x.
We get the best possible line with the m i n J ( θ ) min J(\theta) minJ(θ)
2-4 Cost Function Intuition II
Add θ 0 \theta_0 θ0 ,minimize J ( θ 0 , θ 1 ) J(\theta_0,\theta_1) J(θ0,θ1)
contour plot
A contour line of a two variable function has a constant value at all points of the same line.
Want an efficient algorithm