pydvl.valuation.utility.knn
¶
KNNClassifierUtility
¶
KNNClassifierUtility(
model: KNeighborsClassifier,
test_data: Dataset,
*,
catch_errors: bool = True,
show_warnings: bool = False,
cache_backend: CacheBackend | None = None,
cached_func_options: CachedFuncConfig | None = None,
clone_before_fit: bool = True
)
Bases: ModelUtility[Sample, KNeighborsClassifier]
Utility object for KNN Classifiers.
The utility function is the likelihood of the true class given the model's prediction.
This works both as a Utility object for general game theoretic valuation methods and for specialized valuation methods for KNN classifiers.
PARAMETER | DESCRIPTION |
---|---|
model |
A KNN classifier model.
TYPE:
|
test_data |
The test data to evaluate the model on.
TYPE:
|
catch_errors |
set to
TYPE:
|
show_warnings |
Set to
TYPE:
|
cache_backend |
Optional instance of [CacheBackend][ pydvl.utils.caching.base.CacheBackend] used to wrap the _utility method of the Utility instance. By default, this is set to None and that means that the utility evaluations will not be cached.
TYPE:
|
cached_func_options |
Optional configuration object for cached utility evaluation.
TYPE:
|
clone_before_fit |
If
TYPE:
|
Source code in src/pydvl/valuation/utility/knn.py
cache_stats
property
¶
cache_stats: CacheStats | None
Cache statistics are gathered when cache is enabled. See CacheStats for all fields returned.
__call__
¶
__call__(sample: SampleT | None) -> float
PARAMETER | DESCRIPTION |
---|---|
sample |
contains a subset of valid indices for the
TYPE:
|