continue from 140927-GBC


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 re
import math
import sys
import random

In [2]:
y = y_est = None

In [3]:
for target in ['Dog_1', 'Dog_2', 'Dog_3', 'Dog_4', 'Dog_5', 'Patient_1', 'Patient_2']:
    with open('../data-cache/%s_predict.spkl'%target,'rb') as fp:
        y_target, y_est_target = pickle.load(fp)
    if y is None:
        y = y_target
        y_est = y_est_target
    else:
        y = np.hstack((y, y_target))
        y_est = np.hstack((y_est, y_est_target))

In [4]:
from sklearn.metrics import roc_auc_score
roc_auc_score(y, y_est)


Out[4]:
0.85133243234182465

In [5]:
fpout = open('../submissions/140928-predict.1.csv','w')
print >>fpout,'clip,preictal'

In [6]:
for target in ['Dog_1', 'Dog_2', 'Dog_3', 'Dog_4', 'Dog_5', 'Patient_1', 'Patient_2']:
    with open('../data-cache/%s_test.spkl'%target,'rb') as fp:
        y_proba = pickle.load(fp)
    # write results
    for i,p in enumerate(y_proba):
        print >>fpout,'%s_test_segment_%04d.mat,%.15f' % (target, i+1, p)

In [7]:
fpout.close()

In [9]:
!head ../submissions/140928-predict.1.csv


clip,preictal
Dog_1_test_segment_0001.mat,0.015312143579901
Dog_1_test_segment_0002.mat,0.000353873029750
Dog_1_test_segment_0003.mat,0.000026776180830
Dog_1_test_segment_0004.mat,0.000051089676856
Dog_1_test_segment_0005.mat,0.000547950158771
Dog_1_test_segment_0006.mat,0.000034216222648
Dog_1_test_segment_0007.mat,0.000019276143757
Dog_1_test_segment_0008.mat,0.000390456118013
Dog_1_test_segment_0009.mat,0.000216785105992

In [8]: