【图像聚类】|谱聚类 sklearn

https://www.zhihu.com/question/494753171
https://scikit-learn.org.cn/view/391.html
https://zhuanlan.zhihu.com/p/91154535
https://blog.csdn.net/weixin_36474809/article/details/89927502
谱聚类基于相似度矩阵



import numpy as np
from sklearn import datasets
from sklearn.cluster import SpectralClustering

from sklearn import metrics
X, y = datasets.make_blobs(n_samples=512, n_features=6, centers=5, cluster_std=[0.4, 0.3, 0.4, 0.3, 0.4], random_state=11)
affinity_matrix=np.random.rand(512,512)
for i in range(512):
    for j in range(512):
        if j>i:
            affinity_matrix[j,i]=affinity_matrix[i,j]
        if j==i:
            affinity_matrix[j,i]=1

Cluster=SpectralClustering(n_clusters=32, n_init=10, gamma=1.0, affinity='precomputed', n_neighbors=10, eigen_tol=0.0, assign_labels='kmeans', degree=3,coef0=1)
Cluster=SpectralClustering(n_clusters=32, n_init=10, gamma=1.0, affinity='rbf', n_neighbors=10, eigen_tol=0.0, assign_labels='kmeans', degree=3,coef0=1)
# y_pred = Cluster.fit_predict(affinity_matrix)
y_pred = Cluster.fit_predict(X)
Cluster.affinity_matrix_
Cluster.labels_
# print("Calinski-Harabasz Score", metrics.calinski_harabaz_score(X, y_pred) )

ref
https://blog.csdn.net/qq_45448654/article/details/121013471

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值