mirror of
https://github.com/IBM/ai-privacy-toolkit.git
synced 2026-05-09 03:52:38 +02:00
Fix directory issue when running tests for first time
This commit is contained in:
parent
bcc3d67ba4
commit
60d48ab388
2 changed files with 13 additions and 1 deletions
10
apt/utils.py
10
apt/utils.py
|
|
@ -2,7 +2,7 @@ from sklearn import datasets, model_selection
|
||||||
import sklearn.preprocessing
|
import sklearn.preprocessing
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import ssl
|
import ssl
|
||||||
from os import path
|
from os import path, mkdir
|
||||||
from six.moves.urllib.request import urlretrieve
|
from six.moves.urllib.request import urlretrieve
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -40,9 +40,13 @@ def get_adult_dataset():
|
||||||
'label']
|
'label']
|
||||||
train_url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data'
|
train_url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.data'
|
||||||
test_url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.test'
|
test_url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/adult/adult.test'
|
||||||
|
data_dir = '../datasets/adult'
|
||||||
train_file = '../datasets/adult/train'
|
train_file = '../datasets/adult/train'
|
||||||
test_file = '../datasets/adult/test'
|
test_file = '../datasets/adult/test'
|
||||||
|
|
||||||
|
if not path.exists(data_dir):
|
||||||
|
mkdir(data_dir)
|
||||||
|
|
||||||
ssl._create_default_https_context = ssl._create_unverified_context
|
ssl._create_default_https_context = ssl._create_unverified_context
|
||||||
if not path.exists(train_file):
|
if not path.exists(train_file):
|
||||||
urlretrieve(train_url, train_file)
|
urlretrieve(train_url, train_file)
|
||||||
|
|
@ -139,8 +143,12 @@ def get_nursery_dataset(raw: bool = True, test_set: float = 0.2, transform_socia
|
||||||
:return: Dataset and labels as pandas dataframes.
|
:return: Dataset and labels as pandas dataframes.
|
||||||
"""
|
"""
|
||||||
url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/nursery/nursery.data'
|
url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/nursery/nursery.data'
|
||||||
|
data_dir = '../datasets/nursery'
|
||||||
data_file = '../datasets/nursery/data'
|
data_file = '../datasets/nursery/data'
|
||||||
|
|
||||||
|
if not path.exists(data_dir):
|
||||||
|
mkdir(data_dir)
|
||||||
|
|
||||||
ssl._create_default_https_context = ssl._create_unverified_context
|
ssl._create_default_https_context = ssl._create_unverified_context
|
||||||
if not path.exists(data_file):
|
if not path.exists(data_file):
|
||||||
urlretrieve(url, data_file)
|
urlretrieve(url, data_file)
|
||||||
|
|
|
||||||
4
datasets/.gitignore
vendored
Normal file
4
datasets/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
# Ignore everything in this directory
|
||||||
|
*
|
||||||
|
# Except this file
|
||||||
|
!.gitignore
|
||||||
Loading…
Add table
Add a link
Reference in a new issue