Multiple unsupervised algorithms in scikit-learn have two parameters: affinity and metric, which can take a precomputed matrix for affinity and distance matrix respectively.
AffinityPropagation, AgglomerativeClustering, FeatureAgglomeration, and SpectralClustering take affinity for precomputed matrix
where as
DBSCAN and OPTICS take metric for precomputed matrix.
I have a two part question:
- Is it possible to write a custom function that can be used for all of above mentioned six methods?
- If not, then I want to have a custom function that will be 'callable' for
metricparameter in DBSCAN and OPTICS (both methods use distance matrix).
From the documentation, I understand that
it (metric) must be one of the options allowed by
sklearn.metrics.pairwise_distancesfor its metric parameter.
So is it possible to define a custom function (in DBSCAN and OPTICS) and overwrite one of the preexisting sklearn.metrics.pairwise_distances function or I have to use precomputed in parameters?