#!/usr/bin/env python # coding: utf-8 # In[44]: from keras.models import Sequential from keras.layers import Dense, Activation from keras.datasets import boston_housing # In[45]: (X_train, Y_train), (X_test, Y_test) = boston_housing.load_data() # In[47]: nFeatures = X_train.shape[1] model = Sequential() model.add(Dense(1, input_shape=(nFeatures,), kernel_initializer='uniform')) model.add(Activation('linear')) model.compile(optimizer='rmsprop', loss='mse', metrics=['mse', 'mae']) model.fit(X_train, Y_train, batch_size=4, epochs=1000) # In[48]: model.summary() model.evaluate(X_test, Y_test, verbose=True) # In[39]: Y_pred = model.predict(X_test) # In[40]: print Y_test[:5] print Y_pred[:5,0]