반응형
블로그 이미지
개발자로서 현장에서 일하면서 새로 접하는 기술들이나 알게된 정보 등을 정리하기 위한 블로그입니다. 운 좋게 미국에서 큰 회사들의 프로젝트에서 컬설턴트로 일하고 있어서 새로운 기술들을 접할 기회가 많이 있습니다. 미국의 IT 프로젝트에서 사용되는 툴들에 대해 많은 분들과 정보를 공유하고 싶습니다.
솔웅

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

카테고리

Elements of AI - The types of machine learning

2018. 6. 16. 05:18 | Posted by 솔웅


반응형


Elements of AI




I.The types of machine learning





Handwritten digits are a classic case that is often used when discussing why we use machine learning, and we will make no exception.

Handwritten digits는 machine learning을 사용하는 이유를 논의 할 때 자주 사용되는 고전적인 사례입니다. 우리도 예외는 아니죠.




Below you can see examples of handwritten images from the very commonly used MNIST dataset.



아래 MNIST 데이터 세트로 일반적으로 사용되는 손글씨 이미지의 예를 보실 수 있습니다. 






The correct label (what digit the writer was supposed to write) is shown above each image. Note that some of the "correct” class labels are questionable: see for example the second image from left: is that really a 7, or actually a 4?



올바른 label (작성자가 작성해야하는 숫자)은 각 이미지 위에 표시됩니다. "correct” 클래스 레이블 중 일부는 의문의 여지가 있습니다. 예를 들어 왼쪽의 두 번째 이미지를보십시오 : 실제로 7입니까, 아니면 실제로 4입니까?



Note

MNIST – What's that?

Every machine learning student knows about the MNIST dataset. Fewer know what the acronym stands for. In fact, we had to look it up to be able to tell you that the M stands for Modified, and NIST stands for National Institute of Standards and Technology. Now you probably know something that an average machine learning expert doesn’t!


모든 machine learning 학생은 MNIST 데이터 세트에 대해 알고 있습니다. 그 중 이것이 어떤것의 약어인지 아는 학생은 거의 없을 겁니다.  사실 M이 Modified를 나타내고 NIST가 National Institute of Standards and Technology의 약자라고 말해 보겠습니다. 이제 일반적인 machine learning 전문가가 아니라는 것을 아실 수 있으시겠죠?




In the most common machine learning problems, exactly one class value is correct at a time. This is also true in the MNIST case, although as we said, the correct answer may often be hard to tell. In this kind of problems, it is not possible that an instance belongs to multiple classes (or none at all) at the same time. What we would like to achieve is an AI method that can be given an image like the ones above, and automatically spit out the correct label (a number between 0 and 9).



가장 일반적인 machine learning 문제는 한 번에 하나의 클래스 값만 정확하다는 겁니다. ### 이것은 우리가 말했듯이 MNIST 케이스에서도 마찬가지 입니다. 종종 정답이 무엇인지 확정할 수 있을 때기 있습니다. 이런 종류의 문제에서는 인스턴스가 동시에 여러 클래스에 속하게 되는 것은 불가능 합니다. 우리가 달성하고자하는 것은 위의 이미지와 같은 이미지를 제공 받고도 correct label (0에서 9 사이의 숫자)을 자동으로 내 놓을 수 있는 AI 방법론 입니다.





Note

How not to solve the problem

An automatic digit recognizer could in principle be built manually by writing down rules such as:


자동 숫자 인식기는 원칙적으로 다음과 같은 규칙을 작성하여 수동으로 작성할 수 있습니다.


  • if the black pixels are mostly in the form of a single loop then the label is 0
  • if the black pixels form two intersecting loops then the label is 8
  • if the black pixels are mostly in a straight vertical line in the middle of the figure then the label is 1

and so on...

This was how AI methods were mostly developed in the 1980s (so called “expert systems”). However, even for such a simple task as digit recognition, the task of writing such rules is very laborious. In fact, the above example rules wouldn’t be specific enough to be implemented by programming – we’d have to define precisely what we mean by “mostly”, “loop”, “line”, “middle”, and so on.



이것은 1980 년대에 개발 된  AI 인공지능 방법론 이었습니다. expert systems라고 불렸죠. 그러나 숫자 인식과 같은 단순한 작업에도 이러한 규칙을 작성하는 작업은 매우 힘듭니다. 실제로, 위의 예제 규칙은 프로그래밍으로 구현하기에 충분히 구체적이지 않습니다. 우리는 "mostly", "loop", "line", "middle"등의 의미를 정확하게 정의해야합니다.



