{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "name": "vanila_nn.ipynb",
      "version": "0.3.2",
      "provenance": [],
      "collapsed_sections": [],
      "include_colab_link": true
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "view-in-github",
        "colab_type": "text"
      },
      "source": [
        "[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/gmihaila/machine_learning_toolbox/blob/master/vanila_nn.ipynb)"
      ]
    },
    {
      "metadata": {
        "id": "17LH2G9SZxgF",
        "colab_type": "text"
      },
      "cell_type": "markdown",
      "source": [
        "## Vanila Neural Network\n",
        "\n",
        "### Simple implementation to play around and modify\n",
        "\n",
        "by GeorgeM."
      ]
    },
    {
      "metadata": {
        "id": "Jgf-S2NfZnbP",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 52
        },
        "outputId": "5b147c86-7a3c-48f8-c32b-d6d831541364"
      },
      "cell_type": "code",
      "source": [
        "from IPython.display import clear_output\n",
        "\n",
        "print(\"Install pydot\")\n",
        "!apt-get -qq install -y graphviz && pip install -q pydot\n",
        "clear_output()\n",
        "\n",
        "print(\"Downloading data...\")\n",
        "!wget https://raw.githubusercontent.com/jbrownlee/Datasets/master/pima-indians-diabetes.data.csv\n",
        "clear_output()\n",
        "\n",
        "!ls"
      ],
      "execution_count": 10,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "model.png\t\t\tpima-indians-diabetes.data.csv.1  sample_data\n",
            "pima-indians-diabetes.data.csv\tpima-indians-diabetes.data.csv.2\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "metadata": {
        "id": "FKChHKmWZ3hO",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "outputId": "80389fa7-42ff-4991-c19f-7edb72d19a76"
      },
      "cell_type": "code",
      "source": [
        "import numpy as np\n",
        "import pandas as pd\n",
        "\n",
        "from keras.layers import Input, Dense\n",
        "from keras.models import Model\n",
        "from keras.utils.vis_utils import plot_model\n",
        "\n",
        "from IPython.display import Image"
      ],
      "execution_count": 3,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Using TensorFlow backend.\n"
          ],
          "name": "stderr"
        }
      ]
    },
    {
      "metadata": {
        "id": "MuPFye1YaGsm",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 52
        },
        "outputId": "bf0224c0-00bb-40d0-d689-1b730c03c1d6"
      },
      "cell_type": "code",
      "source": [
        "# Parse data\n",
        "path_file = 'pima-indians-diabetes.data.csv'\n",
        "\n",
        "df = pd.read_csv(path_file, header=None)\n",
        "data = np.array(df.values, dtype=float)\n",
        "\n",
        "x = data[:,:8]  # fist 8 columns\n",
        "y = data[:,8]   # last column\n",
        "\n",
        "print('x shape: ',x.shape)\n",
        "print('y shape: ',y.shape)"
      ],
      "execution_count": 4,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "('x shape: ', (768, 8))\n",
            "('y shape: ', (768,))\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "metadata": {
        "id": "2vPnufPLay7O",
        "colab_type": "code",
        "colab": {}
      },
      "cell_type": "code",
      "source": [
        "# build model\n",
        "\n",
        "n_input = 8  # number of inputs\n",
        "n_output = 1 # number of outputs\n",
        "\n",
        "# build each layer\n",
        "model_input = Input(shape=(n_input,), name='INPUT')\n",
        "model_layer1 = Dense(units=8, activation='relu', name='DENSE1')(model_input)\n",
        "model_output = Dense(units=1, activation='sigmoid', name='OUTPUT')(model_layer1)\n",
        "# assemble model\n",
        "model = Model([model_input], model_output)\n",
        "# compile model\n",
        "model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])"
      ],
      "execution_count": 0,
      "outputs": []
    },
    {
      "metadata": {
        "id": "0a8XLsAxepwg",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 272
        },
        "outputId": "c5ebcd2a-5108-4a33-9ddf-07aa67ddac8a"
      },
      "cell_type": "code",
      "source": [
        "# image model\n",
        "plot_model(model, to_file='model.png')\n",
        "Image('model.png')"
      ],
      "execution_count": 6,
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAALgAAAD/CAYAAABCbhwTAAAABmJLR0QA/wD/AP+gvaeTAAAebElE\nQVR4nO3de1SUdf4H8PczA8PMIAOSICgXAUUCL11V0C2ztdYLlAcQwkvgLutl28BLwm7mz03YVvMs\nagvb6bjibnsOOxTlbcM1S60MK1ezTEFDLiEEhAgxoDDD5/dHP+fnyHAdZka/fF7nzB8+z/fy4cvb\nh2eemXlGIiICY4KS2bsAxqyJA86ExgFnQuOAM6E53L6hqKgIf/7zn+1RC2MWWbNmDcLDw022dTmC\nf/fdd3j77bdtVhRjg+Htt9/Gd99912V7lyP4TW+99ZZVC2JsMEmSZHY7n4MzoXHAmdA44ExoHHAm\nNA44ExoHnAmNA86ExgFnQuOAM6FxwJnQOOBMaBxwJjQOOBMaB5wJzeKAnzx5Evfeey9kMhkkScLI\nkSORkZGBgoICBAYGQpIkSJKEJUuWdOn7xBNPwMXFBXK5HGFhYTh9+nSXfpIkwdHREaNHj8aiRYtw\n4cIFY/8dO3Zg1KhRkCQJMpkMwcHBOHLkiMkc8+fPh0ajgUwmQ0hICE6cOIH4+HiT8Xt6HDx40KJ1\nuJPcvrZeXl5YvHixvcuyLrqNVqslM5t79eSTTxIAamxsNNkeFBRE99xzDwGggwcPdulXWFhITz31\nVJftQUFB5OrqSkRELS0ttH//fvLz86Nhw4ZRcXGxSVsANHXq1G5rO3r0KD3++OPGf8fFxdHhw4fp\n2rVr1NHRQTU1NQSAoqKiqL29nXQ6HdXV1VFycjIdOHBgUNbhTnLr2ooCAGm12i7bbXKKsnPnTshk\nMixfvhxNTU397u/s7IzIyEjs2LEDLS0teO211yyqR5IkTJ8+Ha6urnBwcDDZ7ujoCLVaDQ8PDzz4\n4IMWzWNvbW1tiIiIsHc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n",
            "text/plain": [
              "<IPython.core.display.Image object>"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 6
        }
      ]
    },
    {
      "metadata": {
        "id": "ZFDsNC8xgBlg",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 390
        },
        "outputId": "11a7db92-25d3-4f37-f84c-7b21a014df68"
      },
      "cell_type": "code",
      "source": [
        "# fit model\n",
        "model.fit(x, y, epochs=10, batch_size=10)"
      ],
      "execution_count": 7,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "Epoch 1/10\n",
            "768/768 [==============================] - 0s 321us/step - loss: 6.9649 - acc: 0.3971\n",
            "Epoch 2/10\n",
            "768/768 [==============================] - 0s 127us/step - loss: 2.9483 - acc: 0.5781\n",
            "Epoch 3/10\n",
            "768/768 [==============================] - 0s 126us/step - loss: 1.3735 - acc: 0.6198\n",
            "Epoch 4/10\n",
            "768/768 [==============================] - 0s 123us/step - loss: 1.0576 - acc: 0.6628\n",
            "Epoch 5/10\n",
            "768/768 [==============================] - 0s 125us/step - loss: 0.9600 - acc: 0.6745\n",
            "Epoch 6/10\n",
            "768/768 [==============================] - 0s 132us/step - loss: 0.9091 - acc: 0.6693\n",
            "Epoch 7/10\n",
            "768/768 [==============================] - 0s 130us/step - loss: 0.8888 - acc: 0.6589\n",
            "Epoch 8/10\n",
            "768/768 [==============================] - 0s 119us/step - loss: 0.8684 - acc: 0.6784\n",
            "Epoch 9/10\n",
            "768/768 [==============================] - 0s 127us/step - loss: 0.8222 - acc: 0.6888\n",
            "Epoch 10/10\n",
            "768/768 [==============================] - 0s 128us/step - loss: 0.8253 - acc: 0.6628\n"
          ],
          "name": "stdout"
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "<keras.callbacks.History at 0x7f2dae602d90>"
            ]
          },
          "metadata": {
            "tags": []
          },
          "execution_count": 7
        }
      ]
    },
    {
      "metadata": {
        "id": "Ld6dEra3gJoB",
        "colab_type": "code",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 70
        },
        "outputId": "4d081f22-2203-4732-dcf3-db021b439f60"
      },
      "cell_type": "code",
      "source": [
        "# evaluate the model\n",
        "scores = model.evaluate(x, y)\n",
        "print(\"\\n%s: %.2f%%\" % (model.metrics_names[1], scores[1]*100))"
      ],
      "execution_count": 8,
      "outputs": [
        {
          "output_type": "stream",
          "text": [
            "768/768 [==============================] - 0s 65us/step\n",
            "\n",
            "acc: 65.89%\n"
          ],
          "name": "stdout"
        }
      ]
    },
    {
      "metadata": {
        "id": "JJpFEocVkrs-",
        "colab_type": "text"
      },
      "cell_type": "markdown",
      "source": [
        "ref: https://machinelearningmastery.com/tutorial-first-neural-network-python-keras/ "
      ]
    }
  ]
}