Classification
- Categorizing instances of data into "classes:, where class members share some notion of simiarity ex) having positive sentiment
Tokenization : Splitting the text into units for precessing
- Removing extra spaces: the quality is high
- Removing stop words : article, propositions, etc.
- Contraction are standardizes: won't -> will not
- Removing unhelpful words, e.g., extenral URL links
- Removing unhelpful characters, e.g., non-alphabetical characters.
- Converting capital letter to lowercase
Stemming: wordform stripped of some characters
Lemmatization : the base (or citation) form of a word
Feature Extraction
- We start from raw data, e.g., text, and build values, i.e., features, inteded to be informative and non-redundant to help the subsequent learning and generalization steps.
- Is a non-trivial task and specific to the application
Bag of Words (BoW)
: counting the number of words in the input text.
: 단어들의 순서는 전혀 고려하지 않고, 단어들의 출현 빈도(frequency)만 집중하는 테스트 데이터의 수치화 방법
-> 텍스트 내에 어떤 단어가 중요한지를 알아보기 위함
1. We pick a dictionary of words and then put an arbitary order on the words. 임의의 순서대로
2. We convert the text into a feature vector by reporting the frequency of occurrence of the words in the text.
Limitations of BOW:
1. Insensitive to language structure: "I wanna eat ice cream" VS "wanna eat ice cream?" 데이터 구조에 민감하지 않다
2. Information in word dependencies is overlooked: "new york" VS "new book" 단어 의존성에 대한 정보가 간과됨
3. The resulting vectors are highly sparse which leads to high computatuonal costs 빈벡터가 커지면서 computational 비용이 높아진다.
TF-IDF
: reflect how important a word is to an instance in the dataset.
: 단어의 빈도와 역문서 빈도를 사용하여 DTM내의 각 단어들마다 중요한 정도를 가중치로 준다. 주로 문서의 유사도를 구하거나, 검색시스템에서 검색 결과의 중요도를 정하거나, 문서 내 특정 단어의 중요도를 구하는 데 사용
TF (Term Frequency)
: a measure of how frequently a term t, appears in an instance(document), d:
: 특정문서 d에 특정 단어 t의 등장 횟수를 구함
TF(t, d) = n(t, d) / Number of terms in the document
DF (Document Frequency)
df(t) : 특정 단어 t가 등장한 문서의 수. 단어 t가 몇 번들 오갔는지가 중요한 것이 아니고, t가 몇 개의 문서 안에 들어가 있느냐가 중요함 = document frequency
IDF (Inverse Document Frequency)
: A measurement of how important a term is in the dataset.
df(idf)에 반비례. 아래 수식을보면, log와 +1이 왜 있나 궁금해할 것이다.
- log를 하는 이유는, number of document가 기하급수적으로 커지는 것을 막아준다. 특히, stopwords 불용어 the나 a의 같은 경우에는 거의 모든 문서에 엄청 많이 포함되어 있음 which means that it can be huge.
- 1을 더하는 이유는, 단순히 분모가 0이되는 경우를 막아주기 위해 분모에 1을 더 해준 것이다.
TF-IDF score
: TF-IDF score reflects importance of the word for a particular instance and informative to categorize the documents
TF-IDF scores는 특정 사례에 대한 단어의 중요성을 반영하고 문서를 분류하는 데 유용합니다.
(tf_idf)(t, d) = tf(t, d) * idf(t)
we use TF-IDF to extract the feature vector => X값을 feature vector로 변환하기 위해서 사용 많이 한다.
Statistics Learning
Goal : Finding a predictive function based on an annotated training dataset using probability theory (xi, yi) ~ p(x, y)
Maximum posterior probabilities : P(Y|X) = P(X, Y)/P(X) => P(X,Y) = P(X) P(Y|X)
Generative VS Discriminative Models
Generative | Discriminative |
- Learn a model of the joint probability P(X,Y) | - Model posterior probability P(Y|X) directly |
- Use Bayes' Rule to cacluate P(Y|X) | - Class is a function of feature vector |
- Return the class that most likely to have generated that instance | - Find the exact function that minimizes classification errors on the training dataset and use it for prediction |
- Naive Bayes | - Linear classification, Logistic regression, NNs, SVM - X를 잘 구분하는 지도학습 범주 & decision boundary학습이 목표 |
- 데이터 X가 생성되는 과정을 2개의 확률 모델 P(Y), P(X|Y)로 정의하고, 베이즈를 이용해 P(Y|X)를 간접적으로 도출하는 모델 - 레이블 정보가 있어도 되고 없어도 된다 - 가정 (assumption)이 좋다면 좋은 성능을 기대할 수 있다. |
- 데이터 X가 주어졌을 때, 레이블 Y가 나타날 조건부확률 P(Y|X)를 직접적으로 반환함 |
Generative classifiers VS Discriminative classifiers
Generative classifiers | Discriminative classifiers |
- Generative classifiers directly model the joint probability which is helpful when generating text is necessary | - Discriminative classifiers are more effective since they directly optimize the classification accuracy |
- Modeling the joint probability is a harder problem than classification if only classification is our goal - 분류만이 목적이라면, joint probability는 구하기 어려운 문제이다. 그러므로 분류는 성능 별로 안좋소이다 |
- They are all sensitive to the choice of features, and in tranditional ML these features are extracted heuristically(경험적으로) - 여기에 들어가는 모든 features들은 민감한게 문제여. ML은 보통 경험적으로 추출되어야하는데 모두 민감함 |
- Generative classifiers can easily exploit unlabeled data - 라벨 없이도 쉽게 사용 가능 |
- Overfitting can happen if data is sparse - 데이터가 너무 적으면, 오버피팅 가능성이 있다. |
Bayes Rule
(Multinomial) Naive Bayes Classifier
Chanllenging?
- Computing the joint likelihood probability is practically almost impossible
- Computing the likelihood probability even for single features is practically difficult because many words are not frequently used: superb vs good
- Zero probabilities cannot be conditioned away, no matter the other helpful evidence. 다른 유용한 증거가 있더라도 0 확률은 조건화될 수 없습니다.
- Smoothing: we add samll non-zero probabilities to avoid zero probabilities
Linear classifier
- An interpretation for discriminative models is that we find a boundary between the two classes in the geometrical features space
- A linear classifier assumes that the data points are linearly separable in the feature space
- the gole is to finda boundary
- A linear funcion in n-dimensional space(i.e. we have n features) is define by n+1 weights
- We find the model weights such that the linear function acts as a good predictive model
Linear models is not necessarily unique. It can be many types.
댓글