application_vnd.jupyter.stderr_output_2.png application_vnd.jupyter.stderr_output_1.png
from keras.layers import Conv2D,Dropout,Dense,Flatten

from keras.models import Sequential

import matplotlib.pyplot as plt

import numpy as np

import os

import pandas as pd

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from IPython.display import clear_output
from time import sleep
import os
os.listdir('../input')
train_data = pd.read_csv('../input/training/training.csv')
test_data = pd.read_csv('../input/test/test.csv')
lookid_data = pd.read_csv('../input/IdLookupTable.csv')
train_data.head().T

train_data.isnull().any().value_counts()
train_data.fillna(method='ffill', inplace=True)
train_data.isnull().any().value_counts()

def split_image_feature(data):
    """Return extracted image feature"""
    imag = []
    for i in range(0, data.shape[0]):
        img = data['Image'][i].split(' ')
        img = ['0' if x == '' else x for x in img]
        imag.append(img)
    image_list = np.array(imag, dtype='float')
    X_train = image_list.reshape(-1, 96, 96)
    return X_train
X_train = split_image_feature(train_data)
training = data.drop('Image', axis=1)
y_train = []
for i in range(0, data.shape[0]):
    y = training.iloc[i, :]
    y_train.append(y)
y_train = np.array(y_train, dtype='float')

from keras.layers import Conv2D, Dropout, Dense, Flatten
from keras.models import Sequential
model = Sequential([Flatten(input_shape=(96, 96)), Dense(128, activation='relu'), Dropout(0.1), Dense(64, activation='relu'), Dense(30)])
model.compile(optimizer='adam', loss='mse', metrics=['mae', 'accuracy'])
model.fit(X_train, y_train, epochs=500, batch_size=128, validation_split=0.2)