Skip to content

Commit

Permalink
add docs for fairness
Browse files Browse the repository at this point in the history
  • Loading branch information
ycq091044 committed Sep 1, 2023
1 parent 4ffa2cc commit 9301702
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/api/metrics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ tasks, such as drug drug interaction (DDI) rate.
metrics/pyhealth.metrics.binary
metrics/pyhealth.metrics.calibration
metrics/pyhealth.metrics.prediction_set
metrics/pyhealth.metrics.fairness
14 changes: 14 additions & 0 deletions docs/api/metrics/pyhealth.metrics.fairness.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pyhealth.metrics.fairness
===================================

.. currentmodule:: pyhealth.metrics.fairness

.. autofunction:: fairness_metrics_fn

.. currentmodule:: pyhealth.metrics.fairness_utils

.. autofunction:: disparate_impact

.. autofunction:: statistical_parity_difference

.. autofunction:: sensitive_attributes_from_patient_ids
6 changes: 6 additions & 0 deletions docs/log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ Development logs
======================
We track the new development here:

**Sep 01, 2023**

.. code-block:: rst
1. add Base fairness metrics and example `#216`.
**July 22, 2023**

.. code-block:: rst
Expand Down
2 changes: 2 additions & 0 deletions pyhealth/metrics/fairness_utils/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ def disparate_impact(sensitive_attributes: np.ndarray, y_pred: np.ndarray, favor
Computes the disparate impact between the the protected and unprotected group.
disparate_impact = P(y_pred = favorable_outcome | P) / P(y_pred = favorable_outcome | U)
Args:
sensitive_attributes: Sensitive attributes of shape (n_samples,) where 1 is the protected group and 0 is the unprotected group.
y_pred: Predicted target values of shape (n_samples,).
favorable_outcome: Label value which is considered favorable (i.e. "positive").
allow_zero_division: If True, use epsilon instead of 0 in the denominator if the denominator is 0. Otherwise, raise a ValueError.
Returns:
The disparate impact between the protected and unprotected group.
"""
Expand Down

0 comments on commit 9301702

Please sign in to comment.