pairot.pp.downsample_indices

pairot.pp.downsample_indices#

pairot.pp.downsample_indices(labels, n_samples, random_state=0)#

Downsample indices stratified by labels.

Downsamples an array of labels and returns the indices to keep. For each unique label, if there are fewer than n_samples, keep all indices; otherwise, randomly sample n_samples indices.

Parameters:
  • labels (ndarray) – A numpy array or list of labels.

  • n_samples (int) – Minimum number of samples to uniformly sample per label.

  • random_state (int | None (default: 0)) – Seed for reproducibility (optional).

Return type:

ndarray

Returns:

A numpy array of indices to keep after downsampling.