-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compute EMD with ITML and t-SNE ground metrics
- Loading branch information
Showing
3 changed files
with
37 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#! /usr/bin/python2 | ||
# vim: set fileencoding=utf-8 | ||
"""Distance function between two venues for ITML and t-SNE.""" | ||
import scipy.io as sio | ||
import numpy as np | ||
|
||
COV = sio.loadmat('ITMLall.mat')['A'] | ||
# pylint: disable=E1101 | ||
COV = np.insert(COV, 5, values=0, axis=1) | ||
COV = np.insert(COV, 5, values=0, axis=0) | ||
COV[5, 5] = 1.0 | ||
COV = np.linalg.inv(COV) | ||
|
||
|
||
def dst_itml(u, v, _): | ||
return scipy.spatial.distance.mahalanobis(u, v, COV) | ||
|
||
|
||
def dst_tsne(u, v, _): | ||
return math.sqrt((u[0] - v[0])*(u[0] - v[0]) + (u[1] - v[1])*(u[1] - v[1])) |