@@ -0,0 +1,1518 @@
+%22%22%22%0AThis file generates the sample_submission.csv baseline. %0AEnsure that the 'public_data' is in the same directory %0Aas this file. %0A%22%22%22%0A%0A%0Aimport pandas as pd%0Aimport json %0Aimport numpy as np %0A%0Aimport os%0A%0A%0A%0A%22%22%22%0ALoad the required metadata %0A%22%22%22%0Aannotation_names = json.load(open(os.path.join('public_data', 'annotations.json')))%0A%0A%0A%0A%22%22%22%0ACalculate training training class distribution%0A%22%22%22%0A%0Aprior_probs = np.zeros(len(annotation_names))%0A%0Afor ii in xrange(1, 11): %0A    df = pd.read_csv(os.path.join('public_data', 'train', str(ii).zfill(5), 'targets.csv'))%0A    %0A    non_nans = df%5Bdf.isnull().any(axis=1) == False%5D%0A    prior_probs += np.asarray(non_nans.mean(axis=0)%5Bannotation_names%5D.tolist())%0A        %0Aprior_probs /= prior_probs.sum()%0Aprior_probs = prior_probs.tolist()%0A%0A%0A%0A%22%22%22%0AGenerate submission file%0A%22%22%22%0A%0Ase_cols = %5B'start', 'end'%5D%0A%0Arows = %5B%5D%0A%0Afor te_ind_str in sorted(os.listdir(os.path.join('public_data', 'test'))):%0A    te_ind = int(te_ind_str)%0A    %0A    meta = json.load(open(os.path.join('public_data', 'test', te_ind_str, 'meta.json')))%0A    %0A    starts = range(meta%5B'end'%5D)%0A    ends = range(1, meta%5B'end'%5D + 1)%0A    %0A    for start, end in zip(starts, ends):%0A        pred_row = %5B%5D%0A        %0A        pred_row.extend(%5Bte_ind, start, end%5D)%0A        pred_row.extend(prior_probs)%0A        %0A        rows.append(pred_row)%0A%0A        %0A        %0A%22%22%22%0ASave the predictions to file%0A%22%22%22%0Awith open(os.path.join('public_data', 'sample_submission.csv'), 'w') as fil: %0A    for row in rows: %0A        fil.write(','.join(map(str, row)))%0A        %0A

Create sample_submission.py