1

파이썬 3에서 정서 분석에 참여하고 TDF-IDF 벡터 라이저를 단어 모델로 벡터화하여 문서를 벡터화했습니다.파이썬에서의 문서 벡터화 표현

이렇게 익숙한 사람이라면 결과 행렬 표현이 희박하다는 것을 분명히 알 수 있습니다.

다음은 내 코드 스 니펫입니다. 첫째, 서류들.

tweets = [('Once you get inside you will be impressed with the place.',1),('I got home to see the driest damn wings ever!',0),('An extensive menu provides lots of options for breakfast.',1),('The flair bartenders are absolutely amazing!',1),('My first visit to Hiro was a delight!',1),('Poor service, the waiter made me feel like I was stupid every time he came to the table.',0),('Loved this place.',1),('This restaurant has great food',1), 
     ('Honeslty it did not taste THAT fresh :(',0),('Would not go back.',0), 
     ('I was shocked because no signs indicate cash only.',0), 
     ('Waitress was a little slow in service.',0), 
     ('did not like at all',0),('The food, amazing.',1), 
     ('The burger is good beef, cooked just right.',1), 
     ('They have horrible attitudes towards customers, and talk down to each one when customers do not enjoy their food.',0), 
     ('The cocktails are all handmade and delicious.',1),('This restaurant has terrible food',0), 
     ('Both of the egg rolls were fantastic.',1),('The WORST EXPERIENCE EVER.',0), 
     ('My friend loved the salmon tartar.',1),('Which are small and not worth the price.',0), 
     ('This is the place where I first had pho and it was amazing!!',1), 
     ('Horrible - do not waste your time and money.',0),('Seriously flavorful delights, folks.',1), 
     ('I loved the bacon wrapped dates.',1),('I dressed up to be treated so rudely!',0), 
     ('We literally sat there for 20 minutes with no one asking to take our order.',0), 
     ('you can watch them preparing the delicious food! :)',1),('In the summer, you can dine in a charming outdoor patio - so very delightful.',1)] 

X_train, y_train = zip(*tweets) 

다음 코드는 문서를 벡터화합니다.

tfidfvec = TfidfVectorizer(lowercase=True) 
vectorized = tfidfvec.fit_transform(X_train) 

print(vectorized) 

vectorized을 인쇄 할 때 일반 매트릭스를 출력하지 않습니다. 대신,이 : enter image description here

내가 틀리지 않은 경우, 이것은 희소 매트릭스 표현이어야합니다. 그러나 나는 그 형식과 각 용어의 의미를 이해할 수 없다.

또한 30 개의 문서가 있습니다. 그래서 첫 번째 열에 0-29를 설명합니다. 그것이 추세라면 두 번째 열이 단어의 색인이라고 추측하고 마지막 값은 tf-idf입니까? 내 질문을 입력하는 동안 그것은 단지 나를 때렸다. 그러나 내가 틀리면 친절히 나를 교정해라.

이 경험이있는 사람이라면 누구든지 더 잘 이해할 수 있습니까?

답변

1

예, 기술적으로 처음 두 튜플은 행 - 열 위치를 나타내고 세 번째 열은 해당 위치의 값입니다. 그래서 그것은 기본적으로 0이 아닌 값의 위치와 값을 보여줍니다.