-
Notifications
You must be signed in to change notification settings - Fork 0
/
dataset.py
37 lines (26 loc) · 915 Bytes
/
dataset.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
import pandas as pd
import numpy as np
import os
class Data(object):
def __init__(self, path):
self.data = pd.read_csv(path)
self.data = self.data.reindex(
np.random.permutation(self.data.index)
)
self.data.drop("Id", axis=1, inplace=True)
def get_data(self):
return self.data[
[col for col in self.data.columns if col!="Species"]
]
def get_labels(self):
return self.data["Species"]
class Dataset(Data):
def __init__(self, path, test_split=0.3):
super().__init__(path)
self.test_size = int(len(self.get_labels()) * test_split)
def train(self):
return (self.get_data()[self.test_size:].values,
self.get_labels()[self.test_size:].values)
def test(self):
return (self.get_data()[:self.test_size].values,
self.get_labels()[:self.test_size].values)