다음은 코퍼스에 카운터 벡터를 적용한 결과입니다.
{'this': 13,
'is': 7,
'last': 8,
'chance': 2,
'and': 0,
'if': 6,
'you': 15,
'do': 3,
'not': 10,
'have': 5,
'will': 14,
'never': 9,
'get': 4,
'any': 1,
'one': 11,
'please': 12}
이번에는 CountVectorizer() 적용 결과를 배열로 변환해 보겠습니다.
코드 10-3 배열 변환
vect.transform(['you will never get any chance.']).toarray()
다음은 배열로 변환한 출력 결과입니다.
array([[0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1]], dtype=int64)