pydvl.value.shapley.knn
¶
This module contains Shapley computations for K-Nearest Neighbours.
Todo
Implement approximate KNN computation for sublinear complexity
References¶
-
Jia, R. et al., 2019. Efficient Task-Specific Data Valuation for Nearest Neighbor Algorithms. In: Proceedings of the VLDB Endowment, Vol. 12, No. 11, pp. 1610–1623. ↩
knn_shapley
¶
knn_shapley(u: Utility, *, progress: bool = True) -> ValuationResult
Computes exact Shapley values for a KNN classifier.
This implements the method described in (Jia, R. et al., 2019)1. It exploits the local structure of K-Nearest Neighbours to reduce the number of calls to the utility function to a constant number per index, thus reducing computation time to \(O(n)\).
PARAMETER | DESCRIPTION |
---|---|
u |
Utility with a KNN model to extract parameters from. The object will not be modified nor used other than to call get_params()
TYPE:
|
progress |
Whether to display a progress bar.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
ValuationResult
|
Object with the data values. |
RAISES | DESCRIPTION |
---|---|
TypeError
|
If the model in the utility is not a sklearn.neighbors.KNeighborsClassifier. |
New in version 0.1.0