#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Mar  7 22:15:06 2019

@author: kazuki.onodera
"""

import numpy as np
import pandas as pd
import utils


SUBMIT_FILE_PATH = '../output/0307-2.csv.gz'

COMMENT = 'best712(0307-1)*1 + (ireko708*2 tosh708 tosh709)*1'

EXE_SUBMIT = True

# =============================================================================
# 
# =============================================================================
sub1 = pd.read_csv('../output/0307-1.csv.gz') # 0.287


ireko708    = pd.Series(np.load('../external/ireko708/test_preds.npy'), name='ireko708')
ireko708_v2 = pd.Series(np.load('../external/ireko708_v2/test_preds.npy'), name='ireko708_v2')

tosh708 = pd.read_csv('../external/subNN_v1722.csv.gz')['HasDetections']
tosh708.name = 'tosh708'
tosh709 = pd.read_csv('../external/subNN_v176.csv.gz')['HasDetections']
tosh709.name = 'tosh709'
tosh709 = 1 - tosh709



sub2 = ireko708.rank() + ireko708_v2.rank() + tosh708.rank() + tosh709.rank()
sub2 /= sub2.max()
sub2.name = 'HasDetections'
sub2 = sub2.to_frame()
sub2['HasDetections'] = 1 - sub2['HasDetections']

print( sub1['HasDetections'].corr( sub2['HasDetections'], method='spearman') )



#y_pred = sub1['HasDetections'].rank()*4 + sub2['HasDetections'].rank()*3
y_pred = sub1['HasDetections'].rank() + sub2['HasDetections'].rank()
y_pred /= y_pred.max()

sub = pd.read_csv('../input/sample_submission.csv.zip')
sub['HasDetections'] = y_pred.values


print(f'corr with {utils.SUB_BEST}')
sub_best = pd.read_csv(utils.SUB_BEST)
print('with mybest:', sub['HasDetections'].corr( sub_best['HasDetections'], method='spearman') )





# save
sub.to_csv(SUBMIT_FILE_PATH, index=False, compression='gzip')

# =============================================================================
# submission
# =============================================================================
if EXE_SUBMIT:
    print('submit')
    utils.submit(SUBMIT_FILE_PATH, COMMENT)


#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Mar  7 22:15:06 2019

@author: kazuki.onodera
"""

import numpy as np
import pandas as pd
import utils


SUBMIT_FILE_PATH = '../output/0307-2.csv.gz'

COMMENT = 'best712(0307-1)*1 + (ireko708*2 tosh708 tosh709)*1'

EXE_SUBMIT = True

# =============================================================================
# 
# =============================================================================
sub1 = pd.read_csv('../output/0307-1.csv.gz') # 0.287


ireko708    = pd.Series(np.load('../external/ireko708/test_preds.npy'), name='ireko708')
ireko708_v2 = pd.Series(np.load('../external/ireko708_v2/test_preds.npy'), name='ireko708_v2')

tosh708 = pd.read_csv('../external/subNN_v1722.csv.gz')['HasDetections']
tosh708.name = 'tosh708'
tosh709 = pd.read_csv('../external/subNN_v176.csv.gz')['HasDetections']
tosh709.name = 'tosh709'
tosh709 = 1 - tosh709



sub2 = ireko708.rank() + ireko708_v2.rank() + tosh708.rank() + tosh709.rank()
sub2 /= sub2.max()
sub2.name = 'HasDetections'
sub2 = sub2.to_frame()
sub2['HasDetections'] = 1 - sub2['HasDetections']

print( sub1['HasDetections'].corr( sub2['HasDetections'], method='spearman') )



#y_pred = sub1['HasDetections'].rank()*4 + sub2['HasDetections'].rank()*3
y_pred = sub1['HasDetections'].rank() + sub2['HasDetections'].rank()
y_pred /= y_pred.max()

sub = pd.read_csv('../input/sample_submission.csv.zip')
sub['HasDetections'] = y_pred.values


print(f'corr with {utils.SUB_BEST}')
sub_best = pd.read_csv(utils.SUB_BEST)
print('with mybest:', sub['HasDetections'].corr( sub_best['HasDetections'], method='spearman') )





# save
sub.to_csv(SUBMIT_FILE_PATH, index=False, compression='gzip')

# =============================================================================
# submission
# =============================================================================
if EXE_SUBMIT:
    print('submit')
    utils.submit(SUBMIT_FILE_PATH, COMMENT)


#!/usr/bin/env python3 # -*- coding: utf-8 -*- Created on Thu Mar  7 22:15:06 2019  @author: kazuki.onodera # ============================================================================= # # ============================================================================= # 0.287 #y_pred = sub1['HasDetections'].rank()*4 + sub2['HasDetections'].rank()*3 # save # ============================================================================= # submission # =============================================================================