-
Notifications
You must be signed in to change notification settings - Fork 2
/
load_data.py
55 lines (46 loc) · 1.71 KB
/
load_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import pickle
import numpy as np
from sklearn.impute import SimpleImputer
from sklearn.datasets import load_breast_cancer
def LoadData(dataset):
if dataset == 'breast_cancer':
# Breast Cancer Wisconsin
data = load_breast_cancer()
return data.data, data.target
elif dataset == 'adult':
# Adult
pickle_in = open('datasets/adult.pkl', "rb")
data = pickle.load(pickle_in)
imp = SimpleImputer(missing_values=np.nan, strategy='mean')
data['data'] = imp.fit_transform(data['data'])
return data['data'], data['targets']
elif dataset == 'compas':
# Compas
pickle_in = open('datasets/compas.pkl', "rb")
data = pickle.load(pickle_in)
return data['data'], data['targets']
elif dataset == 'red_wine_quality':
# Red Wine Quality
pickle_in = open('datasets/red_wine.pkl', "rb")
data = pickle.load(pickle_in)
return data['data'], data['targets']
elif dataset == 'vehicle':
# Vehicle
pickle_in = open('datasets/vehicle.pkl', "rb")
data = pickle.load(pickle_in)
return data['data'], data['targets']
elif dataset == 'recidivism':
# Recidivism
pickle_in = open('datasets/recd.pkl', "rb")
data = pickle.load(pickle_in)
return data['data'], data['targets']
elif dataset == 'german_credit':
# German Credit
pickle_in = open('datasets/german.pkl', "rb")
data = pickle.load(pickle_in)
return data['data'], data['targets']
elif dataset == 'glass':
# Glass
pickle_in = open('datasets/glass.pkl', "rb")
data = pickle.load(pickle_in)
return data['data'], data['targets']