Neural Networks with TensorFlow and Keras


In [1]:
import warnings
warnings.filterwarnings('ignore')

In [2]:
%matplotlib inline
%pylab inline


Populating the interactive namespace from numpy and matplotlib

In [3]:
import pandas as pd
print(pd.__version__)


0.19.2

In [4]:
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.ERROR)
print(tf.__version__)


1.1.0

In [5]:
import keras
print(keras.__version__)


Using TensorFlow backend.
2.0.8

First Step: Load Data and disassemble for our purposes

We need a few more data point samples for this approach


In [6]:
df = pd.read_csv('./insurance-customers-1500.csv', sep=';')

In [7]:
y=df['group']

In [8]:
df.drop('group', axis='columns', inplace=True)

In [9]:
X = df.as_matrix()

In [10]:
df.describe()


Out[10]:
max speed age thousand km per year
count 1500.000000 1500.000000 1500.000000
mean 171.386000 44.969333 30.511333
std 19.269126 16.935040 15.112317
min 118.000000 18.000000 5.000000
25% 158.000000 32.000000 18.000000
50% 170.000000 42.000000 29.000000
75% 187.000000 55.000000 42.000000
max 216.000000 90.000000 84.000000

Second Step: Deep Learning as Alchemy


In [11]:
# ignore this, it is just technical code
# should come from a lib, consider it to appear magically 
# http://scikit-learn.org/stable/auto_examples/neighbors/plot_classification.html

import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap

cmap_print = ListedColormap(['#AA8888', '#004000', '#FFFFDD'])
cmap_bold = ListedColormap(['#AA4444', '#006000', '#AAAA00'])
cmap_light = ListedColormap(['#FFAAAA', '#AAFFAA', '#FFFFDD'])
font_size=25

def meshGrid(x_data, y_data):
    h = 1  # step size in the mesh
    x_min, x_max = x_data.min() - 1, x_data.max() + 1
    y_min, y_max = y_data.min() - 1, y_data.max() + 1
    xx, yy = np.meshgrid(np.arange(x_min, x_max, h),
                         np.arange(y_min, y_max, h))
    return (xx,yy)
    
def plotPrediction(clf, x_data, y_data, x_label, y_label, colors, title="", mesh=True, fixed=None, fname=None, print=False):
    xx,yy = meshGrid(x_data, y_data)
    plt.figure(figsize=(20,10))

    if clf and mesh:
        grid_X = np.array(np.c_[yy.ravel(), xx.ravel()])
        if fixed:
            fill_values = np.full((len(grid_X), 1), fixed)
            grid_X = np.append(grid_X, fill_values, axis=1)
        Z = clf.predict(grid_X)
        Z = np.argmax(Z, axis=1)
        Z = Z.reshape(xx.shape)
        plt.pcolormesh(xx, yy, Z, cmap=cmap_light)
    plt.xlim(xx.min(), xx.max())
    plt.ylim(yy.min(), yy.max())
    if print:
        plt.scatter(x_data, y_data, c=colors, cmap=cmap_print, s=200, marker='o', edgecolors='k')
    else:
        plt.scatter(x_data, y_data, c=colors, cmap=cmap_bold, s=80, marker='o', edgecolors='k')
    plt.xlabel(x_label, fontsize=font_size)
    plt.ylabel(y_label, fontsize=font_size)
    plt.title(title, fontsize=font_size)
    if fname:
        plt.savefig(fname)

In [12]:
from sklearn.model_selection import train_test_split

In [13]:
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.4, random_state=42, stratify=y)

In [14]:
X_train.shape, y_train.shape, X_test.shape, y_test.shape


Out[14]:
((900, 3), (900,), (600, 3), (600,))

In [18]:
# tiny little pieces of feature engeneering
from keras.utils.np_utils import to_categorical

num_categories = 3

y_train_categorical = to_categorical(y_train, num_categories)
y_test_categorical = to_categorical(y_test, num_categories)

In [44]:
from keras.layers import Input
from keras.layers import Dense
from keras.models import Model
from keras.layers import Dropout

inputs = Input(name='input', shape=(3, ))
x = Dense(100, name='hidden1', activation='relu')(inputs)
x = Dense(100, name='hidden2', activation='relu')(x)
predictions = Dense(3, name='softmax', activation='softmax')(x)
model = Model(input=inputs, output=predictions)

# loss function: http://cs231n.github.io/linear-classify/#softmax
model.compile(optimizer='adam',
              loss='categorical_crossentropy',
              metrics=['accuracy'])
model.summary()


_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
input (InputLayer)           (None, 3)                 0         
_________________________________________________________________
hidden1 (Dense)              (None, 100)               400       
_________________________________________________________________
hidden2 (Dense)              (None, 100)               10100     
_________________________________________________________________
softmax (Dense)              (None, 3)                 303       
=================================================================
Total params: 10,803
Trainable params: 10,803
Non-trainable params: 0
_________________________________________________________________

In [45]:
%time model.fit(X_train, y_train_categorical, epochs=500, batch_size=100)


