MachineLearning스터디/LinearRegressionWithMultipleVariables (rev. 1.3)
2. Gradient Descent for Multiple Variables ¶
5. Polynomial Regression ¶
7. Octave로 Linear Regression With Multiple Varables 구현하기 ¶
7.1. Feature Normalize ¶
function [X_norm, mu, sigma] = featureNormalize(X)
%FEATURENORMALIZE Normalizes the features in X
% FEATURENORMALIZE(X) returns a normalized version of X where
% the mean value of each feature is 0 and the standard deviation
% is 1. This is often a good preprocessing step to do when
% working with learning algorithms.
% You need to set these values correctly
X_norm = X;
mu = zeros(1, size(X, 2));
sigma = zeros(1, size(X, 2));
n_of_feature = size(X_norm, 2);
for i = 1:n_of_feature
mu(i) = mean(X_norm(:, i));
sigma(i) = std(X_norm(:, i));
X_norm(:, i) = (X_norm(:, i ) - mu(i)) / sigma(i);
end
- mean : 평균 구하는 함수.
- std : 표준 편차 구하는 함수.
- 표준 편차를 이용해서 데이터를 정규화 시킴.