fairodds-auc


Namefairodds-auc JSON
Version 0.2.0 PyPI version JSON
download
home_pageNone
SummaryFairOdds-AUC: A fairness-scaled AUROC metric that penalizes equalized odds gaps across sensitive attributes
upload_time2025-08-20 21:59:37
maintainerNone
docs_urlNone
authorFairOdds-AUC Authors
requires_python>=3.8
licenseMIT License Copyright (c) 2025 FairOdds-AUC Authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords auc auroc bias equalized odds fairness metrics
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ### FairOdds-AUC

FairOdds-AUC is a fairness-scaled AUROC metric that multiplicatively penalizes equalized-odds gaps across user-specified sensitive attributes. It enables a single, tunable score that balances utility and fairness via a nonnegative temperature parameter λ.

Formula:
- FairOdds-AUC = AUROC / (1 + λ · GEO)
- GEO = sum over sensitive attributes of Equalized Odds differences (per Fairlearn)

When λ = 0, the score reduces to AUROC. Larger λ puts more weight on fairness, discounting models with larger equalized-odds disparities.

### Installation

```bash
pip install fairodds-auc
```

From source (editable):

```bash
pip install -U pip
pip install -e .
```

### Quickstart

```python
import numpy as np
from fairodds_auc import fair_odds_auc

y_true = np.array([0, 1, 0, 1, 0, 1])
y_score = np.array([0.1, 0.9, 0.3, 0.8, 0.2, 0.7])

# any attributes you care about
race = np.array(["A", "A", "B", "B", "A", "B"]) 
sex = np.array(["F", "M", "F", "M", "F", "M"])   

sensitive_features = {"race": race, "sex": sex}

score = fair_odds_auc(
    y_true=y_true,
    y_score=y_score,
    sensitive_features=sensitive_features,
    lambda_=1.0,
    threshold=0.5,
    agg="mean",  # or 'worst_case' to match Fairlearn default
)
print(score)
```

### API

- `fair_odds_auc(y_true, y_score, sensitive_features, lambda_=1.0, threshold=0.5, method='between_groups', agg='mean', sample_weight=None) -> float`
- `equalized_odds_gap(y_true, y_pred, group, method='between_groups', agg='mean', sample_weight=None) -> float`
- `generalized_equalized_odds(y_true, y_pred, sensitive_features, method='between_groups', agg='mean', sample_weight=None) -> (dict, float)`

Notes:
- EO uses hard decisions `y_pred` from thresholding `y_score`.
- EO is computed using `fairlearn.metrics.equalized_odds_difference` under the hood.
- Pass `sensitive_features` as a single array-like or a dict of name->array-like.

### References
- Fong et al. (2022): Bias-penalized AUC (fairAUC)
- Pfohl et al. (2021): Balancing performance and fairness in clinical ML
- Dehdashtian et al. (2024): U-FaTE multi-objective framework

