기계학습,machine_learning

AKA 머신러닝, ML

여기서 기계란 컴퓨터,computer를 뜻함. 즉 컴퓨터가 하는 학습,learning.
model이, data { training_data, training_set? } 를 통해 패턴,pattern을 배우고(학습,learning하고), 배운 대로 수행.
ML은 컴퓨터가 배울(learn) 수 있도록 하는 알고리듬,algorithms들과 기술techniques들에 대한 것.
ML은 명시적으로 프로그래밍하지 않으면서도 컴퓨터에게 학습(learn) 능력을 주는 인공지능,artificial_intelligence의 하위분야. (Arthur Samuel 1959)

Sub:
기계학습의 분류:[1]
지도학습,supervised_learning - labeled data로 학습
비지도학습,unsupervised_learning - labeled data 없이 학습, 데이터의 숨겨진 구조/특징 발견
'정답지'가 없는 상태에서, 주어진 입력 데이터 중에 비슷한것끼리 묶는(clustering) 것 - 그럼 이 과정 중에 주어진 입력 데이터에 숨어있는 구조를 찾게 되는?
클러스터링,clustering
semi-supervised_learning (writing) - labeled data 및 unlabeled data 둘 다 사용되는? / 이유는 어떤 ML task에 대해서는 labeling이 힘들거나 비싼 작업이므로 이렇게 절충 방식을 사용하는 거라고..?
강화학습,reinforcement_learning - 보상 시스템으로 학습, 의사결정을 위한 최적의 행동,action 선택

maching learning algorithms/models (via Kwak)
maching learning: tasks (via Kwak) ...pagename? 작업,task? 태스크,task?
  • 분류,classification - assign a class label to a data point (ex. 내일 날씨가 어떨까? sunny? rainy? cloudy?)
  • 회귀,regression - continuous output (ex. What is the highest temperature tomorrow?)
  • clustering - divide input data into several groups (unknown class)
  • ...

강의notes tbw
KU석준희
Andrew_Ng
Geoffrey_Hinton
//// 일단 http://sanghyukchun.github.io/ 여기참조.. Coursera ML강의 한국어 summary 몇개 있음. circa 2013-2016.



1. Terms / Topics


클래스 class : The category to which a given object belongs
instance / exemplar
Any given example feature vector of an object
training data // training_data
Data used during training of a classifier for which the correct labels are a priori known
test/validation data // test_data validation_data
Data used to estimate true (generalization) performance of a classifier, for which correct labels are also a priori known
분류기,classifier가 제대로 작동하는지 평가 관련
decision_boundary // 결정경계,decision_boundary
A boundary in the d-dimensional feature space that separates data points of different classes from each other
분류기,classifier
An algorithm which adjusts its parameters to find the correct decision boundaries
error // 오차,error 오류,error
Incorrect labeling of the data by the classifier
cost/loss function // 비용함수,cost_function 손실함수,loss_function
A quantitative measure that represents the cost of making an error or the deviation from the ground truth
Classifier is often trained to minimize this function
training performance
The ability/performance of the classifier in correctly identifying the classes of the training data, which it has already seen
testing performance (Generalization)
The ability/performance of the classifier in identifying the classes of previously unseen data
(Kwak slide 1 p67-70)



쓰이는 곳은 ... (del ok)
예측,prediction
분류,classification
...

2. 사이트

Open Machine Learning Course mlcourse.ai
https://mlcourse.ai/


3. tmp 기계학습 비교표

되먹임,feedback
지도학습,supervised_learning labeled dataset direct feedback predict outcomes
비지도학습,unsupervised_learning unlabeled dataset no feedback find hidden structure
강화학습,reinforcement_learning interacting with the environment reward systemlearn series of actions
KU오승상 딥러닝 01 34m https://www.youtube.com/watch?v=dkm0RrmnH4s

4. 강의 필기 시작

석준희, 데이터학습과지능

In this course,
  • supervised learning
  • unsupervised & reinforcement learning
  • deep learning & visualization

5. 처음배우는머신러닝 책에서 (tmp)

$E\left(\left(y-\hat{f}(x)\right)^2\right)=Bias\left(\hat{f}(x)\right)^2+Var\left(\hat{f}(x)\right)+\sigma^2$
E: 기댓값
σ: 줄일 수 없는 에러
모델이 데이터를 예측할 때 생기는 오류(error)가 편향(bias)의 제곱과 분산(variance)으로 쪼개진다는 것을 보여줌.
모델이 더 나은 성능을 내려면 편향을 줄이거나 분산을 줄여야 한다는 뜻.

$Bias\left(\hat{f}(x)\right)=E\left(\hat{f}(x)\right)-f(x)$
편향: 데이터로 학습한 결과와 이상적인 모델 간의 차이.

$Var\left[\hat{f}(x)\right]=E\left[\left(\hat{f}(x)-E[\hat{f}(x)]\right)^2\right]$
분산: 모델이 학습시마다 얼마나 달라질 수 있는지 나타냄. 일반적으로 모델이 복잡할수록 분산이 더 큼.

6. 1주 1강

기존 program은 predefined and specific rules에 의해 동작. 그래서 (A machine which learns new rules from data)가 필요.
I/O를 각각 environment, action으로 하는 black box가 필요.
Output을 Y, input을 X=(X1, X2, …, Xp)이라 하면 관계는
$Y=f(X)+\epsilon$
  • X: input variables; predictors, observed data, states & actions
  • Y: output variable; target of prediction, assigned cluster(뭐지?), rewards
기존 program은 f가 알려져 있다. 위에서 말한 black box는 f를 알아내야 만들 수 있다.
f는 simple linear function일 수도, complicated nonlinear form일 수도 있다.
f를 estimate하는 이유는 주로 예측,prediction and 추론,inference.

7. Prediction

Based on X, we want to predict Y through f()
$\hat{Y}=\hat{f}(X)$
  • $\hat{Y}$ : 실제 $Y$ 를 추정한 값
  • $\hat{f}$ : 추정되는 $X,Y$ 사이 관계

Prediction의 목적(fundamental goal)은 $Y\textrm{ and }\hat{Y}$ 사이의 error를 최소화하는 것.
$E(Y-\hat{Y})^2=E(Y-\hat{f}(X))^2$
When we accept the Google:square error , it is easy to show
$E(Y-\hat{Y})^2=E\left[f(X)+\epsilon-\hat{f}(X)\right]^2$
$=\underbrace{E\left[f(X)-\hat{f}(X)\right]^2}_{\textrm{Reducible}}+\underbrace{\mathrm{Var}(\epsilon)}_{\textrm{Irreducible}}$

참고로 error의 square가 error의 absolute value( $|Y-\hat{f}(X)|$ )보다 계산하기에 훨씬 수월하다고 한다. 그 이유는 다항함수는 모든 점에서 미분 가능하기 때문.

7.1. Regression Problem vs Classification Problem

Prediction problem에 두 가지가 있는데, 바로 regression & classification.
Problem Prediction for e.g. MSE=
Regression continuous outcome height, salary, lifespan, number of peeing a day $\frac1{n}\sum_{i=1}^{n}\left(y_i-\hat{f}(x_i)\right)^2$
Classification order가 없는 discrete outcome pass or fail, subtyeps of breast cancer, preference to TV channels, M/F $\frac1{n}\sum_{i=1}^{n}I\left(y_i\neq\hat{f}(x_i)\right)$
high/middle/low는 discrete outcome처럼 보이지만 order가 있으므로 classification problem이 아님.
Error는 Google:mean square error (MSE)로 측정한다.
$y_i$ : observed value
$\hat{f}$ : estimated or predicted value
$I(x)$ : indication function; x가 참이면 1, 거짓이면 0



8. Inference


f를 통해 Y와 X의 관계를 이해하는 것

8.1. Estimating f

  • Parametric approach: 관계를 가정 (usually linear)
  • Nonparametric approach: assumes no prior relation
    e.g. tree-based methods, kNN

Model Flexibility
모델이 넓은 범위의 function을 표현할 수 있다면 flexible or complex하다고 한다.
e.g.
$y=a+bx$
$y=a+bx+cx^2$
에서 후자가 더 flexible하다.
neural model은 linear model보다 flexible하다.

Tradeoff between interpretability and flexibility
Spline function이 더 flexible
Linear line이 더 interpretable

9. 1주 2강

