MachineLearning스터디/LinearRegressionWithMultipleVariables: Difference between revisions
From ZeroWiki
More actions
imported>trailblaze No edit summary |
imported>trailblaze No edit summary |
||
| Line 8: | Line 8: | ||
=== Normal Equation === | === Normal Equation === | ||
=== Octave로 Linear Regression With Multiple Varables 구현하기 === | === Octave로 Linear Regression With Multiple Varables 구현하기 === | ||
==== 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 : 표준 편차 구하는 함수. | |||
* 표준 편차를 이용해서 데이터를 정규화 시킴. | |||
Revision as of 03:18, 18 February 2014
Multiple Features
Gradient Descent for Multiple Variables
Feature Scaling
Learning Rate
Polynomial Regression
Normal Equation
Octave로 Linear Regression With Multiple Varables 구현하기
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 : 표준 편차 구하는 함수.
- 표준 편차를 이용해서 데이터를 정규화 시킴.