사람이 사용하는 언어(자연어)를 컴퓨터가 이해할 수 있는 언어(숫자) 형태인 벡터로 변환한 결과 혹은 일련 과정
N개의 단어를 각 N차원의 벡터로 표현하는 방식 단어가 포함된 위치에 1, 나머지에 0
one-hot vector들은 하나의 요소만 1값을 가지고 나머지는 모두 0인 sparse vector를 갖게 됨
→ 두 단어에 대한 vector inner product를 구해보면 0 값을 갖게 되어 orthogonal
→ 단어끼리 관계성이 없는 독립적인 관계가 됨
curse of dimensionality
문서 집합에서 단어를 토큰으로 생성하고 각 단어의 출현 빈도수를 이용하여 인코딩해서 벡터를 만드는 방법 즉, 토크나이징과 벡터화가 동시에 가능
corpus = ["When I'm away from you, I miss your touch (ooh)",
"You're the reason I believe in love",
"It's been difficult for me to trust (ooh)",
"And I'm afraid that I'ma fuck it up",
"Ain't no way that I can leave you stranded",
"'Cause you ain't never left me empty-handed",
"And you know that I know that I can't live without you"]
from sklearn.feature_extraction.text import CountVectorizer
vectorizer = CountVectorizer()
vectorizer.fit(corpus)
vectorizer.vocabulary_