text_plain_output_1.png
from sklearn.feature_extraction.text import TfidfVectorizer

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

train = pd.read_csv('/kaggle/input/sentiment-analysis-on-movie-reviews/train.tsv.zip', sep='\t')
test = pd.read_csv('/kaggle/input/sentiment-analysis-on-movie-reviews/test.tsv.zip', sep='\t')

train.Sentiment.unique()

from sklearn.feature_extraction.text import TfidfVectorizer
tfv = TfidfVectorizer(min_df=3, max_features=49748, strip_accents='unicode', analyzer='word', token_pattern='\\w{1,}', ngram_range=(1, 3), stop_words='english')
train['Phrase'] = train['Phrase'].fillna('')
tfv_matrix = tfv.fit_transform(train['Phrase'])
tfv_matrix.shape

tfv_matrix