블로그 이미지
윤영식
Full Stacker, Application Architecter, KnowHow Dispenser and Bike Rider

Publication

Category

Recent Post

앤드류응 교수님의 코세라 강좌를 정리한다. 





Supervised Learning


지도학습과 자율학습에 대한 개념이해 


지도학습

- 정답을 주고 학습

- regression과 classification이 있음

- regression: 여러 개 중 하나 

- classification: 0 또는 1

In supervised learning, we are given a data set and already know what our correct output should look like, having the idea that there is a relationship between the input and the output.


Supervised learning problems are categorized into "regression" and "classification" problems. In a regression problem, we are trying to predict results within a continuous output, meaning that we are trying to map input variables to some continuous function. In a classification problem, we are instead trying to predict results in a discrete output. In other words, we are trying to map input variables into discrete categories.


Example 1:


Given data about the size of houses on the real estate market, try to predict their price. Price as a function of size is a continuous output, so this is a regression problem.


We could turn this example into a classification problem by instead making our output about whether the house "sells for more or less than the asking price." Here we are classifying the houses based on price into two discrete categories.


Example 2:


(a) Regression - Given a picture of a person, we have to predict their age on the basis of the given picture


(b) Classification - Given a patient with a tumor, we have to predict whether the tumor is malignant or benign.


예) Housing Prices 예측 - regression 문제



linear regression


training set을 통해 학습 알고리즘을(learning algorith) 적용해서 가설식(hypothesis)을 만든다. 



cost function

- 가설의 정확도를 측정하기 위해 사용한다

- 공식: 가설의 결과값 - 실제값의 제곱의 합 

- 점진적 감소 (gradient descent)를 위해 1/2를 사용한다. 

- 정확도 측정 J 함수를 얻음.




 세타0을 값 zero로 놓고 간략히 표현한 수식

-  x 값을 줄 때 시작점 세타0과 기울기 세타1의 상수 값을 찾아야 한다. 

- 비용함수인 J(세타0, 세타1)에서 세타0 을 zero로 놓으면 시작점이 zero부터 시작해서 비용함수 J(세타1)을 구하는 것이다. 





- J 공식 결과가 0 이면 가장 작은 비용을 들인 경우이다. 이때 J(세타1)에서 세타1의 값이 1일 때 비용이 전부 0으로 나온다. 



- 만일 세타1값이 0.5라면 cost function 처리 값은 다음과 같이 0.58이 나온다. 



- 음수의 영역을 이동하면 cost function 은 가설값 - 실제값의 제곱의 합이므로 다음과 같이 등고선 그래프가 나온다. 





등고선 그래프로 세타0, 세타1 눈으로 확인하기 


등고선을 입체적으로 보면 다음과 같다. 

- 수평선은 세타1, 세타0 이다.

- 수직선은 cost function의 결과값 J(세타0, 세타1) 이다.

세타1=기울기, 세타0은 시작점



이것을 다시 평면으로 H(x) 와 비교하기위해 평면 등고선을 가지고 눈으로 세타0, 세타1의 값을 가지고 가설의 선을 검증할 수 있다. 

예1) 같은 등고선에 있는 3개의 x는 값은 높이 값, 즉 비용함수 결과값을 갖는다. 이것을 h(x)상에 세타0, 세타1을 이용해 그리면 다음과 같이 나온다. 

데이터셋과 h(x) 선의 거리가 전혀 맞아 들어가지 않아 가설 선이 맞지 않음을 알 수 있다. 


예2) 좀 더 중심으로 이동한 빨간색 x는 등고선에서 세타0=360, 세타1=0 값을 가즌다. 이를 세타1=기울기, 세타0은 시작점으로 보면 h(x)는 수평선이 나온다. 이동 실 데이터의 거리값이 작지 않음을 보여준다.



중심으로 이동할 때 다음과 같이 최적의 가설 세타0과 세타1을 얻을 수 있다. 

세타0 = 250

세타1 = 0.12







Unsupervised

자율학습

- 확인된 답을 제공하지 않음 

   예) 고객이 어디 고객군에 속하는지 알 수 없다. 천문학등

- clustringr과 non-clustering 

Unsupervised learning allows us to approach problems with little or no idea what our results should look like. We can derive structure from data where we don't necessarily know the effect of the variables.


We can derive this structure by clustering the data based on relationships among the variables in the data.


With unsupervised learning there is no feedback based on the prediction results.


Example:


Clustering: Take a collection of 1,000,000 different genes, and find a way to automatically group these genes into groups that are somehow similar or related by different variables, such as lifespan, location, roles, and so on.


Non-clustering: The "Cocktail Party Algorithm", allows you to find structure in a chaotic environment. (i.e. identifying individual voices and music from a mesh of sounds at a cocktail party).





참고


- 앤드류 응교수님의 머신러닝 강좌

- 회귀 분석 예제

- 선형 회귀 분석 데이터 이해



posted by 윤영식