skclean.simulate_noise.flip_labels_uniform

skclean.simulate_noise.flip_labels_uniform(Y: numpy.ndarray, noise_level: float, *, random_state=None, exact=True)

All labels are equally likely to be flipped, irrespective of their true label or feature. The new (noisy) label is also chosen with uniform probability from alternative class labels.

Parameters
  • Y (np.ndarray) – 1-D array of labels

  • noise_level (float) – percentage of labels to flip

  • random_state (int, default=None) – Set this value for reproducibility

  • exact (bool default=True) – If True, the generated noise will be as close to noise_level as possible. The approximate version (i.e. exact=False) is faster but less accurate.

Returns

Yn – 1-D array of flipped labels

Return type

np.ndarray