And even if we did all this work, the result would likely be a bad AI method because as you can see, the handwritten digits are often a bit so-and-so, and every rule would need a dozen exceptions.


그리고 우리가 이 모든 작업을 했더라도, 결과는 아마도 안좋은 인공지능 방법론으로 판명 될 것입니다. 왜냐하면 여러분이 보듯이 손으로 쓴 숫자들은 그냥 그렇습니다. 여러분이 만든 룰에 대해 수십개의 예외적인 요소들이 있을 겁니다..







Three types of machine learning


The roots of machine learning are in statistics, which can also be thought of as the art of extracting knowledge from data. Especially methods such as linear regression and Bayesian statistics, which are both already more than two centuries old (!), are even today at the heart of machine learning. For more examples and a brief history, see the timeline of machine learning (Wikipedia).



machine learning의 뿌리는 통계에 있습니다. 데이터로부터 지식을 추출하는 예술이죠. 특히 2 세기 전의 linear regression 선형 회귀 및 Bayesian statistics 와 같은 방법론은 오늘날에도 기계 학습의 핵심입니다. 더 많은 예제와 간단한 역사를 보려면 machine learning (Wikipedia)의 타임 라인을 참조하십시오.




The area of machine learning is often divided in subareas according to the kinds of problems being attacked. A rough categorisation is as follows:


기계 학습 영역은 종종 공격받는 문제의 종류에 따라 하위 영역으로 나뉩니다. 대략적인 분류는 다음과 같습니다.



Supervised learning: We are given an input, for example a photograph with a traffic sign, and the task is to predict the correct output or label, for example which traffic sign is in the picture (speed limit, stop sign, ...). In the simplest cases, the answers are of the form yes/no. (We call these binary classification problems.)



Supervised learning : 우리는 교통 표지가 있는 사진과 같은 입력을받습니다. 그리고 해야 할 일은 해당 사진에 있는 교통 표지(speed limit, stop sign, ...)에 알맞는 output이나 라벨을 예측하는 것입니다. 가장 단순한 경우 답은 예 / 아니오 형식입니다. (우리는 이러한 이진 분류 문제를 호출합니다.)



Unsupervised learning: There are no labels or correct outputs. The task is to discover the structure of the data: for example, grouping similar items to form “clusters”, or reducing the data to a small number of important “dimensions”. Data visualization can also be considered unsupervised learning.



Unsupervised learning : 레이블이나 정확한 결과 outputs가 없습니다. 예를 들어, 유사한 항목을 그룹화하여 "클러스터"를 형성하거나 소수의 중요한 "dimensions"으로 데이터를 축소하는 등의 데이터 구조를 발견해야합니다. 데이터 시각화는 unsupervised learning 으로 간주 될 수도 있습니다.



Reinforcement learning: Commonly used in situations where an AI agent like a self-driving car must operate in an environment and where feedback about good or bad choices is available with some delay. Also used in games where the outcome may be decided only at the end of the game.



Reinforcement learning : 일반적으로 자율 주행 차량과 같은 인공 지능 agent가 한 환경 안에서 작동해야하며 좋은 선택 또는 나쁜 선택에 대한 피드백을 약간의 지연 후에 가능해야 합니다. 또한 게임이 끝날 때만 결과를 결정할 수있는 게임에서도 사용됩니다.



The categories are somewhat overlapping and fuzzy, so a particular method can sometimes be hard to place in one category. For example, as the name suggests, so called semisupervised learning is partly supervised and partly unsupervised.



categories는 다소 겹치고 fuzzy 하기 (뚜렷하지 않기) 때문에 특정 방법을 때로는 한 category에 배치하기가 어려울 수 있습니다. 예를 들어 그 이름에서 알 수 있듯이 semisupervised learning은 부분적으로 supervised 감독 되고 부분적으로 unsupervised 감독을받지 않습니다.



Note

Classification

When it comes to machine learning, we will focus primarily on supervised learning, and in particular, classification tasks. In classification, we observe in input, such as a photograph of a traffic sign, and try to infer its “class”, such as the type of sign (speed limit 80 km/h, pedestrian crossing, stop sign, ...). Other examples of classification tasks include: identification of fake Twitter accounts (input includes the list of followers, and the rate at which they have started following the account, and the class is either fake or real account) and handwritten digit recognition (input is an image, class is 0,...,9).


