When you pass
spenc.SPENC(n_clusters=k, affinity='precomputed').fit(affinity, W)
spenc ignores W altogether, since it treats the precomputed affinity matrix as if it's already filtered by W.
This is not intended. I'd instead always intended in setting attribute_affinity_, then mixing that with spatial_affinity_ to get affinity_matrix_, on which the clustering is based.
When you pass
spencignoresWaltogether, since it treats the precomputed affinity matrix as if it's already filtered byW.This is not intended. I'd instead always intended in setting
attribute_affinity_, then mixing that withspatial_affinity_to getaffinity_matrix_, on which the clustering is based.