[ML] 머신러닝 기초

_·2024년 7월 29일

머신러닝

목록 보기
1/6
post-thumbnail

Hands-On Machine Learning with Scikit-Learn and TensorFlow 책을 공부하고 내용을 정리한 글이다.

Machine Learning

머신러닝이란 별도의 프로그래밍 없이 데이터로부터 스스로 학습하여 개선하는 것이다.

ML을 사용하는 이유는 튜닝이 길게 필요하거나 많은 규칙을 가지고 있는 문제 해결에 대해 더 빠르고 간단하게 알고리즘을 수행할 수 있고, 새로운 데이터나 규칙에 대한 적응이 쉽다. 또한, 학습 과정이나 사용된 데이터를 사람이 확인할 수 있다.

Supervised Learning

알고리즘에 사용되는 training data에 label이 포함되어 있는 경우로, 대표적으로 classification, regression(Logistic Regression은 classification 문제로 사용될 수 있다)

Unsupervised Learning

이는 training data에 label이 포함되어 있지 않은 경우로, 대표적으로 Clustering이 해당된다.

Semisupervised Learning

부분적으로 label된 데이터를 사용한 알고리즘을 Semiunsupervised Learning이라고 한다. 예를 들어, Deep Belieft Networks(DBN)이라고 있는데, unsupervised된 데이터를 활용하지만 해당 데이터가 학습될 때는 supervised된 학습 방법을 사용한다.

Reinforcement Learning

학습 시스템(agent)에서 환경을 살펴보고 학습을 할 때, 보상을 받으며 작동한다. 가장 많은 보상(reward)를 갖기 위한 최고의 전략(policy)을 발견한다. reward나 penalty에 따라 policy를 업데이트하는 학습 과정을 거친다.

Batch Learning

사용할 수 있는 모든 데이터를 활용하기에 시간도 오래 걸리고 컴퓨팅 자원도 많이 소모하여 주로 오프라인으로 이루어진다. 점진적으로 학습이 불가능하기에, 새로운 데이터가 들어왔을 때 새로운 데이터만을 추가 학습시키는 것이 아닌 기존의 데이터를 포함하여 전체를 학습시켜야 한다.

Online Learning

미니 배치라고 불리는 단위로 데이터를 학습시킨다. 연속적으로 데이터를 입력받을 수 있고, 변화를 빠르고 자동적으로 반영할 수 있다.

Instance-Based Learning

유사성 측정을 통해 입력된 새로운 데이터와 기존 데이터를 비교하여 일반화(generalize) 한다.

Model-Based Learning

다른 generalization 방법은 모델을 구축하여 새로 입력된 데이터를 모델을 사용하여 예측하는 것이다.


Appropriate Data

ML에 사용될 데이터는 충분해야 하고, 대표적(새로운 케이스를 잘 나타내야 한다)이어야 한다. 좋은 퀄리티의 데이터(error, outlier, noise X)이어야 한다.

관계가 있는 Feature를 사용해야 한다. Overfitting, Underfitting 되지 않도록 유의해야 한다.

parameter는 모델 학습 과정에서 데이터로부터 발생되는 변수이고, hyperparameter는 학습 과정 이전에 미리 설정해두는 변수이다.

Testing & Validating

모델이 일반화가 잘 되는지 확인하기 위해서는 직접 새로운 데이터를 모델에 적용하는 방법이 있을 것이다. 그 결과와 과정을 모니터링하며 확인해본다.

이 때, 데이터를 training data와 test data로 분리한다. training data로 학습을 진행하고 test data로 test를 진행했을 때 나오는 에러로 모델 성능을 평가한다.

Hyperparameter Tuning & Model Selection

모델을 여러 번 실행시켜보고 에러가 작다고 판단하여 좋은 모델로 선정했음에도, 새로운 데이터에 적용시켰을 때 성능이 그만큼 좋게 나오지 않는 경우를 본 적 있을 것이다.
이는 같은 데이터로 여러번 test를 진행했기 때문에 특정 데이터에 특화된 모델이 만들어졌기 때문이다.

이를 방지하기 위해 나온 방법은 holdout validation이다. 데이터 중 일부(training dataset에서)를 따로 빼두어 모델 성능 비교를 위한 데이터셋으로 남겨두는 것이다.

또는 cross validation 방법을 사용할 수 있다. 하지만, 이는 validation dataset 수에 따라 학습 시간이 늘어난다는 단점이 있다.


No Free Launch Theorem

ML을 위한 알고리즘 중에서 모든 문제를 해결하기 위한 가장 좋은 성능의 알고리즘이 딱 정해져 있는 것이 아니다. 가장 좋은 성능의 알고리즘을 찾기 위해서는 직접 모델을 다 실행하고 평가해보아야 알 수 있는 것이다.


Exercise

  1. How would you define Machine Learning?
  2. Can you name four types of problems where it shines?
  3. What is a labeled training set?
  4. What are the two most common supervised tasks?
  5. Can you name four common unsupervised tasks?
  6. What type of Machine Learning algorithm would you use to allow a robot to
    walk in various unknown terrains?
  7. What type of algorithm would you use to segment your customers into multiple
    groups?
  8. Would you frame the problem of spam detection as a supervised learning prob‐
    lem or an unsupervised learning problem?
  9. What is an online learning system?
  10. What is out-of-core learning?
  11. What type of learning algorithm relies on a similarity measure to make predic‐
    tions?
  12. What is the difference between a model parameter and a learning algorithm’s
    hyperparameter?
  13. What do model-based learning algorithms search for? What is the most common
    strategy they use to succeed? How do they make predictions?
  14. Can you name four of the main challenges in Machine Learning?
  15. If your model performs great on the training data but generalizes poorly to new
    instances, what is happening? Can you name three possible solutions?
  16. What is a test set and why would you want to use it?
    34 | Chapter 1: The Machine Learning Landscape
  17. What is the purpose of a validation set?
  18. What can go wrong if you tune hyperparameters using the test set?
  19. What is repeated cross-validation and why would you prefer it to using a single
    validation set?
profile
Hi

0개의 댓글