application_vnd.jupyter.stderr_output_2.png text_plain_output_1.png
from sklearn.preprocessing import OneHotEncoder

import numpy as np

import pandas as pd

data_path = './data'
train = pd.read_json(data_path + '/' + 'train.json')
test = pd.read_json(data_path + '/' + 'test.json')
submission = pd.read_csv(data_path + '/' + 'sample_submission.csv').set_index('id')

train_band_1 = np.array([np.array(band).astype(np.float32).reshape((75, 75)) for band in train.band_1])
train_band_2 = np.array([np.array(band).astype(np.float32).reshape((75, 75)) for band in train.band_2])
X_train = np.concatenate([train_band_1[:, :, :, np.newaxis], train_band_2[:, :, :, np.newaxis], ((train_band_1 + train_band_2) / 2)[:, :, :, np.newaxis]], axis=-1)
test_band_1 = np.array([np.array(band).astype(np.float32).reshape((75, 75)) for band in test.band_1])
test_band_2 = np.array([np.array(band).astype(np.float32).reshape((75, 75)) for band in test.band_2])
X_test = np.concatenate([test_band_1[:, :, :, np.newaxis], test_band_2[:, :, :, np.newaxis], ((test_band_1 + test_band_2) / 2)[:, :, :, np.newaxis]], axis=-1)
y = np.array([target for target in train.is_iceberg]).reshape((-1, 1))

lbl = OneHotEncoder()
lbl.fit([[0], [1]])
y = lbl.transform(y).toarray()