예제 #1
0
파일: mds.py 프로젝트: foreverjay/divisi2
def compute_distances(matrix1, matrix2):
    nmatrix1 = normalize(matrix1)
    nmatrix2 = normalize(matrix2)
    distances = np.arccos(np.maximum(-1, np.minimum(1, dot(nmatrix1, nmatrix2.T))))
    assert isinstance(distances, DenseMatrix)
    assert distances.same_row_labels_as(nmatrix1)
    return multiply(distances, distances)
예제 #2
0
파일: mds.py 프로젝트: blazarus/charmme
def compute_distances(matrix1, matrix2):
    nmatrix1 = normalize(matrix1)
    nmatrix2 = normalize(matrix2)
    distances = np.arccos(
        np.maximum(-1, np.minimum(1, dot(nmatrix1, nmatrix2.T))))
    assert isinstance(distances, DenseMatrix)
    assert distances.same_row_labels_as(nmatrix1)
    return multiply(distances, distances)
예제 #3
0
파일: mds.py 프로젝트: blazarus/charmme
    def project(self, vector):
        # vector can in fact be a matrix of many vectors

        # Dimensions:
        # vector = (m x ndim) or possibly just (ndim),
        #   with ndim = K from the SVD
        # dist = (m x N)
        # means = (N)
        # mdsarray_sharp = (N x k)
        dist = (compute_distances(vector, self.landmarks) - self.means) / 2
        return dot(dist, -self.mdsarray_sharp)
예제 #4
0
파일: mds.py 프로젝트: foreverjay/divisi2
    def project(self, vector):
        # vector can in fact be a matrix of many vectors

        # Dimensions:
        # vector = (m x ndim) or possibly just (ndim),
        #   with ndim = K from the SVD
        # dist = (m x N)
        # means = (N)
        # mdsarray_sharp = (N x k)
        dist = (compute_distances(vector, self.landmarks) - self.means) / 2
        return dot(dist, -self.mdsarray_sharp)