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_rowarray 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_rowfrom 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_rowis not a 1-dimensional numpy array-like object.- TypeError
The
data_rowis not a binary array. Thesamples_numberis not an integer.- ValueError
The
samples_numberis not a positive integer.