neupy.datasets.make_digits

neupy.datasets.make_digits(n_samples=100, noise_level=0.1, mode='flip')[source]

Returns discrete digits dataset.

Parameters:
n_samples : int

Number of samples. Defaults to 100.

noise_level : float

Defines level of a discrete noise added to the images. Noise level defines probability for the pixel to be removed. Value should be in [0, 1) range. Defaults to 0.1.

mode : {remove, flip}

This option allow to specify how additional noise will modify each image.

  • flip - Per every randomly selected pixel function flips binary value. 1 -> 0 and 0 -> 1.
  • remove - Per every randomly selected pixel function checks if value equal to 1 if it’s true that it gets replaced with 0.
Returns:
tuple

Tuple contains two values. First one is a matrix with shape (n_samples, 24). Second one is a vector that contains labels for each row. Each digit can be transformed into (6, 4) binary image.

Examples

>>> from neupy import datasets, utils
>>>
>>> utils.reproducible()
>>>
>>> digits, labels = datasets.make_digits(noise_level=0.15)
>>> digit, label = digits[0], labels[0]
>>>
>>> label
5
>>>
>>> digit.reshape((6, 4))
array([[0, 0, 1, 1],
       [1, 0, 0, 0],
       [0, 1, 1, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 1],
       [1, 1, 1, 0]], dtype=uint8)