lale.lib.aif360.protected_attributes_encoder module

class lale.lib.aif360.protected_attributes_encoder.ProtectedAttributesEncoder(*args, _lale_trained=False, _lale_impl=None, **kwargs)

Bases: TrainedIndividualOp

Protected attributes encoder.

This documentation is auto-generated from JSON schemas.

The protected_attributes argument describes each sensitive column by a feature name or index and a reference_group list of values or ranges. This transformer encodes protected attributes with values of 0, 0.5, or 1 to indicate membership in the unprivileged, neither, or privileged group, respectively. That encoding makes the protected attributes suitable as input for downstream fairness mitigation operators. This operator does not encode the remaining (non-protected) attributes. A common usage is to encode non-protected attributes with a separate data preparation pipeline and to perform a feature union before piping the transformed data to downstream operators that require numeric data. This operator is used internally by various lale.lib.aif360 metrics and mitigators, so you often do not need to use it directly yourself.

Parameters
  • favorable_labels (union type, optional, not for optimizer, default None) –

    • array, >=1 items

      Label values which are considered favorable (i.e. “positive”).

      • items : union type

        • float

          Numerical value.

        • or string

          Literal string value.

        • or boolean

          Boolean value.

        • or array, >=2 items, <=2 items of items : float

          Numeric range [a,b] from a to b inclusive.

    • or None

    See also constraint-1.

  • protected_attributes (union type, not for optimizer, default None) –

    • array, >=1 items

      Features for which fairness is desired.

      • items : dict

        • feature : union type

          Column name or column index.

          • string

          • or integer

        • reference_group : array, >=1 items

          Values or ranges that indicate being a member of the privileged group.

          • items : union type

            • string

              Literal value.

            • or float

              Numerical value.

            • or array, >=2 items, <=2 items of items : float

              Numeric range [a,b] from a to b inclusive.

        • monitored_group : union type, default None

          Values or ranges that indicate being a member of the unprivileged group.

          • None

            If monitored_group is not explicitly specified, consider any values not captured by reference_group as monitored.

          • or array, >=1 items

            • items : union type

              • string

                Literal value.

              • or float

                Numerical value.

              • or array, >=2 items, <=2 items of items : float

                Numeric range [a,b] from a to b inclusive.

    • or None

    See also constraint-2.

  • unfavorable_labels (union type, optional, not for optimizer, default None) –

    Label values which are considered unfavorable (i.e. “negative”).

    • None

      If unfavorable_labels is not explicitly specified, consider any labels not captured by favorable_labels as unfavorable.

    • or array, >=1 items

      • items : union type

        • float

          Numerical value.

        • or string

          Literal string value.

        • or boolean

          Boolean value.

        • or array, >=2 items, <=2 items of items : float

          Numeric range [a,b] from a to b inclusive.

  • remainder (‘passthrough’ or ‘drop’, optional, not for optimizer, default ‘drop’) – Transformation for columns that were not specified in protected_attributes.

  • return_X_y (boolean, optional, not for optimizer, default False) –

    Deprecated, use transform_X_y instead. If True, transform returns a tuple with X and y; otherwise, transform returns only X, not as a tuple.

    See also constraint-1.

  • combine (‘keep_separate’, ‘and’, ‘or’, or ‘error’, optional, not for optimizer, default ‘keep_separate’) –

    How to handle the case when there is more than one protected attribute.

    See also constraint-2.

Notes

constraint-1 : union type

If returning y, need to know how to encode it.

  • return_X_y : False

  • or favorable_labels : negated type of None

constraint-2 : union type

If combine is error, must have only one protected attribute.

  • combine : negated type of ‘error’

  • or protected_attributes : array, <=1 items

transform(X, y=None)

Transform the data.

Parameters
  • X (array) –

    Features; the outer array is over samples.

    • items : array

      • items : union type

        • float

        • or string

  • y (union type, default None) –

    Target labels.

    • array

      • items : union type

        • float

        • or string

    • or None

Returns

result

  • array

    If return_X_y is False, return X.

    • items : array

      This operator encodes protected attributes as 0, 0.5, or 1. So if the remainder (non-protected attributes) is dropped, the output is numeric. Otherwise, the output may still contain non-numeric values.

      • items : union type

        • float

        • or string

  • or tuple

    If return_X_y is True, return tuple of X and y.

    • item 0 : array

      X

      • items : array

        • items : union type

          • float

          • or string

    • item 1 : array

      y

      • items : union type

        • float

        • or string

Return type

union type

transform_X_y(X, y)

Transform the data and target.

Parameters
  • X (array) –

    Features; the outer array is over samples.

    • items : array

      • items : union type

        • float

        • or string

  • y (array) –

    Target labels.

    • items : union type

      • float

      • or string

Returns

result

  • item 0 : array

    X

    • items : array

      • items : union type

        • float

        • or string

  • item 1 : array

    y

    • items : union type

      • float

      • or string

Return type

tuple