Coursera机器学习week2 编程作业
warmUpExercise.m
A = eye(5);
plotData.m
plot(x, y, 'rx', 'MarkerSize', 10); ylabel('Profit in $10,000s'); xlabel('Population of City in 10,000s');
gradientDescent.m
plot(x, y, 'rx', 'MarkerSize', 10); ylabel('Profit in $10,000s'); xlabel('Population of City in 10,000s');
computeCost.m
predictions = X * theta; sqrErrors = (predictions - y) .^ 2; J = 1 / (2 * m) * sum(sqrErrors)
gradientDescentMulti.m
S = (1 / m) * (X' * (X * theta - y)); theta = theta - alpha .* S;
computeCostMulti.m
J = 1 / (2 * m) * sum( (X * theta - y) .^ 2);
featureNormalize.m
mu = mean(X); sigma = std(X, 1, 1); for i = 1:size(X, 2) X_norm(:, i) = (X(:, i) - mu(i)) ./ sigma(i); end;
normalEqn.m
theta = pinv((X'*X))*X'*y;