In [48]:
import numpy as np
import os
from sklearn.manifold import TSNE
from common import Data
lld=Data('lld')
lld.load_training_data()
print 'training feature shape: ', lld.feature.shape
print 'training label shape: ', lld.label.shape
#lld.load_test_data()
#print 'test feature shape: ',lld.feature_test.shape
#print 'test label shape: ',lld.label_test.shape
In [42]:
import matplotlib.pyplot as plt
%matplotlib inline
feature_table=[1,10,100,300]
for ind,fea in enumerate(feature_table):
f= lld.feature[:,fea]
plt.subplot(2,2,ind+1)
plt.hist(f)
#plt.title("Histogram of feature "+str(ind))
plt.axis('tight')
In [43]:
model=TSNE(n_components=2,random_state=0) # reduct the dimention to 2 for visualization
np.set_printoptions(suppress=True)
Y=model.fit_transform(lld.feature,lld.label) # the reducted data
In [47]:
plt.scatter(Y[:, 0], Y[:, 1],c=lld.label[:,0],cmap=plt.cm.Spectral)
plt.title('training data')
plt.axis('tight')
print Y.shape