sharp.qoi
.DiffQoI¶
- class sharp.qoi.DiffQoI(target_function=None, X=None)[source]¶
A general QoI, suitable for models/methods that output label predictions or scores.
target_function
can output either scores or binary labels.- Parameters:
- target_functionfunction
Method used to predict a label or score. The output of this function should be a 1-dimensional array with the expected target (i.e., label or score) for each of the passed observations.
Notes
This QoI was formerly defined as just
QoI
.Methods
calculate
(rows1, rows2)Calculates the influence score based on the
target_function
outputs forrows1
androws2
.estimate
(rows)Prepares and runs
self.target_function
for a set of samples.Get metadata routing of this object.
get_params
([deep])Get parameters for this estimator.
set_params
(**params)Set the parameters of this estimator.
- calculate(rows1, rows2)¶
Calculates the influence score based on the
target_function
outputs forrows1
androws2
.- 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 torows2
.
- 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.
- 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.