Hi
I want to estimate the mutual information based on nearest neighbor method:
http://arxiv.org/pdf/cond-mat/0305641.pdf
This requires me to use the max norm. For which I have defined a function
norm. Not I want Nearest neighbors to fit according to this norm and when I
find the kneighbors I want it to give me kneighbors based on this max norm
but instead I am getting results in Euclidean distances. How do I fix this?
Here is the class that I have created.
class MaxNormNN:
"""
Nearest neighbors based on max norm
"""
def __init__(self, x_dim, y_dim, x, y):
self.x_dim = x_dim
self.y_dim = y_dim
self.x = x
self.y = y
self. z = np.c_[x,y]
def max_norm(self, z1, z2, ord = 1):
x_dist = np.linalg.norm(np.array(z1[:self.x_dim]) - \
np.array(z2[:self.x_dim]), ord = ord)
y_dist = np.linalg.norm(np.array(z1[self.x_dim:]) - \
np.array(z2[self.x_dim:]), ord = ord)
return np.max([x_dist, y_dist])
def NNs(self):
nn = NearestNeighbors(n_neighbors = 2, func = max_norm)
nn.fit(self.z)
# print nn.kneighbors(self.z)
--
sp
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Scikit-learn-general mailing list
Scikit-learn-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/scikit-learn-general