propogate reproducible random state set by transform_seed through spectral_layout and alignment
@@ -352,11 +352,12 @@ class AlignedUMAP(BaseEstimator):
make_epochs_per_sample(mapper.graph_.tocoo().data, n_epochs)
)
+ rng_state_transform = np.random.RandomState(self.transform_seed)
regularisation_weights = build_neighborhood_similarities(
indptr_list, indices_list, relations,
)
first_init = spectral_layout(
- self.mappers_[0]._raw_data, self.mappers_[0].graph_, self.n_components, np.random,
+ self.mappers_[0]._raw_data, self.mappers_[0].graph_, self.n_components, rng_state_transform,
)
expansion = 10.0 / np.abs(first_init).max()
first_embedding = (first_init * expansion).astype(np.float32, order="C",)
@@ -365,7 +366,7 @@ class AlignedUMAP(BaseEstimator):
embeddings.append(first_embedding)
for i in range(1, self.n_models_):
next_init = spectral_layout(
- self.mappers_[i]._raw_data, self.mappers_[i].graph_, self.n_components, np.random,
+ self.mappers_[i]._raw_data, self.mappers_[i].graph_, self.n_components, rng_state_transform,
)
expansion = 10.0 / np.abs(next_init).max()
next_embedding = (next_init * expansion).astype(np.float32, order="C",)
@@ -380,9 +381,7 @@ class AlignedUMAP(BaseEstimator):
)
)
- random_state = check_random_state(self.random_state)
- rng_state = random_state.randint(INT32_MIN, INT32_MAX, 3).astype(np.int64)
-
+ seed_triplet = rng_state_transform.randint(INT32_MIN, INT32_MAX, 3).astype(np.int64)
self.embeddings_ = optimize_layout_aligned_euclidean(
embeddings,
embeddings,
@@ -392,7 +391,7 @@ class AlignedUMAP(BaseEstimator):
epochs_per_samples,
regularisation_weights,
relations,
- rng_state,
+ seed_triplet,
lambda_=self.alignment_regularisation,
)
@@ -436,6 +435,8 @@ class AlignedUMAP(BaseEstimator):
set_op_mix_ratio=get_nth_item_or_val(self.set_op_mix_ratio, self.n_models_),
unique=get_nth_item_or_val(self.unique, self.n_models_),
n_components=self.n_components,
+ random_state=self.random_state,
+ transform_seed=self.transform_seed,
).fit(X)
self.mappers_ += [new_mapper]
@@ -477,11 +478,10 @@ class AlignedUMAP(BaseEstimator):
self.embeddings_[-1], new_mapper.graph_, new_dict_relations
)
- random_state = check_random_state(self.random_state)
- rng_state = random_state.randint(INT32_MIN, INT32_MAX, 3).astype(np.int64)
-
self.embeddings_.append(new_embedding)
+ rng_state_transform = np.random.RandomState(self.transform_seed)
+ seed_triplet = rng_state_transform.randint(INT32_MIN, INT32_MAX, 3).astype(np.int64)
self.embeddings_ = optimize_layout_aligned_euclidean(
self.embeddings_,
self.embeddings_,
@@ -491,6 +491,6 @@ class AlignedUMAP(BaseEstimator):
epochs_per_samples,
new_regularisation_weights,
new_relations,
- rng_state,
+ seed_triplet,
lambda_=self.alignment_regularisation,
)
