In [2]:
import numpy as np
import pandas as pd
import sklearn as sk
import seaborn as sns
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline
In [3]:
labels = pd.read_csv('trainLabels.csv', header=True)
In [7]:
labels.head()
Out[7]:
In [4]:
data = pd.read_csv('layer2.csv', header=False)
In [6]:
data.head()
Out[6]:
In [8]:
from sklearn.manifold import TSNE
X = data.values
model = TSNE(n_components=2, random_state=0)
vals = model.fit_transform(X)
In [9]:
vals.shape
Out[9]:
In [10]:
labels.values.shape
Out[10]:
In [12]:
forGraph = np.hstack([vals,labels])
In [13]:
header = ["x","y","name","class"]
In [15]:
forSns = pd.DataFrame(forGraph, columns = header)
In [28]:
rightBlob = forSns[forSns['y'] >-8]
In [29]:
rightBlob[rightBlob['class'] == 1]
Out[29]:
In [19]:
forSns.shape
Out[19]:
In [20]:
sns.set_context("notebook", font_scale=1.1)
sns.set_style("ticks")
sns.lmplot('x', 'y',
data=forSns,
hue="class",fit_reg=False)
Out[20]:
In [35]:
model2 = TSNE(n_components=2, random_state=1)
vals2 = model2.fit_transform(X)
forGraph2 = np.hstack([vals2,labels])
forSns2 = pd.DataFrame(forGraph2, columns = header)
sns.lmplot('x', 'y',
data=forSns2,
hue="class",fit_reg=False)
Out[35]:
In [37]:
blob = forSns2[forSns2['y'] >0]
blob[blob['class'] == 2]
Out[37]:
In [38]:
X.shape
Out[38]:
In [ ]: