Using the class sklearn.cluster.SpectralClustering with parameter affinity='precomputed'

前端 未结 1 364
滥情空心
滥情空心 2021-01-03 00:41

I\'m having trouble understanding a specific use case of the sklearn.cluster.SpectralClustering class as outlined in the official documentation here. Say I want

相关标签:
1条回答
  • 2021-01-03 01:21

    Straight from the docs:

    If you have an affinity matrix, such as a distance matrix, for which 0 means identical elements, and high values means very dissimilar elements, it can be transformed in a similarity matrix that is well suited for the algorithm by applying the Gaussian (RBF, heat) kernel:

    np.exp(- X ** 2 / (2. * delta ** 2))
    

    This goes in your own code, and the result of this can be passed to fit. For the purpose of this algorithm, affinity means similarity, not distance.

    0 讨论(0)
提交回复
热议问题