sharp.ShaRP

class sharp.ShaRP(qoi=None, target_function=None, measure='shapley', sample_size=None, coalition_size=None, replace=False, random_state=None, n_jobs=1, verbose=0, **kwargs)[source]

Explains the contributions of features to different aspects of a ranked outcome, based on Shapley values.

This algorithm is an implementation of Shapley for Rankings and Preferences (ShaRP), as presented in [1].

If QoI is None, target_function and parameters X and y need to be passed. if QoI is not None, target_function is ignored.

Parameters:
estimatorML classifier
qoiQuantity of interest
measuremeasure used to estimate feature contributions (unary, set, banzhaf, etc.)
sample_sizeamount of perturbations applied per data point
replaceWhether to sample with replacement
predict_methodestimator’s function that provides inference
random_staterandom seed
Xreference input
ytarget

Notes

See the original paper: [1] for more details.

References

[1] (1,2)

V. Pliatsika, J. Fonseca, T. Wang, J. Stoyanovich, “ShaRP: Explaining Rankings with Shapley Values”, Under submission.

Methods

all([X, y])

set_cols_idx should be passed in kwargs if measure is marginal

feature(feature[, X, y])

set_cols_idx should be passed in kwargs if measure is marginal

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

individual(sample[, X, y])

set_cols_idx should be passed in kwargs if measure is marginal

pairwise(sample1, sample2, **kwargs)

Compare two samples, or one sample against a set of samples.

set_params(**params)

Set the parameters of this estimator.

fit


all(X=None, y=None, **kwargs)[source]

set_cols_idx should be passed in kwargs if measure is marginal

feature(feature, X=None, y=None, **kwargs)[source]

set_cols_idx should be passed in kwargs if measure is marginal

fit(X, y=None)[source]
get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Returns:
routingMetadataRequest

A MetadataRequest encapsulating routing information.

get_params(deep=True)

Get parameters for this estimator.

Parameters:
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:
paramsdict

Parameter names mapped to their values.

individual(sample, X=None, y=None, **kwargs)[source]

set_cols_idx should be passed in kwargs if measure is marginal

pairwise(sample1, sample2, **kwargs)[source]

Compare two samples, or one sample against a set of samples. If sample1 or sample2 are of type int or list, X also needs to be passed.

set_cols_idx should be passed in kwargs if measure is marginal

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters:
**paramsdict

Estimator parameters.

Returns:
selfestimator instance

Estimator instance.