Epoch 1/500
900/900 [==============================] - 0s - loss: 2.9145 - acc: 0.3600     
Epoch 2/500
900/900 [==============================] - 0s - loss: 1.5771 - acc: 0.3844     
Epoch 3/500
900/900 [==============================] - 0s - loss: 1.2478 - acc: 0.4211     
Epoch 4/500
900/900 [==============================] - 0s - loss: 1.1323 - acc: 0.4922     
Epoch 5/500
900/900 [==============================] - 0s - loss: 0.9198 - acc: 0.5667     
Epoch 6/500
900/900 [==============================] - 0s - loss: 0.8798 - acc: 0.6167     
Epoch 7/500
900/900 [==============================] - 0s - loss: 0.8213 - acc: 0.6267     
Epoch 8/500
900/900 [==============================] - 0s - loss: 0.8271 - acc: 0.6389     
Epoch 9/500
900/900 [==============================] - 0s - loss: 0.8202 - acc: 0.6356     
Epoch 10/500
900/900 [==============================] - 0s - loss: 0.7973 - acc: 0.6578     
Epoch 11/500
900/900 [==============================] - 0s - loss: 0.7980 - acc: 0.6600     
Epoch 12/500
900/900 [==============================] - 0s - loss: 0.7981 - acc: 0.6556     
Epoch 13/500
900/900 [==============================] - 0s - loss: 0.8266 - acc: 0.6400     
Epoch 14/500
900/900 [==============================] - 0s - loss: 0.8547 - acc: 0.6300     
Epoch 15/500
900/900 [==============================] - 0s - loss: 0.8548 - acc: 0.6200     
Epoch 16/500
900/900 [==============================] - 0s - loss: 0.8444 - acc: 0.6389     
Epoch 17/500
900/900 [==============================] - 0s - loss: 0.8076 - acc: 0.6489     
Epoch 18/500
900/900 [==============================] - 0s - loss: 0.9410 - acc: 0.5878     
Epoch 19/500
900/900 [==============================] - 0s - loss: 0.9850 - acc: 0.5622     
Epoch 20/500
900/900 [==============================] - 0s - loss: 0.8988 - acc: 0.6033     
Epoch 21/500
900/900 [==============================] - 0s - loss: 0.8325 - acc: 0.6322     
Epoch 22/500
900/900 [==============================] - 0s - loss: 0.8957 - acc: 0.6122     
Epoch 23/500
900/900 [==============================] - 0s - loss: 0.8719 - acc: 0.6089     
Epoch 24/500
900/900 [==============================] - 0s - loss: 0.8794 - acc: 0.6278     
Epoch 25/500
900/900 [==============================] - 0s - loss: 0.8357 - acc: 0.6356     
Epoch 26/500
900/900 [==============================] - 0s - loss: 0.9303 - acc: 0.6144     
Epoch 27/500
900/900 [==============================] - 0s - loss: 0.9099 - acc: 0.6144     
Epoch 28/500
900/900 [==============================] - 0s - loss: 0.8331 - acc: 0.6367     
Epoch 29/500
900/900 [==============================] - 0s - loss: 0.8581 - acc: 0.6133     
Epoch 30/500
900/900 [==============================] - 0s - loss: 0.8657 - acc: 0.6178     
Epoch 31/500
900/900 [==============================] - 0s - loss: 0.8653 - acc: 0.6289     
Epoch 32/500
900/900 [==============================] - 0s - loss: 0.8380 - acc: 0.6433     
Epoch 33/500
900/900 [==============================] - 0s - loss: 0.8821 - acc: 0.6311     
Epoch 34/500
900/900 [==============================] - 0s - loss: 0.8027 - acc: 0.6700     
Epoch 35/500
900/900 [==============================] - 0s - loss: 0.8256 - acc: 0.6267     
Epoch 36/500
900/900 [==============================] - 0s - loss: 0.8337 - acc: 0.6400     
Epoch 37/500
900/900 [==============================] - 0s - loss: 0.8294 - acc: 0.6456     
Epoch 38/500
900/900 [==============================] - 0s - loss: 0.8789 - acc: 0.6089     
Epoch 39/500
900/900 [==============================] - 0s - loss: 0.8723 - acc: 0.6133     
Epoch 40/500
900/900 [==============================] - 0s - loss: 0.8845 - acc: 0.6200     
Epoch 41/500
900/900 [==============================] - 0s - loss: 0.8022 - acc: 0.6522     
Epoch 42/500
900/900 [==============================] - 0s - loss: 0.8009 - acc: 0.6622     
Epoch 43/500
900/900 [==============================] - 0s - loss: 0.8131 - acc: 0.6633     
Epoch 44/500
900/900 [==============================] - 0s - loss: 0.8374 - acc: 0.6333     
Epoch 45/500
900/900 [==============================] - 0s - loss: 0.8098 - acc: 0.6611     
Epoch 46/500
900/900 [==============================] - 0s - loss: 0.8310 - acc: 0.6222     
Epoch 47/500
900/900 [==============================] - 0s - loss: 0.8003 - acc: 0.6622     
Epoch 48/500
900/900 [==============================] - 0s - loss: 0.7975 - acc: 0.6656     
Epoch 49/500
900/900 [==============================] - 0s - loss: 0.7979 - acc: 0.6544     
Epoch 50/500
900/900 [==============================] - 0s - loss: 0.8040 - acc: 0.6522     
Epoch 51/500
900/900 [==============================] - 0s - loss: 0.8242 - acc: 0.6389     
Epoch 52/500
900/900 [==============================] - 0s - loss: 0.7813 - acc: 0.6667     
Epoch 53/500
900/900 [==============================] - 0s - loss: 0.8194 - acc: 0.6400     
Epoch 54/500
900/900 [==============================] - 0s - loss: 0.8065 - acc: 0.6267     
Epoch 55/500
900/900 [==============================] - 0s - loss: 0.7711 - acc: 0.6867     
Epoch 56/500
900/900 [==============================] - 0s - loss: 0.8006 - acc: 0.6622     
Epoch 57/500
900/900 [==============================] - 0s - loss: 0.8114 - acc: 0.6678     
Epoch 58/500
900/900 [==============================] - 0s - loss: 0.7922 - acc: 0.6644     
Epoch 59/500
900/900 [==============================] - 0s - loss: 0.7719 - acc: 0.6778     
Epoch 60/500
900/900 [==============================] - 0s - loss: 0.7791 - acc: 0.6700     
Epoch 61/500
900/900 [==============================] - 0s - loss: 0.8353 - acc: 0.6333     
Epoch 62/500
900/900 [==============================] - 0s - loss: 0.8568 - acc: 0.6222     
Epoch 63/500
900/900 [==============================] - 0s - loss: 0.9529 - acc: 0.5922     
Epoch 64/500
900/900 [==============================] - 0s - loss: 0.9117 - acc: 0.6256     
Epoch 65/500
900/900 [==============================] - 0s - loss: 0.7997 - acc: 0.6678     
Epoch 66/500
900/900 [==============================] - 0s - loss: 0.8117 - acc: 0.6567     
Epoch 67/500
900/900 [==============================] - 0s - loss: 0.7683 - acc: 0.6833     
Epoch 68/500
900/900 [==============================] - 0s - loss: 0.7827 - acc: 0.6733     
Epoch 69/500
900/900 [==============================] - 0s - loss: 0.7814 - acc: 0.6689     
Epoch 70/500
900/900 [==============================] - 0s - loss: 0.7987 - acc: 0.6567     
Epoch 71/500
900/900 [==============================] - 0s - loss: 0.8260 - acc: 0.6356     
Epoch 72/500
900/900 [==============================] - 0s - loss: 0.7835 - acc: 0.6722     
Epoch 73/500
900/900 [==============================] - 0s - loss: 0.7560 - acc: 0.6956     
Epoch 74/500
900/900 [==============================] - 0s - loss: 0.7811 - acc: 0.6778     
Epoch 75/500
900/900 [==============================] - 0s - loss: 0.7930 - acc: 0.6611     
Epoch 76/500
900/900 [==============================] - 0s - loss: 0.7926 - acc: 0.6678     
Epoch 77/500
900/900 [==============================] - 0s - loss: 0.8123 - acc: 0.6511     
Epoch 78/500
900/900 [==============================] - 0s - loss: 0.8259 - acc: 0.6300     
Epoch 79/500
900/900 [==============================] - 0s - loss: 0.8829 - acc: 0.6322     
Epoch 80/500
900/900 [==============================] - 0s - loss: 0.8813 - acc: 0.6322     
Epoch 81/500
900/900 [==============================] - 0s - loss: 0.7842 - acc: 0.6589     
Epoch 82/500
900/900 [==============================] - 0s - loss: 0.7822 - acc: 0.6589     
Epoch 83/500
900/900 [==============================] - 0s - loss: 0.8011 - acc: 0.6600     
Epoch 84/500
900/900 [==============================] - 0s - loss: 0.7697 - acc: 0.6800     
Epoch 85/500
900/900 [==============================] - 0s - loss: 0.8122 - acc: 0.6411     
Epoch 86/500
900/900 [==============================] - 0s - loss: 0.8516 - acc: 0.6211     
Epoch 87/500
900/900 [==============================] - 0s - loss: 0.8480 - acc: 0.6544     
Epoch 88/500
900/900 [==============================] - 0s - loss: 0.8266 - acc: 0.6367     
Epoch 89/500
900/900 [==============================] - 0s - loss: 0.8266 - acc: 0.6467     
Epoch 90/500
900/900 [==============================] - 0s - loss: 0.7779 - acc: 0.6767     
Epoch 91/500
900/900 [==============================] - 0s - loss: 0.8724 - acc: 0.6000     
Epoch 92/500
900/900 [==============================] - 0s - loss: 0.8342 - acc: 0.6433     
Epoch 93/500
900/900 [==============================] - 0s - loss: 0.9186 - acc: 0.6056     
Epoch 94/500
900/900 [==============================] - 0s - loss: 0.8933 - acc: 0.6056     
Epoch 95/500
900/900 [==============================] - 0s - loss: 0.7974 - acc: 0.6611     
Epoch 96/500
900/900 [==============================] - 0s - loss: 0.8495 - acc: 0.6444     
Epoch 97/500
900/900 [==============================] - 0s - loss: 0.8215 - acc: 0.6578     
Epoch 98/500
900/900 [==============================] - 0s - loss: 0.7785 - acc: 0.6700     
Epoch 99/500
900/900 [==============================] - 0s - loss: 0.7801 - acc: 0.6622     
Epoch 100/500
900/900 [==============================] - 0s - loss: 0.8134 - acc: 0.6489     
Epoch 101/500
900/900 [==============================] - 0s - loss: 0.8709 - acc: 0.6367     
Epoch 102/500
900/900 [==============================] - 0s - loss: 0.7572 - acc: 0.6844     
Epoch 103/500
900/900 [==============================] - 0s - loss: 0.7696 - acc: 0.6711     
Epoch 104/500
900/900 [==============================] - 0s - loss: 0.7631 - acc: 0.6822     
Epoch 105/500
900/900 [==============================] - 0s - loss: 0.7767 - acc: 0.6711     
Epoch 106/500
900/900 [==============================] - 0s - loss: 0.7843 - acc: 0.6678     
Epoch 107/500
900/900 [==============================] - 0s - loss: 0.8345 - acc: 0.6378     
Epoch 108/500
900/900 [==============================] - 0s - loss: 0.7706 - acc: 0.6800     
Epoch 109/500
900/900 [==============================] - 0s - loss: 0.8097 - acc: 0.6556     
Epoch 110/500
900/900 [==============================] - 0s - loss: 0.7955 - acc: 0.6722     
Epoch 111/500
900/900 [==============================] - 0s - loss: 0.8174 - acc: 0.6433     
Epoch 112/500
900/900 [==============================] - 0s - loss: 0.8593 - acc: 0.6367     
Epoch 113/500
900/900 [==============================] - 0s - loss: 0.8259 - acc: 0.6367     
Epoch 114/500
900/900 [==============================] - 0s - loss: 0.8343 - acc: 0.6522     
Epoch 115/500
900/900 [==============================] - 0s - loss: 0.7917 - acc: 0.6567     
Epoch 116/500
900/900 [==============================] - 0s - loss: 0.8029 - acc: 0.6744     
Epoch 117/500
900/900 [==============================] - 0s - loss: 0.7824 - acc: 0.6722     
Epoch 118/500
900/900 [==============================] - 0s - loss: 0.7807 - acc: 0.6622     
Epoch 119/500
900/900 [==============================] - 0s - loss: 0.8144 - acc: 0.6422     
Epoch 120/500
900/900 [==============================] - 0s - loss: 0.8167 - acc: 0.6567     
Epoch 121/500
900/900 [==============================] - 0s - loss: 0.8440 - acc: 0.6400     
Epoch 122/500
900/900 [==============================] - 0s - loss: 0.8045 - acc: 0.6489     
Epoch 123/500
900/900 [==============================] - 0s - loss: 0.8260 - acc: 0.6533     
Epoch 124/500
900/900 [==============================] - ETA: 0s - loss: 0.7024 - acc: 0.670 - 0s - loss: 0.8368 - acc: 0.6189     
Epoch 125/500
900/900 [==============================] - 0s - loss: 0.7990 - acc: 0.6667     
Epoch 126/500
900/900 [==============================] - 0s - loss: 0.8681 - acc: 0.6422     
Epoch 127/500
900/900 [==============================] - 0s - loss: 0.8368 - acc: 0.6400     
Epoch 128/500
900/900 [==============================] - 0s - loss: 0.8563 - acc: 0.6322     
Epoch 129/500
900/900 [==============================] - 0s - loss: 0.7908 - acc: 0.6678     
Epoch 130/500
900/900 [==============================] - 0s - loss: 0.8101 - acc: 0.6600     
Epoch 131/500
900/900 [==============================] - 0s - loss: 0.8062 - acc: 0.6500     
Epoch 132/500
900/900 [==============================] - 0s - loss: 0.9332 - acc: 0.6011     
Epoch 133/500
900/900 [==============================] - 0s - loss: 0.8886 - acc: 0.6222     
Epoch 134/500
900/900 [==============================] - 0s - loss: 0.8128 - acc: 0.6533     
Epoch 135/500
900/900 [==============================] - 0s - loss: 0.8749 - acc: 0.6522     
Epoch 136/500
900/900 [==============================] - 0s - loss: 0.9292 - acc: 0.6100     
Epoch 137/500
900/900 [==============================] - 0s - loss: 0.8004 - acc: 0.6556     
Epoch 138/500
900/900 [==============================] - 0s - loss: 0.7571 - acc: 0.6744     
Epoch 139/500
900/900 [==============================] - 0s - loss: 0.7504 - acc: 0.6800     
Epoch 140/500
900/900 [==============================] - 0s - loss: 0.7600 - acc: 0.6811     
Epoch 141/500
900/900 [==============================] - 0s - loss: 0.8043 - acc: 0.6522     
Epoch 142/500
900/900 [==============================] - 0s - loss: 0.7568 - acc: 0.6844     
Epoch 143/500
900/900 [==============================] - 0s - loss: 0.7631 - acc: 0.6744     
Epoch 144/500
900/900 [==============================] - 0s - loss: 0.8484 - acc: 0.6189     
Epoch 145/500
900/900 [==============================] - 0s - loss: 0.8726 - acc: 0.6300     
Epoch 146/500
900/900 [==============================] - 0s - loss: 0.9052 - acc: 0.6067     
Epoch 147/500
900/900 [==============================] - 0s - loss: 0.8558 - acc: 0.6411     
Epoch 148/500
900/900 [==============================] - 0s - loss: 0.7984 - acc: 0.6622     
Epoch 149/500
900/900 [==============================] - 0s - loss: 0.7569 - acc: 0.6744     
Epoch 150/500
900/900 [==============================] - 0s - loss: 0.7746 - acc: 0.6678     
Epoch 151/500
900/900 [==============================] - 0s - loss: 0.7767 - acc: 0.6744     
Epoch 152/500
900/900 [==============================] - 0s - loss: 0.7673 - acc: 0.6844     
Epoch 153/500
900/900 [==============================] - 0s - loss: 0.7577 - acc: 0.6778     
Epoch 154/500
900/900 [==============================] - 0s - loss: 0.7839 - acc: 0.6611     
Epoch 155/500
900/900 [==============================] - 0s - loss: 0.7730 - acc: 0.6900     
Epoch 156/500
900/900 [==============================] - 0s - loss: 0.7728 - acc: 0.6811     
Epoch 157/500
900/900 [==============================] - 0s - loss: 0.7751 - acc: 0.6722     
Epoch 158/500
900/900 [==============================] - 0s - loss: 0.8337 - acc: 0.6433     
Epoch 159/500
900/900 [==============================] - 0s - loss: 0.7629 - acc: 0.6767     
Epoch 160/500
900/900 [==============================] - 0s - loss: 0.7643 - acc: 0.6722     
Epoch 161/500
900/900 [==============================] - 0s - loss: 0.7830 - acc: 0.6756     
Epoch 162/500
900/900 [==============================] - 0s - loss: 0.7732 - acc: 0.6756     
Epoch 163/500
900/900 [==============================] - 0s - loss: 0.8547 - acc: 0.6356     
Epoch 164/500
900/900 [==============================] - 0s - loss: 0.8399 - acc: 0.6400     
Epoch 165/500
900/900 [==============================] - 0s - loss: 0.8591 - acc: 0.5989     
Epoch 166/500
900/900 [==============================] - 0s - loss: 0.8445 - acc: 0.6178     
Epoch 167/500
900/900 [==============================] - 0s - loss: 0.8391 - acc: 0.6333     
Epoch 168/500
900/900 [==============================] - 0s - loss: 0.7935 - acc: 0.6678     
Epoch 169/500
900/900 [==============================] - 0s - loss: 0.7704 - acc: 0.6722     
Epoch 170/500
900/900 [==============================] - 0s - loss: 0.7969 - acc: 0.6678     
Epoch 171/500
900/900 [==============================] - 0s - loss: 0.7689 - acc: 0.6689     
Epoch 172/500
900/900 [==============================] - 0s - loss: 0.8174 - acc: 0.6656     
Epoch 173/500
900/900 [==============================] - 0s - loss: 0.8153 - acc: 0.6600     
Epoch 174/500
900/900 [==============================] - 0s - loss: 0.7811 - acc: 0.6778     
Epoch 175/500
900/900 [==============================] - 0s - loss: 0.8082 - acc: 0.6589     
Epoch 176/500
900/900 [==============================] - 0s - loss: 0.8165 - acc: 0.6411     
Epoch 177/500
900/900 [==============================] - 0s - loss: 0.8278 - acc: 0.6422     
Epoch 178/500
900/900 [==============================] - 0s - loss: 0.8420 - acc: 0.6311     
Epoch 179/500
900/900 [==============================] - 0s - loss: 0.7996 - acc: 0.6622     
Epoch 180/500
900/900 [==============================] - 0s - loss: 0.8626 - acc: 0.6278     
Epoch 181/500
900/900 [==============================] - 0s - loss: 0.7710 - acc: 0.6778     
Epoch 182/500
900/900 [==============================] - 0s - loss: 0.7796 - acc: 0.6611     
Epoch 183/500
900/900 [==============================] - 0s - loss: 0.7492 - acc: 0.6978     
Epoch 184/500
900/900 [==============================] - 0s - loss: 0.7554 - acc: 0.6922     
Epoch 185/500
900/900 [==============================] - 0s - loss: 0.7850 - acc: 0.6533     
Epoch 186/500
900/900 [==============================] - 0s - loss: 0.7676 - acc: 0.6656     - ETA: 0s - loss: 0.7371 - acc: 0.675
Epoch 187/500
900/900 [==============================] - 0s - loss: 0.7633 - acc: 0.7011     
Epoch 188/500
900/900 [==============================] - 0s - loss: 0.7715 - acc: 0.6733     
Epoch 189/500
900/900 [==============================] - 0s - loss: 0.7732 - acc: 0.6622     
Epoch 190/500
900/900 [==============================] - 0s - loss: 0.7983 - acc: 0.6611     
Epoch 191/500
900/900 [==============================] - 0s - loss: 0.7922 - acc: 0.6622     
Epoch 192/500
900/900 [==============================] - 0s - loss: 0.7588 - acc: 0.6922     
Epoch 193/500
900/900 [==============================] - 0s - loss: 0.7607 - acc: 0.6800     
Epoch 194/500
900/900 [==============================] - 0s - loss: 0.7816 - acc: 0.6756     
Epoch 195/500
900/900 [==============================] - 0s - loss: 0.7959 - acc: 0.6522     
Epoch 196/500
900/900 [==============================] - 0s - loss: 0.8041 - acc: 0.6567     
Epoch 197/500
900/900 [==============================] - 0s - loss: 0.8409 - acc: 0.6244     
Epoch 198/500
900/900 [==============================] - 0s - loss: 0.7757 - acc: 0.6722     
Epoch 199/500
900/900 [==============================] - 0s - loss: 0.7609 - acc: 0.6878     
Epoch 200/500
900/900 [==============================] - 0s - loss: 0.7816 - acc: 0.6700     
Epoch 201/500
900/900 [==============================] - 0s - loss: 0.8015 - acc: 0.6578     
Epoch 202/500
900/900 [==============================] - 0s - loss: 0.7791 - acc: 0.6789     
Epoch 203/500
900/900 [==============================] - 0s - loss: 0.8227 - acc: 0.6467     
Epoch 204/500
900/900 [==============================] - 0s - loss: 0.7817 - acc: 0.6600     
Epoch 205/500
900/900 [==============================] - 0s - loss: 0.8077 - acc: 0.6444     
Epoch 206/500
900/900 [==============================] - 0s - loss: 0.8414 - acc: 0.6433     
Epoch 207/500
900/900 [==============================] - 0s - loss: 0.7543 - acc: 0.6744     
Epoch 208/500
900/900 [==============================] - 0s - loss: 0.8213 - acc: 0.6644     
Epoch 209/500
900/900 [==============================] - 0s - loss: 0.7920 - acc: 0.6667     
Epoch 210/500
900/900 [==============================] - 0s - loss: 0.8340 - acc: 0.6411     
Epoch 211/500
900/900 [==============================] - 0s - loss: 0.7762 - acc: 0.6733     
Epoch 212/500
900/900 [==============================] - 0s - loss: 0.7467 - acc: 0.6933     
Epoch 213/500
900/900 [==============================] - 0s - loss: 0.7774 - acc: 0.6700     
Epoch 214/500
900/900 [==============================] - 0s - loss: 0.8092 - acc: 0.6678     
Epoch 215/500
900/900 [==============================] - 0s - loss: 0.8653 - acc: 0.6422     
Epoch 216/500
900/900 [==============================] - 0s - loss: 0.8833 - acc: 0.6311     
Epoch 217/500
900/900 [==============================] - 0s - loss: 0.8545 - acc: 0.6478     
Epoch 218/500
900/900 [==============================] - 0s - loss: 0.7999 - acc: 0.6522     
Epoch 219/500
900/900 [==============================] - 0s - loss: 0.8343 - acc: 0.6567     
Epoch 220/500
900/900 [==============================] - 0s - loss: 0.7754 - acc: 0.6744     
Epoch 221/500
900/900 [==============================] - 0s - loss: 0.7894 - acc: 0.6578     
Epoch 222/500
900/900 [==============================] - 0s - loss: 0.7751 - acc: 0.6611     
Epoch 223/500
900/900 [==============================] - 0s - loss: 0.8077 - acc: 0.6744     
Epoch 224/500
900/900 [==============================] - 0s - loss: 0.7676 - acc: 0.6733     
Epoch 225/500
900/900 [==============================] - 0s - loss: 0.8215 - acc: 0.6333     
Epoch 226/500
900/900 [==============================] - 0s - loss: 0.8168 - acc: 0.6633     
Epoch 227/500
900/900 [==============================] - 0s - loss: 0.7493 - acc: 0.6889     
Epoch 228/500
900/900 [==============================] - 0s - loss: 0.7514 - acc: 0.6867     
Epoch 229/500
900/900 [==============================] - 0s - loss: 0.7979 - acc: 0.6644     
Epoch 230/500
900/900 [==============================] - 0s - loss: 0.7718 - acc: 0.6700     
Epoch 231/500
900/900 [==============================] - 0s - loss: 0.7633 - acc: 0.6789     
Epoch 232/500
900/900 [==============================] - 0s - loss: 0.7609 - acc: 0.6733     
Epoch 233/500
900/900 [==============================] - 0s - loss: 0.7992 - acc: 0.6600     
Epoch 234/500
900/900 [==============================] - 0s - loss: 0.7636 - acc: 0.6756     
Epoch 235/500
900/900 [==============================] - 0s - loss: 0.7712 - acc: 0.6956     
Epoch 236/500
900/900 [==============================] - 0s - loss: 0.7554 - acc: 0.6944     
Epoch 237/500
900/900 [==============================] - 0s - loss: 0.8050 - acc: 0.6656     
Epoch 238/500
900/900 [==============================] - 0s - loss: 0.8034 - acc: 0.6600     
Epoch 239/500
900/900 [==============================] - 0s - loss: 0.7688 - acc: 0.6644     
Epoch 240/500
900/900 [==============================] - 0s - loss: 0.7707 - acc: 0.6744     
Epoch 241/500
900/900 [==============================] - 0s - loss: 0.7817 - acc: 0.6700     
Epoch 242/500
900/900 [==============================] - 0s - loss: 0.7859 - acc: 0.6767     
Epoch 243/500
900/900 [==============================] - 0s - loss: 0.7740 - acc: 0.6622     
Epoch 244/500
900/900 [==============================] - 0s - loss: 0.7914 - acc: 0.6522     
Epoch 245/500
900/900 [==============================] - 0s - loss: 0.7555 - acc: 0.6833     
Epoch 246/500
900/900 [==============================] - 0s - loss: 0.7771 - acc: 0.6689     
Epoch 247/500
900/900 [==============================] - 0s - loss: 0.7733 - acc: 0.6733     
Epoch 248/500
900/900 [==============================] - 0s - loss: 0.7608 - acc: 0.6767     
Epoch 249/500
900/900 [==============================] - 0s - loss: 0.8333 - acc: 0.6400     
Epoch 250/500
900/900 [==============================] - 0s - loss: 0.7699 - acc: 0.6811     
Epoch 251/500
900/900 [==============================] - 0s - loss: 0.8099 - acc: 0.6611     
Epoch 252/500
900/900 [==============================] - 0s - loss: 0.8012 - acc: 0.6578     
Epoch 253/500
900/900 [==============================] - 0s - loss: 0.7686 - acc: 0.6756     
Epoch 254/500
900/900 [==============================] - 0s - loss: 0.7899 - acc: 0.6633     
Epoch 255/500
900/900 [==============================] - 0s - loss: 0.7406 - acc: 0.6844     
Epoch 256/500
900/900 [==============================] - 0s - loss: 0.7399 - acc: 0.6856     
Epoch 257/500
900/900 [==============================] - 0s - loss: 0.7569 - acc: 0.6800     
Epoch 258/500
900/900 [==============================] - 0s - loss: 0.7493 - acc: 0.6733     
Epoch 259/500
900/900 [==============================] - 0s - loss: 0.7557 - acc: 0.6933     
Epoch 260/500
900/900 [==============================] - 0s - loss: 0.7571 - acc: 0.6844     
Epoch 261/500
900/900 [==============================] - 0s - loss: 0.7981 - acc: 0.6711     
Epoch 262/500
900/900 [==============================] - 0s - loss: 0.8186 - acc: 0.6444     
Epoch 263/500
900/900 [==============================] - ETA: 0s - loss: 0.8570 - acc: 0.590 - 0s - loss: 0.8293 - acc: 0.6467     
Epoch 264/500
900/900 [==============================] - 0s - loss: 0.7960 - acc: 0.6778     
Epoch 265/500
900/900 [==============================] - 0s - loss: 0.8068 - acc: 0.6567     
Epoch 266/500
900/900 [==============================] - 0s - loss: 0.7889 - acc: 0.6578     
Epoch 267/500
900/900 [==============================] - 0s - loss: 0.8403 - acc: 0.6422     
Epoch 268/500
900/900 [==============================] - 0s - loss: 0.8576 - acc: 0.6178     
Epoch 269/500
900/900 [==============================] - 0s - loss: 0.7957 - acc: 0.6544     
Epoch 270/500
900/900 [==============================] - 0s - loss: 0.7427 - acc: 0.6900     
Epoch 271/500
900/900 [==============================] - 0s - loss: 0.7606 - acc: 0.6878     
Epoch 272/500
900/900 [==============================] - 0s - loss: 0.8339 - acc: 0.6367     
Epoch 273/500
900/900 [==============================] - 0s - loss: 0.8269 - acc: 0.6589     
Epoch 274/500
900/900 [==============================] - 0s - loss: 0.7676 - acc: 0.6744     
Epoch 275/500
900/900 [==============================] - 0s - loss: 0.7757 - acc: 0.6756     
Epoch 276/500
900/900 [==============================] - 0s - loss: 0.7678 - acc: 0.6767     
Epoch 277/500
900/900 [==============================] - 0s - loss: 0.7979 - acc: 0.6600     
Epoch 278/500
900/900 [==============================] - 0s - loss: 0.8970 - acc: 0.6156     
Epoch 279/500
900/900 [==============================] - 0s - loss: 0.9005 - acc: 0.6256     
Epoch 280/500
900/900 [==============================] - 0s - loss: 0.8580 - acc: 0.6333     
Epoch 281/500
900/900 [==============================] - 0s - loss: 0.7412 - acc: 0.6778     
Epoch 282/500
900/900 [==============================] - 0s - loss: 0.7663 - acc: 0.6778     
Epoch 283/500
900/900 [==============================] - 0s - loss: 0.7781 - acc: 0.6789     
Epoch 284/500
900/900 [==============================] - 0s - loss: 0.7518 - acc: 0.7033     
Epoch 285/500
900/900 [==============================] - 0s - loss: 0.7711 - acc: 0.6678     
Epoch 286/500
900/900 [==============================] - 0s - loss: 0.7642 - acc: 0.6856     
Epoch 287/500
900/900 [==============================] - 0s - loss: 0.8031 - acc: 0.6633     
Epoch 288/500
900/900 [==============================] - 0s - loss: 0.8221 - acc: 0.6489     
Epoch 289/500
900/900 [==============================] - 0s - loss: 0.7885 - acc: 0.6667     
Epoch 290/500
900/900 [==============================] - 0s - loss: 0.8339 - acc: 0.6456     
Epoch 291/500
900/900 [==============================] - 0s - loss: 0.8601 - acc: 0.6267     
Epoch 292/500
900/900 [==============================] - 0s - loss: 0.8915 - acc: 0.6311     
Epoch 293/500
900/900 [==============================] - 0s - loss: 0.9554 - acc: 0.6078     
Epoch 294/500
900/900 [==============================] - 0s - loss: 0.8189 - acc: 0.6500     
Epoch 295/500
900/900 [==============================] - 0s - loss: 0.8500 - acc: 0.6467     
Epoch 296/500
900/900 [==============================] - 0s - loss: 0.8529 - acc: 0.6578     
Epoch 297/500
900/900 [==============================] - 0s - loss: 0.7745 - acc: 0.6833     
Epoch 298/500
900/900 [==============================] - 0s - loss: 0.7887 - acc: 0.6700     
Epoch 299/500
900/900 [==============================] - 0s - loss: 0.7750 - acc: 0.6800     
Epoch 300/500
900/900 [==============================] - 0s - loss: 0.7583 - acc: 0.6867     
Epoch 301/500
900/900 [==============================] - 0s - loss: 0.7537 - acc: 0.6844     
Epoch 302/500
900/900 [==============================] - 0s - loss: 0.7860 - acc: 0.6811     
Epoch 303/500
900/900 [==============================] - 0s - loss: 0.7896 - acc: 0.6744     
Epoch 304/500
900/900 [==============================] - 0s - loss: 0.8124 - acc: 0.6500     
Epoch 305/500
900/900 [==============================] - 0s - loss: 0.8012 - acc: 0.6578     
Epoch 306/500
900/900 [==============================] - 0s - loss: 0.7972 - acc: 0.6622     
Epoch 307/500
900/900 [==============================] - 0s - loss: 0.7742 - acc: 0.6633     
Epoch 308/500
900/900 [==============================] - 0s - loss: 0.7422 - acc: 0.6944     
Epoch 309/500
900/900 [==============================] - 0s - loss: 0.7630 - acc: 0.6811     
Epoch 310/500
900/900 [==============================] - 0s - loss: 0.7709 - acc: 0.6700     
Epoch 311/500
900/900 [==============================] - 0s - loss: 0.7391 - acc: 0.6911     
Epoch 312/500
900/900 [==============================] - 0s - loss: 0.7652 - acc: 0.6867     
Epoch 313/500
900/900 [==============================] - 0s - loss: 0.7515 - acc: 0.6944     
Epoch 314/500
900/900 [==============================] - 0s - loss: 0.7893 - acc: 0.6744     
Epoch 315/500
900/900 [==============================] - 0s - loss: 0.8508 - acc: 0.6011     
Epoch 316/500
900/900 [==============================] - 0s - loss: 0.8113 - acc: 0.6589     
Epoch 317/500
900/900 [==============================] - 0s - loss: 0.7577 - acc: 0.6778     
Epoch 318/500
900/900 [==============================] - 0s - loss: 0.7564 - acc: 0.6789     
Epoch 319/500
900/900 [==============================] - 0s - loss: 0.8458 - acc: 0.6444     
Epoch 320/500
900/900 [==============================] - 0s - loss: 0.8290 - acc: 0.6467     
Epoch 321/500
900/900 [==============================] - 0s - loss: 0.8346 - acc: 0.6422     
Epoch 322/500
900/900 [==============================] - 0s - loss: 0.8274 - acc: 0.6444     - ETA: 0s - loss: 0.8306 - acc: 0.644
Epoch 323/500
900/900 [==============================] - 0s - loss: 0.7793 - acc: 0.6833     
Epoch 324/500
900/900 [==============================] - 0s - loss: 0.8362 - acc: 0.6433     
Epoch 325/500
900/900 [==============================] - 0s - loss: 0.8031 - acc: 0.6544     
Epoch 326/500
900/900 [==============================] - 0s - loss: 0.7798 - acc: 0.6744     
Epoch 327/500
900/900 [==============================] - 0s - loss: 0.7621 - acc: 0.6789     
Epoch 328/500
900/900 [==============================] - 0s - loss: 0.7608 - acc: 0.6856     
Epoch 329/500
900/900 [==============================] - 0s - loss: 0.8602 - acc: 0.6278     
Epoch 330/500
900/900 [==============================] - 0s - loss: 0.8150 - acc: 0.6456     
Epoch 331/500
900/900 [==============================] - 0s - loss: 0.8451 - acc: 0.6367     
Epoch 332/500
900/900 [==============================] - 0s - loss: 0.7976 - acc: 0.6689     
Epoch 333/500
900/900 [==============================] - 0s - loss: 0.8021 - acc: 0.6589     
Epoch 334/500
900/900 [==============================] - 0s - loss: 0.7602 - acc: 0.6811     
Epoch 335/500
900/900 [==============================] - 0s - loss: 0.7579 - acc: 0.6767     
Epoch 336/500
900/900 [==============================] - 0s - loss: 0.7572 - acc: 0.6878     
Epoch 337/500
900/900 [==============================] - 0s - loss: 0.7744 - acc: 0.6756     
Epoch 338/500
900/900 [==============================] - 0s - loss: 0.7707 - acc: 0.6767     
Epoch 339/500
900/900 [==============================] - 0s - loss: 0.7662 - acc: 0.6656     
Epoch 340/500
900/900 [==============================] - 0s - loss: 0.7842 - acc: 0.6578     
Epoch 341/500
900/900 [==============================] - 0s - loss: 0.8794 - acc: 0.6167     
Epoch 342/500
900/900 [==============================] - 0s - loss: 0.8391 - acc: 0.6400     
Epoch 343/500
900/900 [==============================] - 0s - loss: 0.7903 - acc: 0.6667     
Epoch 344/500
900/900 [==============================] - 0s - loss: 0.7355 - acc: 0.6922     
Epoch 345/500
900/900 [==============================] - 0s - loss: 0.7357 - acc: 0.7044     
Epoch 346/500
900/900 [==============================] - 0s - loss: 0.7560 - acc: 0.6944     
Epoch 347/500
900/900 [==============================] - 0s - loss: 0.7416 - acc: 0.6844     
Epoch 348/500
900/900 [==============================] - 0s - loss: 0.7411 - acc: 0.6900     
Epoch 349/500
900/900 [==============================] - 0s - loss: 0.7370 - acc: 0.6967     
Epoch 350/500
900/900 [==============================] - 0s - loss: 0.7766 - acc: 0.6700     
Epoch 351/500
900/900 [==============================] - 0s - loss: 0.7748 - acc: 0.6733     
Epoch 352/500
900/900 [==============================] - 0s - loss: 0.7776 - acc: 0.6689     
Epoch 353/500
900/900 [==============================] - 0s - loss: 0.7789 - acc: 0.6656     
Epoch 354/500
900/900 [==============================] - 0s - loss: 0.7872 - acc: 0.6711     
Epoch 355/500
900/900 [==============================] - 0s - loss: 0.7970 - acc: 0.6678     
Epoch 356/500
900/900 [==============================] - 0s - loss: 0.7817 - acc: 0.6733     
Epoch 357/500
900/900 [==============================] - 0s - loss: 0.7776 - acc: 0.6600     
Epoch 358/500
900/900 [==============================] - 0s - loss: 0.7406 - acc: 0.6933     
Epoch 359/500
900/900 [==============================] - 0s - loss: 0.7957 - acc: 0.6689     
Epoch 360/500
900/900 [==============================] - 0s - loss: 0.7984 - acc: 0.6689     
Epoch 361/500
900/900 [==============================] - 0s - loss: 0.7573 - acc: 0.6989     
Epoch 362/500
900/900 [==============================] - 0s - loss: 0.7930 - acc: 0.6556     
Epoch 363/500
900/900 [==============================] - 0s - loss: 0.7747 - acc: 0.6689     
Epoch 364/500
900/900 [==============================] - 0s - loss: 0.7494 - acc: 0.6833     
Epoch 365/500
900/900 [==============================] - 0s - loss: 0.7907 - acc: 0.6656     
Epoch 366/500
900/900 [==============================] - 0s - loss: 0.7757 - acc: 0.6778     
Epoch 367/500
900/900 [==============================] - 0s - loss: 0.7730 - acc: 0.6711     
Epoch 368/500
900/900 [==============================] - 0s - loss: 0.7616 - acc: 0.6589     
Epoch 369/500
900/900 [==============================] - 0s - loss: 0.7983 - acc: 0.6722     
Epoch 370/500
900/900 [==============================] - 0s - loss: 0.7719 - acc: 0.6889     
Epoch 371/500
900/900 [==============================] - 0s - loss: 0.7988 - acc: 0.6667     
Epoch 372/500
900/900 [==============================] - 0s - loss: 0.8355 - acc: 0.6533     
Epoch 373/500
900/900 [==============================] - 0s - loss: 0.7878 - acc: 0.6689     
Epoch 374/500
900/900 [==============================] - 0s - loss: 0.7399 - acc: 0.6967     
Epoch 375/500
900/900 [==============================] - 0s - loss: 0.7377 - acc: 0.6833     
Epoch 376/500
900/900 [==============================] - 0s - loss: 0.7938 - acc: 0.6511     
Epoch 377/500
900/900 [==============================] - 0s - loss: 0.7680 - acc: 0.6756     
Epoch 378/500
900/900 [==============================] - 0s - loss: 0.8247 - acc: 0.6356     
Epoch 379/500
900/900 [==============================] - 0s - loss: 0.7506 - acc: 0.7011     
Epoch 380/500
900/900 [==============================] - 0s - loss: 0.7519 - acc: 0.6811     
Epoch 381/500
900/900 [==============================] - 0s - loss: 0.7488 - acc: 0.6911     
Epoch 382/500
900/900 [==============================] - 0s - loss: 0.7593 - acc: 0.6822     
Epoch 383/500
900/900 [==============================] - 0s - loss: 0.7780 - acc: 0.6644     
Epoch 384/500
900/900 [==============================] - 0s - loss: 0.7764 - acc: 0.6789     
Epoch 385/500
900/900 [==============================] - 0s - loss: 0.7541 - acc: 0.6900     
Epoch 386/500
900/900 [==============================] - 0s - loss: 0.7645 - acc: 0.6800     
Epoch 387/500
900/900 [==============================] - 0s - loss: 0.7338 - acc: 0.6989     
Epoch 388/500
900/900 [==============================] - 0s - loss: 0.7321 - acc: 0.6933     
Epoch 389/500
900/900 [==============================] - 0s - loss: 0.7432 - acc: 0.6889     
Epoch 390/500
900/900 [==============================] - 0s - loss: 0.7598 - acc: 0.6822     
Epoch 391/500
900/900 [==============================] - 0s - loss: 0.7497 - acc: 0.6900     
Epoch 392/500
900/900 [==============================] - 0s - loss: 0.7810 - acc: 0.6800     
Epoch 393/500
900/900 [==============================] - 0s - loss: 0.7599 - acc: 0.6900     
Epoch 394/500
900/900 [==============================] - 0s - loss: 0.7423 - acc: 0.6756     
Epoch 395/500
900/900 [==============================] - 0s - loss: 0.7357 - acc: 0.6900     
Epoch 396/500
900/900 [==============================] - 0s - loss: 0.7408 - acc: 0.7000     
Epoch 397/500
900/900 [==============================] - 0s - loss: 0.7575 - acc: 0.6767     
Epoch 398/500
900/900 [==============================] - 0s - loss: 0.7711 - acc: 0.6767     
Epoch 399/500
900/900 [==============================] - 0s - loss: 0.7809 - acc: 0.6600     
Epoch 400/500
900/900 [==============================] - 0s - loss: 0.7587 - acc: 0.6744     
Epoch 401/500
900/900 [==============================] - 0s - loss: 0.7372 - acc: 0.7000     
Epoch 402/500
900/900 [==============================] - 0s - loss: 0.7665 - acc: 0.6744     
Epoch 403/500
900/900 [==============================] - 0s - loss: 0.7698 - acc: 0.6867     
Epoch 404/500
900/900 [==============================] - 0s - loss: 0.7600 - acc: 0.6833     
Epoch 405/500
900/900 [==============================] - 0s - loss: 0.7872 - acc: 0.6689     
Epoch 406/500
900/900 [==============================] - 0s - loss: 0.8115 - acc: 0.6589     
Epoch 407/500
900/900 [==============================] - 0s - loss: 0.8888 - acc: 0.6244     
Epoch 408/500
900/900 [==============================] - 0s - loss: 0.8260 - acc: 0.6489     
Epoch 409/500
900/900 [==============================] - 0s - loss: 0.8047 - acc: 0.6856     
Epoch 410/500
900/900 [==============================] - 0s - loss: 0.7565 - acc: 0.6856     
Epoch 411/500
900/900 [==============================] - 0s - loss: 0.7440 - acc: 0.6844     
Epoch 412/500
900/900 [==============================] - 0s - loss: 0.7412 - acc: 0.7044     
Epoch 413/500
900/900 [==============================] - 0s - loss: 0.7393 - acc: 0.7011     
Epoch 414/500
900/900 [==============================] - 0s - loss: 0.7677 - acc: 0.6733     
Epoch 415/500
900/900 [==============================] - 0s - loss: 0.7610 - acc: 0.6789     
Epoch 416/500
900/900 [==============================] - 0s - loss: 0.7663 - acc: 0.6778     
Epoch 417/500
900/900 [==============================] - 0s - loss: 0.7917 - acc: 0.6789     
Epoch 418/500
900/900 [==============================] - 0s - loss: 0.7613 - acc: 0.6767     
Epoch 419/500
900/900 [==============================] - 0s - loss: 0.7698 - acc: 0.6844     
Epoch 420/500
900/900 [==============================] - 0s - loss: 0.7360 - acc: 0.7000     
Epoch 421/500
900/900 [==============================] - 0s - loss: 0.7686 - acc: 0.6889     
Epoch 422/500
900/900 [==============================] - 0s - loss: 0.7424 - acc: 0.6822     
Epoch 423/500
900/900 [==============================] - 0s - loss: 0.7508 - acc: 0.6911     
Epoch 424/500
900/900 [==============================] - 0s - loss: 0.7542 - acc: 0.6767     
Epoch 425/500
900/900 [==============================] - 0s - loss: 0.7835 - acc: 0.6800     
Epoch 426/500
900/900 [==============================] - 0s - loss: 0.7461 - acc: 0.6867     
Epoch 427/500
900/900 [==============================] - 0s - loss: 0.7459 - acc: 0.6878     
Epoch 428/500
900/900 [==============================] - 0s - loss: 0.7940 - acc: 0.6867     
Epoch 429/500
900/900 [==============================] - 0s - loss: 0.7756 - acc: 0.6900     
Epoch 430/500
900/900 [==============================] - 0s - loss: 0.7534 - acc: 0.6922     
Epoch 431/500
900/900 [==============================] - 0s - loss: 0.8688 - acc: 0.6211     
Epoch 432/500
900/900 [==============================] - 0s - loss: 0.8004 - acc: 0.6656     
Epoch 433/500
900/900 [==============================] - 0s - loss: 0.7599 - acc: 0.6833     
Epoch 434/500
900/900 [==============================] - 0s - loss: 0.7803 - acc: 0.6789     
Epoch 435/500
900/900 [==============================] - 0s - loss: 0.7670 - acc: 0.6733     
Epoch 436/500
900/900 [==============================] - 0s - loss: 0.8120 - acc: 0.6678     
Epoch 437/500
900/900 [==============================] - 0s - loss: 0.7993 - acc: 0.6522     
Epoch 438/500
900/900 [==============================] - 0s - loss: 0.8072 - acc: 0.6733     
Epoch 439/500
900/900 [==============================] - 0s - loss: 0.7476 - acc: 0.6989     
Epoch 440/500
900/900 [==============================] - 0s - loss: 0.7319 - acc: 0.6889     
Epoch 441/500
900/900 [==============================] - 0s - loss: 0.7720 - acc: 0.6911     
Epoch 442/500
900/900 [==============================] - 0s - loss: 0.7539 - acc: 0.6922     
Epoch 443/500
900/900 [==============================] - 0s - loss: 0.7643 - acc: 0.6833     
Epoch 444/500
900/900 [==============================] - 0s - loss: 0.7993 - acc: 0.6711     
Epoch 445/500
900/900 [==============================] - 0s - loss: 0.7998 - acc: 0.6433     
Epoch 446/500
900/900 [==============================] - 0s - loss: 0.7552 - acc: 0.6733     
Epoch 447/500
900/900 [==============================] - 0s - loss: 0.7838 - acc: 0.6767     
Epoch 448/500
900/900 [==============================] - 0s - loss: 0.7927 - acc: 0.6711     
Epoch 449/500
900/900 [==============================] - 0s - loss: 0.8070 - acc: 0.6589     
Epoch 450/500
900/900 [==============================] - 0s - loss: 0.7947 - acc: 0.6811     
Epoch 451/500
900/900 [==============================] - 0s - loss: 0.7955 - acc: 0.6678     
Epoch 452/500
900/900 [==============================] - 0s - loss: 0.7786 - acc: 0.6656     
Epoch 453/500
900/900 [==============================] - 0s - loss: 0.7681 - acc: 0.6811     
Epoch 454/500
900/900 [==============================] - 0s - loss: 0.7755 - acc: 0.6833     
Epoch 455/500
900/900 [==============================] - 0s - loss: 0.7652 - acc: 0.6800     
Epoch 456/500
900/900 [==============================] - 0s - loss: 0.7622 - acc: 0.6744     
Epoch 457/500
900/900 [==============================] - 0s - loss: 0.8223 - acc: 0.6544     
Epoch 458/500
900/900 [==============================] - 0s - loss: 0.8033 - acc: 0.6678     
Epoch 459/500
900/900 [==============================] - 0s - loss: 0.7619 - acc: 0.6833     
Epoch 460/500
900/900 [==============================] - 0s - loss: 0.7403 - acc: 0.7011     
Epoch 461/500
900/900 [==============================] - 0s - loss: 0.7453 - acc: 0.6956     
Epoch 462/500
900/900 [==============================] - 0s - loss: 0.7663 - acc: 0.6811     
Epoch 463/500
900/900 [==============================] - 0s - loss: 0.7564 - acc: 0.6878     
Epoch 464/500
900/900 [==============================] - 0s - loss: 0.7467 - acc: 0.6878     
Epoch 465/500
900/900 [==============================] - 0s - loss: 0.7859 - acc: 0.6589     
Epoch 466/500
900/900 [==============================] - 0s - loss: 0.7776 - acc: 0.6733     
Epoch 467/500
900/900 [==============================] - 0s - loss: 0.7662 - acc: 0.6922     
Epoch 468/500
900/900 [==============================] - 0s - loss: 0.7426 - acc: 0.6922     
Epoch 469/500
900/900 [==============================] - 0s - loss: 0.7524 - acc: 0.6878     
Epoch 470/500
900/900 [==============================] - 0s - loss: 0.7468 - acc: 0.7000     
Epoch 471/500
900/900 [==============================] - 0s - loss: 0.8071 - acc: 0.6767     
Epoch 472/500
900/900 [==============================] - 0s - loss: 0.7867 - acc: 0.6822     
Epoch 473/500
900/900 [==============================] - 0s - loss: 0.8301 - acc: 0.6267     
Epoch 474/500
900/900 [==============================] - 0s - loss: 0.7420 - acc: 0.6967     
Epoch 475/500
900/900 [==============================] - 0s - loss: 0.7591 - acc: 0.6956     
Epoch 476/500
900/900 [==============================] - 0s - loss: 0.7473 - acc: 0.6844     
Epoch 477/500
900/900 [==============================] - 0s - loss: 0.7512 - acc: 0.6933     
Epoch 478/500
900/900 [==============================] - 0s - loss: 0.7895 - acc: 0.6644     
Epoch 479/500
900/900 [==============================] - 0s - loss: 0.7806 - acc: 0.6756     
Epoch 480/500
900/900 [==============================] - 0s - loss: 0.7730 - acc: 0.6822     
Epoch 481/500
900/900 [==============================] - 0s - loss: 0.7575 - acc: 0.6956     
Epoch 482/500
900/900 [==============================] - 0s - loss: 0.7429 - acc: 0.6811     
Epoch 483/500
900/900 [==============================] - 0s - loss: 0.7684 - acc: 0.6744     
Epoch 484/500
900/900 [==============================] - 0s - loss: 0.7535 - acc: 0.6789     
Epoch 485/500
900/900 [==============================] - 0s - loss: 0.7354 - acc: 0.6900     
Epoch 486/500
900/900 [==============================] - 0s - loss: 0.7308 - acc: 0.7011     
Epoch 487/500
900/900 [==============================] - 0s - loss: 0.7292 - acc: 0.6900     
Epoch 488/500
900/900 [==============================] - 0s - loss: 0.7449 - acc: 0.6822     
Epoch 489/500
900/900 [==============================] - 0s - loss: 0.7324 - acc: 0.6889     
Epoch 490/500
900/900 [==============================] - 0s - loss: 0.7451 - acc: 0.6833     
Epoch 491/500
900/900 [==============================] - 0s - loss: 0.7327 - acc: 0.6911     
Epoch 492/500
900/900 [==============================] - 0s - loss: 0.7438 - acc: 0.6778     
Epoch 493/500
900/900 [==============================] - 0s - loss: 0.7874 - acc: 0.6700     
Epoch 494/500
900/900 [==============================] - 0s - loss: 0.7528 - acc: 0.6833     
Epoch 495/500
900/900 [==============================] - 0s - loss: 0.7464 - acc: 0.6922     
Epoch 496/500
900/900 [==============================] - 0s - loss: 0.7428 - acc: 0.6822     
Epoch 497/500
900/900 [==============================] - 0s - loss: 0.7419 - acc: 0.6944     
Epoch 498/500
900/900 [==============================] - 0s - loss: 0.7377 - acc: 0.6867     
Epoch 499/500
900/900 [==============================] - 0s - loss: 0.7475 - acc: 0.6833     
Epoch 500/500
900/900 [==============================] - 0s - loss: 0.7439 - acc: 0.6944     
CPU times: user 33.7 s, sys: 5.66 s, total: 39.4 s
Wall time: 33.5 s
Out[45]:
<keras.callbacks.History at 0x7f850c5ecfd0>

