#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Mar  3 07:25:55 2019

@author: Kazuki
"""

import pandas as pd
import numpy as np
import utils


SUBMIT_FILE_PATH = '../output/0302-3.csv.gz'

COMMENT = 'mean(0301-5 0302-2)'

EXE_SUBMIT = True

# =============================================================================
# 
# =============================================================================
sub1 = pd.read_csv('../output/0301-5.csv.gz')
sub2 = pd.read_csv('../output/0302-2.csv.gz')

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('corr with best')
sub_best = pd.read_csv(utils.SUB_BEST)
print('with mybest:', sub['HasDetections'].corr( sub_best['HasDetections'], method='spearman') )
sub_best['HasDetections'] = np.load(utils.SUB_nejumi)
print('with nejumi:', 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)

