In [1]:
import pandas as pd
In [2]:
from numpy.linalg import inv
import numpy as np
from scipy.linalg import eig
from sklearn.datasets import make_blobs
from sklearn.metrics import pairwise_distances
from diffmaps_util import *
In [3]:
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
In [4]:
%matplotlib nbagg
In [6]:
df = pd.read_csv('annulus.csv')
df = df[['X', 'Y']]
df.head()
Out[6]:
In [7]:
X = df.as_matrix()
In [8]:
plt.scatter(X[:,0], X[:,1])
plt.show()
In [29]:
L = k(X, .1)
print 'L shape %s %s' % L.shape
D = diag(L)
print 'D shape %s %s' % D.shape
M = inv(D).dot(L)
print 'M shape %s %s' % M.shape
w, v = eig(M)
w = np.abs(w.real)
v = v.real
print 'eigenvalue shape %s' % w.shape
print 'eigenvector shape %s %s' % v.shape
In [30]:
w, v = sort_eigens(w, v)
print 'eigenvalue shape %s' % w.shape
print 'eigenvector shape %s %s' % v.shape
In [31]:
psi = v / v[:,0]
psi.shape
Out[31]:
In [32]:
diffmap = (w.reshape(-1,1) * psi.T).T[:,1:]
diffmap.shape
Out[32]:
In [33]:
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
diffmap = (w.reshape(-1,1) * psi.T).T[:,1:]
diffmap.shape
ax.scatter(diffmap[:,0], diffmap[:,1], diffmap[:,2])
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
ax.set_title('T = 1')
Out[33]: