continue from 140927-GBC or 140929-RF-hyperopt


In [3]:
%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 [23]:
fpout = open('../submissions/140929-target-combine.validate.2.csv','w')
print >>fpout,'clip,preictal'
y = y_est = None
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))
    # write results
    npreictal = 0
    ninterictal = 0
    for l,p in zip(y_target, y_est_target):
        if l:
            npreictal += 1
            print >>fpout,'%s_preictal_segment_%04d.mat,%.15f' % (target, npreictal, p)
        else:
            ninterictal += 1
            print >>fpout,'%s_interictal_segment_%04d.mat,%.15f' % (target, ninterictal, p)
fpout.close()

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


Out[24]:
0.86163487613427991

In [5]:
fpout = open('../submissions/140930-predict.2.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 [8]:
!head ../submissions/140930-predict.2.csv


clip,preictal
Dog_1_test_segment_0001.mat,0.629439696106363
Dog_1_test_segment_0002.mat,0.117046533713200
Dog_1_test_segment_0003.mat,0.101709401709402
Dog_1_test_segment_0004.mat,0.297435897435897
Dog_1_test_segment_0005.mat,0.183855650522317
Dog_1_test_segment_0006.mat,0.214981006647673
Dog_1_test_segment_0007.mat,0.055413105413105
Dog_1_test_segment_0008.mat,0.160446343779677
Dog_1_test_segment_0009.mat,0.096438746438746

In [14]: