{"cells": [{"metadata": {"_cell_guid": "8f6fa792-c3c2-4749-90bf-1bc3f142f9ba", "_uuid": "ca5c74c8fdf5a1089788f937ea7671a0bb5489eb"}, "cell_type": "markdown", "source": ["This is a generic kernel that doesn't do very much, until you fill in the blanks!"]}, {"metadata": {"_cell_guid": "da854b15-3d24-4a36-b3ed-3d488835cb2c", "_uuid": "bb9a5222d826d11f6ed4367e6e2b4b4a3d5a1edb"}, "cell_type": "markdown", "source": ["# Part 0 - Intro"]}, {"metadata": {"_cell_guid": "66a77cab-abe1-44cf-9276-d1b32187cea5", "collapsed": true, "_uuid": "5dabd530b1d74b3275721cc981311f39d6728b18"}, "cell_type": "code", "source": ["# Import all the necessary libraries\n", "import os\n", "import datetime"], "outputs": [], "execution_count": null}, {"metadata": {"_cell_guid": "1083fdfe-2505-412f-8291-89b6307e2e2d", "collapsed": true, "_uuid": "5c645d5dc179f8aa640021f4a2306cb65873c4b6"}, "cell_type": "code", "source": ["# Have a look at our data folder\n", "topDir = '/kaggle'  #defaults to '/kaggle' in kaggle kernels, different if on own system e.g. '/home/user/kaggle'\n", "os.chdir(topDir)    #changes our python working directory to the top directory of our kaggle files\n", "print(os.listdir(os.path.join(topDir, 'input')))  #see what's in the input folder (where data is in)"], "outputs": [], "execution_count": null}, {"metadata": {"_cell_guid": "dfd17611-4a6b-47ef-b9cc-b2670e1127c6", "collapsed": true, "_uuid": "5b6793bc5f277ffebe01728f40cdeb8a8cd7bc6a"}, "cell_type": "code", "source": ["# "], "outputs": [], "execution_count": null}, {"metadata": {"_cell_guid": "6793f497-21e6-4618-afd9-7797740dfd28", "collapsed": true, "_uuid": "5cbd846af776a95d94cf8d3499ee9025b4f5c27f"}, "cell_type": "code", "source": ["train_path = os.path.join(topDir, '')  #path to training data file/folder\n", "test_path = os.path.join(topDir, '')   #path to test data file/folder"], "outputs": [], "execution_count": null}, {"metadata": {"_cell_guid": "23b9e37c-8250-439c-b50b-3a4ddc652c3a", "_uuid": "a1951e5b2626c7460dda35724fc5503092b89cf9"}, "cell_type": "markdown", "source": ["# Part 1 - Data Input"]}, {"metadata": {"_cell_guid": "d11df0ce-1602-4c9a-9cdf-fdc3f1226101", "collapsed": true, "_uuid": "c8a8f5c908b1d17baa979a45c440920ff9ccf04e"}, "cell_type": "code", "source": ["# Get training data\n", "def get_X_data(path):\n", "    \n", "    return X_data\n", "X_train = get_X_data(train_path)"], "outputs": [], "execution_count": null}, {"metadata": {"_cell_guid": "9e92d149-8dfd-40f0-b3c1-bbce47f8d561", "collapsed": true, "_uuid": "847cbe8f81fa52cf153be18d7cad215bc88bbe9d"}, "cell_type": "code", "source": ["# Get training data labels\n", "def get_Y_data(path):\n", "    \n", "    return Y_data\n", "Y_train = get_Y_data(train_path)"], "outputs": [], "execution_count": null}, {"metadata": {"_cell_guid": "7129b20c-bdc2-43a5-8764-a762e2bf79b2", "_uuid": "0a50c27113c940bd20e527edc422143ba4f8a9e1"}, "cell_type": "markdown", "source": ["# Part 2 - Build model"]}, {"metadata": {"_cell_guid": "1d4cdf5b-be18-4abf-86ef-d76e8294474c", "collapsed": true, "_uuid": "6f9a58dd35b6aa0d43b4bd4dd89b25f52a4ab74f"}, "cell_type": "code", "source": ["# Design our model architecture here\n", "def Model():\n", "    \n", "    return model"], "outputs": [], "execution_count": null}, {"metadata": {"_cell_guid": "30f3c231-d347-4d44-809a-ba5aa4d2944b", "collapsed": true, "_uuid": "796008f7760b64d768b201ae135e06ac9ce60007"}, "cell_type": "code", "source": ["# Set some model compile parameters\n", "optimizer = 'adam'\n", "loss      = 'binary_crossentropy'\n", "metrics   = ['accuracy']\n", "\n", "# Compile our model\n", "model = Model()\n", "model.compile(optimizer=optimizer, loss=loss, metrics=metrics)"], "outputs": [], "execution_count": null}, {"metadata": {"_cell_guid": "05e830e6-c323-4c39-a707-e52a1c17957b", "_uuid": "3ef3e0dfd1e2e22c43c9a880a7e9e77473929ab7"}, "cell_type": "markdown", "source": ["# Part 3 - Run model"]}, {"metadata": {"_cell_guid": "c3b00a59-ca4f-4ed8-b38d-c0c007f227c0", "collapsed": true, "_uuid": "4e95cd22e05505a20deafbf57839ce5e06f82783"}, "cell_type": "code", "source": ["# Runtime data augmentation"], "outputs": [], "execution_count": null}, {"metadata": {"_cell_guid": "d78cd8da-0905-46e4-b969-37096272e00a", "collapsed": true, "_uuid": "7a0fbed34c6b95d6b2abd081b7838f9194af0c95"}, "cell_type": "code", "source": ["# Runtime custom callbacks"], "outputs": [], "execution_count": null}, {"metadata": {"_cell_guid": "cec5a1ff-c983-426d-a0da-581f25966860", "collapsed": true, "_uuid": "b7b93a826a4b4337af83cf9999524035e7470601"}, "cell_type": "code", "source": ["# Finally run the model!!\n", "model.fit(X=X_train, Y=Y_train)"], "outputs": [], "execution_count": null}, {"metadata": {"_cell_guid": "2cf8de83-1486-444d-9200-e1c2784b25cc", "_uuid": "d8b70e56c01002b673e354223a00df0c17b8cb83"}, "cell_type": "markdown", "source": ["# Part 4 - Evaluate output"]}, {"metadata": {"_cell_guid": "bd5ccd5b-72c5-4fc0-a327-fb07d54d636f", "collapsed": true, "_uuid": "23a71c7299667761f811e658ad74b08a5fbbb8d9"}, "cell_type": "code", "source": ["# Get test data\n", "X_test = get_X_data(test_path)"], "outputs": [], "execution_count": null}, {"metadata": {"_cell_guid": "a78cd1cd-f47f-482a-bc7b-b1203beba9ac", "collapsed": true, "_uuid": "9179437a04bf2e63fc9f54d118bdd8840f30636a"}, "cell_type": "code", "source": ["# Use model to predict test labels\n", "Y_hat = model.predict(X_test)"], "outputs": [], "execution_count": null}, {"metadata": {"_cell_guid": "88938860-0dc9-4b99-bc53-292a0758a90a", "_uuid": "25f599e017681e4a269bfc2dc6640bfb4532e2ff"}, "cell_type": "markdown", "source": ["# Part 5 - Submit results"]}, {"metadata": {"_cell_guid": "5acd063c-ddb8-47ae-96c6-14693cd90d6a", "collapsed": true, "_uuid": "d5d8b56f676a732d83d83b979ea30d937700d0cc"}, "cell_type": "code", "source": ["# Create submission DataFrame\n", "sub = pd.DataFrame()\n", "\n", "timestamp = datetime.datetime.now().strftime(\"%Y%m%d-%H%M\")\n", "print('Submission output to: sub-{}.csv'.format(timestamp))\n", "sub.to_csv('sub-{}.csv'.format(timestamp), index=False)"], "outputs": [], "execution_count": null}, {"metadata": {"_cell_guid": "4ece2ece-5d06-4467-bb2f-fc7eb59badc3", "collapsed": true, "_uuid": "59070d50687f10fabc250fb73c9d0fed355f67a1"}, "cell_type": "code", "source": [], "outputs": [], "execution_count": null}], "metadata": {"language_info": {"version": "3.6.4", "pygments_lexer": "ipython3", "mimetype": "text/x-python", "file_extension": ".py", "nbconvert_exporter": "python", "codemirror_mode": {"version": 3, "name": "ipython"}, "name": "python"}, "kernelspec": {"display_name": "Python 3", "name": "python3", "language": "python"}}, "nbformat": 4, "nbformat_minor": 1}