{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "name": "IST718_FinalProject_Colab_Keras_Categorical.ipynb", "provenance": [], "collapsed_sections": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" } }, "cells": [ { "cell_type": "markdown", "metadata": { "id": "RIKbaZtyhAiO", "colab_type": "text" }, "source": [ "# STEP 1: Import ALL the things\n", "[link to tutorial](https://www.tensorflow.org/tutorials/structured_data/feature_columns)" ] }, { "cell_type": "code", "metadata": { "id": "sTc2g5uFgoF3", "colab_type": "code", "colab": { "base_uri": "https://localhost:8080/", "height": 35 }, "outputId": "7a3f0888-eb93-4408-f0a0-1a5f7e12221c" }, "source": [ "%tensorflow_version 2.x\n", "from __future__ import absolute_import, division, print_function, unicode_literals\n", "import numpy as np\n", "import pandas as pd\n", "import tensorflow as tf\n", "from tensorflow import feature_column\n", "from tensorflow.keras import layers\n", "from sklearn.model_selection import train_test_split" ], "execution_count": 1, "outputs": [ { "output_type": "stream", "text": [ "TensorFlow 2.x selected.\n" ], "name": "stdout" } ] }, { "cell_type": "code", "metadata": { "id": "W1tOvP0mgtmp", "colab_type": "code", "colab": { "base_uri": "https://localhost:8080/", "height": 191 }, "outputId": "9ea282c4-1d3f-46d8-c46b-c5dafd48b703" }, "source": [ "url = 'https://storage.googleapis.com/applied-dl/heart.csv'\n", "df = pd.read_csv(url)\n", "df.head()" ], "execution_count": 3, "outputs": [ { "output_type": "execute_result", "data": { "text/html": [ "
\n", " | age | \n", "sex | \n", "cp | \n", "trestbps | \n", "chol | \n", "fbs | \n", "restecg | \n", "thalach | \n", "exang | \n", "oldpeak | \n", "slope | \n", "ca | \n", "thal | \n", "target | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "63 | \n", "1 | \n", "1 | \n", "145 | \n", "233 | \n", "1 | \n", "2 | \n", "150 | \n", "0 | \n", "2.3 | \n", "3 | \n", "0 | \n", "fixed | \n", "0 | \n", "
1 | \n", "67 | \n", "1 | \n", "4 | \n", "160 | \n", "286 | \n", "0 | \n", "2 | \n", "108 | \n", "1 | \n", "1.5 | \n", "2 | \n", "3 | \n", "normal | \n", "1 | \n", "
2 | \n", "67 | \n", "1 | \n", "4 | \n", "120 | \n", "229 | \n", "0 | \n", "2 | \n", "129 | \n", "1 | \n", "2.6 | \n", "2 | \n", "2 | \n", "reversible | \n", "0 | \n", "
3 | \n", "37 | \n", "1 | \n", "3 | \n", "130 | \n", "250 | \n", "0 | \n", "0 | \n", "187 | \n", "0 | \n", "3.5 | \n", "3 | \n", "0 | \n", "normal | \n", "0 | \n", "
4 | \n", "41 | \n", "0 | \n", "2 | \n", "130 | \n", "204 | \n", "0 | \n", "2 | \n", "172 | \n", "0 | \n", "1.4 | \n", "1 | \n", "0 | \n", "normal | \n", "0 | \n", "