Skip to content
/ pyDVL Public
forked from aai-institute/pyDVL

Algorithms for data valuation and benchmarks

License

Notifications You must be signed in to change notification settings

mdbenito/pyDVL

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyDVL Logo

A library for data valuation.

Build Status
PyPI - License

Docs

pyDVL collects algorithms for Data Valuation and Influence Function computation.

Data Valuation is the task of estimating the intrinsic value of a data point wrt. the training set, the model and a scoring function. We currently implement methods from the following papers:

Influence Functions compute the effect that single points have on an estimator / model. We implement methods from the following papers:

Installation

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 Installing pyDVL in the documentation.

Usage

The steps required to compute values for your samples are:

  1. Create a Dataset object with your train and test splits.
  2. Create an instance of a SupervisedModel (basically any sklearn compatible predictor)
  3. Create a Utility object to wrap the Dataset, the model and a scoring function.
  4. Use one of the methods defined in the library to compute the values.

This is how it looks for Truncated Montecarlo Shapley, an efficient method for Data Shapley values:

from sklearn.datasets import load_breast_cancer
from sklearn.linear_model import LogisticRegression
from pydvl.value import *

data = Dataset.from_sklearn(load_breast_cancer(), train_size=0.7)
model = LogisticRegression()
u = Utility(model, data, Scorer("accuracy", default=0.0))
values = compute_shapley_values(
        u,
        mode=ShapleyMode.TruncatedMontecarlo,
        done=MaxUpdates(100) | AbsoluteStandardError(threshold=0.01),
        truncation=RelativeTruncation(u, rtol=0.01),
        )

For more instructions and information refer to Getting Started in the documentation. We provide several examples with details on the algorithms and their applications.

Caching

pyDVL offers the possibility to cache certain results and speed up computation. It uses Memcached For that.

You can run it either locally or, using Docker:

docker container run --rm -p 11211:11211 --name pydvl-cache -d memcached:latest

You can read more in the caching module's documentation.

Contributing

Please open new issues for bugs, feature requests and extensions. You can read about the structure of the project, the toolchain and workflow in the guide for contributions.

License

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.

Packages

No packages published

Languages

  • Python 98.1%
  • Shell 1.6%
  • Other 0.3%