Linear Regression: Multiple Features
Linear regression with multiple variables (features) is also known as "multivariate linear regression".
Hypothesis function for multiple features
The multivariable form of the hypothesis function:
Denoting for , we can rewrite above as:
The above transformation of from to is an example of 'vectorization' technique which is used to speed-up computations using available optimized numerical linear algebra libraries.
- : Number of training examples
- : Number of features
- : Value of feature in the th training example
- : Input (features) of the th training example; this is a vector
m x (n+1) matrix
Note that in this vectorized implementation, we calculate hypotheses of all training examples at once.
Cost function for multiple features
Recall that the cost function is defined as: