/Machine-Learning-Yahac

๐ŸฆŽBasic tutorials about the basic principles of machine learning and practice using Tensorflow.

Primary LanguageJupyter Notebook

Machine-Learning-Yahac

Chapter 1. What is Machine Learning?

Machine Learning - ๊ธฐ๊ณ„ํ•™์Šต

  • A์™€ B์ œํ’ˆ์„ ๊ตฌ๋งคํ•œ๋‹ค๋Š” ์ƒํ™ฉ์„ ๊ฐ€์ •. A, B์˜ ํŠน์ง•์œผ๋กœ๋Š” ์ˆ˜์‹ญ์—ฌ๊ฐ€์ง€๊ฐ€ ์žˆ๋‹ค. ์–ด๋–ค ๊ฒฐ์ •์„ ํ•  ๊ฒƒ์ธ๊ฐ€?
  • ์ˆซ์ž์˜ ๋ฐœ๋ช…์ดํ›„, ์ธ๋ฅ˜๋Š” ์ปดํ“จํ„ฐ๋ฅผ ๋ฐœ๋ช…. ๋ชจ๋“  ๊ณ„์‚ฐ์„ ์ปดํ“จํ„ฐ์—๊ฒŒ ๋งก๊ธฐ๊ฒŒ ๋จ. ์ธ๊ฐ„์˜ ๊ณ ์œ ํ•œ ์˜์—ญ์ด์—ˆ๋˜ ๊ฒฐ์ •(Decision)์„ ๊ธฐ๊ณ„๊ฐ€ ์Šค์Šค๋กœ ํ•  ์ˆ˜ ์žˆ๋„๋ก ๋งŒ๋“ฌ. ์ด๊ฒƒ์ด ๋ฐ”๋กœ Machine Learning ์ฆ‰, ๊ธฐ๊ณ„ํ•™์Šต์ž„.
  • ์ž๋™์ฐจ๊ฐ€ ๋ฐœ๋ช…๋˜์—ˆ๋‹ค๊ณ  ๋ฐœ์ด ์“ธ๋ชจ์—†์–ด์ง€๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ฉฐ, ๋ง์›๊ฒฝ์ด ๊ฐœ๋ฐœ๋˜์—ˆ๋‹ค๊ณ  ๋ˆˆ์ด ํ•„์š”์—†๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋“ฏ์ด, Machine Learning์˜ ๊ฐœ๋ฐœ๋กœ ๋‘๋‡Œ๊ฐ€ ์“ธ๋ชจ์—†์–ด์ง€๋Š” ๊ฒƒ์€ ๊ฒฐ์ฝ” ์•„๋‹˜.

Machine Learning ์˜ ์„ธ๊ฐ€์ง€ KeyWord

  • ์›๋ฆฌ
  • ์ˆ˜ํ•™
  • ์ฝ”๋”ฉ
  • Machine Learning ์ž์ฒด๋ฅผ ๋‹ค๋ฃจ๋Š”๋ฐ์— ๋ฐ˜๋“œ์‹œ ์ˆ˜ํ•™๊ณผ ์ฝ”๋”ฉ์ด ํ•„์š”ํ•œ ๊ฒƒ์€ ์•„๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ, ์–ธ์  ๊ฐ€ Machine Learning์˜ ๊ถ๊ทน์ ์ธ ๋ชฉํ‘œ๋ฅผ ๋‹ฌ์„ฑํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š”, ๋ฐ˜๋“œ์‹œ ์ˆ˜ํ•™๊ณผ ์ฝ”๋”ฉ์ด ํ•„์š”ํ•˜๋‹ค.

๋ฐ์ดํ„ฐ์…‹์˜ ๋‹ค์–‘ํ•œ ์ด๋ฆ„

ํ–‰(row)

  • ๊ฐœ์ฒด (instance)
  • ๊ด€์ธก์น˜ (observed value)
  • ๊ธฐ๋ก (record)
  • ์‚ฌ๋ก€ (example)
  • ๊ฒฝ์šฐ (case)

์—ด(column)

  • ํŠน์„ฑ (feature)
  • ์†์„ฑ (attribute)
  • ๋ณ€์ˆ˜ (variable)
  • field

๊ธฐ๊ณ„ํ•™์Šต (Machine Learning) ์˜ ์ข…๋ฅ˜

  1. ๊ฐ•ํ™”ํ•™์Šต(reinforcement learning)
  • ํ˜„์žฌ์˜ ์ƒํƒœ(State)์—์„œ ์–ด๋–ค ํ–‰๋™(Action)์„ ์ทจํ•˜๋Š” ๊ฒƒ์ด ์ตœ์ ์ธ์ง€๋ฅผ ํ•™์Šตํ•˜๋Š” ๊ฒƒ
  1. ์ง€๋„ํ•™์Šต (supervised learning)
  • ๋ถ„๋ฅ˜(classification)
    • ๊ณต๋ถ€์‹œ๊ฐ„์— ๋”ฐ๋ฅธ ํ•ฉ๊ฒฉ์—ฌ๋ถ€, ์ข…์–‘์˜ ๋‘๊ป˜์— ๋”ฐ๋ฅธ ์•…์„ฑ์ข…์–‘์˜ ์–‘์„ฑ ์Œ์„ฑํŒ๋‹จ, ์‹ ์ฒด๊ฒ€์‚ฌ, ๋ฉ”์ผ ๋ฐœ์‹ ์ธ ์ œ๋ชฉ ๋ณธ๋ฌธ๋‚ด์šฉ์œผ๋กœ ์ŠคํŒธ ๋ฉ”์ผ ์—ฌ๋ถ€ ํŒ๋‹จ, ๊ณ ๊ธฐ์˜ ์ง€๋ฐฉํ•จ๋Ÿ‰, ์ง€๋ฐฉ์ƒ‰, ์„ฑ์ˆ™๋„, ์œก์ƒ‰์œผ๋กœ ๋“ฑ๊ธ‰ ํŒ๋‹จ ๋“ฑ.
  • ํšŒ๊ท€(regression)
    • ๊ฒฐ๊ณผ๊ฐ€ ์‹œ๊ฐ„, ์˜จ๋„, ์ง‘ ๊ฐ’,๊ธฐ์˜จ ๋ณ€ํ™”๋Ÿ‰, ์ž๋™์ฐจ ์ถฉ๋Œ ์‹œ ์‚ฌ๋งํ™•๋ฅ , ๋‚˜์ด, ํ‚ค ๋“ฑ์˜ ์ˆซ์ž ๋ฐ์ดํ„ฐ

3 .๋น„์ง€๋„ํ•™์Šต (unsupervised learning)

  • ๊ตฐ์ง‘ํ™” (clustering)
    • ๋น„์Šทํ•œ ๊ฒƒ ๋ผ๋ฆฌ ๊ทธ๋ฃน์„ ๋งŒ๋“ค์–ด ๋ฐฐ์น˜.
  • ์—ฐ๊ด€ (association)
    • ๊ด€์ธก์น˜์˜ ํŠน์„ฑ์„ ๊ทธ๋ฃนํ™” ํ•ด์ฃผ๋Š” ๊ฒƒ.
  • ๋ณ€ํ™˜ (transform)

Chapter 2. Tensorflow

Tensorflow๊ฐ€ ์‚ฌ์šฉ๋˜๋Š” ๊ณณ

  • Supervised Learning
    • Regression
    • Classification

Deep Learning Library

  • Tensorflow
  • PyTorch
  • Caffe2
  • Theano

Algorithm

  • Decision Tree
  • Random Forest
  • KNN (K-Nearnest Neighbor)
  • SVM (Support Vector Machine)
  • Neural Network Deep Learning

Supervised Learning Process

  1. ๊ณผ๊ฑฐ์˜ ๋ฐ์ดํ„ฐ ์ค€๋น„
  2. ๋ชจ๋ธ ๊ตฌ์กฐ ์ƒ์„ฑ
  3. ๋ฐ์ดํ„ฐ๋ฅผ ๋ชจ๋ธ๋กœ ํ•™์Šต(Fit)์‹œํ‚จ๋‹ค.
  4. ๋ชจ๋ธ์„ ์ด์šฉํ•œ๋‹ค.

Loss ๋ž€?

  • ํ•™์Šต์˜ ์ง„ํ–‰๋„๋ฅผ ์•Œ๋ ค์ฃผ๋Š” ์ง€ํ‘œ
    • ๋…๋ฆฝ๋ณ€์ˆ˜๋ฅผ ๋ชจ๋ธ์— ๋„ฃ์–ด ๋‚˜์˜จ ์˜ˆ์ธก๊ฐ’, ์‹ค์ œ ๊ฒฐ๊ณผ ๊ฐ’์„ ์ด์šฉํ•˜์—ฌ Loss๋ฅผ ๊ตฌํ•จ.
    • Loss ๋Š” (์˜ˆ์ธก๊ฐ’ - ๊ฒฐ๊ณผ๊ฐ’)^2 ์˜ ํ‰๊ท ๊ฐ’์ž„,
    • Loss ๊ฐ€ 0์— ๊ฐ€๊นŒ์›Œ์งˆ์ˆ˜๋ก ์ •ํ™•ํ•œ ๋ชจ๋ธ์ž„.

์ˆ˜์‹

  • y = w1x1 + w2x2 + โ‹ฏโ‹ฏ + w13x13 + b
  • ์ด ๋ชจ๋ธ์€ ํผ์…‰ํŠธ๋ก (Perceptron) ์ด๋ผ๊ณ  ๋ถ€๋ฆ„.
  • ๊ฐ๊ฐ์˜ w๋“ค์€ ๊ฐ€์ค‘์น˜(Weight) ๋ผ๊ณ  ๋ถ€๋ฆ„.
  • b๋Š” ํŽธํ–ฅ(Bias)๋ผ๊ณ  ๋ถ€๋ฆ„.

์› ํ•ซ ์ธ์ฝ”๋”ฉ (Onehot-encoding)

  • ๋ฒ”์ฃผํ˜• ๋ฐ์ดํ„ฐ๋ฅผ ์ˆ˜์น˜ํ˜•์œผ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ๊ณผ์ •
  • ๋…๋ฆฝ๋ณ€์ˆ˜๋Š” X์˜ ๊ฐœ์ˆ˜
  • ์ข…์†๋ณ€์ˆ˜๋Š” ๋ฒ”์ฃผํ˜• ๋ฐ์ดํ„ฐ์˜ ์ข…๋ฅ˜์ˆ˜

(+ Softmax, Sigmoid)

์€๋‹‰์ธต (Hidden Layer)

  • ๊ธฐ์กด์˜ Perceptron์„ ์—ฌ๋Ÿฌ๊ฐœ ์‚ฌ์šฉํ•˜์—ฌ ์—ฐ๊ฒฐํ•˜๋ฉด ๋จ.
  • ์ž…๋ ฅ(Input Layer)๊ณผ ์ถœ๋ ฅ(Output Layer) ์‚ฌ์ด์— ์ถ”๊ฐ€๋˜๋Š” ๊ฒƒ์ด Hidden Layer์ž„.
  • Hidden Layer๋ฅผ ์ด์šฉํ•˜์—ฌ Multi Layer๋ฅผ ๊ตฌํ˜„ํ•˜๋ฉด ๋” ์ •ํ™•๋„ ๋†’์€ ๋ชจ๋ธ์„ ๊ตฌํ˜„๊ฐ€๋Šฅ.