Difference between revisions of "AI:Regression Problems"

From wiki
Jump to navigation Jump to search
m
Line 11: Line 11:
 
;h(x) = &theta;<sub>(0)</sub> + &theta;<sub>(1)</sub>*x
 
;h(x) = &theta;<sub>(0)</sub> + &theta;<sub>(1)</sub>*x
 
:&theta; are the hypothesis parameters, it is the weight a feature gets. For the multiplication tables &theta; is just the table you are working on. So for the table of 4, in the above formula &theta;(1) = 4
 
:&theta; are the hypothesis parameters, it is the weight a feature gets. For the multiplication tables &theta; is just the table you are working on. So for the table of 4, in the above formula &theta;(1) = 4
The aim of the learning algorithm is to choose &theta;(0) and &theta;(1) so that the result for all input values is as close as possible to the given output values. For this we use a cost function like:
+
The aim of the learning algorithm is to choose &theta;(0) and &theta;(1) so that the result for all input values is as close as possible to the given output values. For this we use a 'Squared error cost function' like:
  
 
<math>J(\theta^{(0)},\theta^{(1)}) = \frac{1}{2}m*\sum_{i=1}^m (h( x^{(i)}) - y^{(i)})^2</math>
 
<math>J(\theta^{(0)},\theta^{(1)}) = \frac{1}{2}m*\sum_{i=1}^m (h( x^{(i)}) - y^{(i)})^2</math>
Line 18: Line 18:
 
* m is the number of samples in the data set.
 
* m is the number of samples in the data set.
 
* The square of the difference is taken to force a positive number.
 
* The square of the difference is taken to force a positive number.
We need to pick &theta; so that the outcome of the cost function is as close as possible to 0
+
We need to pick &theta;<sub>(0)</sub> and &theta;<sub>(1)</sub> so that the outcome of the cost function is as close as possible to 0

Revision as of 16:01, 22 April 2019


Learning from a training set. A training set has m samples of x's (input variables or features) and the resulting y's (output/target variables)

The learning algorithm finds the best matching hypothesis that maps the input to the output values.

The hypothesis (h) can be:

Linear regression with 1 variable (Univariate linear regression)

h(x) = θ(0) + θ(1)*x
θ are the hypothesis parameters, it is the weight a feature gets. For the multiplication tables θ is just the table you are working on. So for the table of 4, in the above formula θ(1) = 4

The aim of the learning algorithm is to choose θ(0) and θ(1) so that the result for all input values is as close as possible to the given output values. For this we use a 'Squared error cost function' like:

This means that for each sample in the dataset we calculate the square value of the difference between the output of our hypothesis(h) and the actual value in the training set(y). We sum it all up and multiply by half the number of rows in the dataset.

  • m is the number of samples in the data set.
  • The square of the difference is taken to force a positive number.

We need to pick θ(0) and θ(1) so that the outcome of the cost function is as close as possible to 0