diff --git a/README.md b/README.md index 4d078f8..e430891 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,4 @@ ml-fairness-gym-discuss@google.com. # Versions v0.1.0: Initial release. +v0.1.1: Update to use gym 0.19.0. diff --git a/agents/allocation_agents.py b/agents/allocation_agents.py index b0f7015..7f75048 100644 --- a/agents/allocation_agents.py +++ b/agents/allocation_agents.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import copy diff --git a/agents/allocation_agents_test.py b/agents/allocation_agents_test.py index 908698b..f1cea2a 100644 --- a/agents/allocation_agents_test.py +++ b/agents/allocation_agents_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/agents/classifier_agents.py b/agents/classifier_agents.py index 3e8ca8f..00ff998 100644 --- a/agents/classifier_agents.py +++ b/agents/classifier_agents.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import collections diff --git a/agents/classifier_agents_test.py b/agents/classifier_agents_test.py index 442434f..8a34a38 100644 --- a/agents/classifier_agents_test.py +++ b/agents/classifier_agents_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/agents/college_admission_jury.py b/agents/college_admission_jury.py index 5ae5b95..0f0dba2 100644 --- a/agents/college_admission_jury.py +++ b/agents/college_admission_jury.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import core @@ -324,7 +323,7 @@ def __init__(self, self._subsidy_beta = subsidy_beta self._gaming_control = gaming_control - if burnin < 2: + if burnin < 2: # pytype: disable=unsupported-operands raise ValueError( 'This agent expects a longer burnin period, to work as expected.') diff --git a/agents/college_admission_jury_test.py b/agents/college_admission_jury_test.py index 30d45e8..dcbea59 100644 --- a/agents/college_admission_jury_test.py +++ b/agents/college_admission_jury_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/agents/infectious_disease_agents.py b/agents/infectious_disease_agents.py index cebca8f..fe277f0 100644 --- a/agents/infectious_disease_agents.py +++ b/agents/infectious_disease_agents.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import copy diff --git a/agents/infectious_disease_agents_test.py b/agents/infectious_disease_agents_test.py index bdabd5c..420bcf2 100644 --- a/agents/infectious_disease_agents_test.py +++ b/agents/infectious_disease_agents_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/agents/oracle_lending_agent.py b/agents/oracle_lending_agent.py index 4b81abf..09307af 100644 --- a/agents/oracle_lending_agent.py +++ b/agents/oracle_lending_agent.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function from agents import classifier_agents diff --git a/agents/oracle_lending_agent_test.py b/agents/oracle_lending_agent_test.py index 06eb4a0..f539b0d 100644 --- a/agents/oracle_lending_agent_test.py +++ b/agents/oracle_lending_agent_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/agents/random_agents.py b/agents/random_agents.py index e030a7d..ce8037c 100644 --- a/agents/random_agents.py +++ b/agents/random_agents.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/agents/random_agents_test.py b/agents/random_agents_test.py index a5fcf6e..54099c3 100644 --- a/agents/random_agents_test.py +++ b/agents/random_agents_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/agents/recommenders/__init__.py b/agents/recommenders/__init__.py index 8bbab52..bb04620 100644 --- a/agents/recommenders/__init__.py +++ b/agents/recommenders/__init__.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/agents/recommenders/batched_movielens_rnn_agent.py b/agents/recommenders/batched_movielens_rnn_agent.py index 5a38405..e384a0e 100644 --- a/agents/recommenders/batched_movielens_rnn_agent.py +++ b/agents/recommenders/batched_movielens_rnn_agent.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/agents/recommenders/batched_movielens_rnn_agent_test.py b/agents/recommenders/batched_movielens_rnn_agent_test.py index c34da92..8be2c8e 100644 --- a/agents/recommenders/batched_movielens_rnn_agent_test.py +++ b/agents/recommenders/batched_movielens_rnn_agent_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/agents/recommenders/evaluation.py b/agents/recommenders/evaluation.py index c0454d5..608886b 100644 --- a/agents/recommenders/evaluation.py +++ b/agents/recommenders/evaluation.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -125,9 +125,14 @@ def evaluate_agent(agent, env, alpha, num_users=100, deterministic=False, def plot_trajectories(rewards, health, figure_file_obj): + """Create a KDE or scatter plot of health rewards vs health.""" plt.figure() - g = sns.jointplot(x=rewards, y=health, kind='kde') - g.plot_joint(plt.scatter, c='grey', s=30, linewidth=1, marker='+') + try: + g = sns.jointplot(x=rewards, y=health, kind='kde') + g.plot_joint(plt.scatter, c='grey', s=30, linewidth=1, marker='+') + except np.linalg.LinAlgError: + # If the data does not support KDE plotting, just use scatter. + g = sns.jointplot(x=rewards, y=health, kind='scatter') g.ax_joint.collections[0].set_alpha(0) g.set_axis_labels('$Reward$', '$Health$') if figure_file_obj: diff --git a/agents/recommenders/evaluation_test.py b/agents/recommenders/evaluation_test.py index 94f62a2..18ddab5 100644 --- a/agents/recommenders/evaluation_test.py +++ b/agents/recommenders/evaluation_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/agents/recommenders/model.py b/agents/recommenders/model.py index e8fc000..db48f23 100644 --- a/agents/recommenders/model.py +++ b/agents/recommenders/model.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/agents/recommenders/model_test.py b/agents/recommenders/model_test.py index c66ccb3..2afb000 100644 --- a/agents/recommenders/model_test.py +++ b/agents/recommenders/model_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/agents/recommenders/rnn_agent.py b/agents/recommenders/rnn_agent.py index 60c253f..7864c49 100644 --- a/agents/recommenders/rnn_agent.py +++ b/agents/recommenders/rnn_agent.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/agents/recommenders/rnn_agent_tests.py b/agents/recommenders/rnn_agent_tests.py index d05ca38..9b054ac 100644 --- a/agents/recommenders/rnn_agent_tests.py +++ b/agents/recommenders/rnn_agent_tests.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/agents/recommenders/rnn_cvar_agent.py b/agents/recommenders/rnn_cvar_agent.py index d6b36c1..7998b63 100644 --- a/agents/recommenders/rnn_cvar_agent.py +++ b/agents/recommenders/rnn_cvar_agent.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/agents/recommenders/utils.py b/agents/recommenders/utils.py index 842f8b6..841ff65 100644 --- a/agents/recommenders/utils.py +++ b/agents/recommenders/utils.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/agents/threshold_policies.py b/agents/threshold_policies.py index a5ae9dd..cf35a93 100644 --- a/agents/threshold_policies.py +++ b/agents/threshold_policies.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/agents/threshold_policies_test.py b/agents/threshold_policies_test.py index c2cdef7..c7e6496 100644 --- a/agents/threshold_policies_test.py +++ b/agents/threshold_policies_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/core.py b/core.py index acb1e18..e99bfd6 100644 --- a/core.py +++ b/core.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import copy @@ -270,11 +269,17 @@ class FairnessEnv(gym.Env): def __init__(self, params = None, - initialize_observation_space = True): + initialize_observation_space = True, + init_action_space_random_state = True): self.history = [] # type: HistoryType self.state = None # type: Optional[State] self.reward_fn = None # type: Optional[RewardFn] + # Sometimes the action_space property is not ready here, e.g. RecsimWrapper + if init_action_space_random_state: + # gym.Space.np_random is created lazily, make sure it is created here. + _ = self.action_space.np_random + if initialize_observation_space: self.observation_space = gym.spaces.Dict(self.observable_state_vars) # Copy params so if environment mutates params it is contained to this @@ -601,5 +606,5 @@ def seed(self, value): def sample_from(self, space): """Sample from a space using the agent's own state.""" space = copy.deepcopy(space) - space.np_random = self.rng + space._np_random = self.rng # pylint: disable=protected-access return space.sample() diff --git a/core_test.py b/core_test.py index 9992824..3207abb 100644 --- a/core_test.py +++ b/core_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/distributions.py b/distributions.py index ee0e172..86ef65a 100644 --- a/distributions.py +++ b/distributions.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function from absl import logging diff --git a/distributions_test.py b/distributions_test.py index 33084d3..a222eee 100644 --- a/distributions_test.py +++ b/distributions_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/environments/attention_allocation.py b/environments/attention_allocation.py index 3ff26b1..3031514 100644 --- a/environments/attention_allocation.py +++ b/environments/attention_allocation.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -36,7 +36,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import copy diff --git a/environments/attention_allocation_test.py b/environments/attention_allocation_test.py index ee69093..9f3b144 100644 --- a/environments/attention_allocation_test.py +++ b/environments/attention_allocation_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/environments/college_admission.py b/environments/college_admission.py index 61b4748..af114e8 100644 --- a/environments/college_admission.py +++ b/environments/college_admission.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import copy diff --git a/environments/college_admission_test.py b/environments/college_admission_test.py index 37b0e97..7fd6fb0 100644 --- a/environments/college_admission_test.py +++ b/environments/college_admission_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/environments/infectious_disease.py b/environments/infectious_disease.py index 076c229..721a4f4 100644 --- a/environments/infectious_disease.py +++ b/environments/infectious_disease.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -27,7 +27,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import copy diff --git a/environments/infectious_disease_test.py b/environments/infectious_disease_test.py index 48b6d39..4e32693 100644 --- a/environments/infectious_disease_test.py +++ b/environments/infectious_disease_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/environments/lending.py b/environments/lending.py index 562afb6..9600d2f 100644 --- a/environments/lending.py +++ b/environments/lending.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -27,7 +27,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import copy diff --git a/environments/lending_params.py b/environments/lending_params.py index 412fdb3..510bcc1 100644 --- a/environments/lending_params.py +++ b/environments/lending_params.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import attr diff --git a/environments/lending_test.py b/environments/lending_test.py index b483465..0703c56 100644 --- a/environments/lending_test.py +++ b/environments/lending_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/environments/recommenders/download_movielens.py b/environments/recommenders/download_movielens.py index 8c68fcb..fa3a124 100644 --- a/environments/recommenders/download_movielens.py +++ b/environments/recommenders/download_movielens.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -77,21 +77,19 @@ def read_movielens_data(url): logging.info('Downloaded zip file containing: %s', downloaded_zip.namelist()) movies_df = pd.read_csv( downloaded_zip.open('ml-1m/movies.dat', 'r'), - sep=b'::', + sep='::', names=['movieId', 'title', 'genres'], encoding='iso-8859-1') - movies_df['genres'] = movies_df['genres'].str.decode('utf-8', 'ignore') - movies_df['title'] = movies_df['title'].str.decode('utf-8', 'ignore') users_df = pd.read_csv( downloaded_zip.open('ml-1m/users.dat', 'r'), - sep=b'::', + sep='::', names=['userId', 'sex', 'age', 'occupation', 'zip_code'], encoding='iso-8859-1') ratings_df = pd.read_csv( downloaded_zip.open('ml-1m/ratings.dat', 'r'), - sep=b'::', + sep='::', names=['userId', 'movieId', 'rating', 'timestamp'], encoding='iso-8859-1') return movies_df, users_df, ratings_df diff --git a/environments/recommenders/download_movielens_test.py b/environments/recommenders/download_movielens_test.py new file mode 100644 index 0000000..929409d --- /dev/null +++ b/environments/recommenders/download_movielens_test.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# Copyright 2022 The ML Fairness Gym Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Tests for download_movielens.""" + +from absl import flags +from absl.testing import absltest +import pandas as pd +import six + +FLAGS = flags.FLAGS + + +class DownloadMovielensTest(absltest.TestCase): + + def test_pandas_bytes_behavior(self): + """Check that pandas treats BytesIO stream as a string.""" + f = six.BytesIO(b'movieId::title::genres\n1::Toy Story (1995)::Animation') + _ = pd.read_csv(f, sep='::', encoding='iso-8859-1') + + +if __name__ == '__main__': + absltest.main() diff --git a/environments/recommenders/movie_lens_dynamic.py b/environments/recommenders/movie_lens_dynamic.py index 21c962f..431f2db 100644 --- a/environments/recommenders/movie_lens_dynamic.py +++ b/environments/recommenders/movie_lens_dynamic.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/environments/recommenders/movie_lens_dynamic_test.py b/environments/recommenders/movie_lens_dynamic_test.py index 8d15b0a..0100a14 100644 --- a/environments/recommenders/movie_lens_dynamic_test.py +++ b/environments/recommenders/movie_lens_dynamic_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/environments/recommenders/movie_lens_utils.py b/environments/recommenders/movie_lens_utils.py index 5ff80d5..629301b 100644 --- a/environments/recommenders/movie_lens_utils.py +++ b/environments/recommenders/movie_lens_utils.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/environments/recommenders/recsim_samplers.py b/environments/recommenders/recsim_samplers.py index 03bb25e..471ce33 100644 --- a/environments/recommenders/recsim_samplers.py +++ b/environments/recommenders/recsim_samplers.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/environments/recommenders/recsim_wrapper.py b/environments/recommenders/recsim_wrapper.py index d173a23..d14f414 100644 --- a/environments/recommenders/recsim_wrapper.py +++ b/environments/recommenders/recsim_wrapper.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function from typing import Any @@ -46,9 +45,14 @@ class RecsimWrapper(core.FairnessEnv): def __init__(self, params=None): """Initializes RecsimWrapper.""" super(RecsimWrapper, self).__init__( - params, initialize_observation_space=False) + params, + initialize_observation_space=False, + init_action_space_random_state=False) self.state = State(recsim_env=params.recsim_env) + # gym.Space.np_random is created lazily, make sure it is created here. + _ = self.action_space.np_random + # The use of @property here is intentional. RecsimGym objects have # action_space and observation_space as properties because they are updated # over the course of the simulation. In order to keep up to date with the diff --git a/environments/recommenders/recsim_wrapper_test.py b/environments/recommenders/recsim_wrapper_test.py index 026f837..fea7768 100644 --- a/environments/recommenders/recsim_wrapper_test.py +++ b/environments/recommenders/recsim_wrapper_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/environments/recommenders/restaurant_toy_recsim.py b/environments/recommenders/restaurant_toy_recsim.py index abc04f6..b01642c 100644 --- a/environments/recommenders/restaurant_toy_recsim.py +++ b/environments/recommenders/restaurant_toy_recsim.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/environments/recommenders/restaurant_toy_recsim_test.py b/environments/recommenders/restaurant_toy_recsim_test.py index b661896..819367e 100644 --- a/environments/recommenders/restaurant_toy_recsim_test.py +++ b/environments/recommenders/restaurant_toy_recsim_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/environments/template.py b/environments/template.py index de597f1..1bfd1f6 100644 --- a/environments/template.py +++ b/environments/template.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import copy diff --git a/environments/template_test.py b/environments/template_test.py index 7598aa6..1d25a9a 100644 --- a/environments/template_test.py +++ b/environments/template_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/experiments/acm_fat_2020/aggregate_lending_recall_values.py b/experiments/acm_fat_2020/aggregate_lending_recall_values.py index 6f56fd1..8d51a3e 100644 --- a/experiments/acm_fat_2020/aggregate_lending_recall_values.py +++ b/experiments/acm_fat_2020/aggregate_lending_recall_values.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -30,7 +30,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import os diff --git a/experiments/acm_fat_2020/attention_allocation_experiment_fat_main.py b/experiments/acm_fat_2020/attention_allocation_experiment_fat_main.py index 6366248..97b08db 100644 --- a/experiments/acm_fat_2020/attention_allocation_experiment_fat_main.py +++ b/experiments/acm_fat_2020/attention_allocation_experiment_fat_main.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/experiments/acm_fat_2020/college_admission_main.py b/experiments/acm_fat_2020/college_admission_main.py index af5084f..8538b92 100644 --- a/experiments/acm_fat_2020/college_admission_main.py +++ b/experiments/acm_fat_2020/college_admission_main.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import copy diff --git a/experiments/acm_fat_2020/lending_experiments_main.py b/experiments/acm_fat_2020/lending_experiments_main.py index 2b4c613..7115585 100644 --- a/experiments/acm_fat_2020/lending_experiments_main.py +++ b/experiments/acm_fat_2020/lending_experiments_main.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import functools diff --git a/experiments/attention_allocation_experiment.py b/experiments/attention_allocation_experiment.py index efdc026..1971dc0 100644 --- a/experiments/attention_allocation_experiment.py +++ b/experiments/attention_allocation_experiment.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import copy diff --git a/experiments/attention_allocation_experiment_plotting.py b/experiments/attention_allocation_experiment_plotting.py index 81bd8db..650eda6 100644 --- a/experiments/attention_allocation_experiment_plotting.py +++ b/experiments/attention_allocation_experiment_plotting.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/experiments/attention_allocation_experiment_test.py b/experiments/attention_allocation_experiment_test.py index f65ceb4..d8fa35d 100644 --- a/experiments/attention_allocation_experiment_test.py +++ b/experiments/attention_allocation_experiment_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/experiments/college_admission.py b/experiments/college_admission.py index 9ec185a..047c4f4 100644 --- a/experiments/college_admission.py +++ b/experiments/college_admission.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ """Experiment class for running college admission experiments.""" from __future__ import absolute_import from __future__ import division - from __future__ import print_function import copy diff --git a/experiments/college_admission_test.py b/experiments/college_admission_test.py index f8a1065..28153fc 100644 --- a/experiments/college_admission_test.py +++ b/experiments/college_admission_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/experiments/college_admission_util.py b/experiments/college_admission_util.py index d9a2339..5bcc7a7 100644 --- a/experiments/college_admission_util.py +++ b/experiments/college_admission_util.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ """Experiment class for running college admission experiments.""" from __future__ import absolute_import from __future__ import division - from __future__ import print_function import copy diff --git a/experiments/college_admission_util_test.py b/experiments/college_admission_util_test.py index d3d3513..76042bd 100644 --- a/experiments/college_admission_util_test.py +++ b/experiments/college_admission_util_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/experiments/infectious_disease.py b/experiments/infectious_disease.py index 10ff2b7..93d079f 100644 --- a/experiments/infectious_disease.py +++ b/experiments/infectious_disease.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import attr diff --git a/experiments/infectious_disease_rl.py b/experiments/infectious_disease_rl.py index cae96d6..1d4305f 100644 --- a/experiments/infectious_disease_rl.py +++ b/experiments/infectious_disease_rl.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import collections diff --git a/experiments/infectious_disease_rl_test.py b/experiments/infectious_disease_rl_test.py index 04e1f5a..a967834 100644 --- a/experiments/infectious_disease_rl_test.py +++ b/experiments/infectious_disease_rl_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/experiments/infectious_disease_test.py b/experiments/infectious_disease_test.py index 73bdcb6..7e94efb 100644 --- a/experiments/infectious_disease_test.py +++ b/experiments/infectious_disease_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/experiments/infectious_disease_util.py b/experiments/infectious_disease_util.py index 2f2c756..ebced17 100644 --- a/experiments/infectious_disease_util.py +++ b/experiments/infectious_disease_util.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/experiments/lending.py b/experiments/lending.py index 1456efe..4c08fcd 100644 --- a/experiments/lending.py +++ b/experiments/lending.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import attr diff --git a/experiments/lending_demo.py b/experiments/lending_demo.py index 3eeacc5..638783a 100644 --- a/experiments/lending_demo.py +++ b/experiments/lending_demo.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import os diff --git a/experiments/lending_plots.py b/experiments/lending_plots.py index 5c0686e..6c5d795 100644 --- a/experiments/lending_plots.py +++ b/experiments/lending_plots.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import bisect diff --git a/experiments/lending_plots_test.py b/experiments/lending_plots_test.py index f875ef6..d43e28b 100644 --- a/experiments/lending_plots_test.py +++ b/experiments/lending_plots_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/experiments/lending_test.py b/experiments/lending_test.py index a5a5b31..c571986 100644 --- a/experiments/lending_test.py +++ b/experiments/lending_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/experiments/movielens_recs.py b/experiments/movielens_recs.py index 567387e..e3e75a4 100644 --- a/experiments/movielens_recs.py +++ b/experiments/movielens_recs.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/experiments/movielens_recs_main.py b/experiments/movielens_recs_main.py index 35148fc..ef18a3e 100644 --- a/experiments/movielens_recs_main.py +++ b/experiments/movielens_recs_main.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/experiments/movielens_recs_test.py b/experiments/movielens_recs_test.py index 015855c..9067783 100644 --- a/experiments/movielens_recs_test.py +++ b/experiments/movielens_recs_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/file_util.py b/file_util.py index cf129a0..082b076 100644 --- a/file_util.py +++ b/file_util.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/file_util_test.py b/file_util_test.py index 4f1a668..8783a73 100644 --- a/file_util_test.py +++ b/file_util_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/metrics/distribution_comparison_metrics.py b/metrics/distribution_comparison_metrics.py index a34be81..4f3b70b 100644 --- a/metrics/distribution_comparison_metrics.py +++ b/metrics/distribution_comparison_metrics.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function from typing import Callable, Optional, Text, Tuple diff --git a/metrics/distribution_comparison_metrics_test.py b/metrics/distribution_comparison_metrics_test.py index cc3e182..b1efa2d 100644 --- a/metrics/distribution_comparison_metrics_test.py +++ b/metrics/distribution_comparison_metrics_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/metrics/error_metrics.py b/metrics/error_metrics.py index 97847bc..a185204 100644 --- a/metrics/error_metrics.py +++ b/metrics/error_metrics.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ """Auditors that measure classification errors.""" from __future__ import absolute_import from __future__ import division - from __future__ import print_function import collections diff --git a/metrics/error_metrics_test.py b/metrics/error_metrics_test.py index 42da364..5a22bf8 100644 --- a/metrics/error_metrics_test.py +++ b/metrics/error_metrics_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/metrics/infectious_disease_metrics.py b/metrics/infectious_disease_metrics.py index 6aeefe3..8a16706 100644 --- a/metrics/infectious_disease_metrics.py +++ b/metrics/infectious_disease_metrics.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import core @@ -28,7 +27,7 @@ def num_in_health_state(step, health_state): """Returns the number of people in health_state during a step.""" - state = step.state # type: infectious_disease.State + state = step.state # type: infectious_disease.State # pytype: disable=annotation-type-mismatch return sum(s == health_state for s in state.health_states) diff --git a/metrics/infectious_disease_metrics_test.py b/metrics/infectious_disease_metrics_test.py index e9ac288..a5b66be 100644 --- a/metrics/infectious_disease_metrics_test.py +++ b/metrics/infectious_disease_metrics_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/metrics/lending_metrics.py b/metrics/lending_metrics.py index b5f1319..725c324 100644 --- a/metrics/lending_metrics.py +++ b/metrics/lending_metrics.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,7 +17,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import core @@ -60,7 +59,7 @@ def measure(self, env): history = self._extract_history(env) result = [] for history_item in history: - state = history_item.state # type: lending.State + state = history_item.state # type: lending.State # pytype: disable=annotation-type-mismatch # Take advantage of the one-hot encoding of state.group in order to build # a (num_steps) x (num_groups) array with 1s where loans were given. # Multiplying by action makes a row of all zeros if the loan was rejected. @@ -84,7 +83,7 @@ def measure(self, env): numerator = [] denominator = [] for history_item in history: - state = history_item.state # type: lending.State + state = history_item.state # type: lending.State # pytype: disable=annotation-type-mismatch numerator.append( np.array(state.group) * history_item.action * (1 - state.will_default)) diff --git a/metrics/lending_metrics_test.py b/metrics/lending_metrics_test.py index dcb4399..5d4588c 100644 --- a/metrics/lending_metrics_test.py +++ b/metrics/lending_metrics_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/metrics/value_tracking_metrics.py b/metrics/value_tracking_metrics.py index 190f812..5dfc2d7 100644 --- a/metrics/value_tracking_metrics.py +++ b/metrics/value_tracking_metrics.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function import collections diff --git a/metrics/value_tracking_metrics_test.py b/metrics/value_tracking_metrics_test.py index df360c9..077727b 100644 --- a/metrics/value_tracking_metrics_test.py +++ b/metrics/value_tracking_metrics_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/params.py b/params.py index 8a676f9..b45b545 100644 --- a/params.py +++ b/params.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,6 @@ """Helper objects to store parameters.""" from __future__ import absolute_import from __future__ import division - from __future__ import print_function import attr diff --git a/params_test.py b/params_test.py index 509a437..8b35285 100644 --- a/params_test.py +++ b/params_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/requirements.txt b/requirements.txt index dc4917c..155b3f6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ atari-py attrs dopamine-rl gin-config -gym +gym==0.19.0 matplotlib monty more_itertools @@ -15,5 +15,5 @@ seaborn simplejson sklearn statsmodels -tensorflow==1.15.2 +tensorflow tqdm diff --git a/rewards.py b/rewards.py index cdd4d56..e0abe49 100644 --- a/rewards.py +++ b/rewards.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function from typing import Any, Optional diff --git a/rewards_test.py b/rewards_test.py index d07f0fa..ccc0e28 100644 --- a/rewards_test.py +++ b/rewards_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/run.sh b/run.sh index 90f84b7..d858008 100755 --- a/run.sh +++ b/run.sh @@ -1,4 +1,4 @@ -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/run_util.py b/run_util.py index 57c60ca..b43e177 100644 --- a/run_util.py +++ b/run_util.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/runner.py b/runner.py index 930fa67..88ec9e3 100644 --- a/runner.py +++ b/runner.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -31,7 +31,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function from absl import app diff --git a/runner_lib.py b/runner_lib.py index a6350b5..2848d53 100644 --- a/runner_lib.py +++ b/runner_lib.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function from typing import Any, Callable, Dict, Optional, Text, Type diff --git a/runner_lib_test.py b/runner_lib_test.py index 7580a5e..8f9c6a9 100644 --- a/runner_lib_test.py +++ b/runner_lib_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/spaces/batch.py b/spaces/batch.py index 9b63da0..5bb5180 100644 --- a/spaces/batch.py +++ b/spaces/batch.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function from typing import Any, Iterable, List diff --git a/spaces/batch_test.py b/spaces/batch_test.py index 178ca5e..c9b8382 100644 --- a/spaces/batch_test.py +++ b/spaces/batch_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/spaces/graph.py b/spaces/graph.py index 73e5d5e..3a5b6ad 100644 --- a/spaces/graph.py +++ b/spaces/graph.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function from typing import Any diff --git a/spaces/graph_test.py b/spaces/graph_test.py index c7a1df9..ba9b540 100644 --- a/spaces/graph_test.py +++ b/spaces/graph_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/spaces/multi_discrete_with_none.py b/spaces/multi_discrete_with_none.py index 9d8ddee..e4cb416 100644 --- a/spaces/multi_discrete_with_none.py +++ b/spaces/multi_discrete_with_none.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function from gym.spaces import multi_discrete diff --git a/spaces/multi_discrete_with_none_test.py b/spaces/multi_discrete_with_none_test.py index 39d58b2..9934d34 100644 --- a/spaces/multi_discrete_with_none_test.py +++ b/spaces/multi_discrete_with_none_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/spaces/multinomial.py b/spaces/multinomial.py index 1f65c13..b2b4bd3 100644 --- a/spaces/multinomial.py +++ b/spaces/multinomial.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ from __future__ import absolute_import from __future__ import division - from __future__ import print_function from gym import spaces diff --git a/spaces/multinomial_test.py b/spaces/multinomial_test.py index 843abf3..4ea45fb 100644 --- a/spaces/multinomial_test.py +++ b/spaces/multinomial_test.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/test_util.py b/test_util.py index 93c6f0d..025b36b 100644 --- a/test_util.py +++ b/test_util.py @@ -1,5 +1,5 @@ # coding=utf-8 -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/tests.sh b/tests.sh index c62e9a6..5e1fe2f 100755 --- a/tests.sh +++ b/tests.sh @@ -1,4 +1,4 @@ -# Copyright 2020 The ML Fairness Gym Authors. +# Copyright 2022 The ML Fairness Gym Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.