@@ -177,7 +177,7 @@ def fit(self, X, y=None, precomputed_distances=None, landmark_positions=None):
177
177
Points that are not landmarks should have nan coordinates.
178
178
"""
179
179
if (self .prev_epoch_X is not None ) & (landmark_positions is None ):
180
- # Add the landmark points for training, then make a landmark vector.
180
+ # Add the landmark points for training, then make a landmark vector.
181
181
landmark_positions = np .stack (
182
182
[np .array ([np .nan , np .nan ])]* X .shape [0 ] + list (
183
183
self .transform (
@@ -243,7 +243,7 @@ def fit_transform(
243
243
Points that are not landmarks should have nan coordinates.
244
244
"""
245
245
if (self .prev_epoch_X is not None ) & (landmark_positions is None ):
246
- # Add the landmark points for training, then make a landmark vector.
246
+ # Add the landmark points for training, then make a landmark vector.
247
247
landmark_positions = np .stack (
248
248
[np .array ([np .nan , np .nan ])]* X .shape [0 ] + list (
249
249
self .transform (
@@ -495,8 +495,10 @@ def save(self, save_location, verbose=True):
495
495
if verbose :
496
496
print ("Pickle of ParametricUMAP model saved to {}" .format (model_output ))
497
497
498
- def add_landmarks (self , X , sample_pct = 0.01 , sample_mode = "uniform" , landmark_loss_weight = 0.01 , idx = None ):
499
- """Add some points from a dataset X as "landmarks" to be approximately preserved after retraining.
498
+ def add_landmarks (
499
+ self , X , sample_pct = 0.01 , sample_mode = "uniform" , landmark_loss_weight = 0.01 , idx = None
500
+ ):
501
+ """Add some points from a dataset X as "landmarks."
500
502
501
503
Parameters
502
504
----------
@@ -505,7 +507,7 @@ def add_landmarks(self, X, sample_pct=0.01, sample_mode="uniform", landmark_loss
505
507
sample_pct : float, optional
506
508
Percentage of old data to use as landmarks.
507
509
sample_mode : str, optional
508
- Method for sampling points. Currently only "uniform" and "predefined" are supported.
510
+ Method for sampling points. Allows "uniform" and "predefined."
509
511
landmark_loss_weight : float, optional
510
512
Multiplier for landmark loss function.
511
513
@@ -515,7 +517,9 @@ def add_landmarks(self, X, sample_pct=0.01, sample_mode="uniform", landmark_loss
515
517
self .landmark_loss_weight = landmark_loss_weight
516
518
517
519
if self .sample_mode == "uniform" :
518
- self .prev_epoch_idx = list (np .random .choice (range (X .shape [0 ]), int (X .shape [0 ]* sample_pct ), replace = False ))
520
+ self .prev_epoch_idx = list (
521
+ np .random .choice (range (X .shape [0 ]), int (X .shape [0 ]* sample_pct ), replace = False )
522
+ )
519
523
self .prev_epoch_X = X [self .prev_epoch_idx ]
520
524
elif self .sample_mode == "predetermined" :
521
525
if idx is None :
@@ -525,12 +529,12 @@ def add_landmarks(self, X, sample_pct=0.01, sample_mode="uniform", landmark_loss
525
529
else :
526
530
self .prev_epoch_idx = idx
527
531
self .prev_epoch_X = X [self .prev_epoch_idx ]
528
-
532
+
529
533
else :
530
534
raise ValueError (
531
535
"Choice of sample_mode is not supported."
532
536
)
533
-
537
+
534
538
def remove_landmarks (self ):
535
539
self .prev_epoch_X = None
536
540
0 commit comments