### License
MIT

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "fairodds-auc",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "auc, auroc, bias, equalized odds, fairness, metrics",
    "author": "FairOdds-AUC Authors",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/68/b0/8d9ba249724be20b7e69fc660e80c2e224e7d7c2e4611811d9130e1e5fb4/fairodds_auc-0.2.0.tar.gz",
    "platform": null,
    "description": "### FairOdds-AUC\n\nFairOdds-AUC is a fairness-scaled AUROC metric that multiplicatively penalizes equalized-odds gaps across user-specified sensitive attributes. It enables a single, tunable score that balances utility and fairness via a nonnegative temperature parameter \u03bb.\n\nFormula:\n- FairOdds-AUC = AUROC / (1 + \u03bb \u00b7 GEO)\n- GEO = sum over sensitive attributes of Equalized Odds differences (per Fairlearn)\n\nWhen \u03bb = 0, the score reduces to AUROC. Larger \u03bb puts more weight on fairness, discounting models with larger equalized-odds disparities.\n\n### Installation\n\n```bash\npip install fairodds-auc\n```\n\nFrom source (editable):\n\n```bash\npip install -U pip\npip install -e .\n```\n\n### Quickstart\n\n```python\nimport numpy as np\nfrom fairodds_auc import fair_odds_auc\n\ny_true = np.array([0, 1, 0, 1, 0, 1])\ny_score = np.array([0.1, 0.9, 0.3, 0.8, 0.2, 0.7])\n\n# any attributes you care about\nrace = np.array([\"A\", \"A\", \"B\", \"B\", \"A\", \"B\"]) \nsex = np.array([\"F\", \"M\", \"F\", \"M\", \"F\", \"M\"])   \n\nsensitive_features = {\"race\": race, \"sex\": sex}\n\nscore = fair_odds_auc(\n    y_true=y_true,\n    y_score=y_score,\n    sensitive_features=sensitive_features,\n    lambda_=1.0,\n    threshold=0.5,\n    agg=\"mean\",  # or 'worst_case' to match Fairlearn default\n)\nprint(score)\n```\n\n### API\n\n- `fair_odds_auc(y_true, y_score, sensitive_features, lambda_=1.0, threshold=0.5, method='between_groups', agg='mean', sample_weight=None) -> float`\n- `equalized_odds_gap(y_true, y_pred, group, method='between_groups', agg='mean', sample_weight=None) -> float`\n- `generalized_equalized_odds(y_true, y_pred, sensitive_features, method='between_groups', agg='mean', sample_weight=None) -> (dict, float)`\n\nNotes:\n- EO uses hard decisions `y_pred` from thresholding `y_score`.\n- EO is computed using `fairlearn.metrics.equalized_odds_difference` under the hood.\n- Pass `sensitive_features` as a single array-like or a dict of name->array-like.\n\n### References\n- Fong et al. (2022): Bias-penalized AUC (fairAUC)\n- Pfohl et al. (2021): Balancing performance and fairness in clinical ML\n- Dehdashtian et al. (2024): U-FaTE multi-objective framework\n\n### License\nMIT\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2025 FairOdds-AUC Authors\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.",
    "summary": "FairOdds-AUC: A fairness-scaled AUROC metric that penalizes equalized odds gaps across sensitive attributes",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/your-name/fairodds-auc",
        "Issues": "https://github.com/your-name/fairodds-auc/issues",
        "Repository": "https://github.com/your-name/fairodds-auc"
    },
    "split_keywords": [
        "auc",
        " auroc",
        " bias",
        " equalized odds",
        " fairness",
        " metrics"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "ab86786802c6ea0f07e7cf90321c336b5459ce0c987196354918d713f8d179ca",
                "md5": "8d985e2664b895d2d86782837bde2336",
                "sha256": "3b678f9eb933ffcc1315091059a19b1f118e78ffe4d3ecc8f03fb6e4f9dd7eac"
            },
            "downloads": -1,
            "filename": "fairodds_auc-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8d985e2664b895d2d86782837bde2336",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 7962,
            "upload_time": "2025-08-20T21:59:36",
            "upload_time_iso_8601": "2025-08-20T21:59:36.912705Z",
            "url": "https://files.pythonhosted.org/packages/ab/86/786802c6ea0f07e7cf90321c336b5459ce0c987196354918d713f8d179ca/fairodds_auc-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "68b08d9ba249724be20b7e69fc660e80c2e224e7d7c2e4611811d9130e1e5fb4",
                "md5": "f4504fbdb6fedd4d05a1bcb1873801d9",
                "sha256": "5db38b2a9628f41fb6489c79e33f6f301ab2e4cdbb951fbd442d2a8022ce673e"
            },
            "downloads": -1,
            "filename": "fairodds_auc-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "f4504fbdb6fedd4d05a1bcb1873801d9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 4379,
            "upload_time": "2025-08-20T21:59:37",
            "upload_time_iso_8601": "2025-08-20T21:59:37.854634Z",
            "url": "https://files.pythonhosted.org/packages/68/b0/8d9ba249724be20b7e69fc660e80c2e224e7d7c2e4611811d9130e1e5fb4/fairodds_auc-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-20 21:59:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "your-name",
    "github_project": "fairodds-auc",
    "github_not_found": true,
    "lcname": "fairodds-auc"
}
        
Elapsed time: 0.99046s