sharp.qoi
.RankScoreQoI¶
- class sharp.qoi.RankScoreQoI(target_function=None, X=None)[source]¶
A general, ranking-oriented QoI, similar to
DiffQoI
.target_function
must output scores.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.
rank
(X[, X_base])Computes the ranking of samples
X
within a datasetX_base
.set_params
(**params)Set the parameters of this estimator.
Notes
This QoI was formerly defined as
RankingScore
.- 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.
- rank(X, X_base=None)¶
Computes the ranking of samples
X
within a datasetX_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.