Kaggle competition: Recursion Cellular Image Classification
<SOS> metric: CategorizationAccuracy Kaggle data source: recursion-cellular-image-classification<string_transform>
warnings.filterwarnings("ignore")
 all_files = glob.glob(".. /input/cellstack/*.csv")
 all_files
def create_sequences(data, stats):
sequences = []
to_compute = []
for idx, s in enumerate(stats):
seq = data[data[:, 2] == idx]
if pd.isnull(seq[0, 1]):
seq = np.delete(seq, [1], 1)
 else:
to_compute.append(seq)
 stats_p = list(np.unique(seq[:, 1]))
for idx2, s2 in enumerate(stats_p):
seqs2 = seq[seq[:, 1] == s2]
seqs2 = np.delete(seqs2, [0, 1, 3], 1)
 for idx, value in enumerate(reversed(seqs2[:, 1:])) :
if idx + 1 < len(seqs2):
cases = value[0] - seqs2[-(idx + 2), 1]
deaths = value[1] - seqs2[-(idx + 2), 2]
seqs2[-(idx + 1), 1] = cases
seqs2[-(idx + 1), 2] = deaths
offset = float(idx2)/ 10
seqs2[:, 0] = seqs2[:, 0] + offset
sequences.append(seqs2)
 continue
seq = np.delete(seq, [0, 2], 1)
 for idx,value in enumerate(reversed(seq[:,1:])) :
if idx + 1 < len(seq):
cases = value[0] - seq[-(idx + 2), 1]
deaths = value[1] - seq[-(idx + 2), 2]
seq[-(idx + 1), 1] = cases
seq[-(idx + 1), 2] = deaths
sequences.append(seq)
 return np.array(sequences )<categorify>
outs = [pd.read_csv(( f), index_col=0)['sirna'].values for f in all_files]
collected = np.array(outs)
 m = stats.mode(collected)[0][0]
submission = pd.read_csv('.. /input/recursion-cellular-image-classification/sample_submission.csv')
 submission['sirna'] = m
submission.to_csv('ModeStacker.csv', index=False )