Skip to content

Commit

Permalink
Added HLLE and LTSA to swissroll graphical example
Browse files Browse the repository at this point in the history
  • Loading branch information
lisitsyn committed Jul 27, 2011
1 parent 34dfe53 commit ec69179
Showing 1 changed file with 16 additions and 6 deletions.
Expand Up @@ -7,7 +7,7 @@
from shogun.Preprocessor import LocallyLinearEmbedding
lle = LocallyLinearEmbedding()
lle.set_k(9)
preprocs.append((lle, "Locally Linear Embedding with k=%d" % lle.get_k()))
preprocs.append((lle, "LLE with k=%d" % lle.get_k()))

from shogun.Preprocessor import ClassicMDS
mds = ClassicMDS()
Expand All @@ -16,26 +16,36 @@
from shogun.Preprocessor import LandmarkMDS
lmds = LandmarkMDS()
lmds.set_landmark_number(50)
preprocs.append((lmds,"Landmark MDS with %d landmarks" % lmds.get_landmark_number()))
preprocs.append((lmds,"LMDS with %d landmarks" % lmds.get_landmark_number()))

from shogun.Preprocessor import ClassicIsomap, KISOMAP
cisomap = ClassicIsomap()
cisomap.set_type(KISOMAP)
cisomap.set_k(9)
preprocs.append((cisomap,"Classic K-Isomap with k=%d" % cisomap.get_k()))
preprocs.append((cisomap,"K-Isomap with k=%d" % cisomap.get_k()))

from shogun.Preprocessor import LandmarkIsomap
lisomap = LandmarkIsomap()
lisomap.set_landmark_number(50)
lisomap.set_type(KISOMAP)
lisomap.set_k(9)
preprocs.append((lisomap,"L-K-Isomap with k=%d, %d landmarks" % (lisomap.get_k(),lisomap.get_landmark_number())))
preprocs.append((lisomap,"K-LIsomap with k=%d, %d landmarks" % (lisomap.get_k(),lisomap.get_landmark_number())))

from shogun.Preprocessor import HessianLocallyLinearEmbedding
hlle = HessianLocallyLinearEmbedding()
hlle.set_k(6)
preprocs.append((hlle,"Hessian LLE with k=%d" % (hlle.get_k())))

from shogun.Preprocessor import LocalTangentSpaceAlignment
ltsa = LocalTangentSpaceAlignment()
ltsa.set_k(6)
preprocs.append((ltsa,"LTSA with k=%d" % (ltsa.get_k())))

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

fig = plt.figure()
swiss_roll_fig = fig.add_subplot(len(preprocs)/2+1,len(preprocs)/2,1,projection='3d')
swiss_roll_fig = fig.add_subplot(3,3,1,projection='3d')
swiss_roll_fig.scatter(X[0], X[1], X[2], s=10, c=tt, cmap=plt.cm.Spectral)
plt.subplots_adjust(hspace=0.4)

Expand All @@ -46,7 +56,7 @@
features = RealFeatures(X)
preproc.set_target_dim(2)
new_feats = preproc.apply_to_feature_matrix(features)
preproc_subplot = fig.add_subplot(len(preprocs)/2+1,len(preprocs)/2,i+2)
preproc_subplot = fig.add_subplot(3,3,i+2)
preproc_subplot.scatter(new_feats[0],new_feats[1], c=tt, cmap=plt.cm.Spectral)
plt.title(label)
print preproc.get_name(), 'done'
Expand Down

0 comments on commit ec69179

Please sign in to comment.