10. Types of Learning

Supervised vs. Unsupervised Learning

Supervised learning: both X and Y are given
e.g. prediction and inference

Unsupervised learning: only X is given; Y is unknown or hidden
e.g. clustering (see pics)

Semisupervised learning: 둘의 사이
e.g. supervised clustering, prediction after dimension reduction

Reinforcement learning: finding the next action maximizing rewards
$Y=f(a|X)$
e.g. automated robots


Training set의 MSE를 원하는 만큼 줄일 수 있다. Model flexibility를 증가시킴으로써.

Overfitting
: too much flexibility increase the test set's MSE
WpEn:Overfitting

11. Bias-Variance Tradeoff

MSE can be rewritten by
$E\left[\left(Y-\hat{f}(X)\right)^2\right]=\operatorname{Var}\left[\hat{f}(X)\right]+\left[\operatorname{Bias}\left(\hat{f}(X)\right)\right]^2+\operatorname{Var}(\epsilon)$
앞의 Var, Bias는 reducible하고 그 오른쪽 Var는 irreducible

Variance
: How much $\hat{f}()$ is variable when trained by different training sets
이상적이라면, $\hat{f}()$ 가 너무 variable해선 안됨
Bias
: Error

Variance와 Bias 관계는 화학 첫시간에 했던 그거랑 비슷.

Trade-off: No free lunch
Reducing the variance by reducing the flexibility increase the bias.
Reducing the bias by increasing the flexibility increase the variance.

↓ : reducing, ↑ : increase
flexibility↓ - variance↓ but bias↑
flexibility↑ - bias↓ but variance↑

분산,variance

12. KNN

K-nearest neightbor method
Determine the outcome of a sample, using the k nearest samples of known outcomes
Totally nonparametric
Simple but powerful

k가 작으면 high flexibility.

13. 1-1, 1-2 Summary

  • Machine learning is to find unspecified rules from data
  • Prediction is to guess Y when X is given
  • Inference is to select important X for Y
  • Generally, low model flexibility means high interpretability, high bias, and low variance
  • High model flexibility means low interpretability, low bias, and high variance

14. 2-1

Univariate(일변량/단변량 : 변량이 하나인) Linear Regression
(페이지 만듦: 회귀,regression)

One output variable, one input variable:
$Y\approx\beta_0+\beta_1X$

The data is modeled by
$y_i=\beta_0+\beta_1x_i+e_i$
for $i=1\cdots n$

X, Y는 확률변수,random_variable
x, y는 observed sample values in real data
$e_i$ : 편차,deviation

RSS: residual sum of squares //.... curr goto 잔차,residual
$\mathrm{RSS}=\sum_{i=1}^{n}e_i^2$
$=\sum_{i=1}^{n}(y_i-\hat{\beta}_0-\hat{\beta}_1x_i)^2$
We estimate coefficients by minimizing RSS.
$\hat{\beta}_1=\frac{\textstyle\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})}{\textstyle\sum_{i=1}^{n}(x_i-\bar{x})^2}$
$\hat{\beta}_0=\bar{y}-\hat{\beta}_1x$

Confidence of Coefficient Estimates
  • How much are $\hat{\beta}_0$ and $\hat{\beta}_1$ close to $\beta_0$ and $\beta_1$ ?

  • Recall the mean of population from random samples.
  • Confidence interval:
    $p=\operatorname{Pr}\left[\hat{\mu}-k\operatorname{SE}(\hat{\mu})<\mu<\hat{\mu}+k\operatorname{SE}(\hat{\mu})\right]$
    $\textrm{SE}(\hat{\mu})=\frac{\hat{\sigma}}{\sqrt{n}}$
  • T-test against H0
    $\mu=\mu_0$ using a t-statistic $t=\frac{\hat{\mu}-\mu_0}{\operatorname{SE}(\hat{\mu})}$

16. 강의 필기 끝


17. 역사


Jaime Carbonell et al.의 1983년 논문에 의하면 ML은 지금까지 세 가지 접근법으로 연구되었다.
  1. 신경 모형 패러다임 neural model paradigm; 퍼셉트론,perceptron에서 출발, 이후 심층학습,deep_learning으로 발전
  2. 심볼 개념의 학습 패러다임 symbolic concept-acquisition paradigm: 숫자나 통계 대신 논리,logic학이나 그래프,graph구조 사용; 1970중반-80후반까지 AI의 핵심 접근법
  3. 현대지식의 집약적 패러다임 modern knowledge-intensive paradigm: tabula rasa를 지양, 대표적인 경우가 의사결정 트리 decision tree

CMU의 Tom Mitchell 교수의 저서 Machine Learning에선 학습,learning의 정의를 다음과 같이 내렸다.
만약 컴퓨터 프로그램이 특정한 태스크 T를 수행할 때 성능 P만큼 개선되는 경험 E를 보이면, 그 컴퓨터 프로그램은 태스크 T와 성능 P에 대해 경험 E를 학습했다고 할 수 있다.
Tom Mitchell (1997)
“ A computer program is said to learn from experience E with respect to some class of tasks T and performance measure P, if its performance at tasks in T as measured by P, improves with experience E ”

Ex. 필기체 인식 학습
T: 필기체를 인식하고 분류하는 것
P: 필기체를 정확히 구분한 확률
E: 글자 데이터셋

분류, 군집 같은 기술을 CS 관점에서는 머신러닝이라고 하고 통계,statistics학 관점에서는 데이터마이닝,data_mining이라고 한다. 다만 ML은 학습과 예측에 초점을, DM은 가지고 있는 자료,data에서 현상과 특성을 발견하는 것에 초점을 맞춘다.

18. Softwares

어떤건 심층학습,deep_learning에만 해당? 저기로 mv? 암튼 대충적음, 나중에 mv/fix

텐서플로,TensorFlow
케라스,Keras
{
텐서플로,TensorFlow 위에
... Google:keras
}
토치,Torch
파이토치,PyTorch
MXNet
{
Apache MXNet
엠엑스넷?
... Google:mxnet
}
Caffe
Caffe (Convolutional Architecture for Fast Feature Embedding)
open source (BSD)
developed by Berkeley AI Research (BAIR) Berkeley Vision and Learning Center (BVLC)
image_classification
image_segmentation { WpKo:영상_분할 WpEn:Image_segmentation }
파생: Caffe2 (최초 개발자가 Facebook으로 이직하면서 PyTorch로 흡수?), NVCaffe (Nvidia)
WpEn:Caffe_(software)
Theano
테아노 ?
... Google:theano
CNTK
Microsoft Research
... Google:CNTK

19. Links

로봇공학 / 기계학습 무료 교재(pdf) 15가지
http://t-robotics.blogspot.com/2015/01/pdf-15.html

Machine Learning Engineering Book (mlebook.com)
http://www.mlebook.com/wiki/doku.php
유료이나, draft의 PDF 공개. (Released Drafts of the Chapters: 1-10)
https://news.ycombinator.com/item?id=24726818

모두를 위한 머신러닝/딥러닝 강의
홍콩과기대 김성훈
http://hunkim.github.io/ml/
TensorFlow 사용

via 마스터 알고리즘 책 끝에서
UCI(UC Irvine) Machine Learning Repository https://archive.ics.uci.edu/ml/
https://www.kaggle.com/


Machine Learning  |  Google Developers (Google 머신러닝 교육, 튜토리얼들)
https://developers.google.com/machine-learning?hl=ko

20. tmp links ko

여러 머신러닝 방법론
https://junklee.tistory.com/127

Learning From Data(Abu-Mostafa et al)과, [https]Caltech의 강의(18강) 정리. (한국어, pdf, 11쪽, 2015)
http://theyearlyprophet.com/lfd.html
[ISBN-1600490069]


21. Books


[ISBN-0070428077] http://www.cs.cmu.edu/~tom/mlbook.html ... Machine Learning, Tom Mitchell, McGraw Hill, 1997.

[ISBN-0387310738] Pattern Recognition & Machine Learning - PRML - Christopher Bishop ... Google:prml book
http://norman3.github.io/prml/ - "이 페이지는 PRML을 정리한 문서입니다." (요약)

22. Ref

석준희, 데이터학습과지능(영강)(DATA LEARNING AND INTELLIGENCE(English))
김의중, "인공지능, 머신러닝, 딥러닝 입문"

----