一份为KREpresentives和LSHK代表准备的套餐

krepresentatives的Python项目详细描述


用于聚类分类数据的k-Representatives和LSH-k-Representatives算法的Python实现:

与k-模式算法不同,k-代表和LSH-k-代表定义了保持聚类所有分类值频率的“代表”。在

安装:

使用pip:

pip install krepresentatives

导入包:

^{pr2}$

生成一个简单的分类数据集:

X= np.array([[0,0],[0,1],[0,0],[1,1],[2,2],[2,3],[2,3]])y= np.array([0,0,0,0,1,1,1])

k代表:

kreps= kRepresentatives(X,y,n_init=5,n_clusters=2 ,verbose=3)
kreps.fit_predict()

内置评估指标:

kreps.CalcScore()

输出:

kRepresentatives Init 0
Iter 0  Cost: 8.00  Move: 0  Num empty: 0  Timelapse: 0.00
Iter 1  Cost: 4.83  Move: 0  Num empty: 0  Timelapse: 0.00
Iter 2  Cost: 4.83  Move: 0  Num empty: 0  Timelapse: 0.00
kRepresentatives Init 1
Iter 0  Cost: 9.48  Move: 0  Num empty: 0  Timelapse: 0.00
Iter 1  Cost: 6.50  Move: 1  Num empty: 0  Timelapse: 0.00
Iter 2  Cost: 5.33  Move: 0  Num empty: 0  Timelapse: 0.00
Iter 3  Cost: 5.33  Move: 0  Num empty: 0  Timelapse: 0.00
kRepresentatives Init 2
Iter 0  Cost: 9.08  Move: 0  Num empty: 0  Timelapse: 0.00
Iter 1  Cost: 7.60  Move: 0  Num empty: 0  Timelapse: 0.00
Iter 2  Cost: 7.60  Move: 0  Num empty: 0  Timelapse: 0.00
kRepresentatives Init 3
Iter 0  Cost: 9.31  Move: 0  Num empty: 0  Timelapse: 0.00
Iter 1  Cost: 6.50  Move: 1  Num empty: 0  Timelapse: 0.00
Iter 2  Cost: 5.33  Move: 0  Num empty: 0  Timelapse: 0.00
Iter 3  Cost: 5.33  Move: 0  Num empty: 0  Timelapse: 0.00
kRepresentatives Init 4
Iter 0  Cost: 9.42  Move: 0  Num empty: 0  Timelapse: 0.00
Iter 1  Cost: 7.60  Move: 0  Num empty: 0  Timelapse: 0.00
Iter 2  Cost: 7.60  Move: 0  Num empty: 0  Timelapse: 0.00
Score:  4.833333333333334  Time: 0.0015569399999999956
Purity: 1.00 NMI: 1.00 ARI: 1.00 Sil:  0.52 Acc: 1.00 Recall: 1.00 Precision: 1.00

参数:

X:分类数据集
y: 对象标签(仅供评估)
n_init:初始化次数
n_clusters:目标簇数
最大迭代次数:最大迭代次数
冗长:
随机状态:

输出:

集群代表:最终代表名单
标签:预测标签
成本:物体到质心的距离平方和
迭代次数
epoch_costs_u:初始化的平均时间

LSH-k-代表:待更新

参考文献:

[1]San,Ohn Mar,Van Nam Huynh和Yoshiteru Nakamori。”分类数据聚类k-means算法的另一种扩展〉,《国际应用数学和计算机科学杂志》14(2004):241-247。 [2] 待更新

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Android:如何写入特定行,Java   Java中从欧元货币字符串中删除空格的数字   Java非均匀多维数组   解密AES时出现java空指针异常   java ConcurrentModificationException尝试移除列表上的所有内容时(非迭代)   Java数学库计算日志   java ISO8601,使用Jackson以毫秒表示json   避免副作用的java最佳实践   java获取JMeterException:调用bsh方法时出错:未定义参数:saa。使用beanshell取样器时   使用javascript将会话从一个jsp页面传输到另一个jsp页面   java在列表中组合相邻元素   java多行JTextPane   java Hibernate映射文件连接两个表而不定义关系?   如何使用Ajax、Java和Spring框架将文件从网页上传到Google云存储   多线程多线程Java中producerconsumer代码的多线程没有提供正确的输出?