preserve named attrs in DataFrameUMAP as well
@@ -2338,34 +2338,7 @@ class DataFrameUMAP(BaseEstimator):
self.metrics = metrics
self.n_neighbors = n_neighbors
self.output_metric = output_metric
- if output_metric_kwds is not None:
self.output_metric_kwds = output_metric_kwds
- else:
- self.output_metric_kwds = {}
-
- if callable(self.output_metric):
- self._output_distance_func = self.output_metric
- elif (
- self.output_metric in dist.named_distances
- and self.output_metric in dist.named_distances_with_gradients
- ):
- self._output_distance_func = dist.named_distances_with_gradients[
- self.output_metric
- ]
- elif self.output_metric == "precomputed":
- raise ValueError("output_metric cannnot be 'precomputed'")
- else:
- if self.output_metric in dist.named_distances:
- raise ValueError(
- "gradient function is not yet implemented for "
- + repr(self.output_metric)
- + "."
- )
- else:
- raise ValueError(
- "output_metric is neither callable, " + "nor a recognised string"
- )
-
self.n_epochs = n_epochs
self.init = init
self.n_components = n_components
@@ -2424,6 +2397,10 @@ class DataFrameUMAP(BaseEstimator):
self.n_epochs <= 10 or not isinstance(self.n_epochs, int)
):
raise ValueError("n_epochs must be a positive integer " "larger than 10")
+ if self.output_metric_kwds is None:
+ self._output_metric_kwds = {}
+ else:
+ self._output_metric_kwds = self.output_metric_kwds
if callable(self.output_metric):
self._output_distance_func = self.output_metric
