# Understanding a few terms in Andrew Ng's definition of the cost function for linear regression

I have completed week 1 of Andrew Ng's course. I understand that the cost function for linear regression is defined as $$J (\theta_0, \theta_1) = 1/2m*\sum (h(x)-y)^2$$ and the $$h$$ is defined as $$h(x) = \theta_0 + \theta_1(x)$$. But I don't understand what $$\theta_0$$ and $$\theta_1$$ represent in the equation. Is someone able to explain this?

• Specifically, theta0 is the bias and theta1 is 'slope' of the regression line. – Daniel Feb 15 '18 at 18:20

Linear regression is always associated with an activation function, the weights between layers and the structure of the network. The weights between layers are theta0 and theta1. This weights and the input features undergoes the dot product operation which is then the input to the activation function of the next layers node/nodes.

An apparently different but the same use of theta0 and theta1 is as coefficients to one or more number of terms which themselves are combination of the input vectors.

Broadly theta-n denotes an weight i.e. how much preference you want to give to a feature.

As said above, they are weights to your hypothesis function that are changed during training to minimize your Error function. You can think of them like slope and y intercept in basic algebra. However, a linear regression hypothesis function can be parameterized by many more weight terms than just theta_0, and theta_1.

I detail this process more in this post: How does an activation function's derivative measure error rate in a neural network?

The prediction made by linear regression can simply be thought of as a vector dot product.

$$\overrightarrow{x}^T \cdot \overrightarrow{y}$$

One of those two vectors is the "data" for one case (like a row in your data matrix), the other is a vector of the model's parameters, which is usually called $$\overrightarrow{\theta}$$ or $$\overrightarrow{\beta}$$.

So in the case shown by yourself, we have:

$$h(x) = \theta_0 + \theta_1 \cdot x$$

Often we add a row of ones to the beginning of the data matrix, that way we are consistent in the sense that the $$\theta_0 = 1 \cdot \theta_0$$

This way we arrive at:

$$h(x) = \overrightarrow{\theta}^T \cdot \overrightarrow{x}$$

The aim of reinforcement learning is to make an agent which plays games. The agent uses weights in his policy for adapting the decisions to the game. Learning means, that the agent changes it's weights. The cost function defines how good the agent has adapted the weights to the problem. Linear regression is a method for determine the weights inside the policy. Instead of linear regression any other algorithm like hill climbing, simulated annealing or brute force can be used. The general idea is, that the agent fluctuates his weights until he has won the game.

The equation of Andrew Ng can't be seen as a tutorial of how to construct the agent, it is more a self-referential symbol in a proof-workflow. That means, the formula is used together with many more of them to fulfil a thought-system which has nothing to do with agent-programming itself.

• This isn't necessarily right to imply that reinforcement learning is the general goal here. Reinforcement learning is a subset of machine learning, and machine learning can be applied to reinforcement learning; Andrew Ng's course is on machine learning not reinforcement learning. – skim Feb 20 '18 at 19:23
• @skim: There is not difference between them. Both techniques are working data-oriented, that means example input-output vectors are given and the learned model maps between them. The weights of the model are fluctuating and it's up to the programmer to find them. – Manuel Rodriguez Feb 20 '18 at 19:46