# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import os, sys
import numpy as np
import pandas as pd

draw_predict_1 = np.load('../preds/draw_predict_1.npy')
draw_predict_2 = np.load('../preds/draw_predict_2.npy')
draw_predict_3 = np.load('../preds/draw_predict_3.npy')
draw_predict_4 = np.load('../preds/draw_predict_4.npy')
draw_predict_5 = np.load('../preds/draw_predict_5.npy')
draw_predict_6 = np.load('../preds/draw_predict_6.npy')
draw_predict_7 = np.load('../preds/draw_predict_7.npy')
draw_predict_4_b = np.load('../preds/draw_predict_4_b.npy')
draw_predict_5_b = np.load('../preds/draw_predict_5_b.npy')
draw_predict_6_b = np.load('../preds/draw_predict_6_b.npy')
draw_predict_7_b = np.load('../preds/draw_predict_7_b.npy')

# +
# Load dataset info
path_to_train = '../../Human_Protein_Atlas/input/train/'
data = pd.read_csv('../../Human_Protein_Atlas/input/train.csv')

train_dataset_info = []
for name, labels in zip(data['Id'], data['Target'].str.split(' ')):
    train_dataset_info.append({
        'path':os.path.join(path_to_train, name),
        'labels':np.array([int(label) for label in labels])})
train_dataset_info = np.array(train_dataset_info)

# +
submit = pd.read_csv('../../Human_Protein_Atlas/input/sample_submission.csv')

predicted = []
for i, _ in enumerate(submit['Id']):
    score_predict = (0.9*(0.7*(0.5*(0.3*draw_predict_1[i]+0.35*draw_predict_2[i])+1.5*0.35*draw_predict_3[i])+
                    0.3*(0.25*draw_predict_4[i]+0.25*draw_predict_5[i]+0.25*draw_predict_6[i]+0.25*draw_predict_7[i]))+
                     0.1*(0.25*draw_predict_4_b[i]+0.25*draw_predict_5_b[i]+0.25*draw_predict_6_b[i]+0.25*draw_predict_7_b[i]))
    label_predict = np.arange(28)[score_predict>=0.2]
    str_predict_label = ' '.join(str(l) for l in label_predict)
    predicted.append(str_predict_label)
    
submit['Predicted'] = predicted
submit.to_csv('blend_InceptionV3_InceptionResNetV2_9.csv', index=False)

# +
th_t = np.array([0.565,0.39,0.55,0.345,0.33,0.39,0.33,0.45,0.38,0.39,
               0.34,0.42,0.31,0.38,0.49,0.50,0.38,0.43,0.46,0.40,
               0.39,0.505,0.37,0.47,0.41,0.545,0.32,0.1])

submit = pd.read_csv('../../Human_Protein_Atlas/input/sample_submission.csv')

predicted = []
for i, _ in enumerate(submit['Id']):
    score_predict = (0.9*(0.7*(0.5*(0.3*draw_predict_1[i]+0.35*draw_predict_2[i])+1.5*0.35*draw_predict_3[i])+
                    0.3*(0.25*draw_predict_4[i]+0.25*draw_predict_5[i]+0.25*draw_predict_6[i]+0.25*draw_predict_7[i]))+
                     0.1*(0.25*draw_predict_4_b[i]+0.25*draw_predict_5_b[i]+0.25*draw_predict_6_b[i]+0.25*draw_predict_7_b[i]))
    label_predict = np.arange(28)[score_predict>=th_t]
    str_predict_label = ' '.join(str(l) for l in label_predict)
    predicted.append(str_predict_label)
    
submit['Predicted'] = predicted
submit.to_csv('blend_InceptionV3_InceptionResNetV2_th_t.csv', index=False)
# -

submit.head()



StarcoderdataJupyterScriptsDedupFiltered