Advertisement

AP聚类算法代码

阅读量:

AP聚类算法的测试已于昨晚完成,所参考的内容源自另一位博主的分享,不过其中存在一些细节上的错误。目前该代码已修正完毕,可直接运行。

复制代码
    import sklearn
    import numpy as np
    import matplotlib.pyplot as plt
    from sklearn import *
    
    
    #########设置实验数据################
    
    def init_sample():
    centers = [[1, 1], [-1, -1], [1, -1]]
    # 生成数据
    X, label_true = sklearn.datasets.make_blobs(n_samples=150, centers=centers, cluster_std=0.5, random_state=0)
    return X, label_true
    ##########AP聚类####################
    class AP(object):
    """ AP聚类 """
    
    def __init__(self):
        self.Xn = None
        self.Xn_len = None

全部评论 (0)

还没有任何评论哟~