Example #1
0
def spectral_clustering(similarity, concepts=2, euclid=False):
    if euclid:
        X = similarity_euclidean(similarity)
    else:
        X = similarity
        X[X < 0] = 0
    sc = SpectralClusterer(X, kcut=X.shape[0] / 2, mutual=True)
    return sc.run(cluster_number=concepts, KMiter=50, sc_type=2)
Example #2
0
def spectral(similarity, euclid=False):
    if euclid:
        similarity = similarity_euclidean(similarity)
    else:
        similarity[similarity < 0] = 0
    sc = SpectralClusterer(similarity, kcut=similarity.shape[0] / 2, mutual=True)

    sc.run(cluster_number=2, KMiter=50, sc_type=2)
    return (sc.eig_vect[:, 1], sc.eig_vect[:, 2])