fairness-datasets
PyTorch dataset wrappers for the several popular datasets from fair machine learning research.
The following datasets are wrapped:
- Adult (Census Income).
- Default
- Law School (data from here)
- SouthGerman
Installation
pip install fairness-datasets
Basic Usage
from fairnessdatasets import Adult
# load (if necessary, download) the Adult training dataset
train_set = Adult(root="datasets", download=True)
# load the test set
test_set = Adult(root="datasets", train=False, download=True)
inputs, target = train_set[0] # retrieve the first sample of the training set
# iterate over the training set
for inputs, target in iter(train_set):
... # Do something with a single sample
# use a PyTorch data loader
from torch.utils.data import DataLoader
loader = DataLoader(test_set, batch_size=32, shuffle=True)
for epoch in range(100):
for inputs, targets in iter(loader):
... # Do something with a batch of samples
You can use Adult(..., raw=True) to turn off the one-hot encoding
and z-score normalization applied by the Adult class by default.
The remaining dataset classes can be used in the same way as Adult.
However, these datasets don't come with a fixed train/test split,
so that the dataset instances always contain all data.
To create a train/test split, use
from fairnessdatasets import Default
from torch.utils.data import random_split
dataset = Default(root="datasets", download=True)
rng = torch.Generator().manual_seed(42) # for reproducible results
train_set, test_set = random_split(dataset, [0.7, 0.3], generator=rng)
Advanced Usage
Turn off status messages while downloading the dataset:
Adult(root=..., output_fn=None)
Use the logging module for logging status messages while downloading the
dataset instead of placing the status messages on sys.stdout.
import logging
Adult(root=..., output_fn=logging.info)
Metadata
Release files for fairness-datasets 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fairness_datasets-0.4.0.tar.gz | 17.5 kB | Without provenance | Details for fairness_datasets-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fairness_datasets-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for fairness_datasets-0.4.0-py3-none-any.whl |
Total release size: 35.8 kB
Release files / fairness_datasets-0.4.0.tar.gz
| Download URL | fairness_datasets-0.4.0.tar.gz |
|---|---|
| Size | 17.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bca7dc534f064b9941a1a10083c84c684ef4d34fe6f2b4aa2ed7d33cdf7da2d1
|
|
BLAKE2b-256 checksum How to use checksums |
9c4bd0d6e6d40adab59773b33141bacfd380f706f0cf908b40d148b60701f8f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|
Release files / fairness_datasets-0.4.0-py3-none-any.whl
| Download URL | fairness_datasets-0.4.0-py3-none-any.whl |
|---|---|
| Size | 18.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ca2c711f0ca768457bcf5f48cc33ae9a40e10eb77df94e0e16f9c73309b675aa
|
|
BLAKE2b-256 checksum How to use checksums |
7d1ab16b824d2ec2bbbe24809b30ce148f77c4510761a104dbe401c00e57e588
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|
Security for fairness-datasets 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.