fair_forge.datasets

Classes

AdultGroup(…)

Dataset(…)

GroupDataset(…)

A dataset containing features, labels, and groups.

Functions

grouping_by_prefix(*, columns, prefixes)

Create slices for feature grouping based on column prefixes.

load_adult(group, *[, group_in_features, ...])

Load the Adult dataset with specified group information.

load_dummy_dataset(seed)

Load a dummy dataset for testing purposes, based on a mixture of 2 2D Gaussians.

load_ethicml_toy([group_in_features])

Load the EthicML toy dataset.

class fair_forge.datasets.AdultGroup(*values)[source]

Bases: Enum

RACE = 'Race'
SEX = 'Sex'
class fair_forge.datasets.Dataset(*args, **kwargs)[source]

Bases: Protocol

data: ndarray[tuple[Any, ...], dtype[_ScalarT]]
feature_names: list[str]
target: ndarray[tuple[Any, ...], dtype[_ScalarT]]
class fair_forge.datasets.GroupDataset(data: ndarray[tuple[Any, ...], dtype[float32]], target: ndarray[tuple[Any, ...], dtype[int32]], groups: ndarray[tuple[Any, ...], dtype[int32]], name: str, feature_grouping: list[slice], feature_names: list[str])[source]

Bases: NamedTuple

A dataset containing features, labels, and groups.

Parameters:
  • data – Features of the dataset.

  • target – Labels of the dataset.

  • groups – Groups of the dataset.

  • name – Name of the dataset.

  • feature_grouping – Slices indicating groups of features.

  • feature_names – Names of the features in the dataset.

data: ndarray[tuple[Any, ...], dtype[float32]]

Alias for field number 0

feature_grouping: list[slice]

Alias for field number 4

feature_names: list[str]

Alias for field number 5

groups: ndarray[tuple[Any, ...], dtype[int32]]

Alias for field number 2

name: str

Alias for field number 3

target: ndarray[tuple[Any, ...], dtype[int32]]

Alias for field number 1

fair_forge.datasets.grouping_by_prefix(*, columns: list[str], prefixes: list[str]) list[slice][source]

Create slices for feature grouping based on column prefixes.

fair_forge.datasets.load_adult(group: AdultGroup, *, group_in_features: bool = False, binarize_nationality: bool = False, binarize_race: bool = False) GroupDataset[source]

Load the Adult dataset with specified group information.

Parameters:

group – The group to use for the dataset.

Returns:

A Dataset object containing the Adult dataset.

fair_forge.datasets.load_dummy_dataset(seed: int) GroupDataset[source]

Load a dummy dataset for testing purposes, based on a mixture of 2 2D Gaussians.

The groups are random.

Parameters:

seed – Random seed for reproducibility.

fair_forge.datasets.load_ethicml_toy(group_in_features: bool = False) GroupDataset[source]

Load the EthicML toy dataset.