text_plain_output_1.png
import matplotlib.pyplot as plt

import numpy as np

train = np.loadtxt('../input/train.csv', delimiter=',', skiprows=1)

train_label = train[:, 0]
train_img = np.resize(train[:, 1:], (train.shape[0], 28, 28))

train_img.shape

fig = plt.figure(figsize=(20, 10))
for i, img in enumerate(train_img[0:5], 1):
    subplot = fig.add_subplot(1, 7, i)
    plt.imshow(img, cmap='gray');
    subplot.set_title('%s' % train_label[i - 1]);

fig = plt.figure(figsize=(20, 10))
for i, img in enumerate(train_g[:5], 1):
    subplot = fig.add_subplot(1, 7, i)
    plt.imshow(img, cmap='gray')
    subplot.set_title('%s' % train_label[i - 1])
    subplot = fig.add_subplot(3, 7, i)
    plt.hist(train_theta[i - 1].flatten(), bins=16, weights=train_g[i - 1].flatten())