Last active
March 29, 2017 20:10
-
-
Save tejasshah93/f7e9e7df2b60cdcefdc7b970c7b20fe2 to your computer and use it in GitHub Desktop.
PySparNN custom distance different outputs
This file contains hidden or 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
# In[5]: | |
B = sparse.csr_matrix([[1, 1, 1],[1, 1, 1],[1, 1, 1]]) | |
A = sparse.csr_matrix( | |
[ | |
[2, 2, 1], | |
[1, 0, 1], | |
[1, 1, 1] | |
]) | |
# In[6]: | |
u_dist = UserCustomDistance(A, range(A.shape[0])) | |
u_dist._distance(A) | |
# Out[6]: | |
array([[-2., 1., 0.], | |
[ 1., 1., 1.], | |
[ 0., 1., 0.]]) | |
# In[7]: | |
su_dist = SpencerUserCustomDistance(A, range(A.shape[0])) | |
su_dist._distance(A) | |
# Out[7]: | |
array([[-6, 0, -2], | |
[ 0, 1, 1], | |
[-2, 1, 0]]) | |
# In [8]: | |
u_dist._distance(B) | |
Out[8]: | |
array([[ 0., 1., 0.], | |
[ 0., 1., 0.], | |
[ 0., 1., 0.]]) | |
# In [9]: | |
su_dist._distance(B) | |
Out[9]: | |
array([[-2, 1, 0], | |
[-2, 1, 0], | |
[-2, 1, 0]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment