text_plain_output_1.png
from glob import glob

from sklearn.model_selection import train_test_split

import numpy as np

import os

DATA = '../input/sleepstate/sleep-state'
fnames = sorted(glob(os.path.join(DATA, '*.edf')))

PP_DATA = '../input/respiracion1'
fnames = sorted(glob(os.path.join(PP_DATA, '*.npz')))
total_fs = [f for f in fnames if f.split('/')[-1][:5]]
total_data = {k: np.load(k) for k in total_fs}
samples = total_data['../input/respiracion1/SC4001E0.npz']
samples['x'].shape

X = np.zeros((0, 3000, 1))
y = []
for fn in total_fs:
    samples = np.load(fn)
    X_data = samples['x']
    X = np.concatenate((X, X_data), axis=0)
    y.extend(samples['y'])
y = np.array(y)

X = (X - np.mean(X)) / np.std(X)

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1, random_state=42)
X_train, X_val, y_train, y_val = train_test_split(X_train, y_train, test_size=0.1, random_state=42)
(X_train.shape, X_test.shape, X_val.shape)