fatf.utils.data.instance_augmentation.binary_sampler

fatf.utils.data.instance_augmentation.binary_sampler(data_row: Union[numpy.ndarray, numpy.void], samples_number: int = 50) → numpy.ndarray[source]

Samples non-zero elements of the binary data_row array uniformly.

New in version 0.0.2.

Uniformly samples all of the features that have non-zero (i.e., 1) value in the input data_row from a {0, 1} set. For example, for a [0, 1, 1, 0] data_row, only the two middle features will be sampled. Therefore, all of the possible data rows in the output sample have to be a subset of: [0, 1, 1, 0], [0, 1, 0, 0], [0, 0, 1, 0] and [0, 0, 0, 0] arrays.

Returns
binary_samplesnumpy.ndarray

Binary data sampled based on the input data_row.

Raises
IncorrectShapeError

The data_row is not a 1-dimensional numpy array-like object.

TypeError

The data_row is not a binary array. The samples_number is not an integer.

ValueError

The samples_number is not a positive integer.