8000 FIX create utils module by romanlutz · Pull Request #878 · fairlearn/fairlearn · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

FIX create utils module #878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHu 8000 b”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jun 29, 2021
4 changes: 2 additions & 2 deletions fairlearn/postprocessing/_interpolated_thresholder.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
from warnings import warn

from ..utils._common import _get_soft_predictions
from .._input_validation import _validate_and_reformat_input
from ..utils._input_validation import _validate_and_reformat_input
from ._constants import (
BASE_ESTIMATOR_NONE_ERROR_MESSAGE,
BASE_ESTIMATOR_NOT_FITTED_WARNING)


class InterpolatedThresholder(BaseEstimator, MetaEstimatorMixin):
"""Binary predictor that thresholds continuous predictions of a base estimator.
r"""Binary predictor that thresholds continuous predictions of a base estimator.

At prediction time, the predictor takes as input both standard and sensitive features.
Based on the values of sensitive features, it then applies a randomized thresholding
Expand Down
2 changes: 1 addition & 1 deletion fairlearn/postprocessing/_threshold_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from sklearn.utils import Bunch

from ..utils._common import _get_soft_predictions
from .._input_validation import (
from ..utils._input_validation import (
_validate_and_reformat_input,
_KW_CONTROL_FEATURES,
)
Expand Down
2 changes: 1 addition & 1 deletion fairlearn/reductions/_moments/bounded_group_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .moment import LossMoment
from .moment import _GROUP_ID, _LABEL, _LOSS, _PREDICTION, _ALL

from fairlearn._input_validation import _validate_and_reformat_input
from fairlearn.utils._input_validation import _validate_and_reformat_input


class ConditionalLossMoment(LossMoment):
Expand Down
2 changes: 1 addition & 1 deletion fairlearn/reductions/_moments/error_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from .moment import ClassificationMoment
from .moment import _ALL, _LABEL

from fairlearn._input_validation import _validate_and_reformat_input
from fairlearn.utils._input_validation import _validate_and_reformat_input


class ErrorRate(ClassificationMoment):
Expand Down
5 changes: 4 additions & 1 deletion fairlearn/reductions/_moments/utility_parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

from .moment import ClassificationMoment
from .moment import _GROUP_ID, _LABEL, _PREDICTION, _ALL, _EVENT, _SIGN
from fairlearn._input_validation import _MESSAGE_RATIO_NOT_IN_RANGE, _validate_and_reformat_input
from fairlearn.utils._input_validation import (
_MESSAGE_RATIO_NOT_IN_RANGE,
_validate_and_reformat_input
)
from .error_rate import ErrorRate


Expand Down
4 changes: 4 additions & 0 deletions fairlearn/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) Fairlearn contributors.
# Licensed under the MIT License.

"""This module contains utilities for Fairlearn."""
2 changes: 1 addition & 1 deletion fairlearn/utils/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the MIT License.

def _get_soft_predictions(estimator, X, predict_method):
"""Return soft predictions of a classifier.
r"""Return soft predictions of a classifier.

Parameters
----------
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/unit/input_convertors.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy as np
import pandas as pd

from fairlearn._input_validation import _merge_columns
from fairlearn.utils._input_validation import _merge_columns


def ensure_list(X):
Expand Down
15 changes: 7 additions & 8 deletions test/unit/postprocessing/test_threshold_optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
from copy import deepcopy
import numpy as np
import pytest
from fairlearn._input_validation import \
(_MESSAGE_Y_NONE,
_MESSAGE_SENSITIVE_FEATURES_NONE,
_LABELS_NOT_0_1_ERROR_MESSAGE)
from fairlearn.utils._input_validation import (
_MESSAGE_Y_NONE,
_MESSAGE_SENSITIVE_FEATURES_NONE,
_LABELS_NOT_0_1_ERROR_MESSAGE)
from fairlearn.postprocessing import ThresholdOptimizer
from fairlearn.postprocessing._threshold_optimizer import \
(NOT_SUPPORTED_CONSTRAINTS_ERROR_MESSAGE,
BASE_ESTIMATOR_NONE_ERROR_MESSAGE,
)
from fairlearn.postprocessing._threshold_optimizer import (
NOT_SUPPORTED_CONSTRAINTS_ERROR_MESSAGE,
BASE_ESTIMATOR_NONE_ERROR_MESSAGE)
from fairlearn.postprocessing._tradeoff_curve_utilities import DEGENERATE_LABELS_ERROR_MESSAGE
from .conftest import (sensitive_features_ex1, labels_ex, degenerate_labels_ex,
scores_ex, sensitive_feature_names_ex1, X_ex,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from fairlearn.reductions import ExponentiatedGradient
from fairlearn.reductions import DemographicParity
from fairlearn.reductions import ErrorRate
from fairlearn._input_validation import \
from fairlearn.utils._input_validation import \
(_LABELS_NOT_0_1_ERROR_MESSAGE)
from .simple_learners import LeastSquaresBinaryClassifierLearner
from .test_utilities import _get_data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler

from fairlearn._input_validation import \
from fairlearn.utils._input_validation import \
(_MESSAGE_Y_NONE,
_LABELS_NOT_0_1_ERROR_MESSAGE)
from fairlearn.reductions import GridSearch, DemographicParity, EqualizedOdds, BoundedGroupLoss, \
Expand Down
0