Skip to main content

The Python Data Valuation Library

Project description

pyDVL Logo

A library for data valuation.

Build Status

Docs

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

Usage

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.

Contributing

Please open new issues for bugs, feature requests and extensions. See more details about the structure and workflow in the developer's readme.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyDVL-0.1.0.tar.gz (63.5 kB view hashes)

Uploaded Source

Built Distribution

pyDVL-0.1.0-py3-none-any.whl (71.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page