In [46]:
train_loss, train_accuracy = model.evaluate(X_train, y_train_categorical, batch_size=100)
train_accuracy


100/900 [==>...........................] - ETA: 1s
Out[46]:
0.70666667487886214

In [47]:
test_loss, test_accuracy = model.evaluate(X_test, y_test_categorical, batch_size=100)
test_accuracy


100/600 [====>.........................] - ETA: 0s
Out[47]:
0.69999999801317847

Look at all the different shapes for different kilometers per year

  • now we have three dimensions, so we need to set one to a certain number

In [52]:
kms_per_year = 20
plotPrediction(model, X_test[:, 1], X_test[:, 0],
               'Age', 'Max Speed', y_test,
                fixed = kms_per_year,
                title="Test Data Max Speed vs Age with Prediction, 20 km/year")



In [53]:
kms_per_year = 50
plotPrediction(model, X_test[:, 1], X_test[:, 0],
               'Age', 'Max Speed', y_test,
                fixed = kms_per_year,
                title="Test Data Max Speed vs Age with Prediction, 50 km/year")



In [54]:
kms_per_year = 5
plotPrediction(model, X_test[:, 1], X_test[:, 0],
               'Age', 'Max Speed', y_test,
                fixed = kms_per_year,
                title="Test Data Max Speed vs Age with Prediction, 5 km/year")



In [ ]: