added precomputed metric option to fit
@@ -184,6 +184,20 @@ class ParametricUMAP(UMAP):
)
)
+ def fit(self, X, y=None, precomputed_distances=None):
+ if self.metric == "precomputed":
+ if precomputed_distances is None:
+ raise ValueError(
+ "Precomputed distances must be supplied if metric \
+ is precomputed."
+ )
+ # prepare X for training the network
+ self._X = X
+ # geneate the graph on precomputed distances
+ return super().fit(precomputed_distances, y)
+ else:
+ return super().fit(X, y)
+
def fit_transform(self, X, y=None, precomputed_distances=None):
if self.metric == "precomputed":
