Commit 5b44f6ef authored by Mark Daoust's avatar Mark Daoust
Browse files

clear output

parent 9ba5b316
...@@ -54,11 +54,7 @@ ...@@ -54,11 +54,7 @@
"metadata": { "metadata": {
"id": "NQgONe5ecYvE", "id": "NQgONe5ecYvE",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 17
},
"outputId": "7ab0889a-32f9-4ace-f848-6c808893b88c"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
...@@ -70,7 +66,7 @@ ...@@ -70,7 +66,7 @@
"import sys\n", "import sys\n",
"from IPython.display import clear_output" "from IPython.display import clear_output"
], ],
"execution_count": 1, "execution_count": 0,
"outputs": [] "outputs": []
}, },
{ {
...@@ -88,11 +84,7 @@ ...@@ -88,11 +84,7 @@
"metadata": { "metadata": {
"id": "yVvFyhnkcYvL", "id": "yVvFyhnkcYvL",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 136
},
"outputId": "e57030d7-7f5c-455e-ea0f-55038e909d97"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
...@@ -103,22 +95,8 @@ ...@@ -103,22 +95,8 @@
" os.environ['PYTHONPATH'] += os.pathsep+models_path\n", " os.environ['PYTHONPATH'] += os.pathsep+models_path\n",
" os.chdir(\"models/official/wide_deep\")" " os.chdir(\"models/official/wide_deep\")"
], ],
"execution_count": 2, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "stream",
"text": [
"Cloning into 'models'...\n",
"remote: Counting objects: 2826, done.\u001b[K\n",
"remote: Compressing objects: 100% (2375/2375), done.\u001b[K\n",
"remote: Total 2826 (delta 543), reused 1731 (delta 382), pack-reused 0\u001b[K\n",
"Receiving objects: 100% (2826/2826), 371.22 MiB | 39.17 MiB/s, done.\n",
"Resolving deltas: 100% (543/543), done.\n",
"Checking out files: 100% (2934/2934), done.\n"
],
"name": "stdout"
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -134,11 +112,7 @@ ...@@ -134,11 +112,7 @@
"metadata": { "metadata": {
"id": "6QilS4-0cYvQ", "id": "6QilS4-0cYvQ",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 17
},
"outputId": "3faf2df7-677e-4a91-c09b-3d81ca30c9c1"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
...@@ -147,7 +121,7 @@ ...@@ -147,7 +121,7 @@
"\n", "\n",
"census_dataset.download(\"/tmp/census_data/\")" "census_dataset.download(\"/tmp/census_data/\")"
], ],
"execution_count": 3, "execution_count": 0,
"outputs": [] "outputs": []
}, },
{ {
...@@ -164,27 +138,15 @@ ...@@ -164,27 +138,15 @@
"metadata": { "metadata": {
"id": "vbJ8jPAhcYvT", "id": "vbJ8jPAhcYvT",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "cc0182c0-90d7-4f9c-b421-0dd67166c6d2"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"output = !python -m census_main --model_type=wide --train_epochs=2\n", "output = !python -m census_main --model_type=wide --train_epochs=2\n",
"print([line for line in output if 'accuracy:' in line])" "print([line for line in output if 'accuracy:' in line])"
], ],
"execution_count": 4, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "stream",
"text": [
"['I0711 22:27:15.442501 140285526747008 tf_logging.py:115] accuracy: 0.8360666']\n"
],
"name": "stdout"
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -216,54 +178,34 @@ ...@@ -216,54 +178,34 @@
"metadata": { "metadata": {
"id": "N6Tgye8bcYvX", "id": "N6Tgye8bcYvX",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "75152d8d-6afa-4e4e-cc0e-3eac7127f8fd"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"!ls /tmp/census_data/" "!ls /tmp/census_data/"
], ],
"execution_count": 5, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "stream",
"text": [
"adult.data adult.test\r\n"
],
"name": "stdout"
}
]
}, },
{ {
"metadata": { "metadata": {
"id": "6y3mj9zKcYva", "id": "6y3mj9zKcYva",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 17
},
"outputId": "3b44b7dd-5a2d-4943-eb19-20f26d5c7098"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"train_file = \"/tmp/census_data/adult.data\"\n", "train_file = \"/tmp/census_data/adult.data\"\n",
"test_file = \"/tmp/census_data/adult.test\"" "test_file = \"/tmp/census_data/adult.test\""
], ],
"execution_count": 6, "execution_count": 0,
"outputs": [] "outputs": []
}, },
{ {
"metadata": { "metadata": {
"id": "vkn1FNmpcYvb", "id": "vkn1FNmpcYvb",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 204
},
"outputId": "4e27b186-b76c-4f19-ea9d-abe19110e93b"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
...@@ -273,171 +215,8 @@ ...@@ -273,171 +215,8 @@
"\n", "\n",
"train_df.head()" "train_df.head()"
], ],
"execution_count": 7, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>age</th>\n",
" <th>workclass</th>\n",
" <th>fnlwgt</th>\n",
" <th>education</th>\n",
" <th>education_num</th>\n",
" <th>marital_status</th>\n",
" <th>occupation</th>\n",
" <th>relationship</th>\n",
" <th>race</th>\n",
" <th>gender</th>\n",
" <th>capital_gain</th>\n",
" <th>capital_loss</th>\n",
" <th>hours_per_week</th>\n",
" <th>native_country</th>\n",
" <th>income_bracket</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>39</td>\n",
" <td>State-gov</td>\n",
" <td>77516</td>\n",
" <td>Bachelors</td>\n",
" <td>13</td>\n",
" <td>Never-married</td>\n",
" <td>Adm-clerical</td>\n",
" <td>Not-in-family</td>\n",
" <td>White</td>\n",
" <td>Male</td>\n",
" <td>2174</td>\n",
" <td>0</td>\n",
" <td>40</td>\n",
" <td>United-States</td>\n",
" <td>&lt;=50K</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>50</td>\n",
" <td>Self-emp-not-inc</td>\n",
" <td>83311</td>\n",
" <td>Bachelors</td>\n",
" <td>13</td>\n",
" <td>Married-civ-spouse</td>\n",
" <td>Exec-managerial</td>\n",
" <td>Husband</td>\n",
" <td>White</td>\n",
" <td>Male</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>13</td>\n",
" <td>United-States</td>\n",
" <td>&lt;=50K</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>38</td>\n",
" <td>Private</td>\n",
" <td>215646</td>\n",
" <td>HS-grad</td>\n",
" <td>9</td>\n",
" <td>Divorced</td>\n",
" <td>Handlers-cleaners</td>\n",
" <td>Not-in-family</td>\n",
" <td>White</td>\n",
" <td>Male</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>40</td>\n",
" <td>United-States</td>\n",
" <td>&lt;=50K</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>53</td>\n",
" <td>Private</td>\n",
" <td>234721</td>\n",
" <td>11th</td>\n",
" <td>7</td>\n",
" <td>Married-civ-spouse</td>\n",
" <td>Handlers-cleaners</td>\n",
" <td>Husband</td>\n",
" <td>Black</td>\n",
" <td>Male</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>40</td>\n",
" <td>United-States</td>\n",
" <td>&lt;=50K</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>28</td>\n",
" <td>Private</td>\n",
" <td>338409</td>\n",
" <td>Bachelors</td>\n",
" <td>13</td>\n",
" <td>Married-civ-spouse</td>\n",
" <td>Prof-specialty</td>\n",
" <td>Wife</td>\n",
" <td>Black</td>\n",
" <td>Female</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>40</td>\n",
" <td>Cuba</td>\n",
" <td>&lt;=50K</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" age workclass fnlwgt education education_num \\\n",
"0 39 State-gov 77516 Bachelors 13 \n",
"1 50 Self-emp-not-inc 83311 Bachelors 13 \n",
"2 38 Private 215646 HS-grad 9 \n",
"3 53 Private 234721 11th 7 \n",
"4 28 Private 338409 Bachelors 13 \n",
"\n",
" marital_status occupation relationship race gender \\\n",
"0 Never-married Adm-clerical Not-in-family White Male \n",
"1 Married-civ-spouse Exec-managerial Husband White Male \n",
"2 Divorced Handlers-cleaners Not-in-family White Male \n",
"3 Married-civ-spouse Handlers-cleaners Husband Black Male \n",
"4 Married-civ-spouse Prof-specialty Wife Black Female \n",
"\n",
" capital_gain capital_loss hours_per_week native_country income_bracket \n",
"0 2174 0 40 United-States <=50K \n",
"1 0 0 13 United-States <=50K \n",
"2 0 0 40 United-States <=50K \n",
"3 0 0 40 United-States <=50K \n",
"4 0 0 40 Cuba <=50K "
]
},
"metadata": {
"tags": []
},
"execution_count": 7
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -486,11 +265,7 @@ ...@@ -486,11 +265,7 @@
"metadata": { "metadata": {
"id": "N7zNJflKcYvg", "id": "N7zNJflKcYvg",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 17
},
"outputId": "4aebe747-0fca-4209-cf28-3164080ab89f"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
...@@ -506,7 +281,7 @@ ...@@ -506,7 +281,7 @@
"\n", "\n",
" return ds" " return ds"
], ],
"execution_count": 8, "execution_count": 0,
"outputs": [] "outputs": []
}, },
{ {
...@@ -523,11 +298,7 @@ ...@@ -523,11 +298,7 @@
"metadata": { "metadata": {
"id": "ygaKuikecYvi", "id": "ygaKuikecYvi",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 136
},
"outputId": "071665a2-d23f-4c15-da43-ce0d106d473f"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
...@@ -542,22 +313,8 @@ ...@@ -542,22 +313,8 @@
"print()\n", "print()\n",
"print('A batch of Labels:', label_batch )" "print('A batch of Labels:', label_batch )"
], ],
"execution_count": 9, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "stream",
"text": [
"Some feature keys: ['age', 'workclass', 'fnlwgt', 'education', 'education_num']\n",
"\n",
"A batch of Ages : tf.Tensor([52 57 31 33 34 22 32 66 35 44], shape=(10,), dtype=int32)\n",
"\n",
"A batch of Labels: tf.Tensor(\n",
"[b'<=50K' b'<=50K' b'<=50K' b'<=50K' b'<=50K' b'<=50K' b'<=50K' b'<=50K'\n",
" b'<=50K' b'>50K'], shape=(10,), dtype=string)\n"
],
"name": "stdout"
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -576,54 +333,15 @@ ...@@ -576,54 +333,15 @@
"metadata": { "metadata": {
"id": "vUTeXaEUcYvn", "id": "vUTeXaEUcYvn",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 493
},
"outputId": "2da7413a-5e54-4e86-f3c5-07387156ab79"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"import inspect\n", "import inspect\n",
"print(inspect.getsource(census_dataset.input_fn))" "print(inspect.getsource(census_dataset.input_fn))"
], ],
"execution_count": 10, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "stream",
"text": [
"def input_fn(data_file, num_epochs, shuffle, batch_size):\n",
" \"\"\"Generate an input function for the Estimator.\"\"\"\n",
" assert tf.gfile.Exists(data_file), (\n",
" '%s not found. Please make sure you have run census_dataset.py and '\n",
" 'set the --data_dir argument to the correct path.' % data_file)\n",
"\n",
" def parse_csv(value):\n",
" tf.logging.info('Parsing {}'.format(data_file))\n",
" columns = tf.decode_csv(value, record_defaults=_CSV_COLUMN_DEFAULTS)\n",
" features = dict(zip(_CSV_COLUMNS, columns))\n",
" labels = features.pop('income_bracket')\n",
" classes = tf.equal(labels, '>50K') # binary classification\n",
" return features, classes\n",
"\n",
" # Extract lines from input files using the Dataset API.\n",
" dataset = tf.data.TextLineDataset(data_file)\n",
"\n",
" if shuffle:\n",
" dataset = dataset.shuffle(buffer_size=_NUM_EXAMPLES['train'])\n",
"\n",
" dataset = dataset.map(parse_csv, num_parallel_calls=5)\n",
"\n",
" # We call repeat after shuffling, rather than before, to prevent separate\n",
" # epochs from blending together.\n",
" dataset = dataset.repeat(num_epochs)\n",
" dataset = dataset.batch(batch_size)\n",
" return dataset\n",
"\n"
],
"name": "stdout"
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -639,44 +357,20 @@ ...@@ -639,44 +357,20 @@
"metadata": { "metadata": {
"id": "DlsqRZS5cYvr", "id": "DlsqRZS5cYvr",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 68
},
"outputId": "31dee63f-80f7-4c7e-f749-a5531d33ab95"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"ds = census_dataset.input_fn(train_file, num_epochs=5, shuffle=True, batch_size=10)" "ds = census_dataset.input_fn(train_file, num_epochs=5, shuffle=True, batch_size=10)"
], ],
"execution_count": 11, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "stream",
"text": [
"INFO:tensorflow:Parsing /tmp/census_data/adult.data\n"
],
"name": "stdout"
},
{
"output_type": "stream",
"text": [
"WARNING: Logging before flag parsing goes to stderr.\n",
"I0711 22:27:19.570451 140174775953280 tf_logging.py:115] Parsing /tmp/census_data/adult.data\n"
],
"name": "stderr"
}
]
}, },
{ {
"metadata": { "metadata": {
"id": "Mv3as_CEcYvu", "id": "Mv3as_CEcYvu",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 102
},
"outputId": "3834b00d-9655-488f-d6d2-8d7405848d78"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
...@@ -689,20 +383,8 @@ ...@@ -689,20 +383,8 @@
"print()\n", "print()\n",
"print('Label batch :', label_batch )" "print('Label batch :', label_batch )"
], ],
"execution_count": 12, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "stream",
"text": [
"Feature keys: ['age', 'workclass', 'fnlwgt', 'education', 'education_num']\n",
"\n",
"Age batch : tf.Tensor([31 88 36 46 20 51 30 40 31 49], shape=(10,), dtype=int32)\n",
"\n",
"Label batch : tf.Tensor([False False True True False True True False False True], shape=(10,), dtype=bool)\n"
],
"name": "stdout"
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -718,11 +400,7 @@ ...@@ -718,11 +400,7 @@
"metadata": { "metadata": {
"id": "wnQdpEcVcYv0", "id": "wnQdpEcVcYv0",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 17
},
"outputId": "b9050d80-e603-4363-dbe9-11c2b368e29d"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
...@@ -730,7 +408,7 @@ ...@@ -730,7 +408,7 @@
"train_inpf = functools.partial(census_dataset.input_fn, train_file, num_epochs=2, shuffle=True, batch_size=64)\n", "train_inpf = functools.partial(census_dataset.input_fn, train_file, num_epochs=2, shuffle=True, batch_size=64)\n",
"test_inpf = functools.partial(census_dataset.input_fn, test_file, num_epochs=1, shuffle=False, batch_size=64)" "test_inpf = functools.partial(census_dataset.input_fn, test_file, num_epochs=1, shuffle=False, batch_size=64)"
], ],
"execution_count": 13, "execution_count": 0,
"outputs": [] "outputs": []
}, },
{ {
...@@ -766,17 +444,13 @@ ...@@ -766,17 +444,13 @@
"metadata": { "metadata": {
"id": "ZX0r2T5OcYv6", "id": "ZX0r2T5OcYv6",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 17
},
"outputId": "283bf438-2a96-4bf3-fa89-94da99f93927"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"age = fc.numeric_column('age')" "age = fc.numeric_column('age')"
], ],
"execution_count": 14, "execution_count": 0,
"outputs": [] "outputs": []
}, },
{ {
...@@ -793,40 +467,14 @@ ...@@ -793,40 +467,14 @@
"metadata": { "metadata": {
"id": "kREtIPfwcYv_", "id": "kREtIPfwcYv_",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 187
},
"outputId": "197a798b-9809-45e1-a8d4-ed5d237eea9d"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"fc.input_layer(feature_batch, [age]).numpy()" "fc.input_layer(feature_batch, [age]).numpy()"
], ],
"execution_count": 15, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([[31.],\n",
" [88.],\n",
" [36.],\n",
" [46.],\n",
" [20.],\n",
" [51.],\n",
" [30.],\n",
" [40.],\n",
" [31.],\n",
" [49.]], dtype=float32)"
]
},
"metadata": {
"tags": []
},
"execution_count": 15
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -842,11 +490,7 @@ ...@@ -842,11 +490,7 @@
"metadata": { "metadata": {
"id": "9R5eSJ1pcYwE", "id": "9R5eSJ1pcYwE",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 54
},
"outputId": "ea791197-8300-4f31-cee1-f7d1b8209838"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
...@@ -857,16 +501,8 @@ ...@@ -857,16 +501,8 @@
"clear_output()\n", "clear_output()\n",
"print(result)" "print(result)"
], ],
"execution_count": 16, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "stream",
"text": [
"{'accuracy': 0.76334375, 'accuracy_baseline': 0.76377374, 'auc': 0.67818105, 'auc_precision_recall': 0.31133735, 'average_loss': 0.52437353, 'label/mean': 0.23622628, 'loss': 33.479706, 'precision': 0.31578946, 'prediction/mean': 0.22410269, 'recall': 0.0015600624, 'global_step': 1018}\n"
],
"name": "stdout"
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -883,11 +519,7 @@ ...@@ -883,11 +519,7 @@
"metadata": { "metadata": {
"id": "uqPbUqlxcYwJ", "id": "uqPbUqlxcYwJ",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 17
},
"outputId": "68f4ccfd-d71b-4327-b8e8-25c40e986bed"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
...@@ -896,65 +528,34 @@ ...@@ -896,65 +528,34 @@
"capital_loss = tf.feature_column.numeric_column('capital_loss')\n", "capital_loss = tf.feature_column.numeric_column('capital_loss')\n",
"hours_per_week = tf.feature_column.numeric_column('hours_per_week')" "hours_per_week = tf.feature_column.numeric_column('hours_per_week')"
], ],
"execution_count": 17, "execution_count": 0,
"outputs": [] "outputs": []
}, },
{ {
"metadata": { "metadata": {
"id": "yqCF0a4DcYwM", "id": "yqCF0a4DcYwM",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 17
},
"outputId": "0f9097a4-bc79-4e67-bd63-6a4d4461736d"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"my_numeric_columns = [age,education_num, capital_gain, capital_loss, hours_per_week]" "my_numeric_columns = [age,education_num, capital_gain, capital_loss, hours_per_week]"
], ],
"execution_count": 18, "execution_count": 0,
"outputs": [] "outputs": []
}, },
{ {
"metadata": { "metadata": {
"id": "xDrZtAZ0cYwO", "id": "xDrZtAZ0cYwO",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 204
},
"outputId": "6fd558ea-9f0c-4deb-cb8a-6211ec233016"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"fc.input_layer(feature_batch, my_numeric_columns).numpy()" "fc.input_layer(feature_batch, my_numeric_columns).numpy()"
], ],
"execution_count": 19, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([[3.1000e+01, 0.0000e+00, 0.0000e+00, 1.4000e+01, 4.3000e+01],\n",
" [8.8000e+01, 0.0000e+00, 0.0000e+00, 1.5000e+01, 4.0000e+01],\n",
" [3.6000e+01, 1.5024e+04, 0.0000e+00, 9.0000e+00, 4.0000e+01],\n",
" [4.6000e+01, 0.0000e+00, 0.0000e+00, 1.4000e+01, 5.5000e+01],\n",
" [2.0000e+01, 0.0000e+00, 0.0000e+00, 1.0000e+01, 1.0000e+01],\n",
" [5.1000e+01, 5.1780e+03, 0.0000e+00, 1.2000e+01, 4.5000e+01],\n",
" [3.0000e+01, 1.5024e+04, 0.0000e+00, 1.4000e+01, 6.0000e+01],\n",
" [4.0000e+01, 0.0000e+00, 0.0000e+00, 9.0000e+00, 4.0000e+01],\n",
" [3.1000e+01, 0.0000e+00, 0.0000e+00, 1.0000e+01, 1.0000e+01],\n",
" [4.9000e+01, 0.0000e+00, 0.0000e+00, 1.3000e+01, 4.0000e+01]],\n",
" dtype=float32)"
]
},
"metadata": {
"tags": []
},
"execution_count": 19
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -970,11 +571,7 @@ ...@@ -970,11 +571,7 @@
"metadata": { "metadata": {
"id": "XN8k5S95cYwR", "id": "XN8k5S95cYwR",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 204
},
"outputId": "72be27c1-e25c-4609-a703-8297c936177a"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
...@@ -987,26 +584,8 @@ ...@@ -987,26 +584,8 @@
"for key,value in sorted(result.items()):\n", "for key,value in sorted(result.items()):\n",
" print('%s: %s' % (key, value))" " print('%s: %s' % (key, value))"
], ],
"execution_count": 20, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "stream",
"text": [
"accuracy: 0.76377374\n",
"accuracy_baseline: 0.76377374\n",
"auc: 0.539677\n",
"auc_precision_recall: 0.334656\n",
"average_loss: 1.4886041\n",
"global_step: 1018\n",
"label/mean: 0.23622628\n",
"loss: 95.04299\n",
"precision: 0.0\n",
"prediction/mean: 0.21315515\n",
"recall: 0.0\n"
],
"name": "stdout"
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -1027,11 +606,7 @@ ...@@ -1027,11 +606,7 @@
"metadata": { "metadata": {
"id": "0IjqSi9tcYwV", "id": "0IjqSi9tcYwV",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 37
},
"outputId": "859f282d-7a9c-417b-a615-643a15d10118"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
...@@ -1040,7 +615,7 @@ ...@@ -1040,7 +615,7 @@
" 'Husband', 'Not-in-family', 'Wife', 'Own-child', 'Unmarried',\n", " 'Husband', 'Not-in-family', 'Wife', 'Own-child', 'Unmarried',\n",
" 'Other-relative'])\n" " 'Other-relative'])\n"
], ],
"execution_count": 21, "execution_count": 0,
"outputs": [] "outputs": []
}, },
{ {
...@@ -1063,41 +638,14 @@ ...@@ -1063,41 +638,14 @@
"metadata": { "metadata": {
"id": "kI43CYlncYwY", "id": "kI43CYlncYwY",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 224
},
"outputId": "458177e5-4bc0-48f2-b1fb-614b91dd99e6"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"fc.input_layer(feature_batch, [age, fc.indicator_column(relationship)])" "fc.input_layer(feature_batch, [age, fc.indicator_column(relationship)])"
], ],
"execution_count": 22, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "execute_result",
"data": {
"text/plain": [
"<tf.Tensor: id=4361, shape=(10, 7), dtype=float32, numpy=\n",
"array([[31., 0., 1., 0., 0., 0., 0.],\n",
" [88., 1., 0., 0., 0., 0., 0.],\n",
" [36., 1., 0., 0., 0., 0., 0.],\n",
" [46., 1., 0., 0., 0., 0., 0.],\n",
" [20., 0., 1., 0., 0., 0., 0.],\n",
" [51., 1., 0., 0., 0., 0., 0.],\n",
" [30., 1., 0., 0., 0., 0., 0.],\n",
" [40., 1., 0., 0., 0., 0., 0.],\n",
" [31., 0., 0., 1., 0., 0., 0.],\n",
" [49., 0., 1., 0., 0., 0., 0.]], dtype=float32)>"
]
},
"metadata": {
"tags": []
},
"execution_count": 22
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -1114,18 +662,14 @@ ...@@ -1114,18 +662,14 @@
"metadata": { "metadata": {
"id": "8pSBaliCcYwb", "id": "8pSBaliCcYwb",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 37
},
"outputId": "e9b2e611-1311-4933-af0a-489e03fdc960"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"occupation = tf.feature_column.categorical_column_with_hash_bucket(\n", "occupation = tf.feature_column.categorical_column_with_hash_bucket(\n",
" 'occupation', hash_bucket_size=1000)" " 'occupation', hash_bucket_size=1000)"
], ],
"execution_count": 23, "execution_count": 0,
"outputs": [] "outputs": []
}, },
{ {
...@@ -1143,36 +687,15 @@ ...@@ -1143,36 +687,15 @@
"metadata": { "metadata": {
"id": "dCvQNv36cYwe", "id": "dCvQNv36cYwe",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 207
},
"outputId": "23ebfedd-faf8-425b-a855-9897aba20341"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"for item in feature_batch['occupation'].numpy():\n", "for item in feature_batch['occupation'].numpy():\n",
" print(item.decode())" " print(item.decode())"
], ],
"execution_count": 24, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "stream",
"text": [
"Prof-specialty\n",
"Exec-managerial\n",
"Prof-specialty\n",
"Exec-managerial\n",
"Tech-support\n",
"Sales\n",
"Exec-managerial\n",
"Machine-op-inspct\n",
"?\n",
"Exec-managerial\n"
],
"name": "stdout"
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -1188,11 +711,7 @@ ...@@ -1188,11 +711,7 @@
"metadata": { "metadata": {
"id": "0Y16peWacYwh", "id": "0Y16peWacYwh",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 54
},
"outputId": "524b1af5-c492-4d0e-b736-7974ca618089"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
...@@ -1200,21 +719,8 @@ ...@@ -1200,21 +719,8 @@
"\n", "\n",
"occupation_result.numpy().shape" "occupation_result.numpy().shape"
], ],
"execution_count": 25, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "execute_result",
"data": {
"text/plain": [
"(10, 1000)"
]
},
"metadata": {
"tags": []
},
"execution_count": 25
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -1234,31 +740,14 @@ ...@@ -1234,31 +740,14 @@
"metadata": { "metadata": {
"id": "q_ryRglmcYwk", "id": "q_ryRglmcYwk",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 54
},
"outputId": "e1797664-1200-48e3-c774-52e7e0a18f00"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"tf.argmax(occupation_result, axis=1).numpy()" "tf.argmax(occupation_result, axis=1).numpy()"
], ],
"execution_count": 26, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([979, 800, 979, 800, 413, 631, 800, 911, 65, 800])"
]
},
"metadata": {
"tags": []
},
"execution_count": 26
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -1281,11 +770,7 @@ ...@@ -1281,11 +770,7 @@
"metadata": { "metadata": {
"id": "0Z5eUrd_cYwo", "id": "0Z5eUrd_cYwo",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 37
},
"outputId": "becd1bda-9014-4b9e-92ef-ba4ee2ed52fa"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
...@@ -1305,24 +790,20 @@ ...@@ -1305,24 +790,20 @@
" 'Self-emp-not-inc', 'Private', 'State-gov', 'Federal-gov',\n", " 'Self-emp-not-inc', 'Private', 'State-gov', 'Federal-gov',\n",
" 'Local-gov', '?', 'Self-emp-inc', 'Without-pay', 'Never-worked'])\n" " 'Local-gov', '?', 'Self-emp-inc', 'Without-pay', 'Never-worked'])\n"
], ],
"execution_count": 27, "execution_count": 0,
"outputs": [] "outputs": []
}, },
{ {
"metadata": { "metadata": {
"id": "a03l9ozUcYwp", "id": "a03l9ozUcYwp",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 37
},
"outputId": "374c7f00-8d2e-458f-ec32-b4cbc6b7386f"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"my_categorical_columns = [relationship, occupation, education, marital_status, workclass]" "my_categorical_columns = [relationship, occupation, education, marital_status, workclass]"
], ],
"execution_count": 28, "execution_count": 0,
"outputs": [] "outputs": []
}, },
{ {
...@@ -1339,11 +820,7 @@ ...@@ -1339,11 +820,7 @@
"metadata": { "metadata": {
"id": "_i_MLoo9cYws", "id": "_i_MLoo9cYws",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 224
},
"outputId": "95ab18a4-2ec1-4fad-c207-2f86b607a333"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
...@@ -1355,26 +832,8 @@ ...@@ -1355,26 +832,8 @@
"for key,value in sorted(result.items()):\n", "for key,value in sorted(result.items()):\n",
" print('%s: %s' % (key, value))" " print('%s: %s' % (key, value))"
], ],
"execution_count": 29, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "stream",
"text": [
"accuracy: 0.81978995\n",
"accuracy_baseline: 0.76377374\n",
"auc: 0.869223\n",
"auc_precision_recall: 0.6459037\n",
"average_loss: 1.9878242\n",
"global_step: 1018\n",
"label/mean: 0.23622628\n",
"loss: 126.916725\n",
"precision: 0.60679156\n",
"prediction/mean: 0.2908891\n",
"recall: 0.6736869\n"
],
"name": "stdout"
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -1410,18 +869,14 @@ ...@@ -1410,18 +869,14 @@
"metadata": { "metadata": {
"id": "KT4pjD9AcYww", "id": "KT4pjD9AcYww",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 17
},
"outputId": "633c1bb5-e5e2-4cf3-8392-5caf473607da"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"age_buckets = tf.feature_column.bucketized_column(\n", "age_buckets = tf.feature_column.bucketized_column(\n",
" age, boundaries=[18, 25, 30, 35, 40, 45, 50, 55, 60, 65])" " age, boundaries=[18, 25, 30, 35, 40, 45, 50, 55, 60, 65])"
], ],
"execution_count": 30, "execution_count": 0,
"outputs": [] "outputs": []
}, },
{ {
...@@ -1442,41 +897,14 @@ ...@@ -1442,41 +897,14 @@
"metadata": { "metadata": {
"id": "Lr40vm3qcYwy", "id": "Lr40vm3qcYwy",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 204
},
"outputId": "e53a3d92-f8d4-4ff7-da5e-46f498eb2316"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"fc.input_layer(feature_batch, [age, age_buckets]).numpy()" "fc.input_layer(feature_batch, [age, age_buckets]).numpy()"
], ],
"execution_count": 31, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([[31., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0.],\n",
" [88., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1.],\n",
" [36., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.],\n",
" [46., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0.],\n",
" [20., 0., 1., 0., 0., 0., 0., 0., 0., 0., 0., 0.],\n",
" [51., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0.],\n",
" [30., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0.],\n",
" [40., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.],\n",
" [31., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0., 0.],\n",
" [49., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0.]],\n",
" dtype=float32)"
]
},
"metadata": {
"tags": []
},
"execution_count": 31
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -1502,18 +930,14 @@ ...@@ -1502,18 +930,14 @@
"metadata": { "metadata": {
"id": "IAPhPzXscYw1", "id": "IAPhPzXscYw1",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 37
},
"outputId": "4dd22eaf-3917-449d-9068-5306ae60b6a6"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"education_x_occupation = tf.feature_column.crossed_column(\n", "education_x_occupation = tf.feature_column.crossed_column(\n",
" ['education', 'occupation'], hash_bucket_size=1000)" " ['education', 'occupation'], hash_bucket_size=1000)"
], ],
"execution_count": 32, "execution_count": 0,
"outputs": [] "outputs": []
}, },
{ {
...@@ -1533,18 +957,14 @@ ...@@ -1533,18 +957,14 @@
"metadata": { "metadata": {
"id": "y8UaBld9cYw7", "id": "y8UaBld9cYw7",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 37
},
"outputId": "4abb43e7-c406-4caf-f15e-71af723ec8df"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"age_buckets_x_education_x_occupation = tf.feature_column.crossed_column(\n", "age_buckets_x_education_x_occupation = tf.feature_column.crossed_column(\n",
" [age_buckets, 'education', 'occupation'], hash_bucket_size=1000)" " [age_buckets, 'education', 'occupation'], hash_bucket_size=1000)"
], ],
"execution_count": 33, "execution_count": 0,
"outputs": [] "outputs": []
}, },
{ {
...@@ -1587,11 +1007,7 @@ ...@@ -1587,11 +1007,7 @@
"metadata": { "metadata": {
"id": "Klmf3OxpcYw-", "id": "Klmf3OxpcYw-",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 105
},
"outputId": "a8f46b90-a9d0-4d33-fff5-38b530e35d43"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
...@@ -1612,37 +1028,8 @@ ...@@ -1612,37 +1028,8 @@
"model = tf.estimator.LinearClassifier(\n", "model = tf.estimator.LinearClassifier(\n",
" model_dir=model_dir, feature_columns=base_columns + crossed_columns)" " model_dir=model_dir, feature_columns=base_columns + crossed_columns)"
], ],
"execution_count": 34, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "stream",
"text": [
"INFO:tensorflow:Using default config.\n"
],
"name": "stdout"
},
{
"output_type": "stream",
"text": [
"I0711 22:27:55.502184 140174775953280 tf_logging.py:115] Using default config.\n"
],
"name": "stderr"
},
{
"output_type": "stream",
"text": [
"INFO:tensorflow:Using config: {'_model_dir': '/tmp/tmp93vf5hp6', '_tf_random_seed': None, '_save_summary_steps': 100, '_save_checkpoints_steps': None, '_save_checkpoints_secs': 600, '_session_config': None, '_keep_checkpoint_max': 5, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 100, '_train_distribute': None, '_device_fn': None, '_service': None, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7f7cc6df0ba8>, '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1}\n"
],
"name": "stdout"
},
{
"output_type": "stream",
"text": [
"I0711 22:27:55.509107 140174775953280 tf_logging.py:115] Using config: {'_model_dir': '/tmp/tmp93vf5hp6', '_tf_random_seed': None, '_save_summary_steps': 100, '_save_checkpoints_steps': None, '_save_checkpoints_secs': 600, '_session_config': None, '_keep_checkpoint_max': 5, '_keep_checkpoint_every_n_hours': 10000, '_log_step_count_steps': 100, '_train_distribute': None, '_device_fn': None, '_service': None, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7f7cc6df0ba8>, '_task_type': 'worker', '_task_id': 0, '_global_id_in_cluster': 0, '_master': '', '_evaluation_master': '', '_is_chief': True, '_num_ps_replicas': 0, '_num_worker_replicas': 1}\n"
],
"name": "stderr"
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -1667,18 +1054,14 @@ ...@@ -1667,18 +1054,14 @@
"metadata": { "metadata": {
"id": "ZlrIBuoecYxD", "id": "ZlrIBuoecYxD",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 17
},
"outputId": "5aa0bc8c-9496-4301-963a-78bcef54e17a"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"model.train(train_inpf)\n", "model.train(train_inpf)\n",
"clear_output()" "clear_output()"
], ],
"execution_count": 35, "execution_count": 0,
"outputs": [] "outputs": []
}, },
{ {
...@@ -1696,11 +1079,7 @@ ...@@ -1696,11 +1079,7 @@
"metadata": { "metadata": {
"id": "L9nVJEO8cYxI", "id": "L9nVJEO8cYxI",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 204
},
"outputId": "8eb14bd7-9030-4381-c18a-6a5c7c17c569"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
...@@ -1709,26 +1088,8 @@ ...@@ -1709,26 +1088,8 @@
"for key in sorted(results):\n", "for key in sorted(results):\n",
" print('%s: %0.2f' % (key, results[key]))" " print('%s: %0.2f' % (key, results[key]))"
], ],
"execution_count": 36, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "stream",
"text": [
"accuracy: 0.84\n",
"accuracy_baseline: 0.76\n",
"auc: 0.88\n",
"auc_precision_recall: 0.70\n",
"average_loss: 0.35\n",
"global_step: 1018.00\n",
"label/mean: 0.24\n",
"loss: 22.42\n",
"precision: 0.71\n",
"prediction/mean: 0.22\n",
"recall: 0.52\n"
],
"name": "stdout"
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -1751,11 +1112,7 @@ ...@@ -1751,11 +1112,7 @@
"metadata": { "metadata": {
"id": "8R5bz5CxcYxL", "id": "8R5bz5CxcYxL",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 669
},
"outputId": "71f5e775-0d24-4356-d785-3b06aa385957"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
...@@ -1777,190 +1134,8 @@ ...@@ -1777,190 +1134,8 @@
"clear_output()\n", "clear_output()\n",
"predict_df[['income_bracket','predicted_class', 'correct']]" "predict_df[['income_bracket','predicted_class', 'correct']]"
], ],
"execution_count": 37, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>income_bracket</th>\n",
" <th>predicted_class</th>\n",
" <th>correct</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>&lt;=50K</td>\n",
" <td>&lt;=50K</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>&lt;=50K</td>\n",
" <td>&lt;=50K</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>&gt;50K</td>\n",
" <td>&lt;=50K</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>&gt;50K</td>\n",
" <td>&lt;=50K</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>&lt;=50K</td>\n",
" <td>&lt;=50K</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>&lt;=50K</td>\n",
" <td>&lt;=50K</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>&lt;=50K</td>\n",
" <td>&lt;=50K</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>&gt;50K</td>\n",
" <td>&gt;50K</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>&lt;=50K</td>\n",
" <td>&lt;=50K</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>&lt;=50K</td>\n",
" <td>&lt;=50K</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>&gt;50K</td>\n",
" <td>&lt;=50K</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>&lt;=50K</td>\n",
" <td>&gt;50K</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>&lt;=50K</td>\n",
" <td>&lt;=50K</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>&lt;=50K</td>\n",
" <td>&lt;=50K</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>&gt;50K</td>\n",
" <td>&lt;=50K</td>\n",
" <td>False</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>&gt;50K</td>\n",
" <td>&gt;50K</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>&lt;=50K</td>\n",
" <td>&lt;=50K</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>17</th>\n",
" <td>&lt;=50K</td>\n",
" <td>&lt;=50K</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>18</th>\n",
" <td>&lt;=50K</td>\n",
" <td>&lt;=50K</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>19</th>\n",
" <td>&gt;50K</td>\n",
" <td>&gt;50K</td>\n",
" <td>True</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" income_bracket predicted_class correct\n",
"0 <=50K <=50K True\n",
"1 <=50K <=50K True\n",
"2 >50K <=50K False\n",
"3 >50K <=50K False\n",
"4 <=50K <=50K True\n",
"5 <=50K <=50K True\n",
"6 <=50K <=50K True\n",
"7 >50K >50K True\n",
"8 <=50K <=50K True\n",
"9 <=50K <=50K True\n",
"10 >50K <=50K False\n",
"11 <=50K >50K False\n",
"12 <=50K <=50K True\n",
"13 <=50K <=50K True\n",
"14 >50K <=50K False\n",
"15 >50K >50K True\n",
"16 <=50K <=50K True\n",
"17 <=50K <=50K True\n",
"18 <=50K <=50K True\n",
"19 >50K >50K True"
]
},
"metadata": {
"tags": []
},
"execution_count": 37
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -1991,11 +1166,7 @@ ...@@ -1991,11 +1166,7 @@
"metadata": { "metadata": {
"id": "cVv2HsqocYxO", "id": "cVv2HsqocYxO",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 204
},
"outputId": "68504270-5bcc-4a87-dbfa-7fd94cf54dff"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
...@@ -2014,26 +1185,8 @@ ...@@ -2014,26 +1185,8 @@
"for key in sorted(results):\n", "for key in sorted(results):\n",
" print('%s: %0.2f' % (key, results[key]))" " print('%s: %0.2f' % (key, results[key]))"
], ],
"execution_count": 38, "execution_count": 0,
"outputs": [ "outputs": []
{
"output_type": "stream",
"text": [
"accuracy: 0.84\n",
"accuracy_baseline: 0.76\n",
"auc: 0.89\n",
"auc_precision_recall: 0.70\n",
"average_loss: 0.35\n",
"global_step: 2036.00\n",
"label/mean: 0.24\n",
"loss: 22.28\n",
"precision: 0.70\n",
"prediction/mean: 0.24\n",
"recall: 0.55\n"
],
"name": "stdout"
}
]
}, },
{ {
"metadata": { "metadata": {
...@@ -2129,17 +1282,13 @@ ...@@ -2129,17 +1282,13 @@
"metadata": { "metadata": {
"id": "jpdw2z5WcYxV", "id": "jpdw2z5WcYxV",
"colab_type": "code", "colab_type": "code",
"colab": { "colab": {}
"base_uri": "https://localhost:8080/",
"height": 17
},
"outputId": "403d18f6-d01e-47dc-dfc7-8c95d9a8ec34"
}, },
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"" ""
], ],
"execution_count": 38, "execution_count": 0,
"outputs": [] "outputs": []
} }
] ]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment