sharp.qoi.TopKQoI

class sharp.qoi.TopKQoI(target_function=None, top_k=10, X=None)[source]

Rank-specific QoI. Estimates the likelihood of reaching the top-K as the quantity of interest.

Parameters:
top_kint, default=10

The number of items to consider as part of the top-ranked group.

Methods

calculate(rows1, rows2)

Calculates the influence score based on the target_function outputs for rows1 and rows2.

estimate(rows)

Prepares and runs self.target_function for a set of samples.

get_metadata_routing()

Get metadata routing of this object.

get_params([deep])

Get parameters for this estimator.

rank(X[, X_base])

Computes the ranking of samples X within a dataset X_base.

set_params(**params)

Set the parameters of this estimator.


calculate(rows1, rows2)

Calculates the influence score based on the target_function outputs for rows1 and rows2.

Parameters:
rows1array-like of shape (n_samples, n_features)

First set of samples to compare.

rows2array-like of shape (n_samples, n_features)

Second set of samples to compare.

Returns:
influence_scorefloat

Influence score for rows1, compared to rows2.

estimate(rows)

Prepares and runs self.target_function for a set of samples.

Parameters:
rowsarray-like of shape (n_samples, n_features)

Samples over which target_function will be applied.

Returns:
target_outputnp.ndarray of shape (n_samples,)

Label predictions or score estimations.

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.

rank(X, X_base=None)

Computes the ranking of samples X within a dataset X_base.

Parameters:
Xarray-like of shape (n_samples, n_features)

The input samples to calculate the rankings for.

Returns:
rankingsnp.ndarray of shape (n_samples,)

Rankings for all samples in X.

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.