coursera 吴恩达机器学习第一次作业提交

ex1的提交,只贴添加内容

warmUpExercise.m

A = eye(5);

computeCost.m

J = sum((X*theta-y).^2);
J = J/(2*m);

gradientDescent.m

theta = theta - alpha*X'*(X*theta - y)/m;

featureNormalize.m

for i = 1:size(X,2)
    mu(1,i) = mean(X(:,i));
end

for i = 1:size(X,2)
    sigma(1, i) = std(X(:,i));
end
for i = 1:size(X,1)
    for j = 1:size(X,2)
        X_norm(i,j) = (X(i,j)-mu(1,j))/sigma(1,j);
    end

computeCostMulti.m

J = (X*theta-y)'*(X*theta-y)/(2*m);

gradientDescentMulti.m

theta = theta - alpha*X'*(X*theta - y)/m;

normalEqn.m

theta = (pinv(X*X')*X)'*y
原文地址:https://www.cnblogs.com/lxb0478/p/8242219.html