text_plain_output_1.png image_output_1.png
import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

df = pd.read_csv('../input/train.csv')
test = pd.read_csv('../input/test.csv')

f,ax = plt.subplots(1,3,figsize=(15,6))
ax[0].imshow(test.iloc[0].reshape(28,28),cmap='binary')
ax[1].imshow(test.iloc[1].reshape(28,28),cmap='binary')
ax[2].imshow(test.iloc[2].reshape(28,28),cmap='binary')

np.array([np.array([int(i == label) for i in range(10)]) for label in [5, 2, 3, 9]])

labels_encoded = np.array([np.array([int(i == label) for i in range(10)]) for label in df.iloc[:, 0].values])

dataset = df.drop('label', axis=1)
dataset = np.multiply(dataset.values.astype(np.float32), 1.0 / 255.0)
test = np.multiply(test.values.astype(np.float32), 1.0 / 255.0)
(dataset.shape, labels_encoded.shape)

train_size = 40000
validation_size = 2000

train = dataset[:train_size]
train_targets = labels_encoded[:train_size]
validation = dataset[train_size:]
validation_targets = labels_encoded[train_size:]
(train.shape, train_targets.shape, validation.shape, validation_targets.shape, test.shape)