规范方程(The normal equations)
这一部分主要讲述怎样用矩阵的形式描述线性回归。
首先定义几个概念:
(1)A为m*n的矩阵,f(A)是关于A的函数,它将矩阵A映射为一个实数,
f关于A的导数可以定义为:









%normalEquation function is used to train data for linear regression.
%FEATURE is the matrix that composed of features of the training examples.
%VALUE is the matrix that composed of output values of the training
%examples.
%THETA is the parameter of the hypotheses function.
function [theta] = normalEquation(feature,value)
num = size(feature,1);
features = [ones(num,1) feature];
invertMat = (features'*features)^-1;
theta = invertMat*features'*value;
hypvalue = features*theta;
plot(feature,hypvalue,'rx-',feature,value,'bo');
end