text_plain_output_35.png text_plain_output_43.png text_plain_output_37.png text_plain_output_5.png text_plain_output_30.png application_vnd.jupyter.stderr_output_2.png text_plain_output_15.png text_plain_output_9.png text_plain_output_44.png text_plain_output_40.png text_plain_output_31.png text_plain_output_20.png text_plain_output_4.png text_plain_output_13.png text_plain_output_45.png text_plain_output_14.png text_plain_output_32.png text_plain_output_29.png text_plain_output_27.png text_plain_output_10.png text_plain_output_6.png text_plain_output_24.png text_plain_output_21.png text_plain_output_25.png text_plain_output_18.png text_plain_output_36.png text_plain_output_3.png text_plain_output_22.png text_plain_output_38.png text_plain_output_7.png text_plain_output_16.png text_plain_output_8.png text_plain_output_26.png text_plain_output_41.png text_plain_output_34.png text_plain_output_42.png text_plain_output_23.png text_plain_output_28.png text_plain_output_1.png text_plain_output_33.png text_plain_output_39.png text_plain_output_19.png text_plain_output_17.png text_plain_output_11.png text_plain_output_12.png text_plain_output_46.png
from sklearn.model_selection import StratifiedKFold

import numpy as np

import os

import pandas as pd

import random

import torch

class CFG:
    seed = 46
    debug = False
    n_fold = 4
    n_epoch = 11
    height = 480
    width = 480
    model_name = 'efficientnet_b0'
    lr = 0.0001
    min_lr = 1e-06
    weight_decay = 0.0001
    T_max = 10
    device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
def seed_torch(seed):
    random.seed(seed)
    os.environ['PYTHONHASHSEED'] = str(seed)
    np.random.seed(seed)
    torch.manual_seed(seed)
    torch.cuda.manual_seed(seed)
    torch.backends.cudnn.deterministic = True
seed_torch(CFG.seed)

av = pd.read_csv('../input/seti-adversarial-validation/oof.csv')
tmp = pd.read_csv('../input/seti-breakthrough-listen/train_labels.csv')
tmp['label'] = tmp['target']
av = pd.merge(av, tmp[['id', 'label']], on='id', how='left')
av.query('target == 0 and pred > 1e-4')

train = av.query('target == 0 and pred > 1e-4').reset_index(drop=True)
train['target'] = train['label']
train = train.drop(['label', 'pred'], axis=1)
test = pd.read_csv('../input/seti-breakthrough-listen/sample_submission.csv')
train['file_path'] = train['id'].apply(lambda x: f'../input/seti-breakthrough-listen/train/{x[0]}/{x}.npy')
test['file_path'] = test['id'].apply(lambda x: f'../input/seti-breakthrough-listen/test/{x[0]}/{x}.npy')
print(train['target'].value_counts())
if CFG.debug:
    CFG.n_epoch = 2
    train = train.sample(n=1000, random_state=CFG.seed).reset_index(drop=True)
    test = test.sample(n=1000, random_state=CFG.seed).reset_index(drop=True)
skf = StratifiedKFold(n_splits=CFG.n_fold, shuffle=True, random_state=CFG.seed)
for fold, (_, val_index) in enumerate(skf.split(train, train['target'])):
    train.loc[val_index, 'fold'] = fold
train['fold'] = train['fold'].astype(int)
train.groupby(['fold', 'target']).size()