吴恩达机器学习课程ex1:Linear Regression
程序员文章站
2022-07-13 08:51:53
...
吴恩达机器学习课程ex1:Linear Regression
matlab实现
# computeCost.m
function J = computeCost(X, y, theta)
m = length(y);
J = 0;
h_func = X * theta;
J = (1 / (2 * m)) * sum((h_func - y).^2);
end
# gradientDescent.m
function [theta, J_history] = gradientDescent(X, y, theta, alpha, num_iters)
m = length(y);
J_history = zeros(num_iters, 1);
for iter = 1:num_iters
h_func = X * theta;
theta = theta - 0.01 * (X') * (1/m) * (h_func - y);
J_history(iter) = computeCost(X, y, theta);
end
end
上一篇: Python微信自动回复机器人
推荐阅读
-
Chapter7:正则化 Regularization:AndrewNg吴恩达《机器学习》笔记
-
Coursera吴恩达《神经网络与深度学习》课程笔记(3)-- 神经网络基础之Python与向量化
-
吴恩达 机器学习第二周 logistic_regression 单层网络梯度下降法实现
-
吴恩达机器学习课程ex2:Logistic Regression
-
Coursera吴恩达机器学习课程 第2周作业代码
-
吴恩达机器学习 8.6 逻辑回归(Logistic Regression)
-
吴恩达 机器学习课程 coursera 第一次编程作业(Linear Regression Multi) python实现
-
吴恩达机器学习编程作业python版:第一次作业
-
吴恩达 机器学习课程 coursera 第二次编程作业(Logistic Regression Regularized) python实现
-
吴恩达老师机器学习第一次作业:梯度下降【python实现】