diff --git a/AUTHORS.md b/AUTHORS.md index e123a5f90..05ebdf145 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -23,3 +23,4 @@ All names are sorted alphabetically by last name. Contributors, please add your - [Hanna Wallach](https://www.microsoft.com/en-us/research/people/wallach/) - [Vincent Xu](https://github.com/vingu) - [Beth Zeranski](https://github.com/bethz) +- [Arjun Singh](https://github.com/arjsingh) \ No newline at end of file diff --git a/CHANGES.md b/CHANGES.md index f23d632b7..f2ad600b9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -41,6 +41,7 @@ * Add new constraints and objectives in `ThresholdOptimizer` * Add class `InterpolatedThresholder` to represent the fitted `ThresholdOptimizer` * Add `fairlearn.datasets` module. +* Display progress bar for grid search and exponentiated gradient ### v0.4.6 diff --git a/fairlearn/reductions/_exponentiated_gradient/exponentiated_gradient.py b/fairlearn/reductions/_exponentiated_gradient/exponentiated_gradient.py index d6b007bbf..1c2a7e546 100644 --- a/fairlearn/reductions/_exponentiated_gradient/exponentiated_gradient.py +++ b/fairlearn/reductions/_exponentiated_gradient/exponentiated_gradient.py @@ -9,6 +9,7 @@ from ._constants import _ACCURACY_MUL, _REGRET_CHECK_START_T, _REGRET_CHECK_INCREASE_T, \ _SHRINK_REGRET, _SHRINK_ETA, _MIN_ITER, _PRECISION, _INDENTATION from ._lagrangian import _Lagrangian +from tqdm import tqdm from fairlearn.reductions._moments import ClassificationMoment from fairlearn._input_validation import _validate_and_reformat_input @@ -101,7 +102,7 @@ def fit(self, X, y, **kwargs): last_regret_checked = _REGRET_CHECK_START_T last_gap = np.PINF - for t in range(0, self.max_iter): + for t in tqdm(range(0, self.max_iter)): logger.debug("...iter=%03d", t) # set lambdas for every constraint diff --git a/fairlearn/reductions/_grid_search/grid_search.py b/fairlearn/reductions/_grid_search/grid_search.py index 7b7d6bdf4..e6d0dc640 100644 --- a/fairlearn/reductions/_grid_search/grid_search.py +++ b/fairlearn/reductions/_grid_search/grid_search.py @@ -9,6 +9,7 @@ from sklearn.dummy import DummyClassifier from sklearn.utils.validation import check_is_fitted from time import time +from tqdm import tqdm from fairlearn._input_validation import _validate_and_reformat_input, _KW_SENSITIVE_FEATURES from fairlearn.reductions._moments import Moment, ClassificationMoment @@ -151,7 +152,7 @@ def fit(self, X, y, **kwargs): # Fit the estimates logger.debug("Setup complete. Starting grid search") - for i in grid.columns: + for i in tqdm(grid.columns): lambda_vec = grid[i] logger.debug("Obtaining weights") weights = self.constraints.signed_weights(lambda_vec) diff --git a/requirements.txt b/requirements.txt index 691f7afe8..b1fa1fceb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,7 @@ numpy>=1.17.2 pandas>=0.25.1 scikit-learn>=0.22.1 scipy>=1.4.1 +tqdm>=4.47.0 # Required for environment autopep8 diff --git a/setup.py b/setup.py index 99ed22c70..e02c54d4e 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,8 @@ "numpy>=1.17.2", "pandas>=0.25.1", "scikit-learn>=0.22.1", - "scipy>=1.3.1" + "scipy>=1.3.1", + "tqdm>=4.47.0" ], extras_require={ "customplots": [