How to use the aif360.metrics.SampleDistortionMetric function in aif360

To help you get started, we’ve selected a few aif360 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github IBM / AIF360 / tests / test_sample_distortion_metric.py View on Github external
def test_conditional():
    sdm = SampleDistortionMetric(sd, sd_distorted, unprivileged_groups=unpriv,
        privileged_groups=priv)
    assert sdm.total_manhattan_distance(privileged=False) == 3
github IBM / AIF360 / tests / test_sample_distortion_metric.py View on Github external
def test_euclidean_distance():
    sdm = SampleDistortionMetric(sd, sd_distorted)
    assert sdm.total_euclidean_distance() == 4*np.sqrt(3)
github IBM / AIF360 / tests / test_sample_distortion_metric.py View on Github external
def test_mahalanobis_distance():
    sdm = SampleDistortionMetric(sd_rand, sd_rand2)
    assert np.isclose(sdm.total_mahalanobis_distance(),
        np.diag(cdist(rand[:, :3], rand2[:, :3], 'mahalanobis')).sum())
github IBM / AIF360 / tests / test_sample_distortion_metric.py View on Github external
def test_average():
    sd_distorted.features[-1, -1] += 1
    sd.instance_weights = sd_distorted.instance_weights = np.array([1, 1, 1, 3])
    sdm = SampleDistortionMetric(sd, sd_distorted)
    assert sdm.average_manhattan_distance() == 3.5
github IBM / AIF360 / tests / test_sample_distortion_metric.py View on Github external
def test_error():
    try:
        sd.protected_attributes -= 1
        sdm = SampleDistortionMetric(sd, sd_distorted)
    except ValueError:
        assert True
github IBM / AIF360 / tests / test_sample_distortion_metric.py View on Github external
def test_manhattan_distance():
    sdm = SampleDistortionMetric(sd, sd_distorted)
    assert sdm.total_manhattan_distance() == 12