text_plain_output_1.png
from sklearn.decomposition import TruncatedSVD

from sklearn.feature_extraction.text import TfidfVectorizer

from sklearn.manifold import TSNE

import hypertools as hyp

import pandas as pd

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

messages = pd.read_csv('../input/spam.csv', encoding='latin-1')

messages.drop(['Unnamed: 2', 'Unnamed: 3', 'Unnamed: 4'], axis=1, inplace=True)

messages = messages.rename(columns={'v1': 'class', 'v2': 'text'})

from sklearn.feature_extraction.text import TfidfVectorizer
vectors = TfidfVectorizer().fit_transform(messages.text)

X_reduced = TruncatedSVD(n_components=100, random_state=0).fit_transform(vectors)
tsne = TSNE(n_components=2, perplexity=110, verbose=2).fit_transform(X_reduced)

import hypertools as hyp
hyp.plot(tsne, 'o', group=messages['class'], legend=list({'ham': 0, 'spam': 1}))