DwangoMediaVillage/pqkmeans

Getting centroid vector

Closed this issue · 2 comments

Hi,

Is there any function to get centroid vector which is not encoded with encoder?

Hi,
You mean reconstructing centers from PQ-codes to the original vectors after the clustering is finished? Then the codes will be:

# Run clustering
kmeans = pqkmeans.clustering.PQKMeans(encoder=encoder, k=5)
kmeans.fit_predict(X_pqcode)

# Need to convert from list to np.array
centers_pqcodes = np.array(kmeans.cluster_centers_, dtype=encoder.code_dtype) 
# PQ-codes -> D-dim vectors
centers = encoder.inverse_transform(centers_pqcodes)

See the tutorial as well: https://github.com/DwangoMediaVillage/pqkmeans/blob/master/tutorial/1_pqkmeans.ipynb

It works! Thank you.