You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1123 lines
55 KiB
1123 lines
55 KiB
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# https://machinelearningmastery.com/tutorial-first-neural-network-python-keras/"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from keras.models import Sequential\n",
|
|
"from keras.layers import Dense\n",
|
|
"import numpy\n",
|
|
"# fix random seed for reproducibility\n",
|
|
"numpy.random.seed(7)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 6,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#load pima indians dataset\n",
|
|
"dataset = numpy.loadtxt(\"pima-indians-diabetes.data\", delimiter=\",\")\n",
|
|
"# split into input (X) and output (Y) variables\n",
|
|
"X = dataset[:,0:8]\n",
|
|
"Y = dataset[:,8]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 7,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# create model\n",
|
|
"model = Sequential()\n",
|
|
"model.add(Dense(12, input_dim=8, activation='relu'))\n",
|
|
"model.add(Dense(8, activation='relu'))\n",
|
|
"model.add(Dense(1, activation='sigmoid'))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 8,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"# Compile model\n",
|
|
"model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 9,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Epoch 1/150\n",
|
|
"768/768 [==============================] - 1s 2ms/step - loss: 3.7106 - acc: 0.5977\n",
|
|
"Epoch 2/150\n",
|
|
"768/768 [==============================] - 0s 358us/step - loss: 0.9376 - acc: 0.5924\n",
|
|
"Epoch 3/150\n",
|
|
"768/768 [==============================] - 0s 311us/step - loss: 0.7478 - acc: 0.6445\n",
|
|
"Epoch 4/150\n",
|
|
"768/768 [==============================] - 0s 224us/step - loss: 0.7121 - acc: 0.6549\n",
|
|
"Epoch 5/150\n",
|
|
"768/768 [==============================] - 0s 174us/step - loss: 0.6842 - acc: 0.6680\n",
|
|
"Epoch 6/150\n",
|
|
"768/768 [==============================] - 0s 257us/step - loss: 0.6522 - acc: 0.6797\n",
|
|
"Epoch 7/150\n",
|
|
"768/768 [==============================] - 0s 254us/step - loss: 0.6496 - acc: 0.6836\n",
|
|
"Epoch 8/150\n",
|
|
"768/768 [==============================] - 0s 307us/step - loss: 0.6380 - acc: 0.6875\n",
|
|
"Epoch 9/150\n",
|
|
"768/768 [==============================] - 0s 215us/step - loss: 0.6238 - acc: 0.6953\n",
|
|
"Epoch 10/150\n",
|
|
"768/768 [==============================] - 0s 184us/step - loss: 0.6288 - acc: 0.6771\n",
|
|
"Epoch 11/150\n",
|
|
"768/768 [==============================] - 0s 316us/step - loss: 0.6433 - acc: 0.6745\n",
|
|
"Epoch 12/150\n",
|
|
"768/768 [==============================] - 0s 273us/step - loss: 0.6400 - acc: 0.6732\n",
|
|
"Epoch 13/150\n",
|
|
"768/768 [==============================] - 0s 241us/step - loss: 0.6262 - acc: 0.6719\n",
|
|
"Epoch 14/150\n",
|
|
"768/768 [==============================] - 0s 302us/step - loss: 0.6179 - acc: 0.7018\n",
|
|
"Epoch 15/150\n",
|
|
"768/768 [==============================] - 0s 327us/step - loss: 0.6020 - acc: 0.6953\n",
|
|
"Epoch 16/150\n",
|
|
"768/768 [==============================] - 0s 244us/step - loss: 0.5877 - acc: 0.7018\n",
|
|
"Epoch 17/150\n",
|
|
"768/768 [==============================] - 0s 277us/step - loss: 0.5848 - acc: 0.6992\n",
|
|
"Epoch 18/150\n",
|
|
"768/768 [==============================] - 0s 202us/step - loss: 0.6008 - acc: 0.6849\n",
|
|
"Epoch 19/150\n",
|
|
"768/768 [==============================] - 0s 180us/step - loss: 0.5807 - acc: 0.7070\n",
|
|
"Epoch 20/150\n",
|
|
"768/768 [==============================] - 0s 275us/step - loss: 0.5811 - acc: 0.7174\n",
|
|
"Epoch 21/150\n",
|
|
"768/768 [==============================] - 0s 189us/step - loss: 0.5688 - acc: 0.7161\n",
|
|
"Epoch 22/150\n",
|
|
"768/768 [==============================] - 0s 214us/step - loss: 0.5824 - acc: 0.6966\n",
|
|
"Epoch 23/150\n",
|
|
"768/768 [==============================] - 0s 197us/step - loss: 0.5743 - acc: 0.7122\n",
|
|
"Epoch 24/150\n",
|
|
"768/768 [==============================] - 0s 172us/step - loss: 0.5677 - acc: 0.7344\n",
|
|
"Epoch 25/150\n",
|
|
"768/768 [==============================] - 0s 177us/step - loss: 0.5580 - acc: 0.7370\n",
|
|
"Epoch 26/150\n",
|
|
"768/768 [==============================] - 0s 197us/step - loss: 0.5708 - acc: 0.7031\n",
|
|
"Epoch 27/150\n",
|
|
"768/768 [==============================] - 0s 246us/step - loss: 0.5558 - acc: 0.7214\n",
|
|
"Epoch 28/150\n",
|
|
"768/768 [==============================] - 0s 288us/step - loss: 0.5559 - acc: 0.7344\n",
|
|
"Epoch 29/150\n",
|
|
"768/768 [==============================] - 0s 323us/step - loss: 0.5742 - acc: 0.7135\n",
|
|
"Epoch 30/150\n",
|
|
"768/768 [==============================] - 0s 188us/step - loss: 0.5613 - acc: 0.7214\n",
|
|
"Epoch 31/150\n",
|
|
"768/768 [==============================] - 0s 176us/step - loss: 0.5690 - acc: 0.7148\n",
|
|
"Epoch 32/150\n",
|
|
"768/768 [==============================] - 0s 171us/step - loss: 0.5655 - acc: 0.7096\n",
|
|
"Epoch 33/150\n",
|
|
"768/768 [==============================] - 0s 171us/step - loss: 0.5539 - acc: 0.7174\n",
|
|
"Epoch 34/150\n",
|
|
"768/768 [==============================] - 0s 176us/step - loss: 0.5528 - acc: 0.7305\n",
|
|
"Epoch 35/150\n",
|
|
"768/768 [==============================] - 0s 288us/step - loss: 0.5540 - acc: 0.7148\n",
|
|
"Epoch 36/150\n",
|
|
"768/768 [==============================] - 0s 224us/step - loss: 0.5627 - acc: 0.7096\n",
|
|
"Epoch 37/150\n",
|
|
"768/768 [==============================] - 0s 241us/step - loss: 0.5357 - acc: 0.7344\n",
|
|
"Epoch 38/150\n",
|
|
"768/768 [==============================] - 0s 301us/step - loss: 0.5459 - acc: 0.7135\n",
|
|
"Epoch 39/150\n",
|
|
"768/768 [==============================] - 0s 198us/step - loss: 0.5491 - acc: 0.7227\n",
|
|
"Epoch 40/150\n",
|
|
"768/768 [==============================] - 0s 216us/step - loss: 0.5494 - acc: 0.7174\n",
|
|
"Epoch 41/150\n",
|
|
"768/768 [==============================] - 0s 340us/step - loss: 0.5454 - acc: 0.7292\n",
|
|
"Epoch 42/150\n",
|
|
"768/768 [==============================] - 0s 293us/step - loss: 0.5388 - acc: 0.7396\n",
|
|
"Epoch 43/150\n",
|
|
"768/768 [==============================] - 0s 202us/step - loss: 0.5336 - acc: 0.7422\n",
|
|
"Epoch 44/150\n",
|
|
"768/768 [==============================] - 0s 329us/step - loss: 0.5353 - acc: 0.7448\n",
|
|
"Epoch 45/150\n",
|
|
"768/768 [==============================] - 0s 431us/step - loss: 0.5333 - acc: 0.7578\n",
|
|
"Epoch 46/150\n",
|
|
"768/768 [==============================] - 0s 346us/step - loss: 0.5293 - acc: 0.7578\n",
|
|
"Epoch 47/150\n",
|
|
"768/768 [==============================] - 0s 230us/step - loss: 0.5340 - acc: 0.7396\n",
|
|
"Epoch 48/150\n",
|
|
"768/768 [==============================] - 0s 234us/step - loss: 0.5353 - acc: 0.7370\n",
|
|
"Epoch 49/150\n",
|
|
"768/768 [==============================] - 0s 250us/step - loss: 0.5355 - acc: 0.7474\n",
|
|
"Epoch 50/150\n",
|
|
"768/768 [==============================] - 0s 251us/step - loss: 0.5275 - acc: 0.7409\n",
|
|
"Epoch 51/150\n",
|
|
"768/768 [==============================] - 0s 299us/step - loss: 0.5295 - acc: 0.7474\n",
|
|
"Epoch 52/150\n",
|
|
"768/768 [==============================] - 0s 255us/step - loss: 0.5306 - acc: 0.7422\n",
|
|
"Epoch 53/150\n",
|
|
"768/768 [==============================] - 0s 266us/step - loss: 0.5377 - acc: 0.7422\n",
|
|
"Epoch 54/150\n",
|
|
"768/768 [==============================] - 0s 234us/step - loss: 0.5384 - acc: 0.7279\n",
|
|
"Epoch 55/150\n",
|
|
"768/768 [==============================] - 0s 240us/step - loss: 0.5231 - acc: 0.7487\n",
|
|
"Epoch 56/150\n",
|
|
"768/768 [==============================] - 0s 237us/step - loss: 0.5281 - acc: 0.7435\n",
|
|
"Epoch 57/150\n",
|
|
"768/768 [==============================] - 0s 280us/step - loss: 0.5323 - acc: 0.7383\n",
|
|
"Epoch 58/150\n",
|
|
"768/768 [==============================] - 0s 242us/step - loss: 0.5233 - acc: 0.7539\n",
|
|
"Epoch 59/150\n",
|
|
"768/768 [==============================] - 0s 245us/step - loss: 0.5130 - acc: 0.7617\n",
|
|
"Epoch 60/150\n",
|
|
"768/768 [==============================] - 0s 238us/step - loss: 0.5341 - acc: 0.7370\n",
|
|
"Epoch 61/150\n",
|
|
"768/768 [==============================] - 0s 241us/step - loss: 0.5265 - acc: 0.7370\n",
|
|
"Epoch 62/150\n",
|
|
"768/768 [==============================] - 0s 232us/step - loss: 0.5177 - acc: 0.7487\n",
|
|
"Epoch 63/150\n",
|
|
"768/768 [==============================] - 0s 220us/step - loss: 0.5449 - acc: 0.7357\n",
|
|
"Epoch 64/150\n",
|
|
"768/768 [==============================] - 0s 260us/step - loss: 0.5319 - acc: 0.7422\n",
|
|
"Epoch 65/150\n",
|
|
"768/768 [==============================] - 0s 246us/step - loss: 0.5236 - acc: 0.7422\n",
|
|
"Epoch 66/150\n",
|
|
"768/768 [==============================] - 0s 294us/step - loss: 0.5078 - acc: 0.7487\n",
|
|
"Epoch 67/150\n",
|
|
"768/768 [==============================] - 0s 253us/step - loss: 0.5167 - acc: 0.7448\n",
|
|
"Epoch 68/150\n",
|
|
"768/768 [==============================] - 0s 253us/step - loss: 0.5143 - acc: 0.7526\n",
|
|
"Epoch 69/150\n",
|
|
"768/768 [==============================] - 0s 286us/step - loss: 0.5138 - acc: 0.7500\n",
|
|
"Epoch 70/150\n",
|
|
"768/768 [==============================] - 0s 264us/step - loss: 0.5377 - acc: 0.7240\n",
|
|
"Epoch 71/150\n",
|
|
"768/768 [==============================] - 0s 280us/step - loss: 0.5180 - acc: 0.7409\n",
|
|
"Epoch 72/150\n",
|
|
"768/768 [==============================] - 0s 219us/step - loss: 0.5176 - acc: 0.7448\n",
|
|
"Epoch 73/150\n",
|
|
"768/768 [==============================] - 0s 245us/step - loss: 0.5164 - acc: 0.7461\n",
|
|
"Epoch 74/150\n",
|
|
"768/768 [==============================] - 0s 221us/step - loss: 0.5108 - acc: 0.7604\n",
|
|
"Epoch 75/150\n",
|
|
"768/768 [==============================] - 0s 238us/step - loss: 0.5095 - acc: 0.7617\n",
|
|
"Epoch 76/150\n",
|
|
"768/768 [==============================] - 0s 232us/step - loss: 0.5119 - acc: 0.7513\n",
|
|
"Epoch 77/150\n",
|
|
"768/768 [==============================] - 0s 296us/step - loss: 0.5169 - acc: 0.7617\n",
|
|
"Epoch 78/150\n",
|
|
"768/768 [==============================] - 0s 316us/step - loss: 0.5131 - acc: 0.7474\n",
|
|
"Epoch 79/150\n",
|
|
"768/768 [==============================] - 0s 223us/step - loss: 0.5138 - acc: 0.7461\n",
|
|
"Epoch 80/150\n",
|
|
"768/768 [==============================] - 0s 259us/step - loss: 0.5105 - acc: 0.7565\n",
|
|
"Epoch 81/150\n",
|
|
"768/768 [==============================] - 0s 275us/step - loss: 0.5056 - acc: 0.7695\n",
|
|
"Epoch 82/150\n",
|
|
"768/768 [==============================] - 0s 228us/step - loss: 0.5060 - acc: 0.7513\n",
|
|
"Epoch 83/150\n",
|
|
"768/768 [==============================] - 0s 238us/step - loss: 0.5030 - acc: 0.7591\n",
|
|
"Epoch 84/150\n",
|
|
"768/768 [==============================] - 0s 228us/step - loss: 0.4995 - acc: 0.7526\n",
|
|
"Epoch 85/150\n",
|
|
"768/768 [==============================] - 0s 230us/step - loss: 0.5063 - acc: 0.7461\n",
|
|
"Epoch 86/150\n",
|
|
"768/768 [==============================] - 0s 210us/step - loss: 0.5064 - acc: 0.7474\n",
|
|
"Epoch 87/150\n",
|
|
"768/768 [==============================] - 0s 221us/step - loss: 0.4992 - acc: 0.7526\n",
|
|
"Epoch 88/150\n",
|
|
"768/768 [==============================] - 0s 250us/step - loss: 0.5010 - acc: 0.7643\n",
|
|
"Epoch 89/150\n",
|
|
"768/768 [==============================] - 0s 216us/step - loss: 0.5045 - acc: 0.7682\n",
|
|
"Epoch 90/150\n",
|
|
"768/768 [==============================] - 0s 233us/step - loss: 0.5102 - acc: 0.7513\n",
|
|
"Epoch 91/150\n",
|
|
"768/768 [==============================] - 0s 246us/step - loss: 0.5022 - acc: 0.7526\n",
|
|
"Epoch 92/150\n",
|
|
"768/768 [==============================] - 0s 286us/step - loss: 0.5057 - acc: 0.7396\n",
|
|
"Epoch 93/150\n",
|
|
"768/768 [==============================] - 0s 227us/step - loss: 0.4981 - acc: 0.7656\n",
|
|
"Epoch 94/150\n",
|
|
"768/768 [==============================] - 0s 227us/step - loss: 0.4992 - acc: 0.7656\n",
|
|
"Epoch 95/150\n",
|
|
"768/768 [==============================] - 0s 258us/step - loss: 0.5040 - acc: 0.7500\n",
|
|
"Epoch 96/150\n",
|
|
"768/768 [==============================] - 0s 212us/step - loss: 0.4908 - acc: 0.7669\n",
|
|
"Epoch 97/150\n",
|
|
"768/768 [==============================] - 0s 245us/step - loss: 0.5004 - acc: 0.7747\n",
|
|
"Epoch 98/150\n",
|
|
"768/768 [==============================] - 0s 210us/step - loss: 0.4905 - acc: 0.7617\n",
|
|
"Epoch 99/150\n",
|
|
"768/768 [==============================] - 0s 260us/step - loss: 0.4914 - acc: 0.7630\n",
|
|
"Epoch 100/150\n",
|
|
"768/768 [==============================] - 0s 232us/step - loss: 0.4845 - acc: 0.7773\n",
|
|
"Epoch 101/150\n",
|
|
"768/768 [==============================] - 0s 217us/step - loss: 0.4897 - acc: 0.7773\n",
|
|
"Epoch 102/150\n",
|
|
"768/768 [==============================] - 0s 225us/step - loss: 0.4984 - acc: 0.7578\n",
|
|
"Epoch 103/150\n",
|
|
"768/768 [==============================] - 0s 246us/step - loss: 0.4987 - acc: 0.7539\n",
|
|
"Epoch 104/150\n",
|
|
"768/768 [==============================] - 0s 212us/step - loss: 0.4918 - acc: 0.7839\n",
|
|
"Epoch 105/150\n",
|
|
"768/768 [==============================] - 0s 238us/step - loss: 0.5303 - acc: 0.7422\n",
|
|
"Epoch 106/150\n",
|
|
"768/768 [==============================] - 0s 215us/step - loss: 0.4976 - acc: 0.7656\n",
|
|
"Epoch 107/150\n",
|
|
"768/768 [==============================] - 0s 233us/step - loss: 0.4922 - acc: 0.7708\n",
|
|
"Epoch 108/150\n",
|
|
"768/768 [==============================] - 0s 293us/step - loss: 0.4982 - acc: 0.7695\n",
|
|
"Epoch 109/150\n",
|
|
"768/768 [==============================] - 0s 268us/step - loss: 0.4874 - acc: 0.7695\n",
|
|
"Epoch 110/150\n",
|
|
"768/768 [==============================] - 0s 194us/step - loss: 0.4906 - acc: 0.7682\n",
|
|
"Epoch 111/150\n",
|
|
"768/768 [==============================] - 0s 228us/step - loss: 0.4833 - acc: 0.7812\n",
|
|
"Epoch 112/150\n",
|
|
"768/768 [==============================] - 0s 249us/step - loss: 0.4916 - acc: 0.7773\n",
|
|
"Epoch 113/150\n",
|
|
"768/768 [==============================] - 0s 309us/step - loss: 0.4938 - acc: 0.7630\n",
|
|
"Epoch 114/150\n",
|
|
"768/768 [==============================] - 0s 358us/step - loss: 0.4911 - acc: 0.7604\n",
|
|
"Epoch 115/150\n",
|
|
"768/768 [==============================] - 0s 410us/step - loss: 0.4905 - acc: 0.7760\n",
|
|
"Epoch 116/150\n",
|
|
"768/768 [==============================] - 0s 327us/step - loss: 0.4944 - acc: 0.7721\n",
|
|
"Epoch 117/150\n",
|
|
"768/768 [==============================] - 0s 445us/step - loss: 0.4917 - acc: 0.7604\n",
|
|
"Epoch 118/150\n",
|
|
"768/768 [==============================] - 0s 293us/step - loss: 0.4894 - acc: 0.7826\n",
|
|
"Epoch 119/150\n",
|
|
"768/768 [==============================] - 0s 203us/step - loss: 0.4829 - acc: 0.7695\n",
|
|
"Epoch 120/150\n",
|
|
"768/768 [==============================] - 0s 307us/step - loss: 0.4927 - acc: 0.7786\n",
|
|
"Epoch 121/150\n",
|
|
"768/768 [==============================] - 0s 367us/step - loss: 0.4924 - acc: 0.7721\n",
|
|
"Epoch 122/150\n",
|
|
"768/768 [==============================] - 0s 194us/step - loss: 0.4862 - acc: 0.7721\n",
|
|
"Epoch 123/150\n",
|
|
"768/768 [==============================] - 0s 182us/step - loss: 0.4838 - acc: 0.7656\n",
|
|
"Epoch 124/150\n",
|
|
"768/768 [==============================] - 0s 181us/step - loss: 0.4831 - acc: 0.7708\n",
|
|
"Epoch 125/150\n",
|
|
"768/768 [==============================] - 0s 184us/step - loss: 0.4874 - acc: 0.7852\n",
|
|
"Epoch 126/150\n",
|
|
"768/768 [==============================] - 0s 181us/step - loss: 0.4817 - acc: 0.7786\n",
|
|
"Epoch 127/150\n",
|
|
"768/768 [==============================] - 0s 177us/step - loss: 0.4903 - acc: 0.7682\n",
|
|
"Epoch 128/150\n",
|
|
"768/768 [==============================] - 0s 172us/step - loss: 0.4721 - acc: 0.7786\n",
|
|
"Epoch 129/150\n",
|
|
"768/768 [==============================] - 0s 176us/step - loss: 0.4813 - acc: 0.7721\n",
|
|
"Epoch 130/150\n",
|
|
"768/768 [==============================] - 0s 172us/step - loss: 0.4749 - acc: 0.7865\n",
|
|
"Epoch 131/150\n",
|
|
"768/768 [==============================] - 0s 172us/step - loss: 0.4815 - acc: 0.7773\n",
|
|
"Epoch 132/150\n",
|
|
"768/768 [==============================] - 0s 174us/step - loss: 0.4805 - acc: 0.7839\n",
|
|
"Epoch 133/150\n",
|
|
"768/768 [==============================] - 0s 171us/step - loss: 0.4839 - acc: 0.7721\n",
|
|
"Epoch 134/150\n",
|
|
"768/768 [==============================] - 0s 174us/step - loss: 0.4837 - acc: 0.7734\n",
|
|
"Epoch 135/150\n",
|
|
"768/768 [==============================] - 0s 177us/step - loss: 0.4780 - acc: 0.7773\n",
|
|
"Epoch 136/150\n",
|
|
"768/768 [==============================] - 0s 172us/step - loss: 0.4739 - acc: 0.7786\n",
|
|
"Epoch 137/150\n",
|
|
"768/768 [==============================] - 0s 173us/step - loss: 0.4673 - acc: 0.7786\n",
|
|
"Epoch 138/150\n",
|
|
"768/768 [==============================] - 0s 172us/step - loss: 0.4806 - acc: 0.7839\n",
|
|
"Epoch 139/150\n",
|
|
"768/768 [==============================] - 0s 177us/step - loss: 0.4656 - acc: 0.7917\n",
|
|
"Epoch 140/150\n",
|
|
"768/768 [==============================] - 0s 172us/step - loss: 0.4834 - acc: 0.7773\n",
|
|
"Epoch 141/150\n",
|
|
"768/768 [==============================] - 0s 172us/step - loss: 0.4743 - acc: 0.7839\n",
|
|
"Epoch 142/150\n",
|
|
"768/768 [==============================] - 0s 176us/step - loss: 0.4836 - acc: 0.7708\n",
|
|
"Epoch 143/150\n",
|
|
"768/768 [==============================] - 0s 310us/step - loss: 0.4769 - acc: 0.7734\n",
|
|
"Epoch 144/150\n",
|
|
"768/768 [==============================] - 0s 333us/step - loss: 0.4772 - acc: 0.7747\n",
|
|
"Epoch 145/150\n",
|
|
"768/768 [==============================] - 0s 245us/step - loss: 0.4890 - acc: 0.7643\n",
|
|
"Epoch 146/150\n",
|
|
"768/768 [==============================] - 0s 229us/step - loss: 0.4942 - acc: 0.7669\n",
|
|
"Epoch 147/150\n",
|
|
"768/768 [==============================] - 0s 194us/step - loss: 0.4846 - acc: 0.7773\n",
|
|
"Epoch 148/150\n",
|
|
"768/768 [==============================] - 0s 180us/step - loss: 0.4715 - acc: 0.7773\n",
|
|
"Epoch 149/150\n",
|
|
"768/768 [==============================] - 0s 181us/step - loss: 0.4752 - acc: 0.7695\n",
|
|
"Epoch 150/150\n",
|
|
"768/768 [==============================] - 0s 184us/step - loss: 0.4776 - acc: 0.7721\n"
|
|
]
|
|
},
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"<keras.callbacks.History at 0x2683b99f630>"
|
|
]
|
|
},
|
|
"execution_count": 9,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"# Fit the model\n",
|
|
"model.fit(X, Y, epochs=150, batch_size=10)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 10,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"768/768 [==============================] - 0s 94us/step\n",
|
|
"\n",
|
|
"acc: 79.82%\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# evaluate the model\n",
|
|
"scores = model.evaluate(X, Y)\n",
|
|
"print(\"\\n%s: %.2f%%\" % (model.metrics_names[1], scores[1]*100))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 12,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Epoch 1/150\n",
|
|
"768/768 [==============================] - 1s 2ms/step - loss: 3.7104 - acc: 0.5977\n",
|
|
"Epoch 2/150\n",
|
|
"768/768 [==============================] - 0s 411us/step - loss: 0.9374 - acc: 0.5938\n",
|
|
"Epoch 3/150\n",
|
|
"768/768 [==============================] - 0s 250us/step - loss: 0.7478 - acc: 0.6445\n",
|
|
"Epoch 4/150\n",
|
|
"768/768 [==============================] - 0s 421us/step - loss: 0.7120 - acc: 0.6549\n",
|
|
"Epoch 5/150\n",
|
|
"768/768 [==============================] - 0s 333us/step - loss: 0.6839 - acc: 0.6667\n",
|
|
"Epoch 6/150\n",
|
|
"768/768 [==============================] - 0s 201us/step - loss: 0.6520 - acc: 0.6771\n",
|
|
"Epoch 7/150\n",
|
|
"768/768 [==============================] - 0s 174us/step - loss: 0.6505 - acc: 0.6810\n",
|
|
"Epoch 8/150\n",
|
|
"768/768 [==============================] - 0s 188us/step - loss: 0.6392 - acc: 0.6862\n",
|
|
"Epoch 9/150\n",
|
|
"768/768 [==============================] - 0s 211us/step - loss: 0.6249 - acc: 0.6953\n",
|
|
"Epoch 10/150\n",
|
|
"768/768 [==============================] - 0s 172us/step - loss: 0.6308 - acc: 0.6784\n",
|
|
"Epoch 11/150\n",
|
|
"768/768 [==============================] - 0s 178us/step - loss: 0.6498 - acc: 0.6719\n",
|
|
"Epoch 12/150\n",
|
|
"768/768 [==============================] - 0s 174us/step - loss: 0.6399 - acc: 0.6758\n",
|
|
"Epoch 13/150\n",
|
|
"768/768 [==============================] - 0s 197us/step - loss: 0.6252 - acc: 0.6745\n",
|
|
"Epoch 14/150\n",
|
|
"768/768 [==============================] - 0s 185us/step - loss: 0.6177 - acc: 0.7005\n",
|
|
"Epoch 15/150\n",
|
|
"768/768 [==============================] - 0s 260us/step - loss: 0.6019 - acc: 0.6953\n",
|
|
"Epoch 16/150\n",
|
|
"768/768 [==============================] - 0s 180us/step - loss: 0.5883 - acc: 0.7005\n",
|
|
"Epoch 17/150\n",
|
|
"768/768 [==============================] - 0s 171us/step - loss: 0.5838 - acc: 0.6992\n",
|
|
"Epoch 18/150\n",
|
|
"768/768 [==============================] - 0s 182us/step - loss: 0.6003 - acc: 0.6875\n",
|
|
"Epoch 19/150\n",
|
|
"768/768 [==============================] - 0s 313us/step - loss: 0.5797 - acc: 0.7135\n",
|
|
"Epoch 20/150\n",
|
|
"768/768 [==============================] - 0s 305us/step - loss: 0.5794 - acc: 0.7227\n",
|
|
"Epoch 21/150\n",
|
|
"768/768 [==============================] - 0s 264us/step - loss: 0.5690 - acc: 0.7148\n",
|
|
"Epoch 22/150\n",
|
|
"768/768 [==============================] - 0s 177us/step - loss: 0.5812 - acc: 0.7005\n",
|
|
"Epoch 23/150\n",
|
|
"768/768 [==============================] - 0s 171us/step - loss: 0.5739 - acc: 0.7135\n",
|
|
"Epoch 24/150\n",
|
|
"768/768 [==============================] - 0s 172us/step - loss: 0.5681 - acc: 0.7331\n",
|
|
"Epoch 25/150\n",
|
|
"768/768 [==============================] - 0s 173us/step - loss: 0.5573 - acc: 0.7357\n",
|
|
"Epoch 26/150\n",
|
|
"768/768 [==============================] - 0s 172us/step - loss: 0.5707 - acc: 0.7018\n",
|
|
"Epoch 27/150\n",
|
|
"768/768 [==============================] - 0s 171us/step - loss: 0.5557 - acc: 0.7253\n",
|
|
"Epoch 28/150\n",
|
|
"768/768 [==============================] - 0s 173us/step - loss: 0.5553 - acc: 0.7318\n",
|
|
"Epoch 29/150\n",
|
|
"768/768 [==============================] - 0s 188us/step - loss: 0.5738 - acc: 0.7201\n",
|
|
"Epoch 30/150\n",
|
|
"768/768 [==============================] - 0s 172us/step - loss: 0.5611 - acc: 0.7227\n",
|
|
"Epoch 31/150\n",
|
|
"768/768 [==============================] - 0s 172us/step - loss: 0.5681 - acc: 0.7174\n",
|
|
"Epoch 32/150\n",
|
|
"768/768 [==============================] - 0s 177us/step - loss: 0.5637 - acc: 0.7161\n",
|
|
"Epoch 33/150\n",
|
|
"768/768 [==============================] - 0s 174us/step - loss: 0.5515 - acc: 0.7214\n",
|
|
"Epoch 34/150\n",
|
|
"768/768 [==============================] - 0s 173us/step - loss: 0.5510 - acc: 0.7331\n",
|
|
"Epoch 35/150\n",
|
|
"768/768 [==============================] - 0s 178us/step - loss: 0.5508 - acc: 0.7240\n",
|
|
"Epoch 36/150\n",
|
|
"768/768 [==============================] - 0s 335us/step - loss: 0.5597 - acc: 0.7057\n",
|
|
"Epoch 37/150\n",
|
|
"768/768 [==============================] - 0s 220us/step - loss: 0.5371 - acc: 0.7331\n",
|
|
"Epoch 38/150\n",
|
|
"768/768 [==============================] - 0s 177us/step - loss: 0.5406 - acc: 0.7227\n",
|
|
"Epoch 39/150\n",
|
|
"768/768 [==============================] - 0s 171us/step - loss: 0.5447 - acc: 0.7214\n",
|
|
"Epoch 40/150\n",
|
|
"768/768 [==============================] - 0s 174us/step - loss: 0.5439 - acc: 0.7240\n",
|
|
"Epoch 41/150\n",
|
|
"768/768 [==============================] - 0s 290us/step - loss: 0.5435 - acc: 0.7357\n",
|
|
"Epoch 42/150\n",
|
|
"768/768 [==============================] - 0s 223us/step - loss: 0.5363 - acc: 0.7370\n",
|
|
"Epoch 43/150\n",
|
|
"768/768 [==============================] - 0s 210us/step - loss: 0.5320 - acc: 0.7513\n",
|
|
"Epoch 44/150\n",
|
|
"768/768 [==============================] - 0s 174us/step - loss: 0.5325 - acc: 0.7396\n",
|
|
"Epoch 45/150\n",
|
|
"768/768 [==============================] - 0s 174us/step - loss: 0.5308 - acc: 0.7539\n",
|
|
"Epoch 46/150\n",
|
|
"768/768 [==============================] - 0s 210us/step - loss: 0.5292 - acc: 0.7500\n",
|
|
"Epoch 47/150\n",
|
|
"768/768 [==============================] - 0s 197us/step - loss: 0.5329 - acc: 0.7357\n",
|
|
"Epoch 48/150\n",
|
|
"768/768 [==============================] - 0s 220us/step - loss: 0.5326 - acc: 0.7448\n",
|
|
"Epoch 49/150\n",
|
|
"768/768 [==============================] - 0s 276us/step - loss: 0.5327 - acc: 0.7500\n",
|
|
"Epoch 50/150\n",
|
|
"768/768 [==============================] - 0s 182us/step - loss: 0.5270 - acc: 0.7396\n",
|
|
"Epoch 51/150\n",
|
|
"768/768 [==============================] - 0s 276us/step - loss: 0.5271 - acc: 0.7500\n",
|
|
"Epoch 52/150\n",
|
|
"768/768 [==============================] - 0s 346us/step - loss: 0.5286 - acc: 0.7448\n",
|
|
"Epoch 53/150\n",
|
|
"768/768 [==============================] - 0s 240us/step - loss: 0.5378 - acc: 0.7435\n",
|
|
"Epoch 54/150\n",
|
|
"768/768 [==============================] - 0s 174us/step - loss: 0.5365 - acc: 0.7318\n",
|
|
"Epoch 55/150\n",
|
|
"768/768 [==============================] - 0s 172us/step - loss: 0.5221 - acc: 0.7500\n",
|
|
"Epoch 56/150\n",
|
|
"768/768 [==============================] - 0s 172us/step - loss: 0.5292 - acc: 0.7409\n",
|
|
"Epoch 57/150\n",
|
|
"768/768 [==============================] - 0s 309us/step - loss: 0.5305 - acc: 0.7370\n",
|
|
"Epoch 58/150\n",
|
|
"768/768 [==============================] - 0s 331us/step - loss: 0.5231 - acc: 0.7513\n",
|
|
"Epoch 59/150\n",
|
|
"768/768 [==============================] - 0s 302us/step - loss: 0.5121 - acc: 0.7630\n",
|
|
"Epoch 60/150\n",
|
|
"768/768 [==============================] - 0s 357us/step - loss: 0.5331 - acc: 0.7331\n",
|
|
"Epoch 61/150\n",
|
|
"768/768 [==============================] - 0s 448us/step - loss: 0.5277 - acc: 0.7383\n",
|
|
"Epoch 62/150\n",
|
|
"768/768 [==============================] - 0s 290us/step - loss: 0.5173 - acc: 0.7565\n",
|
|
"Epoch 63/150\n",
|
|
"768/768 [==============================] - 0s 258us/step - loss: 0.5453 - acc: 0.7331\n",
|
|
"Epoch 64/150\n",
|
|
"768/768 [==============================] - 0s 241us/step - loss: 0.5307 - acc: 0.7448\n",
|
|
"Epoch 65/150\n",
|
|
"768/768 [==============================] - 0s 228us/step - loss: 0.5197 - acc: 0.7474\n",
|
|
"Epoch 66/150\n",
|
|
"768/768 [==============================] - 0s 257us/step - loss: 0.5057 - acc: 0.7500\n",
|
|
"Epoch 67/150\n",
|
|
"768/768 [==============================] - 0s 247us/step - loss: 0.5159 - acc: 0.7422\n",
|
|
"Epoch 68/150\n",
|
|
"768/768 [==============================] - 0s 212us/step - loss: 0.5139 - acc: 0.7565\n",
|
|
"Epoch 69/150\n",
|
|
"768/768 [==============================] - 0s 257us/step - loss: 0.5119 - acc: 0.7513\n",
|
|
"Epoch 70/150\n",
|
|
"768/768 [==============================] - 0s 266us/step - loss: 0.5364 - acc: 0.7188\n",
|
|
"Epoch 71/150\n",
|
|
"768/768 [==============================] - 0s 233us/step - loss: 0.5171 - acc: 0.7396\n",
|
|
"Epoch 72/150\n",
|
|
"768/768 [==============================] - 0s 241us/step - loss: 0.5171 - acc: 0.7513\n",
|
|
"Epoch 73/150\n",
|
|
"768/768 [==============================] - 0s 246us/step - loss: 0.5161 - acc: 0.7500\n",
|
|
"Epoch 74/150\n",
|
|
"768/768 [==============================] - 0s 224us/step - loss: 0.5096 - acc: 0.7604\n",
|
|
"Epoch 75/150\n",
|
|
"768/768 [==============================] - 0s 259us/step - loss: 0.5089 - acc: 0.7578\n",
|
|
"Epoch 76/150\n",
|
|
"768/768 [==============================] - 0s 228us/step - loss: 0.5100 - acc: 0.7526\n",
|
|
"Epoch 77/150\n",
|
|
"768/768 [==============================] - 0s 238us/step - loss: 0.5152 - acc: 0.7604\n",
|
|
"Epoch 78/150\n",
|
|
"768/768 [==============================] - 0s 297us/step - loss: 0.5117 - acc: 0.7500\n",
|
|
"Epoch 79/150\n",
|
|
"768/768 [==============================] - 0s 267us/step - loss: 0.5129 - acc: 0.7448\n",
|
|
"Epoch 80/150\n",
|
|
"768/768 [==============================] - 0s 225us/step - loss: 0.5107 - acc: 0.7578\n",
|
|
"Epoch 81/150\n",
|
|
"768/768 [==============================] - 0s 266us/step - loss: 0.5062 - acc: 0.7669\n",
|
|
"Epoch 82/150\n",
|
|
"768/768 [==============================] - 0s 270us/step - loss: 0.5038 - acc: 0.7539\n",
|
|
"Epoch 83/150\n",
|
|
"768/768 [==============================] - 0s 241us/step - loss: 0.4990 - acc: 0.7591\n",
|
|
"Epoch 84/150\n",
|
|
"768/768 [==============================] - 0s 258us/step - loss: 0.4976 - acc: 0.7591\n",
|
|
"Epoch 85/150\n",
|
|
"768/768 [==============================] - 0s 237us/step - loss: 0.5046 - acc: 0.7487\n",
|
|
"Epoch 86/150\n",
|
|
"768/768 [==============================] - 0s 228us/step - loss: 0.5052 - acc: 0.7487\n",
|
|
"Epoch 87/150\n",
|
|
"768/768 [==============================] - 0s 232us/step - loss: 0.4980 - acc: 0.7565\n",
|
|
"Epoch 88/150\n",
|
|
"768/768 [==============================] - 0s 309us/step - loss: 0.5011 - acc: 0.7604\n",
|
|
"Epoch 89/150\n",
|
|
"768/768 [==============================] - 0s 281us/step - loss: 0.5046 - acc: 0.7734\n",
|
|
"Epoch 90/150\n",
|
|
"768/768 [==============================] - 0s 220us/step - loss: 0.5077 - acc: 0.7552\n",
|
|
"Epoch 91/150\n",
|
|
"768/768 [==============================] - 0s 236us/step - loss: 0.5025 - acc: 0.7565\n",
|
|
"Epoch 92/150\n",
|
|
"768/768 [==============================] - 0s 227us/step - loss: 0.5046 - acc: 0.7448\n",
|
|
"Epoch 93/150\n",
|
|
"768/768 [==============================] - 0s 238us/step - loss: 0.4970 - acc: 0.7721\n",
|
|
"Epoch 94/150\n",
|
|
"768/768 [==============================] - 0s 230us/step - loss: 0.4990 - acc: 0.7656\n",
|
|
"Epoch 95/150\n",
|
|
"768/768 [==============================] - 0s 251us/step - loss: 0.5025 - acc: 0.7500\n",
|
|
"Epoch 96/150\n",
|
|
"768/768 [==============================] - 0s 236us/step - loss: 0.4905 - acc: 0.7695\n",
|
|
"Epoch 97/150\n",
|
|
"768/768 [==============================] - 0s 233us/step - loss: 0.4975 - acc: 0.7747\n",
|
|
"Epoch 98/150\n",
|
|
"768/768 [==============================] - 0s 260us/step - loss: 0.4887 - acc: 0.7656\n",
|
|
"Epoch 99/150\n",
|
|
"768/768 [==============================] - 0s 234us/step - loss: 0.4900 - acc: 0.7721\n",
|
|
"Epoch 100/150\n",
|
|
"768/768 [==============================] - 0s 216us/step - loss: 0.4846 - acc: 0.7760\n",
|
|
"Epoch 101/150\n",
|
|
"768/768 [==============================] - 0s 201us/step - loss: 0.4900 - acc: 0.7773\n",
|
|
"Epoch 102/150\n",
|
|
"768/768 [==============================] - 0s 221us/step - loss: 0.4988 - acc: 0.7552\n",
|
|
"Epoch 103/150\n",
|
|
"768/768 [==============================] - 0s 232us/step - loss: 0.4997 - acc: 0.7565\n",
|
|
"Epoch 104/150\n",
|
|
"768/768 [==============================] - 0s 246us/step - loss: 0.4911 - acc: 0.7865\n",
|
|
"Epoch 105/150\n",
|
|
"768/768 [==============================] - 0s 249us/step - loss: 0.5291 - acc: 0.7487\n",
|
|
"Epoch 106/150\n",
|
|
"768/768 [==============================] - 0s 233us/step - loss: 0.4943 - acc: 0.7747\n",
|
|
"Epoch 107/150\n",
|
|
"768/768 [==============================] - 0s 206us/step - loss: 0.4912 - acc: 0.7721\n",
|
|
"Epoch 108/150\n",
|
|
"768/768 [==============================] - 0s 225us/step - loss: 0.5003 - acc: 0.7630\n",
|
|
"Epoch 109/150\n",
|
|
"768/768 [==============================] - 0s 305us/step - loss: 0.4852 - acc: 0.7669\n",
|
|
"Epoch 110/150\n",
|
|
"768/768 [==============================] - 0s 193us/step - loss: 0.4900 - acc: 0.7656\n",
|
|
"Epoch 111/150\n",
|
|
"768/768 [==============================] - 0s 250us/step - loss: 0.4838 - acc: 0.7786\n",
|
|
"Epoch 112/150\n",
|
|
"768/768 [==============================] - 0s 241us/step - loss: 0.4958 - acc: 0.7708\n",
|
|
"Epoch 113/150\n",
|
|
"768/768 [==============================] - 0s 240us/step - loss: 0.4955 - acc: 0.7604\n",
|
|
"Epoch 114/150\n",
|
|
"768/768 [==============================] - 0s 227us/step - loss: 0.4927 - acc: 0.7604\n",
|
|
"Epoch 115/150\n",
|
|
"768/768 [==============================] - 0s 199us/step - loss: 0.4912 - acc: 0.7695\n",
|
|
"Epoch 116/150\n",
|
|
"768/768 [==============================] - 0s 207us/step - loss: 0.4928 - acc: 0.7721\n",
|
|
"Epoch 117/150\n",
|
|
"768/768 [==============================] - 0s 199us/step - loss: 0.4901 - acc: 0.7604\n",
|
|
"Epoch 118/150\n",
|
|
"768/768 [==============================] - 0s 186us/step - loss: 0.4889 - acc: 0.7786\n",
|
|
"Epoch 119/150\n",
|
|
"768/768 [==============================] - 0s 223us/step - loss: 0.4811 - acc: 0.7630\n",
|
|
"Epoch 120/150\n",
|
|
"768/768 [==============================] - 0s 225us/step - loss: 0.4934 - acc: 0.7721\n",
|
|
"Epoch 121/150\n",
|
|
"768/768 [==============================] - 0s 185us/step - loss: 0.4924 - acc: 0.7734\n",
|
|
"Epoch 122/150\n",
|
|
"768/768 [==============================] - 0s 216us/step - loss: 0.4843 - acc: 0.7826\n",
|
|
"Epoch 123/150\n",
|
|
"768/768 [==============================] - 0s 198us/step - loss: 0.4804 - acc: 0.7682\n",
|
|
"Epoch 124/150\n",
|
|
"768/768 [==============================] - 0s 211us/step - loss: 0.4831 - acc: 0.7760\n",
|
|
"Epoch 125/150\n",
|
|
"768/768 [==============================] - 0s 199us/step - loss: 0.4878 - acc: 0.7812\n",
|
|
"Epoch 126/150\n",
|
|
"768/768 [==============================] - 0s 227us/step - loss: 0.4795 - acc: 0.7826\n",
|
|
"Epoch 127/150\n",
|
|
"768/768 [==============================] - 0s 199us/step - loss: 0.4900 - acc: 0.7682\n",
|
|
"Epoch 128/150\n",
|
|
"768/768 [==============================] - 0s 211us/step - loss: 0.4723 - acc: 0.7721\n",
|
|
"Epoch 129/150\n",
|
|
"768/768 [==============================] - 0s 207us/step - loss: 0.4819 - acc: 0.7695\n",
|
|
"Epoch 130/150\n",
|
|
"768/768 [==============================] - 0s 219us/step - loss: 0.4749 - acc: 0.7878\n",
|
|
"Epoch 131/150\n",
|
|
"768/768 [==============================] - 0s 227us/step - loss: 0.4827 - acc: 0.7656\n",
|
|
"Epoch 132/150\n",
|
|
"768/768 [==============================] - 0s 228us/step - loss: 0.4809 - acc: 0.7839\n",
|
|
"Epoch 133/150\n",
|
|
"768/768 [==============================] - 0s 216us/step - loss: 0.4828 - acc: 0.7708\n",
|
|
"Epoch 134/150\n",
|
|
"768/768 [==============================] - 0s 210us/step - loss: 0.4847 - acc: 0.7747\n",
|
|
"Epoch 135/150\n",
|
|
"768/768 [==============================] - 0s 219us/step - loss: 0.4776 - acc: 0.7747\n",
|
|
"Epoch 136/150\n",
|
|
"768/768 [==============================] - 0s 201us/step - loss: 0.4738 - acc: 0.7786\n",
|
|
"Epoch 137/150\n",
|
|
"768/768 [==============================] - 0s 215us/step - loss: 0.4691 - acc: 0.7773\n",
|
|
"Epoch 138/150\n",
|
|
"768/768 [==============================] - 0s 214us/step - loss: 0.4804 - acc: 0.7812\n",
|
|
"Epoch 139/150\n",
|
|
"768/768 [==============================] - 0s 228us/step - loss: 0.4651 - acc: 0.7930\n",
|
|
"Epoch 140/150\n",
|
|
"768/768 [==============================] - 0s 199us/step - loss: 0.4825 - acc: 0.7826\n",
|
|
"Epoch 141/150\n",
|
|
"768/768 [==============================] - 0s 214us/step - loss: 0.4743 - acc: 0.7799\n",
|
|
"Epoch 142/150\n",
|
|
"768/768 [==============================] - 0s 249us/step - loss: 0.4843 - acc: 0.7721\n",
|
|
"Epoch 143/150\n",
|
|
"768/768 [==============================] - 0s 193us/step - loss: 0.4758 - acc: 0.7734\n",
|
|
"Epoch 144/150\n",
|
|
"768/768 [==============================] - 0s 214us/step - loss: 0.4767 - acc: 0.7734\n",
|
|
"Epoch 145/150\n",
|
|
"768/768 [==============================] - 0s 220us/step - loss: 0.4900 - acc: 0.7630\n",
|
|
"Epoch 146/150\n",
|
|
"768/768 [==============================] - 0s 216us/step - loss: 0.4935 - acc: 0.7669\n",
|
|
"Epoch 147/150\n",
|
|
"768/768 [==============================] - 0s 221us/step - loss: 0.4839 - acc: 0.7747\n",
|
|
"Epoch 148/150\n",
|
|
"768/768 [==============================] - 0s 220us/step - loss: 0.4724 - acc: 0.7695\n",
|
|
"Epoch 149/150\n",
|
|
"768/768 [==============================] - 0s 221us/step - loss: 0.4742 - acc: 0.7682\n",
|
|
"Epoch 150/150\n",
|
|
"768/768 [==============================] - 0s 233us/step - loss: 0.4776 - acc: 0.7695\n",
|
|
"768/768 [==============================] - 0s 134us/step\n",
|
|
"\n",
|
|
"acc: 79.43%\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"#all in one cell \n",
|
|
"# Create your first MLP in Keras\n",
|
|
"from keras.models import Sequential\n",
|
|
"from keras.layers import Dense\n",
|
|
"import numpy\n",
|
|
"# fix random seed for reproducibility\n",
|
|
"numpy.random.seed(7)\n",
|
|
"# load pima indians dataset\n",
|
|
"dataset = numpy.loadtxt(\"pima-indians-diabetes.data\", delimiter=\",\")\n",
|
|
"# split into input (X) and output (Y) variables\n",
|
|
"X = dataset[:,0:8]\n",
|
|
"Y = dataset[:,8]\n",
|
|
"# create model\n",
|
|
"model = Sequential()\n",
|
|
"model.add(Dense(12, input_dim=8, activation='relu'))\n",
|
|
"model.add(Dense(8, activation='relu'))\n",
|
|
"model.add(Dense(1, activation='sigmoid'))\n",
|
|
"# Compile model\n",
|
|
"model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])\n",
|
|
"# Fit the model\n",
|
|
"model.fit(X, Y, epochs=150, batch_size=10)\n",
|
|
"# evaluate the model\n",
|
|
"scores = model.evaluate(X, Y)\n",
|
|
"print(\"\\n%s: %.2f%%\" % (model.metrics_names[1], scores[1]*100))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 16,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Epoch 1/150\n",
|
|
" - 1s - loss: 0.6771 - acc: 0.6510\n",
|
|
"Epoch 2/150\n",
|
|
" - 0s - loss: 0.6586 - acc: 0.6510\n",
|
|
"Epoch 3/150\n",
|
|
" - 0s - loss: 0.6470 - acc: 0.6510\n",
|
|
"Epoch 4/150\n",
|
|
" - 0s - loss: 0.6393 - acc: 0.6510\n",
|
|
"Epoch 5/150\n",
|
|
" - 0s - loss: 0.6320 - acc: 0.6510\n",
|
|
"Epoch 6/150\n",
|
|
" - 0s - loss: 0.6188 - acc: 0.6510\n",
|
|
"Epoch 7/150\n",
|
|
" - 0s - loss: 0.6194 - acc: 0.6510\n",
|
|
"Epoch 8/150\n",
|
|
" - 0s - loss: 0.6135 - acc: 0.6510\n",
|
|
"Epoch 9/150\n",
|
|
" - 0s - loss: 0.6087 - acc: 0.6510\n",
|
|
"Epoch 10/150\n",
|
|
" - 0s - loss: 0.6164 - acc: 0.6510\n",
|
|
"Epoch 11/150\n",
|
|
" - 0s - loss: 0.6052 - acc: 0.6510\n",
|
|
"Epoch 12/150\n",
|
|
" - 0s - loss: 0.6034 - acc: 0.6510\n",
|
|
"Epoch 13/150\n",
|
|
" - 0s - loss: 0.6004 - acc: 0.6510\n",
|
|
"Epoch 14/150\n",
|
|
" - 0s - loss: 0.6033 - acc: 0.6510\n",
|
|
"Epoch 15/150\n",
|
|
" - 0s - loss: 0.5989 - acc: 0.6510\n",
|
|
"Epoch 16/150\n",
|
|
" - 0s - loss: 0.6000 - acc: 0.6510\n",
|
|
"Epoch 17/150\n",
|
|
" - 0s - loss: 0.5995 - acc: 0.6510\n",
|
|
"Epoch 18/150\n",
|
|
" - 0s - loss: 0.6007 - acc: 0.6510\n",
|
|
"Epoch 19/150\n",
|
|
" - 0s - loss: 0.5972 - acc: 0.6510\n",
|
|
"Epoch 20/150\n",
|
|
" - 0s - loss: 0.5982 - acc: 0.6510\n",
|
|
"Epoch 21/150\n",
|
|
" - 0s - loss: 0.5950 - acc: 0.6510\n",
|
|
"Epoch 22/150\n",
|
|
" - 0s - loss: 0.5936 - acc: 0.6510\n",
|
|
"Epoch 23/150\n",
|
|
" - 0s - loss: 0.5930 - acc: 0.6510\n",
|
|
"Epoch 24/150\n",
|
|
" - 0s - loss: 0.5989 - acc: 0.6510\n",
|
|
"Epoch 25/150\n",
|
|
" - 0s - loss: 0.5956 - acc: 0.6510\n",
|
|
"Epoch 26/150\n",
|
|
" - 0s - loss: 0.6006 - acc: 0.6510\n",
|
|
"Epoch 27/150\n",
|
|
" - 0s - loss: 0.5949 - acc: 0.6510\n",
|
|
"Epoch 28/150\n",
|
|
" - 0s - loss: 0.5905 - acc: 0.6510\n",
|
|
"Epoch 29/150\n",
|
|
" - 0s - loss: 0.5927 - acc: 0.6510\n",
|
|
"Epoch 30/150\n",
|
|
" - 0s - loss: 0.5909 - acc: 0.6510\n",
|
|
"Epoch 31/150\n",
|
|
" - 0s - loss: 0.5900 - acc: 0.6510\n",
|
|
"Epoch 32/150\n",
|
|
" - 0s - loss: 0.5903 - acc: 0.6510\n",
|
|
"Epoch 33/150\n",
|
|
" - 0s - loss: 0.5844 - acc: 0.6510\n",
|
|
"Epoch 34/150\n",
|
|
" - 0s - loss: 0.5894 - acc: 0.6510\n",
|
|
"Epoch 35/150\n",
|
|
" - 0s - loss: 0.5916 - acc: 0.6510\n",
|
|
"Epoch 36/150\n",
|
|
" - 0s - loss: 0.5834 - acc: 0.6510\n",
|
|
"Epoch 37/150\n",
|
|
" - 0s - loss: 0.5824 - acc: 0.6510\n",
|
|
"Epoch 38/150\n",
|
|
" - 0s - loss: 0.5923 - acc: 0.6510\n",
|
|
"Epoch 39/150\n",
|
|
" - 0s - loss: 0.5833 - acc: 0.6471\n",
|
|
"Epoch 40/150\n",
|
|
" - 0s - loss: 0.5869 - acc: 0.6693\n",
|
|
"Epoch 41/150\n",
|
|
" - 0s - loss: 0.5820 - acc: 0.6953\n",
|
|
"Epoch 42/150\n",
|
|
" - 0s - loss: 0.5807 - acc: 0.7070\n",
|
|
"Epoch 43/150\n",
|
|
" - 0s - loss: 0.5787 - acc: 0.7122\n",
|
|
"Epoch 44/150\n",
|
|
" - 0s - loss: 0.5865 - acc: 0.7031\n",
|
|
"Epoch 45/150\n",
|
|
" - 0s - loss: 0.5788 - acc: 0.7096\n",
|
|
"Epoch 46/150\n",
|
|
" - 0s - loss: 0.5774 - acc: 0.7018\n",
|
|
"Epoch 47/150\n",
|
|
" - 0s - loss: 0.5782 - acc: 0.7148\n",
|
|
"Epoch 48/150\n",
|
|
" - 0s - loss: 0.5752 - acc: 0.7070\n",
|
|
"Epoch 49/150\n",
|
|
" - 0s - loss: 0.5744 - acc: 0.7122\n",
|
|
"Epoch 50/150\n",
|
|
" - 0s - loss: 0.5740 - acc: 0.7174\n",
|
|
"Epoch 51/150\n",
|
|
" - 0s - loss: 0.5731 - acc: 0.7174\n",
|
|
"Epoch 52/150\n",
|
|
" - 0s - loss: 0.5706 - acc: 0.7135\n",
|
|
"Epoch 53/150\n",
|
|
" - 0s - loss: 0.5729 - acc: 0.7122\n",
|
|
"Epoch 54/150\n",
|
|
" - 0s - loss: 0.5707 - acc: 0.7096\n",
|
|
"Epoch 55/150\n",
|
|
" - 0s - loss: 0.5728 - acc: 0.7057\n",
|
|
"Epoch 56/150\n",
|
|
" - 0s - loss: 0.5710 - acc: 0.7109\n",
|
|
"Epoch 57/150\n",
|
|
" - 0s - loss: 0.5678 - acc: 0.7083\n",
|
|
"Epoch 58/150\n",
|
|
" - 0s - loss: 0.5725 - acc: 0.7096\n",
|
|
"Epoch 59/150\n",
|
|
" - 0s - loss: 0.5668 - acc: 0.7044\n",
|
|
"Epoch 60/150\n",
|
|
" - 0s - loss: 0.5690 - acc: 0.7057\n",
|
|
"Epoch 61/150\n",
|
|
" - 0s - loss: 0.5662 - acc: 0.7083\n",
|
|
"Epoch 62/150\n",
|
|
" - 0s - loss: 0.5680 - acc: 0.7201\n",
|
|
"Epoch 63/150\n",
|
|
" - 0s - loss: 0.5712 - acc: 0.7096\n",
|
|
"Epoch 64/150\n",
|
|
" - 0s - loss: 0.5658 - acc: 0.7174\n",
|
|
"Epoch 65/150\n",
|
|
" - 0s - loss: 0.5630 - acc: 0.7109\n",
|
|
"Epoch 66/150\n",
|
|
" - 0s - loss: 0.5588 - acc: 0.7135\n",
|
|
"Epoch 67/150\n",
|
|
" - 0s - loss: 0.5586 - acc: 0.7135\n",
|
|
"Epoch 68/150\n",
|
|
" - 0s - loss: 0.5603 - acc: 0.7083\n",
|
|
"Epoch 69/150\n",
|
|
" - 0s - loss: 0.5559 - acc: 0.7279\n",
|
|
"Epoch 70/150\n",
|
|
" - 0s - loss: 0.5609 - acc: 0.7109\n",
|
|
"Epoch 71/150\n",
|
|
" - 0s - loss: 0.5571 - acc: 0.7044\n",
|
|
"Epoch 72/150\n",
|
|
" - 0s - loss: 0.5556 - acc: 0.7096\n",
|
|
"Epoch 73/150\n",
|
|
" - 0s - loss: 0.5501 - acc: 0.7148\n",
|
|
"Epoch 74/150\n",
|
|
" - 0s - loss: 0.5577 - acc: 0.6992\n",
|
|
"Epoch 75/150\n",
|
|
" - 0s - loss: 0.5540 - acc: 0.7201\n",
|
|
"Epoch 76/150\n",
|
|
" - 0s - loss: 0.5508 - acc: 0.7227\n",
|
|
"Epoch 77/150\n",
|
|
" - 0s - loss: 0.5504 - acc: 0.7253\n",
|
|
"Epoch 78/150\n",
|
|
" - 0s - loss: 0.5465 - acc: 0.7292\n",
|
|
"Epoch 79/150\n",
|
|
" - 0s - loss: 0.5498 - acc: 0.7174\n",
|
|
"Epoch 80/150\n",
|
|
" - 0s - loss: 0.5448 - acc: 0.7266\n",
|
|
"Epoch 81/150\n",
|
|
" - 0s - loss: 0.5427 - acc: 0.7305\n",
|
|
"Epoch 82/150\n",
|
|
" - 0s - loss: 0.5529 - acc: 0.7174\n",
|
|
"Epoch 83/150\n",
|
|
" - 0s - loss: 0.5524 - acc: 0.7109\n",
|
|
"Epoch 84/150\n",
|
|
" - 0s - loss: 0.5451 - acc: 0.7187\n",
|
|
"Epoch 85/150\n",
|
|
" - 0s - loss: 0.5465 - acc: 0.7201\n",
|
|
"Epoch 86/150\n",
|
|
" - 0s - loss: 0.5498 - acc: 0.7266\n",
|
|
"Epoch 87/150\n",
|
|
" - 0s - loss: 0.5405 - acc: 0.7253\n",
|
|
"Epoch 88/150\n",
|
|
" - 0s - loss: 0.5399 - acc: 0.7201\n",
|
|
"Epoch 89/150\n",
|
|
" - 0s - loss: 0.5583 - acc: 0.7318\n",
|
|
"Epoch 90/150\n",
|
|
" - 0s - loss: 0.5416 - acc: 0.7253\n",
|
|
"Epoch 91/150\n",
|
|
" - 0s - loss: 0.5391 - acc: 0.7266\n",
|
|
"Epoch 92/150\n",
|
|
" - 0s - loss: 0.5405 - acc: 0.7266\n",
|
|
"Epoch 93/150\n",
|
|
" - 0s - loss: 0.5402 - acc: 0.7174\n",
|
|
"Epoch 94/150\n",
|
|
" - 0s - loss: 0.5392 - acc: 0.7357\n",
|
|
"Epoch 95/150\n",
|
|
" - 0s - loss: 0.5359 - acc: 0.7214\n",
|
|
"Epoch 96/150\n",
|
|
" - 0s - loss: 0.5413 - acc: 0.7357\n",
|
|
"Epoch 97/150\n",
|
|
" - 0s - loss: 0.5401 - acc: 0.7266\n",
|
|
"Epoch 98/150\n",
|
|
" - 0s - loss: 0.5332 - acc: 0.7305\n",
|
|
"Epoch 99/150\n",
|
|
" - 0s - loss: 0.5274 - acc: 0.7409\n",
|
|
"Epoch 100/150\n",
|
|
" - 0s - loss: 0.5339 - acc: 0.7279\n",
|
|
"Epoch 101/150\n",
|
|
" - 0s - loss: 0.5313 - acc: 0.7279\n",
|
|
"Epoch 102/150\n",
|
|
" - 0s - loss: 0.5323 - acc: 0.7409\n",
|
|
"Epoch 103/150\n",
|
|
" - 0s - loss: 0.5404 - acc: 0.7227\n",
|
|
"Epoch 104/150\n",
|
|
" - 0s - loss: 0.5351 - acc: 0.7344\n",
|
|
"Epoch 105/150\n",
|
|
" - 0s - loss: 0.5287 - acc: 0.7318\n",
|
|
"Epoch 106/150\n",
|
|
" - 0s - loss: 0.5291 - acc: 0.7305\n",
|
|
"Epoch 107/150\n",
|
|
" - 0s - loss: 0.5335 - acc: 0.7409\n",
|
|
"Epoch 108/150\n",
|
|
" - 0s - loss: 0.5314 - acc: 0.7331\n",
|
|
"Epoch 109/150\n",
|
|
" - 0s - loss: 0.5269 - acc: 0.7383\n",
|
|
"Epoch 110/150\n",
|
|
" - 0s - loss: 0.5249 - acc: 0.7422\n",
|
|
"Epoch 111/150\n",
|
|
" - 0s - loss: 0.5323 - acc: 0.7383\n",
|
|
"Epoch 112/150\n",
|
|
" - 0s - loss: 0.5241 - acc: 0.7396\n",
|
|
"Epoch 113/150\n",
|
|
" - 0s - loss: 0.5236 - acc: 0.7409\n",
|
|
"Epoch 114/150\n",
|
|
" - 0s - loss: 0.5257 - acc: 0.7435\n",
|
|
"Epoch 115/150\n",
|
|
" - 0s - loss: 0.5204 - acc: 0.7435\n",
|
|
"Epoch 116/150\n",
|
|
" - 0s - loss: 0.5213 - acc: 0.7422\n",
|
|
"Epoch 117/150\n",
|
|
" - 0s - loss: 0.5189 - acc: 0.7461\n",
|
|
"Epoch 118/150\n",
|
|
" - 0s - loss: 0.5240 - acc: 0.7435\n",
|
|
"Epoch 119/150\n",
|
|
" - 0s - loss: 0.5125 - acc: 0.7448\n",
|
|
"Epoch 120/150\n",
|
|
" - 0s - loss: 0.5154 - acc: 0.7435\n",
|
|
"Epoch 121/150\n",
|
|
" - 0s - loss: 0.5159 - acc: 0.7565\n",
|
|
"Epoch 122/150\n",
|
|
" - 0s - loss: 0.5131 - acc: 0.7578\n",
|
|
"Epoch 123/150\n",
|
|
" - 0s - loss: 0.5104 - acc: 0.7474\n",
|
|
"Epoch 124/150\n",
|
|
" - 0s - loss: 0.5059 - acc: 0.7617\n",
|
|
"Epoch 125/150\n",
|
|
" - 0s - loss: 0.5067 - acc: 0.7448\n",
|
|
"Epoch 126/150\n",
|
|
" - 0s - loss: 0.5088 - acc: 0.7227\n",
|
|
"Epoch 127/150\n",
|
|
" - 0s - loss: 0.5109 - acc: 0.7539\n",
|
|
"Epoch 128/150\n",
|
|
" - 0s - loss: 0.5037 - acc: 0.7708\n",
|
|
"Epoch 129/150\n",
|
|
" - 0s - loss: 0.5129 - acc: 0.7591\n",
|
|
"Epoch 130/150\n",
|
|
" - 0s - loss: 0.4990 - acc: 0.7656\n",
|
|
"Epoch 131/150\n",
|
|
" - 0s - loss: 0.4970 - acc: 0.7617\n",
|
|
"Epoch 132/150\n",
|
|
" - 0s - loss: 0.4951 - acc: 0.7656\n",
|
|
"Epoch 133/150\n",
|
|
" - 0s - loss: 0.5020 - acc: 0.7565\n",
|
|
"Epoch 134/150\n",
|
|
" - 0s - loss: 0.5000 - acc: 0.7721\n",
|
|
"Epoch 135/150\n",
|
|
" - 0s - loss: 0.4927 - acc: 0.7617\n",
|
|
"Epoch 136/150\n",
|
|
" - 0s - loss: 0.4975 - acc: 0.7578\n",
|
|
"Epoch 137/150\n",
|
|
" - 0s - loss: 0.5046 - acc: 0.7643\n",
|
|
"Epoch 138/150\n",
|
|
" - 0s - loss: 0.4963 - acc: 0.7643\n",
|
|
"Epoch 139/150\n",
|
|
" - 0s - loss: 0.4869 - acc: 0.7643\n",
|
|
"Epoch 140/150\n",
|
|
" - 0s - loss: 0.4884 - acc: 0.7591\n",
|
|
"Epoch 141/150\n",
|
|
" - 0s - loss: 0.4879 - acc: 0.7630\n",
|
|
"Epoch 142/150\n",
|
|
" - 0s - loss: 0.4911 - acc: 0.7617\n",
|
|
"Epoch 143/150\n",
|
|
" - 0s - loss: 0.4841 - acc: 0.7721\n",
|
|
"Epoch 144/150\n",
|
|
" - 0s - loss: 0.4856 - acc: 0.7708\n",
|
|
"Epoch 145/150\n",
|
|
" - 0s - loss: 0.4869 - acc: 0.7760\n",
|
|
"Epoch 146/150\n",
|
|
" - 0s - loss: 0.4883 - acc: 0.7682\n",
|
|
"Epoch 147/150\n",
|
|
" - 0s - loss: 0.4831 - acc: 0.7747\n",
|
|
"Epoch 148/150\n",
|
|
" - 0s - loss: 0.4880 - acc: 0.7852\n",
|
|
"Epoch 149/150\n",
|
|
" - 0s - loss: 0.4779 - acc: 0.7721\n",
|
|
"Epoch 150/150\n",
|
|
" - 0s - loss: 0.4756 - acc: 0.7669\n",
|
|
"[1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 1.0, 1.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0]\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# Create first network with Keras\n",
|
|
"from keras.models import Sequential\n",
|
|
"from keras.layers import Dense\n",
|
|
"import numpy\n",
|
|
"# fix random seed for reproducibility\n",
|
|
"seed = 7\n",
|
|
"numpy.random.seed(seed)\n",
|
|
"# load pima indians dataset\n",
|
|
"dataset = numpy.loadtxt(\"pima-indians-diabetes.data\", delimiter=\",\")\n",
|
|
"# split into input (X) and output (Y) variables\n",
|
|
"X = dataset[:,0:8]\n",
|
|
"Y = dataset[:,8]\n",
|
|
"# create model\n",
|
|
"model = Sequential()\n",
|
|
"model.add(Dense(12, input_dim=8, kernel_initializer='uniform', activation='relu'))\n",
|
|
"model.add(Dense(8, kernel_initializer='uniform', activation='relu'))\n",
|
|
"model.add(Dense(1, kernel_initializer='uniform', activation='sigmoid'))\n",
|
|
"# Compile model\n",
|
|
"model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])\n",
|
|
"# Fit the model\n",
|
|
"model.fit(X, Y, epochs=150, batch_size=10, verbose=2)\n",
|
|
"# calculate predictions\n",
|
|
"predictions = model.predict(X)\n",
|
|
"# round predictions\n",
|
|
"rounded = [round(x[0]) for x in predictions]\n",
|
|
"print(rounded)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.6.4"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|