src/core/util.py
def spectral_clustering(x, scale, n_nbrs=None, affinity='full', W=None):
    '''
    Computes the eigenvectors of the graph Laplacian of x,
    using the full Gaussian affinity matrix (full), the
    symmetrized Gaussian affinity matrix with k nonzero
    affinities for each point (knn), or the Siamese affinity
    matrix (siamese)

    x:          input data
    n_nbrs:     number of neighbors used
    affinity:   the aforementeiond affinity mode

    returns:    the eigenvectors of the spectral clustering algorithm
    '''
    if affinity == 'full':
        W =  K.eval(cf.full_affinity(K.variable(x), scale))
    elif affinity == 'knn':
        if n_nbrs is None:
            raise ValueError('n_nbrs must be provided if affinity = knn!')
        W =  K.eval(cf.knn_affinity(K.variable(x), scale, n_nbrs))
    elif affinity == 'siamese':
        if W is None:
            print ('no affinity matrix supplied')
            return
    d = np.sum(W, axis=1)
    D = np.diag(d)
    # (unnormalized) graph laplacian for spectral clustering
    L = D - W
    Lambda, V = np.linalg.eigh(L)
    return(Lambda, V)

    Computes the eigenvectors of the graph Laplacian of x,
    using the full Gaussian affinity matrix (full), the
    symmetrized Gaussian affinity matrix with k nonzero
    affinities for each point (knn), or the Siamese affinity
    matrix (siamese)

    x:          input data
    n_nbrs:     number of neighbors used
    affinity:   the aforementeiond affinity mode

    returns:    the eigenvectors of the spectral clustering algorithm
    
Computes the eigenvectors of the graph Laplacian of x,
using the full Gaussian affinity matrix (full), the
symmetrized Gaussian affinity matrix with k nonzero
affinities for each point (knn), or the Siamese affinity
matrix (siamese)

input data
n_nbrs:     number of neighbors used
affinity:   the aforementeiond affinity mode

the eigenvectors of the spectral clustering algorithm
Computes the eigenvectors of the graph Laplacian of x using the full Gaussian affinity matrix ( full ) the symmetrized Gaussian affinity matrix with k nonzero affinities for each point ( knn ) or the Siamese affinity matrix ( siamese ) input data n_nbrs : number of neighbors used affinity : the aforementeiond affinity mode the eigenvectors of the spectral clustering algorithm
def spectral_clustering(x, scale, n_nbrs=None, affinity='full', W=None):
    if affinity == 'full':
        W =  K.eval(cf.full_affinity(K.variable(x), scale))
    elif affinity == 'knn':
        if n_nbrs is None:
            raise ValueError('n_nbrs must be provided if affinity = knn!')
        W =  K.eval(cf.knn_affinity(K.variable(x), scale, n_nbrs))
    elif affinity == 'siamese':
        if W is None:
            print ('no affinity matrix supplied')
            return
    d = np.sum(W, axis=1)
    D = np.diag(d)
    L = D - W
    Lambda, V = np.linalg.eigh(L)
    return(Lambda, V)
def spectral_clustering ( x , scale , n_nbrs = None , affinity = 'full' , W = None ) : if affinity == 'full' : W = K . eval ( cf . full_affinity ( K . variable ( x ) , scale ) ) elif affinity == 'knn' : if n_nbrs is None : raise ValueError ( 'n_nbrs must be provided if affinity = knn!' ) W = K . eval ( cf . knn_affinity ( K . variable ( x ) , scale , n_nbrs ) ) elif affinity == 'siamese' : if W is None : print ( 'no affinity matrix supplied' ) return d = np . sum ( W , axis = 1 ) D = np . diag ( d ) L = D - W Lambda , V = np . linalg . eigh ( L ) return ( Lambda , V )
Computes the eigenvectors of the graph Laplacian of x,
using the full Gaussian affinity matrix (full), the
symmetrized Gaussian affinity matrix with k nonzero
affinities for each point (knn), or the Siamese affinity
matrix (siamese)
Computes the eigenvectors of the graph Laplacian of x using the full Gaussian affinity matrix ( full ) the symmetrized Gaussian affinity matrix with k nonzero affinities for each point ( knn ) or the Siamese affinity matrix ( siamese )
'''
    Computes the eigenvectors of the graph Laplacian of x,
    using the full Gaussian affinity matrix (full), the
    symmetrized Gaussian affinity matrix with k nonzero
    affinities for each point (knn), or the Siamese affinity
    matrix (siamese)

    x:          input data
    n_nbrs:     number of neighbors used
    affinity:   the aforementeiond affinity mode

    returns:    the eigenvectors of the spectral clustering algorithm
    ''' # (unnormalized) graph laplacian for spectral clustering
x
scale
n_nbrs
affinity
W