-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtask.py
executable file
·67 lines (51 loc) · 1.54 KB
/
task.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
55
56
57
58
59
60
61
62
63
64
65
66
67
from sklearn.model_selection import train_test_split
class Task:
def __init__(self, X, y, center_X, center_y, test_size=0.5):
self.X = X
self.y = y
self.center_X = center_X
self.center_y = center_y
if X is not None:
self.num, self.dim = X.shape
else:
_, self.dim = center_X.shape
self.num = 0
if X is None or len(X) == 1:
self.X_train = X
self.y_train = y
self.X_test = X
self.y_test = y
else:
self.X_train, self.X_test, self.y_train, self.y_test = \
train_test_split(X, y, test_size=test_size)
def get_all(self):
return self.X, self.y
def get_train(self):
return self.X_train, self.y_train
def get_test(self):
return self.X_test, self.y_test
def get_num(self):
return self.num
def get_len(self):
return self.dim
def get_center(self):
return self.center_X, self.center_y
class TestTask:
def __init__(self, X, y, center_X, center_y):
self.X = X
self.y = y
self.center_X = center_X
self.center_y = center_y
if X is not None:
self.num, self.dim = X.shape
else:
_, self.dim = center_X.shape
self.num = 0
def get_all(self):
return self.X, self.y
def get_num(self):
return self.num
def get_len(self):
return self.dim
def get_center(self):
return self.center_X, self.center_y