Last active
March 31, 2017 09:35
-
-
Save katsu1110/1d1055001e74620618aef8fc2f832b57 to your computer and use it in GitHub Desktop.
数学の苦手なバイオの学生がCourseraの機械学習コースを修了して気づいたこと ref: http://qiita.com/katsu1110/items/423fc9ac567710a1bd9b
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Compute covariance matrix | |
sigma = (X'*X)/size(X,1); | |
% Singular value decomposition | |
[U,S,V] = svd(sigma); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% Compute covariance matrix | |
sigma = (X'*X)/size(X,1); | |
% Singular value decomposition | |
[U,S,V] = svd(sigma); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
J(\theta) = \frac{1}{2m} (X\theta - y)^{\mathrm{T}}(X\theta - y) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
J = 0; | |
for i = 1:m | |
for k = 1:n | |
J = J + (X(i,k)*theta(k) - y(i))^2; | |
end | |
end | |
J = J/(2*m); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
J = 0; | |
for i = 1:m | |
for k = 1:n | |
J = J + (X(i,k)*theta(k) - y(i))^2; | |
end | |
end | |
J = J/(2*m); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
J = ((X*theta - y)'*(X*theta - y))/(2*m); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
J = ((X*theta - y)'*(X*theta - y))/(2*m); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment