Skip to content

Commit

Permalink
removed __future__ imports
Browse files Browse the repository at this point in the history
  • Loading branch information
hoffmansc committed May 17, 2019
1 parent 0bf1153 commit ca48d65
Show file tree
Hide file tree
Showing 45 changed files with 10 additions and 241 deletions.
5 changes: 0 additions & 5 deletions aif360/algorithms/inprocessing/adversarial_debiasing.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import numpy as np

try:
Expand Down
5 changes: 0 additions & 5 deletions aif360/algorithms/inprocessing/art_classifier.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import numpy as np

from aif360.datasets import BinaryLabelDataset
Expand Down
5 changes: 0 additions & 5 deletions aif360/algorithms/inprocessing/meta_fair_classifier.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# The code for Meta-Classification-Algorithm is based on, the paper https://arxiv.org/abs/1806.06055
# See: https://github.com/vijaykeswani/FairClassification
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import numpy as np

from aif360.algorithms import Transformer
Expand Down
5 changes: 0 additions & 5 deletions aif360/algorithms/inprocessing/prejudice_remover.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@
See: changes-to-downloaded-code.diff and KamishimaAlgorithm.py for more details.
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import numpy as np
import pandas as pd
import tempfile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
# 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.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import numpy as np

from aif360.algorithms import Transformer
Expand Down
5 changes: 0 additions & 5 deletions aif360/algorithms/postprocessing/eq_odds_postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@
# 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.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import numpy as np
from scipy.optimize import linprog

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import numpy as np
from warnings import warn

Expand Down
5 changes: 0 additions & 5 deletions aif360/algorithms/preprocessing/disparate_impact_remover.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import numpy as np

from aif360.algorithms import Transformer
Expand Down
5 changes: 0 additions & 5 deletions aif360/algorithms/preprocessing/lfr.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import numpy as np
import scipy.optimize as optim

Expand Down
25 changes: 10 additions & 15 deletions aif360/algorithms/preprocessing/lfr_helpers/helpers.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
# Based on code from https://github.com/zjelveh/learning-fair-representations
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from numba.decorators import jit
import numpy as np

@jit
def distances(X, v, alpha, N, P, k):
dists = np.zeros((N, P))
for i in range(N):
for p in range(P):
for j in range(k):
for j in range(k):
dists[i, j] += (X[i, p] - v[j, p]) * (X[i, p] - v[j, p]) * alpha[p]
return dists

Expand All @@ -32,7 +27,7 @@ def M_nk(dists, N, k):
M_nk[i, j] = exp[i, j] / 1e-6
return M_nk

@jit
@jit
def M_k(M_nk, N, k):
M_k = np.zeros(k)
for j in range(k):
Expand All @@ -41,7 +36,7 @@ def M_k(M_nk, N, k):
M_k[j] /= N
return M_k

@jit
@jit
def x_n_hat(X, M_nk, v, N, P, k):
x_n_hat = np.zeros((N, P))
L_x = 0.0
Expand All @@ -67,25 +62,25 @@ def yhat(M_nk, y, w, N, k):
@jit
def LFR_optim_obj(params, data_sensitive, data_nonsensitive, y_sensitive,
y_nonsensitive, k=10, A_x = 0.01, A_y = 0.1, A_z = 0.5, results=0, print_inteval=250):

LFR_optim_obj.iters += 1
Ns, P = data_sensitive.shape
Nns, _ = data_nonsensitive.shape

alpha0 = params[:P]
alpha1 = params[P : 2 * P]
w = params[2 * P : (2 * P) + k]
v = np.matrix(params[(2 * P) + k:]).reshape((k, P))

dists_sensitive = distances(data_sensitive, v, alpha1, Ns, P, k)
dists_nonsensitive = distances(data_nonsensitive, v, alpha0, Nns, P, k)

M_nk_sensitive = M_nk(dists_sensitive, Ns, k)
M_nk_nonsensitive = M_nk(dists_nonsensitive, Nns, k)

M_k_sensitive = M_k(M_nk_sensitive, Ns, k)
M_k_nonsensitive = M_k(M_nk_nonsensitive, Nns, k)

L_z = 0.0
for j in range(k):
L_z += abs(M_k_sensitive[j] - M_k_nonsensitive[j])
Expand All @@ -102,7 +97,7 @@ def LFR_optim_obj(params, data_sensitive, data_nonsensitive, y_sensitive,

if LFR_optim_obj.iters % print_inteval == 0:
print(LFR_optim_obj.iters, criterion)

if results:
return yhat_sensitive, yhat_nonsensitive, M_nk_sensitive, M_nk_nonsensitive
else:
Expand Down
5 changes: 0 additions & 5 deletions aif360/algorithms/preprocessing/optim_preproc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
# 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.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from warnings import warn

import numpy as np
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from aif360.datasets import AdultDataset, GermanDataset, CompasDataset
import pandas as pd
import numpy as np
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
# Contains the helper functions for the optim_preproc class
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import numpy as np
import pandas as pd

Expand Down
5 changes: 0 additions & 5 deletions aif360/algorithms/preprocessing/reweighing.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import numpy as np

from aif360.algorithms import Transformer
Expand Down
5 changes: 0 additions & 5 deletions aif360/algorithms/transformer.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from abc import abstractmethod
from functools import wraps

Expand Down
5 changes: 0 additions & 5 deletions aif360/datasets/adult_dataset.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import os

import pandas as pd
Expand Down
5 changes: 0 additions & 5 deletions aif360/datasets/bank_dataset.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import os

import pandas as pd
Expand Down
5 changes: 0 additions & 5 deletions aif360/datasets/binary_label_dataset.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import numpy as np

from aif360.datasets import StructuredDataset
Expand Down
5 changes: 0 additions & 5 deletions aif360/datasets/compas_dataset.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import os

import pandas as pd
Expand Down
5 changes: 0 additions & 5 deletions aif360/datasets/dataset.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from abc import ABC, abstractmethod
import copy

Expand Down
5 changes: 0 additions & 5 deletions aif360/datasets/german_dataset.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import os

import pandas as pd
Expand Down
5 changes: 0 additions & 5 deletions aif360/datasets/lime_encoder.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import sklearn.preprocessing
import numpy as np

Expand Down
5 changes: 0 additions & 5 deletions aif360/datasets/meps_dataset_panel19_fy2015.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import os

import pandas as pd
Expand Down
5 changes: 0 additions & 5 deletions aif360/datasets/meps_dataset_panel20_fy2015.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import os

import pandas as pd
Expand Down
5 changes: 0 additions & 5 deletions aif360/datasets/meps_dataset_panel21_fy2016.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import os

import pandas as pd
Expand Down
5 changes: 0 additions & 5 deletions aif360/datasets/standard_dataset.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from logging import warning

import numpy as np
Expand Down
5 changes: 0 additions & 5 deletions aif360/datasets/structured_dataset.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from collections import defaultdict
from contextlib import contextmanager
from copy import deepcopy
Expand Down
5 changes: 0 additions & 5 deletions aif360/decorating_metaclass.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from abc import ABCMeta


Expand Down
5 changes: 0 additions & 5 deletions aif360/explainers/explainer.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from abc import ABC, abstractmethod


Expand Down
5 changes: 0 additions & 5 deletions aif360/explainers/metric_json_explainer.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from collections import OrderedDict
import json

Expand Down
5 changes: 0 additions & 5 deletions aif360/explainers/metric_text_explainer.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from aif360.explainers import Explainer
from aif360.metrics import Metric

Expand Down
5 changes: 0 additions & 5 deletions aif360/metrics/binary_label_dataset_metric.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import numpy as np
from sklearn.neighbors import NearestNeighbors

Expand Down
5 changes: 0 additions & 5 deletions aif360/metrics/classification_metric.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from itertools import product

import numpy as np
Expand Down
Loading

0 comments on commit ca48d65

Please sign in to comment.