我有兩個密集矩陣(title
和para
)。我希望使用親和傳播算法對它們進行聚類,然後繪製聚類。關於兩個特徵和繪圖結果的集羣
我已經寫了下面的代碼,哪些集羣基於一個特徵。我怎樣才能適應這兩個功能集羣,然後繪製結果?
import os
import time
import string
import pickle
import matplotlib.pyplot as plt
from sklearn.cluster import AffinityPropagation
from sklearn import metrics
import matplotlib.pyplot as plt
from itertools import cycle
#from sklearn.ensemble import RandomForestClassifier
#Opens and stores preprocessed data.
filepath = '...'
with open((filepath + 'para.dat'), 'rb') as infile:
para = pickle.load(infile)
with open(filepath + 'title.dat', 'rb') as infile:
title = pickle.load(infile)
with open(filepath + 'y.dat', 'rb') as infile:
y = pickle.load(infile)
af = AffinityPropagation().fit(para)
cluster_centers_indices = af.cluster_centers_indices_
labels = af.labels_
n_clusters_= len(cluster_centers_indices)
這是我用這爲執行聚類,由此整個數據集簇和簇的質心形成產生訓練數據集代表的訓練數據集的查詢的主動學習方法的一部分整個數據集。
已編輯問題以澄清目的。 – user7347576
在這種情況下,它們的權重不相等? – user7347576
他們可能無法比較,所以即使將alpha設置爲0.5,他們也不會產生相同的影響。 –