alibi.confidence.model_linearity module
- class alibi.confidence.model_linearity.LinearityMeasure(method='grid', epsilon=0.04, nb_samples=10, res=100, alphas=None, model_type='classifier', agg='pairwise', verbose=False)[source]
Bases:
object
- __init__(method='grid', epsilon=0.04, nb_samples=10, res=100, alphas=None, model_type='classifier', agg='pairwise', verbose=False)[source]
- Parameters:
method (
str
) – Method for sampling. Supported methods:'knn'
|'grid'
.epsilon (
float
) – Size of the sampling region around the central instance as a percentage of the features range.nb_samples (
int
) – Number of samples to generate.res (
int
) – Resolution of the grid. Number of intervals in which the feature range is discretized.alphas (
Optional
[ndarray
]) – Coefficients in the superposition.agg (
str
) – Aggregation method. Supported values:'global'
|'pairwise'
.model_type (
str
) – Type of task. Supported values:'regressor'
|'classifier'
.
- alibi.confidence.model_linearity.infer_feature_range(X_train)[source]
Infers the feature range from the training set.
- Parameters:
X_train (
ndarray
) – Training set.- Return type:
ndarray
- Returns:
Feature range.
- alibi.confidence.model_linearity.linearity_measure(predict_fn, x, feature_range=None, method='grid', X_train=None, epsilon=0.04, nb_samples=10, res=100, alphas=None, agg='global', model_type='classifier')[source]
Calculate the linearity measure of the model around an instance of interest x.
- Parameters:
predict_fn (
Callable
) – Predict function.x (
ndarray
) – Instance of interest.feature_range (
Union
[List
,ndarray
,None
]) – Array with min and max values for each feature.method (
str
) – Method for sampling. Supported values:'knn'
|'grid'
.X_train (
Optional
[ndarray
]) – Training set.epsilon (
float
) – Size of the sampling region as a percentage of the feature range.nb_samples (
int
) – Number of samples to generate.res (
int
) – Resolution of the grid. Number of intervals in which the features range is discretized.alphas (
Optional
[ndarray
]) – Coefficients in the superposition.agg (
str
) – Aggregation method. Supported values:'global'
|'pairwise'
.model_type (
str
) – Type of task. Supported values:'regressor'
|'classifier'
.
- Return type:
ndarray
- Returns:
Linearity measure.