Phân tích cảm xúc với Python
Violeta Misheva
Data Scientist
TF: tần suất thuật ngữ: Một từ xuất hiện bao nhiêu lần trong một tài liệu của tập văn bản
IDF: nghịch tần số tài liệu: Tỷ lệ log giữa tổng số tài liệu và số tài liệu chứa từ đó
TfIdf = tần suất thuật ngữ * nghịch tần số tài liệu
# Import the TfidfVectorizer
from sklearn.feature_extraction.text import TfidfVectorizer
vect = TfidfVectorizer(max_features=100).fit(tweets.text)
X = vect.transform(tweets.text)
X
<14640x100 sparse matrix of type '<class 'numpy.float64'>'
with 119182 stored elements in Compressed Sparse Row format>
X_df = pd.DataFrame(X_txt.toarray(), columns=vect.get_feature_names())
X_df.head()
Phân tích cảm xúc với Python