<jupyter_start><jupyter_text>Manually create tensorflow session to avoid potential OEM errors on laptop's GPU.<jupyter_code>#Manually create tensorflow session to avoid potential OEM errors on laptop's GPU.
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config)
K.set_session(session)
K.set_image_dim_ordering('tf')<jupyter_output><empty_output><jupyter_text>Load Data<jupyter_code>data = pd.read_json("Data/train/train.json")
train_df = data
train_df.head()
#merge bands and create 3rd and 4th channel
band_1 = np.array(train_df['band_1'].tolist()).reshape(-1,75,75)
band_2 = np.array(train_df['band_2'].tolist()).reshape(-1,75,75)
band_3 = (band_1 + band_2)/2
band_4 = -(band_1 * band_2) #negate band_4
band_5 = band_1 - band_2
X = np.stack((band_1,band_2,band_3,band_4,band_5),axis=3)
X.shape
plt.hist(band_1.flatten(), bins=200, color="red", alpha=0.4)
plt.hist(band_2.flatten(),bins=200, color="blue", alpha=0.4)
plt.show()
plt.hist(train_df['inc_angle'][train_df['inc_angle'] != 'na'],bins='auto', alpha=0.75)
plt.show()
train_df['inc_angle'][train_df['inc_angle'] == 'na'] = None
train_df['inc_angle_f'] = train_df['inc_angle'].astype(np.float)
train_g = train_df.groupby('is_iceberg')
train_g['inc_angle_f'].hist(alpha=0.5)
plt.show()
train_df['inc_angle_f'].median()
print(X.max())
print(X.min())
print(X.std())
def plot_bands(index, cmap="gray"):
    fig = plt.figure(figsize=(12,6))
    fig.suptitle("Is Iceberg: %x" % (train_df.loc[index,'is_iceberg']), fontsize=16)
    ax1 = fig.add_subplot(241)
    ax1.set_title("Band 1")
    ax1.imshow(band_1[index], cmap=cmap)
    ax2 = fig.add_subplot(242)
    ax2.set_title("Band 2")
    ax2.imshow(band_2[index], cmap=cmap)
    ax3 = fig.add_subplot(243)
    ax3.set_title("Band 3")
    ax3.imshow(band_3[index], cmap=cmap)
    ax3 = fig.add_subplot(244)
    ax3.set_title("Band 4")
    ax3.imshow(band_4[index], cmap=cmap)
    fig.tight_layout(rect=[0, 0.03, 1, 0.95])
    plt.show()
    
def plot_bands125(index, cmap="gray"):
    fig = plt.figure(figsize=(18,14))
    fig.suptitle("Is Iceberg: %x - inc_angle: %.2f" % (train_df.loc[index,'is_iceberg'], train_df.loc[index,'inc_angle']), fontsize=16)
    ax1 = fig.add_subplot(231)
    ax1.set_title("Band 1")
    cax1 = ax1.imshow(band_1[index], cmap=cmap, vmin=-35, vmax=10)
    #cax1.colorbar()
    ax2 = fig.add_subplot(232)
    ax2.set_title("Band 2")
    cax2 = ax2.imshow(band_2[index], cmap=cmap, vmin=-35, vmax=10)
    #cax2.colorbar()
    ax3 = fig.add_subplot(233)
    ax3.set_title("Band 5")
    cax3 = ax3.imshow(band_3[index], cmap=cmap, vmin=-35, vmax=10)
    fig.tight_layout()
    #cax3.colorbar()
    plt.show()

for index in train_df.index[:5]:    
    plot_bands125(index,cmap="gray")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17761033369214208, 'fraction_numerical': 0.054180121994976675, 'mean_word_length': 5.321995464852607, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '335295', 'license': 'MIT', 'n_tokens_mistral': 1239, 'n_tokens_neox': 1175, 'n_words': 176, 'path': 'Iceberg - EDA.ipynb', 'repo_name': 'MarekKZielinski/Statoil-C-CORE-Iceberg-Classifier-Challenge', 'size': '2787'}