-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsplit.py
52 lines (46 loc) · 1.15 KB
/
split.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
import numpy as np
def delete_question_mark(X, y):
N = len(X)
pos = np.where(y != 6)
return X[pos], y[pos]
def split_wake_and_asleep(X, y):
y_new = y.copy()
pos = np.where(y_new != 0)
y_new[pos] = 1
return X, y_new
def split_eye_movement(X, y):
pos = np.where(y != 0)
X_new = X[pos]
y_new = y[pos]
pos = np.where(y_new != 5)
y_new[pos] = 0
pos = np.where(y_new == 5)
y_new[pos] = 1
return X_new, y_new
def split_deep_sleep(X, y):
pos = np.where((y != 0) * (y != 5))
X_new = X[pos]
y_new = y[pos]
pos = np.where((y_new == 1) ^ (y_new == 2))
y_new[pos] = 0
pos = np.where((y_new == 3) ^ (y_new == 4))
y_new[pos] = 1
return X_new, y_new
def split_1_2(X, y):
pos = np.where((y == 1) ^ (y == 2))
X_new = X[pos]
y_new = y[pos]
pos = np.where(y_new == 1)
y_new[pos] = 0
pos = np.where(y_new == 2)
y_new[pos] = 1
return X_new, y_new
def split_3_4(X, y):
pos = np.where((y == 3) ^ (y == 4))
X_new = X[pos]
y_new = y[pos]
pos = np.where(y_new == 3)
y_new[pos] = 0
pos = np.where(y_new == 4)
y_new[pos] = 1
return X_new, y_new