Skip to content

Commit

Permalink
Update ci.yml s.t. it downloads bank data and change bank dataset tes…
Browse files Browse the repository at this point in the history
…t without mock
  • Loading branch information
joosjegoedhart committed Jul 24, 2023
1 parent 8f3d181 commit 1466316
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jobs:
wget ${UCI_DB}/statlog/german/german.data -P aif360/data/raw/german/
wget ${UCI_DB}/statlog/german/german.doc -P aif360/data/raw/german/
wget ${PROPUBLICA_GH}/compas-scores-two-years.csv -P aif360/data/raw/compas/
wget -qO- ${UCI_DB}/00222/bank-additional.zip && unzip -j bank-additional.zip -d aif360/data/raw/bank/ && rm bank-additional.zip
(cd aif360/data/raw/meps;Rscript generate_data.R <<< y)
- name: Lint with flake8
Expand Down
22 changes: 14 additions & 8 deletions tests/test_standard_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,17 @@ def test_bank():
bank_dataset = BankDataset()
bank_dataset.validate_dataset()

@patch("pandas.read_csv")
def test_bank_priviliged_attributes(mock_read_csv):
''' Test if priviliged attributes are correctly transformed '''
data = {'y': ['yes', 'no', 'no', 'yes'],
'age': [43, 18, 89, 25]}
mock_read_csv.return_value = pd.DataFrame(data)
bank_dataset = BankDataset(categorical_features=[])
assert bank_dataset.convert_to_dataframe()[0]["age"].tolist() == [1.0, 0.0, 0.0, 1.0]
def test_bank_priviliged_attributes():
''' Test if protected attribute age is correctly processed '''
# Bank Data Set
bank_dataset = BankDataset()
num_priv = bank_dataset.protected_attributes.sum()
# Raw data
bank_dataset_unpreproc = pd.read_csv("aif360/data/raw/bank/bank-additional-full.csv", sep = ";", na_values = ["unknown"])
bank_dataset_unpreproc = bank_dataset_unpreproc.dropna()
num_priv_raw = len(bank_dataset_unpreproc[(bank_dataset_unpreproc["age"] >= 25) & (bank_dataset_unpreproc["age"] < 60)])
assert num_priv == num_priv_raw




0 comments on commit 1466316

Please sign in to comment.