완료
This commit is contained in:
@@ -13,7 +13,8 @@ J = 0;
|
|||||||
% Instructions: Compute the cost of a particular choice of theta
|
% Instructions: Compute the cost of a particular choice of theta
|
||||||
% You should set J to the cost.
|
% You should set J to the cost.
|
||||||
|
|
||||||
|
hx = X*theta;
|
||||||
|
J = sum((hx - y).^2)/(2*m);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ J = 0;
|
|||||||
% You should set J to the cost.
|
% You should set J to the cost.
|
||||||
|
|
||||||
|
|
||||||
|
hx = X*theta;
|
||||||
|
J = sum((hx - y).^2)/(2*m);
|
||||||
|
|
||||||
|
|
||||||
% =========================================================================
|
% =========================================================================
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ fprintf('\n');
|
|||||||
% Recall that the first column of X is all-ones. Thus, it does
|
% Recall that the first column of X is all-ones. Thus, it does
|
||||||
% not need to be normalized.
|
% not need to be normalized.
|
||||||
price = 0; % You should change this
|
price = 0; % You should change this
|
||||||
|
price = [1, 1650, 3]*theta;
|
||||||
|
|
||||||
% ============================================================
|
% ============================================================
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ fprintf('\n');
|
|||||||
% Estimate the price of a 1650 sq-ft, 3 br house
|
% Estimate the price of a 1650 sq-ft, 3 br house
|
||||||
% ====================== YOUR CODE HERE ======================
|
% ====================== YOUR CODE HERE ======================
|
||||||
price = 0; % You should change this
|
price = 0; % You should change this
|
||||||
|
price = [1, 1650, 3]*theta;
|
||||||
|
|
||||||
% ============================================================
|
% ============================================================
|
||||||
|
|
||||||
|
|||||||
@@ -26,9 +26,10 @@ sigma = zeros(1, size(X, 2));
|
|||||||
% Hint: You might find the 'mean' and 'std' functions useful.
|
% Hint: You might find the 'mean' and 'std' functions useful.
|
||||||
%
|
%
|
||||||
|
|
||||||
|
mu = mean(X);
|
||||||
|
X_norm .-= mu;
|
||||||
|
sigma = std(X);
|
||||||
|
X_norm ./= sigma;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ for iter = 1:num_iters
|
|||||||
%
|
%
|
||||||
|
|
||||||
|
|
||||||
|
hx = X*theta;
|
||||||
|
theta -= (alpha*sum((hx-y).*X)/m)';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,8 @@ for iter = 1:num_iters
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
hx = X*theta;
|
||||||
|
theta -= (alpha*sum((hx-y).*X)/m)';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ theta = zeros(size(X, 2), 1);
|
|||||||
|
|
||||||
% ---------------------- Sample Solution ----------------------
|
% ---------------------- Sample Solution ----------------------
|
||||||
|
|
||||||
|
theta = pinv(X'*X)*X'*y;
|
||||||
|
|
||||||
|
|
||||||
% -------------------------------------------------------------
|
% -------------------------------------------------------------
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ figure; % open a new figure window
|
|||||||
% markers larger by using plot(..., 'rx', 'MarkerSize', 10);
|
% markers larger by using plot(..., 'rx', 'MarkerSize', 10);
|
||||||
|
|
||||||
|
|
||||||
|
plot(x, y, 'rx', 'MarkerSize', 10);
|
||||||
|
ylabel('Profit in $10,000s');
|
||||||
|
xlabel('Population of City in 10,000s');
|
||||||
|
|
||||||
|
|
||||||
% ============================================================
|
% ============================================================
|
||||||
|
|||||||
15
ex1/token.mat
Normal file
15
ex1/token.mat
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Created by Octave 4.2.1, Sun May 28 17:11:16 2017 GMT <unknown@unknown>
|
||||||
|
# name: email
|
||||||
|
# type: sq_string
|
||||||
|
# elements: 1
|
||||||
|
# length: 16
|
||||||
|
mjjo53@gmail.com
|
||||||
|
|
||||||
|
|
||||||
|
# name: token
|
||||||
|
# type: sq_string
|
||||||
|
# elements: 1
|
||||||
|
# length: 16
|
||||||
|
9Dxrb898sAaadc8j
|
||||||
|
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ A = [];
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
A = eye(5);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user