machine learning 이라고 하면 우리는 주로 supervised learning와 in particular, classification tasks 에 우선적으로 주목합니다.  classification에서 우리는 교통 표지판 사진 같은 입력을 살펴 봅니다. 그리고 그 “class” 를 추론하죠. 즉 표지판의 타입 (speed limit 80 km/h, pedestrian crossing, stop sign, ...) 같은 클래스를 추론하는 겁니다.  classification의 다른 예는 다음과 같습니다 : 가짜 트위터 계정 (입력에는 팔로어 목록, 그 계정을 팔로우 하기 시작한 시기 등이 포함되어 있고 class는 가짜 계정 또는 진짜 계정이 됩니다.) 및 손글씨 숫자 인식 (입력은 이미지, 클래스는 0, ..., 9) 등이 있습니다..






Humans teaching machines: supervised learning



Instead of manually writing down exact rules to do the classification, the point in supervised machine learning is to take a number of examples, label each one by the correct label, and use them to “train” an AI method to automatically recognize the correct label for the training examples as well as (at least hopefully) any other images. This of course requires that the correct labels are provided, which is why we talk about supervised learning. The user who provides the correct labels is a supervisor who guides the learning algorithm towards correct answers so that eventually, the algorithm can independently produce them.



분류 작업 (classification)을 수행하기 위해 정확한 규칙을 수동으로 작성하는 대신, supervised machine learning의 포인트는 examples들의 숫자를 받아서 정확한 레이블로 각각을 레이블 하고 그것을 인공지능 방법론으로 “train” 훈련 해서 training 된 예제들 뿐만 아니라 트레이닝 되지 않은 예제들에 대해서도 정확한 레이블을 자동적으로 인식하도록 하는 겁니다. 이것은 당연히 올바른 레이블이 제공될 것이 요구됩니다. 그렇기 때문에 supervised learning 이라고 하는 겁니다. 올바른 레이블을 제공하는 사용자는 학습 알고리즘을 정답으로 이끄는 감독자이며 그 감독을 바탕으로 결국 알고리즘이 독립적으로 스스로의 알고리즘을 재생성 할 수 있게 되는 겁니다.




In addition to learning how to predict the correct label in a classification problem, supervised learning can also be used in situations where the predicted outcome is a number. Examples include predicting the number of people who will click a Google ad based on the ad content and data about the user’s prior online behavior, predicting the number of traffic accidents based on road conditions and speed limit, or predicting the selling price of real estate based on its location, size, and condition. These problems are called regression. You probably recognize the term linear regression, which is a classical, still very popular technique for regression.




classification 문제에서 올바른 레이블을 예측하는 방법을 배우는 것 외에도 supervised learning은 예측 된 결과가 숫자 인 경우에도 사용할 수 있습니다. 예를 들어 광고 내용과 사용자의 이전 온라인 행동에 대한 데이터를 기반으로 Google 광고를 클릭하는 사람의 수를 예측하고, 도로 상태 및 속도 제한에 따라 교통 사고의 횟수를 예측하거나 부동산의 위치, 크기, 상태등을 기반으로 그 부동산의 판매가를 예측하는 것들이 그것입니다. 이러한 문제를 회귀 (regression)라고 합니다. 아마도 선형 회귀 linear regression라는 용어를 알고 있을 것입니다. 고전적인 용어죠. 이 선형회귀는 여전히 널리 사용되는 기술입니다.



Note

Example

Suppose we have a data set consisting of apartment sales data. For each purchase, we would obviously have the price that was paid, together with the size of the apartment in square meters (or square feet, if you like), and the number of bedrooms, the year of construction, the condition (on a scale from “disaster“ to “spick and span”). We could then use machine learning to train a regression model that predicts the selling price based on these features. See a real-life example here


아파트 판매 데이터로 구성된 데이터 세트가 있다고 가정합시다. 매 구입마다 아파트의 크기와 함께 평방 미터 (또는 원하는 경우 평방 피트), 침실 수, 건축 연도, 조건 ( "재해"에서 "스픽과 스팬"에 대한 조건) 들에 대한 정보를 얻을 수 있습니다. 그런 다음 machine learning을 사용하여 이러한 기능을 기반으로 판매 가격을 예측하는 회귀 regression 모델을 train 할 수 있습니다. 실생활 예를 들어 보겠습니다.






Caveat: Careful with that Machine Learning algorithm



There are a couple potential mistakes that we'd like to make you aware of. They are related to the fact that unless you are careful with the way you apply machine learning methods, you could become too confident about the accuracy of your predictions, and be heavily disappointed when the accuracy turns out to be worse than expected.



우리가 저지를 수 있는 몇가지 잠재적인 mistakes들이 있습니다.. 그들은 당신이 machine learning 방법을 적용하는 방법에 주의하지 않는 한, 예측의 정확성에 대해 너무 확신 할 수 있고, 정확성이 예상보다 나쁠 때 크게 실망 할 수 있다는 사실과 관련이 있습니다.



