From aa2a602e800084a828871ec3aea83a62f84b292d Mon Sep 17 00:00:00 2001 From: Leland McInnes Date: Tue, 14 Nov 2017 20:47:25 -0500 Subject: [PATCH] Doc fixes for feature additions. --- umap/umap_.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/umap/umap_.py b/umap/umap_.py index e7985a59..bd58a50d 100644 --- a/umap/umap_.py +++ b/umap/umap_.py @@ -703,6 +703,7 @@ class UMAP(BaseEstimator): How to initialize the low dimensional embedding. Options are: * 'spectral': use a spectral embedding of the fuzzy 1-skeleton * 'random': assign initial embedding positions at random. + * A numpy array of initial embedding positions. min_dist: float (optional, default 0.1) The effective minimum distance between embedded points. Smaller values @@ -725,6 +726,10 @@ class UMAP(BaseEstimator): values are set automatically as determined by ``min_dist`` and ``spread``. + random_seed: int (optional, default None) + Provide a fixed seed for reproducibility (currently experimental, + do not expect consistent results yet, consider this a placeholder). + metric_kwds: dict (optional, default {}) Arguments to pass on to the metric, such as the ``p`` value for Minkowski distance. @@ -758,6 +763,7 @@ def __init__(self, self.spread = spread self.min_dist = min_dist + self.random_seed = random_seed if metric in dist.named_distances: self._metric = dist.named_distances[self.metric] @@ -767,9 +773,6 @@ def __init__(self, raise ValueError('Supplied metric is neither ' 'a recognised string, nor callable') - if random_seed is not None: - np.random.seed(random_seed) - if a is None or b is None: self.a, self.b = find_ab_params(self.spread, self.min_dist) else: @@ -791,6 +794,9 @@ def fit(self, X, y=None): # Handle other array dtypes (TODO: do this properly) X = X.astype(np.float64) + if self.random_seed is not None: + np.random.seed(self.random_seed) + graph = fuzzy_simplicial_set(X, self.n_neighbors, self._metric, self.metric_kwds)