pydvl.valuation.methods.data_oob
¶
This module implements the method described in Kwon and Zou, (2023).1
Data-OOB value is tailored to bagging models. It defines a data point's value as the average loss of the estimators which were not fit on it.
As such it is not a semi-value, and it is not based on marginal contributions.
Info
For details on the method and a discussion on how and whether to use it by bagging models a posteriori, see the main documentation.
References¶
-
Kwon, Yongchan, and James Zou. Data-OOB: Out-of-bag Estimate as a Simple and Efficient Data Value. In Proceedings of the 40th International Conference on Machine Learning, 18135–52. PMLR, 2023. ↩
DataOOBValuation
¶
DataOOBValuation(model: BaggingModel, score: PointwiseScore | None = None)
Bases: Valuation
Computes Data Out-Of-Bag values.
This class implements the method described in Kwon and Zou, (2023)1.
PARAMETER | DESCRIPTION |
---|---|
model
|
A fitted bagging model. Bagging models in sklearn include
[[BaggingClassifier]], [[BaggingRegressor]], [[IsolationForest]],
RandomForest,
ExtraTrees, or any model which defines an attribute
TYPE:
|
score
|
A callable for point-wise comparison of true values with the predictions.
If
TYPE:
|
Tensor Support
DataOOBValuation supports PyTorch tensors for input data with some limitations: - The scoring functions (point_wise_accuracy and neg_l2_distance) have been updated to work with both NumPy arrays and PyTorch tensors. - Custom scoring functions must handle both array types if you plan to use tensors. - The bagging model implementation must be tensor-compatible and implement the required BaggingModel interface attributes and methods.
New in version 0.11.0
Added (partial) support for PyTorch tensors.
Source code in src/pydvl/valuation/methods/data_oob.py
fit
¶
fit(data: Dataset, continue_from: ValuationResult | None = None) -> Self
Compute the Data-OOB values.
This requires the bagging model passed upon construction to be fitted.
PARAMETER | DESCRIPTION |
---|---|
data
|
Data for which to compute values
TYPE:
|
continue_from
|
A previously computed valuation result to continue from.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Self
|
The fitted object. |
Source code in src/pydvl/valuation/methods/data_oob.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
values
¶
values(sort: bool = False) -> ValuationResult
Returns a copy of the valuation result.
The valuation must have been run with fit()
before calling this method.
PARAMETER | DESCRIPTION |
---|---|
sort
|
Whether to sort the valuation result by value before returning it.
TYPE:
|
Returns: The result of the valuation.
Source code in src/pydvl/valuation/base.py
neg_l2_distance
¶
Point-wise negative \(l_2\) distance between two arrays.
Higher is better.
PARAMETER | DESCRIPTION |
---|---|
y_true
|
Array of true values (e.g. labels)
TYPE:
|
y_pred
|
Array of estimated values (e.g. model predictions)
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
NDArray[float64]
|
Array with point-wise negative \(l_2\) distances between labels and model |
NDArray[float64]
|
predictions |
Source code in src/pydvl/valuation/methods/data_oob.py
point_wise_accuracy
¶
Point-wise accuracy, or 0-1 score between two arrays.
Higher is better.
PARAMETER | DESCRIPTION |
---|---|
y_true
|
Array of true values (e.g. labels)
TYPE:
|
y_pred
|
Array of estimated values (e.g. model predictions)
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
NDArray[float64]
|
Array with point-wise 0-1 accuracy between labels and model predictions |