The first thing to keep in mind in order to avoid big mistakes, is to split your data set into two parts: the training data and the test data. We first train the algorithm using only the training data. This gives us a model or a rule that predicts the output based on the input variables.



큰 실수를 피하기 위해 염두에 두어야 할 첫 번째 사항은 데이터 세트를 training 데이터와 테스트 데이터의 두 부분으로 분리하는 것입니다. 우리는 우선 training 데이터만을 사용하여 알고리즘을 training 시킵니다. 이것은 입력 변수들을 기반으로 출력을 예측하는 모델 또는 규칙을 제공합니다.



To assess how well we can actually predict the outputs, we can't count on the training data. While a model may be a very good predictor in the training data, it is no proof that it can generalize to any other data. This is where the test data comes in handy: we can apply the trained model to predict the outputs for the test data and compare the predictions to the actual outputs (for example, future apartment sale prices).



실제 출력을 얼마나 잘 예측할 수 있는지 평가하기 위해 training data에만 의지할 수 없습니다. 모델이 training 데이터에서 매우 좋은 예측인자 일 수 있지만, 다른 어떤 데이터로도 일반화 할 수 있다는 증거는 아닙니다. 이것이 테스트 데이터를 사용해야 되는 이유입니다. 우리는 trained model을 적용하여 테스트 데이터의 출력을 예측하고 예상 결과를 실제 출력 (예 : 향후 아파트 판매 가격)과 비교할 수 있습니다.




Note

Too fit to be true! Overfitting alert


It is very important to keep in mind that the accuracy of a predictor learned by machine learning can be quite different in the training data and in separate test data. This is the so called overfitting phenomenon, and a lot of machine learning research is focused on avoiding it one way or another. Intuitively, overfitting means trying to be too smart. When predicting the success of a new song by a known artist, you can look at the track record of the artist's earlier songs, and come up with a rule like “if the song is about love, and includes a catchy chorus, it will be top-20“. However, maybe there are two love songs with catchy choruses that didn't make the top-20, so you decide to continue the rule “...except if Sweden or yoga are mentioned“ to improve your rule. This could make your rule fit the past data perfectly, but it could in fact make it work worse on future test data.


training 데이터와 별도의 테스트 데이터에서 machine learning으로 얻은 예측 변수의 정확도가 매우 다를 수 있다는 점을 명심해야합니다. 이것은 소위 오버 피팅 (overfitting) 현상이며, machine learning 연구의 많은 부분은 이를 피하는 데 초점을 맞추고 있습니다. 직관적으로 overfitting은 너무 똑똑한 것을 의미합니다. 알려진 아티스트의 새로운 노래 성공을 예측할 때 아티스트의 이전 곡의 트랙 레코드를 보고 "노래가 사랑에 관한 것이고 괜찮은 코러스를 넣으면 탑 20에 들 것이다. ". 그러나 괜찮은 코러스가 있는 두개의 사랑노래가 탑 20에 들지 못했다면 규칙을 개선하겠죠. "스웨덴이나 요가에 대한 노래를 제외하고....." 같은 예외 조건들을 넣을 겁니다. 이렇게하면 규칙이 과거 데이터에는 잘 맞을 수 있겠지만 사실 미래의 테스트 데이터에서는 더 안 맞을 수 있습니다.



Machine learning methods are especially prone to overfitting because they can try a huge number of different “rules“ until one that fits the training data perfectly is found. Especially methods that are very flexible and can adapt to almost any pattern in the data can overfit unless the amount of data is enormous. For example, compared to quite restricted linear models obtained by linear regression, neural networks can require massive amounts of data before they produce reliable prediction.


Machine learning 방법은 특히 훈련 데이터에 완벽하게 맞는 것이 발견 될 때까지 엄청난 수의 서로 다른 "규칙"을 시도 할 수 있기 때문에 overfitting에 취약합니다. 특히 매우 유연하고 데이터의 거의 모든 패턴에 적용 할 수있는 방법은 데이터 양이 엄청나지 않는 한 과장 될 수 있습니다. 예를 들어, 선형 회귀에 의해 얻어진 매우 제한된 선형 모델과 비교할 때, 신경망은 신뢰할 수있는 예측을 생성하기 전에 엄청난 양의 데이터를 필요로 할 수 있습니다.




Learning to avoid overfitting and choose a model that is not too restricted, nor too flexible, is one of the most essential skills of a data scientist.



overfitting을 피하고 너무 제한적이거나 너무 두리뭉실하지 않은 모델을 고르기 위한 Learning은 data scientist의 가장 핵김 기술 중 하나입니다. 





Learning without a teacher: unsupervised learning



