<jupyter_start><jupyter_text>model = Sequential()model.add(Dense(16, input_dim=10, activation='relu'))model.add(Dense(1))model.compile(loss='mse',optimizer=keras.optimizers.RMSprop(0.005), metrics=['mae', 'mse'])history = model.fit(train_X, train_y, epochs=1000, batch_size=16, validation_split = 0.2)_,_, MSE = model.evaluate(train_X, train_y)print('RMSE: %.2f' % (np.sqrt(MSE)))<jupyter_code>from sklearn.model_selection import train_test_split
# define the keras model
model = Sequential()
model.add(Dense(8, input_dim=10, activation='relu'))
# model.add(Dense(4, activation='relu'))
model.add(Dense(1))
# compile the keras model
model.compile(loss='mse',
                optimizer=keras.optimizers.RMSprop(0.005),
                metrics=['mae', 'mse'])
# fit the keras model on the dataset
history = model.fit(train_X, train_y, epochs=1000, batch_size=16, validation_split=0.2)

# evaluate the keras model
_,_, MSE = model.evaluate(train_X, train_y)
print('RMSE: %.2f' % (np.sqrt(MSE)))
hist = pd.DataFrame(history.history)
hist['epoch'] = history.epoch
hist.tail()
# summarize history for loss
plt.plot(history.history['loss'])
plt.plot(history.history['val_loss'])
plt.title('Model Loss')
plt.ylabel('loss')
plt.xlabel('epoch')
plt.legend(['train', 'validation'], loc='upper right')
plt.show()

# summarize history for mse
plt.plot(history.history['mse'])
plt.plot(history.history['val_mse'])
plt.title('Model Fit')
plt.ylabel('MSE')
plt.xlabel('epoch')
plt.legend(['train', 'validation'], loc='upper right')
plt.show()
test_predictions = model.predict(test_X)
np.size(test_predictions)
np.array(test_labels)[1]
error = []
error_squared = []
for i in range(np.size(test_predictions)):
    error.append(test_predictions[i][0] - np.array(test_labels)[i])
    error_squared.append(np.square(test_predictions[i][0] - np.array(test_labels)[i]))
error_squared
RMSE = np.sqrt(np.sum(error_squared)/np.size(test_predictions))
RMSE
a = plt.axes(aspect='equal')
plt.scatter(test_labels, test_predictions)
plt.xlabel('True Values [Price]')
plt.ylabel('Predictions [Price]')
lims = [0, 5e+06]
plt.xlim(lims)
plt.ylim(lims)
_ = plt.plot(lims, lims)
plt.hist(error, bins = 25)
plt.xlabel("Prediction Error [Price]")
_ = plt.ylabel("Count")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1794871794871795, 'fraction_numerical': 0.01989389920424403, 'mean_word_length': 6.9125874125874125, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '285381', 'license': 'MIT', 'n_tokens_mistral': 903, 'n_tokens_neox': 845, 'n_words': 139, 'path': 'Scripts/Neural_Network/NN Regressor.ipynb', 'repo_name': 'c-helmlinger/Project0', 'size': '2262'}