Trusted-AI / AIF360

A comprehensive set of fairness metrics for datasets and machine learning models, explanations for these metrics, and algorithms to mitigate bias in datasets and models.
https://aif360.res.ibm.com/
Apache License 2.0
2.46k stars 840 forks source link

type(...) instead of isinstance(...) #292

Closed alfa-yohannis closed 2 years ago

alfa-yohannis commented 2 years ago

https://github.com/Trusted-AI/AIF360/blob/48acf62c827a00dff881d4b08903fee2d108a9b9/aif360/explainers/metric_json_explainer.py#L155

I think there is a logic error in disparate_impact() and statistical_parity_difference(). The line if isinstance(self.metric, BinaryLabelDatasetMetric): should be if type(self.metric) is BinaryLabelDatasetMetric:, otherwise any class derived from BinaryLabelDatasetMetric, including ClassificationMetric, always goes to the first condition.

Cheers,