alibi.utils.discretizer module
- class alibi.utils.discretizer.Discretizer(data, numerical_features, feature_names, percentiles=(25, 50, 75))[source]
Bases:
object
- __init__(data, numerical_features, feature_names, percentiles=(25, 50, 75))[source]
Initialize the discretizer.
- bins(data)[source]
- Parameters:
data (
ndarray
) – Data to discretize.- Return type:
List
[ndarray
]- Returns:
List with bin values for each feature that is discretized.
- discretize(data)[source]
- Parameters:
data (
ndarray
) – Data to discretize.- Return type:
ndarray
- Returns:
Discretized version of data with the same dimension.
- static get_percentiles(x, qts)[source]
Discretizes the the data in x using the quantiles in qts. This is achieved by searching for the index of each value in x into qts, which is assumed to be a 1-D sorted array.
- Parameters:
x (
ndarray
) – A numpy array of data to be discretizedqts (
ndarray
) – A numpy array of percentiles. This should be a 1-D array sorted in ascending order.
- Return type:
ndarray
- Returns:
A discretized data numpy array.