A library for data valuation.
To install the latest release use:
$ pip install pyDVL
You can also install the latest development version from TestPyPI:
pip install pyDVL --index-url https://test.pypi.org/simple/
For more instructions and information refer to the Installing pyDVL section of the documentation.
pyDVL requires Memcached in order to cache certain results and speed-up computation.
You need to run it either locally or using Docker:
docker container run -it --rm -p 11211:11211 memcached:latest -v
Caching is enabled by default but can be disabled if not needed or desired.
Once that's done you should start by creating a Dataset object with your train and test splits. Then, you should create a model instance and a Utility object that will wrap the dataset, the model and the scoring function. Finally, you should use one of the methods defined in the library to compute the data valuation. Here we use Truncated Montecarlo Shapley because it is the most efficient.
Put all together:
import numpy as np
from pydvl.utils import Dataset, Utility
from pydvl.shapley.montecarlo import truncated_montecarlo_shapley
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
X, y = np.arange(100).reshape((50, 2)), np.arange(50)
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.5, random_state=16
)
dataset = Dataset(X_train, X_test, y_train, y_test)
model = LinearRegression()
utility = Utility(model, dataset)
values, errors = truncated_montecarlo_shapley(u=utility, max_iterations=100)
For more instructions and information refer to the Getting Started section of the documentation
Refer to the Examples section of the documentation for more detailed examples.
Please open new issues for bugs, feature requests and extensions. See more details about the structure and workflow in the developer's readme.
pyDVL is distributed under LGPL-3.0. A complete version can be found in two files: here and here.
All contributions will be distributed under this license.