In [1]:
%matplotlib inline
from matplotlib import pylab as pl
import cPickle as pickle
import pandas as pd
import numpy as np
import os
import random

In [2]:
import sys
sys.path.append('..')

Read precomputed features

uncommoent the relevant pipeline in ../seizure_detection.py and run

cd ..
./doall predict

In [3]:
FEATURES = 'gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600'

In [4]:
from common.data import CachedDataLoader
cached_data_loader = CachedDataLoader('../data-cache')

In [5]:
def read_data(target, data_type):
    return cached_data_loader.load('data_%s_%s_%s'%(data_type,target,FEATURES),None)

Explore


In [9]:
for target in ['Dog_1', 'Dog_2', 'Dog_3', 'Dog_4', 'Dog_5', 'Patient_1', 'Patient_2']:
    pdata = read_data(target, 'preictal') # positive examples
    ndata = read_data(target, 'interictal') # negative examples
    X = np.concatenate((pdata.X, ndata.X))
    y = np.zeros(X.shape[0])
    y[:pdata.X.shape[0]] = 1
    tdata = read_data(target, 'test')
    X_test = tdata.X
    print target, y.mean(), X.shape, X_test.shape


Loaded ../data-cache/data_preictal_Dog_1_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Loaded ../data-cache/data_interictal_Dog_1_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Loaded ../data-cache/data_test_Dog_1_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Dog_1 0.178082191781 (584, 3072) (502, 3072)
Loaded ../data-cache/data_preictal_Dog_2_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Loaded ../data-cache/data_interictal_Dog_2_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Loaded ../data-cache/data_test_Dog_2_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Dog_2 0.266862170088 (682, 3072) (1000, 3072)
Loaded ../data-cache/data_preictal_Dog_3_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Loaded ../data-cache/data_interictal_Dog_3_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Loaded ../data-cache/data_test_Dog_3_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Dog_3 0.178082191781 (1752, 3072) (907, 3072)
Loaded ../data-cache/data_preictal_Dog_4_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Loaded ../data-cache/data_interictal_Dog_4_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Loaded ../data-cache/data_test_Dog_4_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Dog_4 0.341523341523 (1221, 3072) (990, 3072)
Loaded ../data-cache/data_preictal_Dog_5_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Loaded ../data-cache/data_interictal_Dog_5_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Loaded ../data-cache/data_test_Dog_5_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Dog_5 0.224137931034 (580, 2835) (191, 2835)
Loaded ../data-cache/data_preictal_Patient_1_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Loaded ../data-cache/data_interictal_Patient_1_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Loaded ../data-cache/data_test_Patient_1_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Patient_1 0.609375 (128, 2835) (195, 2835)
Loaded ../data-cache/data_preictal_Patient_2_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Loaded ../data-cache/data_interictal_Patient_2_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Loaded ../data-cache/data_test_Patient_2_gen4_medianwindow-fft-with-time-freq-corr-1-48-r400-usf-w600.hkl in 0s
Patient_2 0.65 (120, 5184) (150, 5184)

In [ ]: