무냐의 개발일지
[Coursera ML Specialization] C1 지도, 비지도학습 / Week1 본문
1) Supervised Learning ( 회귀 Regression, 분류 Classification)
가장 많이 사용된다. learns from being given 'right answers'. 과거 데이터를 기반으로 예측할 때 유용함.
(spam filtering, speech recognition, machine translation, online advertising, self-driving car)
- Regression algorithm : predict a number from infinitely many possible numbers
- Classification algorithm : predict only small number of possible outputs/categories
2) Unsupervised Learning
find something interesting in unlabeled data.
- Clustering algorithm(구글 뉴스 - 키워드별로 군집을 보아서 관련 기사들을 표출한다). Algorithms has to find structure in the data.
- Anomaly detection : find unusual data points
- Dimensionality reduction : compress data using fewer numbers
3) Recommneder system
4) Reinforcement learning
| Linear Regression
Supervised Learning의 일종
- training set : x(input variable, feature), y(output variable, target variable)
(w, b: parameters)
- learning algorithm가 hypothesis(the model)를 형성한다
- 여기서 feature에 따른 prediction(estimated y)예측결과를 형성
linear model with 1 input variable : univariate linear regression
| Cost function
tell us how well the model is doing
measure the difference between predictions and actual true value for y
결국 이 오차(cost function)를 줄이는 것이 최종 목표임!
def compute_cost(x, y, w, b):
# number of training examples
m = x.shape[0]
cost_sum = 0
for i in range(m):
f_wb = w * x[i] + b
cost = (f_wb - y[i]) ** 2
cost_sum = cost_sum + cost
total_cost = (1 / (2 * m)) * cost_sum
return total_cost
| Gradient descent
: finding values of parameters w and b that minimize the cost function J
local minima : 최저점
*Gradient Descent의 공식

J = Derivative (which direction to go)
수렴할 때까지 w,b 동시에 이 두 업데이트 단계를 반복한다
Simultaneouos update 가 중요하다
* Learning Rate(알파)를 고르는 방법
너무 작으면, minimum까지 가는 게 너무 느려서 비효율적이다.
너무 크면, minimum을 가뿐히 지나칠 수 있어서 비효율적이다.
이미 w가 local minimum에 있으면, J 기울기가 0 이기 때문에 w = w 가 된다.
| Linear Regression Model
* squared error cost를 쓰면 bowl shape(convex function)이므로, global minimum을 가진다 (단 하나의 최솟값)