Skip to content

Export MulticlassLabelDataset from aif360.datasets - #581

Open
siddhantharsh wants to merge 1 commit into
Trusted-AI:mainfrom
siddhantharsh:export-multiclass-label-dataset
Open

siddhantharsh wants to merge 1 commit into
Trusted-AI:mainfrom
siddhantharsh:export-multiclass-label-dataset

Conversation

@siddhantharsh

Copy link
Copy Markdown

Closes #425

Problem

MulticlassLabelDataset cannot be imported from aif360.datasets the way the other dataset classes can:

>>> from aif360.datasets import MulticlassLabelDataset
ImportError: cannot import name 'MulticlassLabelDataset' from 'aif360.datasets'

It is only reachable through aif360.datasets.multiclass_label_dataset, and it has no page in the API docs.

Fix

  • Import the class in aif360/datasets/__init__.py, after BinaryLabelDataset. The order matters: multiclass_label_dataset.py does from aif360.datasets import StructuredDataset, so importing it before StructuredDataset is defined in the package raises a circular import error.
  • Add it to "Base classes" in docs/source/modules/datasets.rst.
  • Remove a stray zero-width space (U+200B) from the validate_dataset docstring in multiclass_label_dataset.py. It sat on what should be a blank line, and once the class was added to the docs it made Sphinx report "Unexpected indentation" on the class page. This is a one-line change and the file's CRLF line endings are unchanged.
  • Add tests/test_multiclass_label_dataset.py.

No behaviour changes: this only makes an existing class importable from the package and documents it. No new dependencies or datasets.

Testing

Python 3.12, following CONTRIBUTING.

  • The new tests fail on main with the ImportError above and pass with this change.
  • pytest tests/test_multiclass_label_dataset.py tests/test_classification_metric.py tests/test_structured_dataset.py: 13 passed.
  • Full pytest tests: no new failures compared with main. Every test that fails with this change also fails on main; in my environment those need R (MEPS, fairadapt) or hit dependency version drift (fmin_l_bfgs_b in the LFR tests, the bank loader).
  • flake8 . --select=E9,F63,F7,F82 (the CI hard-fail rules): no errors.
  • make html in docs/ builds, the MulticlassLabelDataset page is generated, and there are no warnings about it.

The commit is signed off (DCO).

MulticlassLabelDataset could only be imported from its submodule,
unlike every other dataset class, and had no page in the docs.

- Import it in aif360/datasets/__init__.py (after BinaryLabelDataset,
  since the module itself imports StructuredDataset from the package).
- List it under "Base classes" in docs/source/modules/datasets.rst.
- Remove a stray zero-width space from the validate_dataset docstring
  that made Sphinx report "Unexpected indentation" once the class
  was added to the docs.
- Add tests/test_multiclass_label_dataset.py.

Closes Trusted-AI#425

Signed-off-by: siddhantharsh <siddhant101213@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing MulticlassLabelDataset Import

1 participant