Above we discussed supervised learning where the correct answers are available, and the taks of the machine learning algorithm is to find a model that predicts them based on the input data.



앞에서 우리는 정답이 가능한 supervised learnin에 대해 논의했으며 machine learning 알고리즘의 작업은 입력 데이터를 기반으로 예측하는 모델을 찾는 것이라고 배웠습니다



In unsupervised learning, the correct answers are not provided. This makes the situation quite different since we can't build the model by making it fit the correct answers on training data. It also makes the evaluation of performance more complicated since we can't check whether the learned model is doing well or not.



unsupervised learning에서 정답은 제공되지 않습니다. 이것은 우리가 모델을 training data에 대한 training data를 맞추어서 만들 수 없기 때문에 상황이 상당히 달랐습니다. 또한 학습 된 모델 learned model이 잘 작동하는지 여부를 확인할 수 없으므로 성능 평가가 더 복잡해집니다.



Typical unsupervised learning methods attempt to learn some kind of “structure” underlying the data. This can mean, for example, visualization where similar items are placed near each other and dissimilar items further away from each other. It can also mean clustering where we use the data to identify groups or “clusters” of items that are similar to each other but dissimilar from data in other clusters.


일반적인 unsupervised learning 방법은 데이터의 기초를 이루는 일종의 "구조 structure"를 배우려고 시도합니다. 예를 들어, 비슷한 항목이 서로 가까이 있고 다른 항목이 서로 멀리 떨어져있는 시각화를 의미 할 수 있습니다. 또한 클러스터링을 사용하여 데이터를 사용하여 서로 비슷한 그룹이나 다른 클러스터의 데이터와 다른 그룹의 "클러스터"를 식별 할 수 있습니다.




Note

Example

As a concrete example, grocery store chains collect data about their customers' shopping behavior (that's why you have all those loyalty cards). To better understand their customers, the store can either visualize the data using a graph where each customer is represented by a dot and customers who tend to buy the same products are placed nearer each other than customers who buy different products. Or, the store could apply clustering to obtain a set of customer groups such as ‘low-budget health food enthusiasts’, ‘high-end fish lovers’, ‘soda and pizza 6 days a week’, and so on. Note that the machine learning method would only group the customers into clusters, but it wouldn't automatically generate the cluster labels (‘fish lovers’ and so on). This task would be left for the user.


구체적인 예를 들어, 식료품 점 체인은 고객의 쇼핑 행동에 대한 데이터를 수집합니다 (loyalty cards가있는 이유입니다). 고객을 더 잘 이해하기 위해 각 고객이 점으로 표시되고 동일한 제품을 구매하려는 고객이 다른 제품을 구매하는 고객보다 서로 가깝게 배치되는 그래프를 사용하여 데이터를 시각화 할 수 있습니다. 또는 상점은 클러스터링을 적용하여 '저예산 건강 음식 애호가', '고급 생선 애호가', '일주일에 6 일 동안의 소다 및 피자'등과 같은 일련의 고객 그룹을 얻을 수 있습니다. 기계 학습 방법은 고객을 클러스터로만 그룹화하지만 클러스터 레이블 ( '생선 애호가'등)을 자동으로 생성하지는 않습니다. 이 작업은 사용자를 위해 남겨 둡니다.



Yet another example of unsupervised learning can be termed generative modeling. This has become a prominent approach since the last few years as a deep learning technique called /generative adversarial networks/ (GANs) has lead to great advances. Given some data, for example, photographs of people's faces, a generative model can generate more of the same: more real-looking but artificial images of people's faces.



unsupervised learning의 또 다른 예는 generative modeling 생성 적 모델링이라고 할 수 있습니다. 지난 몇 년 동안 / generative adversarial networks / (GANs)라고 불리는 심층적 인 학습 기법이 큰 진보를 이끌어내는 등 주목할만한 접근 방식이 되었습니다. 예를 들어 사람들의 얼굴 사진과 같은 일부 데이터를 감안할 때 generative modeling 생성 모델은 사람들의 얼굴을 보다 실제처럼 보이지만 인공적인 이미지로 생성합니다.



We will return to GANs and the implications of being able to produce high-quality artificial image content a bit later in the course, but next we will take a closer look at supervised learning and discuss some specific methods in more detail.



우리는 이 GANs를 다시 살펴 볼 것입니다. 이마도 이 코스에서 artificial image content를 만들 수 있겠구나 라고 생각하실 지 모르지만 그건 아니고 다음 단원에서는  supervised learning을 좀 더 자세히 살펴보고 특정 방법들에 대해 조금 더 자세히 얘기 나누겠습니다. 





반응형