moved random_sample variable declaration later in the fit function to ensure reproducibility
@@ -2348,8 +2348,6 @@ class UMAP(BaseEstimator):
if self._sparse_data and not X.has_sorted_indices:
X.sort_indices()
- random_state = check_random_state(self.random_state)
-
if self.verbose:
print(ts(), "Construct fuzzy simplicial set")
@@ -2396,7 +2394,7 @@ class UMAP(BaseEstimator):
) = fuzzy_simplicial_set(
X[index],
self.n_neighbors,
- random_state,
+ self.random_state,
"precomputed",
self._metric_kwds,
self._knn_indices,
@@ -2464,7 +2462,7 @@ class UMAP(BaseEstimator):
) = fuzzy_simplicial_set(
dmat,
self._n_neighbors,
- random_state,
+ self.random_state,
"precomputed",
self._metric_kwds,
None,
@@ -2509,7 +2507,7 @@ class UMAP(BaseEstimator):
nn_metric,
self._metric_kwds,
self.angular_rp_forest,
- random_state,
+ self.random_state,
self.low_memory,
use_pynndescent=True,
n_jobs=self.n_jobs,
@@ -2533,7 +2531,7 @@ class UMAP(BaseEstimator):
) = fuzzy_simplicial_set(
X[index],
self.n_neighbors,
- random_state,
+ self.random_state,
nn_metric,
self._metric_kwds,
self._knn_indices,
@@ -2558,6 +2556,8 @@ class UMAP(BaseEstimator):
verbose=self.verbose,
)
+ random_state = check_random_state(self.random_state)
+
# Currently not checking if any duplicate points have differing labels
# Might be worth throwing a warning...
if y is not None:
