application_vnd.jupyter.stderr_output_1.png
import pandas as pd

NUM_FOLDS = 5
import pandas as pd
from tqdm import tqdm
data_dir = '../input/ranzcr-clip-catheter-line-classification/'
target_col = ['ETT - Abnormal', 'ETT - Borderline', 'ETT - Normal', 'NGT - Abnormal', 'NGT - Borderline', 'NGT - Incompletely Imaged', 'NGT - Normal', 'CVC - Abnormal', 'CVC - Borderline', 'CVC - Normal', 'Swan Ganz Catheter Present']
def annotation_col_name(x):
    x = x[1]
    return 'annotation-' + ''.join([c for c in x if c.upper() == c and c != ' '])
annotations_df = pd.read_csv(data_dir + 'train_annotations.csv', usecols=['StudyInstanceUID', 'label'])
annotations_df['ones'] = 1
annotations_df = pd.pivot_table(annotations_df, values=['ones'], index=['StudyInstanceUID'], columns=['label'], aggfunc=np.sum).fillna(0)
annotations_df.columns = [annotation_col_name(col_name) for col_name in annotations_df.columns]
train_gt_df = pd.read_csv(data_dir + '/train.csv')
train_gt_df = train_gt_df.merge(annotations_df, on='StudyInstanceUID', how='left').fillna(0)
target_col += [x for x in annotations_df.columns]
num_target = len(target_col)
kfold_df = train_gt_df.copy().drop(['StudyInstanceUID'], axis=1)
print(len(train_gt_df.PatientID.unique()), 'patients')