In [1]:
%matplotlib inline
import numpy as np
from sklearn.neighbors import NearestNeighbors
from sklearn import preprocessing
import matplotlib.pyplot as plt

In [2]:
lrgs = np.loadtxt('../data/CFHTLS_LRGs.txt')
features = lrgs[:,2:]
positions = lrgs[:,:2]
scaler = preprocessing.StandardScaler().fit(features)
scaled_features = scaler.transform(features)
test_gal = np.array([.6,25,24,23,22,21])
scaled_test = scaler.transform(test_gal)

In [55]:
nbrFinder = NearestNeighbors(n_neighbors=1,algorithm='auto',metric='euclidean').fit(scaled_features)

In [56]:
dists, inds = nbrFinder.kneighbors(scaled_test)

In [57]:
print dists, inds


[[ 0.19256446]] [[4247]]

In [59]:
positions[4247,:]


Out[59]:
array([ 34.79139747,  -9.97309596])

In [61]:
type(scaler)


Out[61]:
sklearn.preprocessing.data.StandardScaler

In [ ]: