|
11 | 11 | "cell_type": "markdown",
|
12 | 12 | "metadata": {},
|
13 | 13 | "source": [
|
14 |
| - "## Learning Objectives\n", |
| 14 | + "## Learning objectives\n", |
15 | 15 | "\n",
|
16 | 16 | "1. Develop a high level understanding of TFX pipeline components.\n",
|
17 | 17 | "2. Learn how to use a TFX Interactive Context for prototype development of TFX pipelines.\n",
|
18 | 18 | "3. Work with the Tensorflow Data Validation (TFDV) library to check and analyze input data.\n",
|
19 | 19 | "4. Utilize the Tensorflow Transform (TFT) library for scalable data preprocessing and feature transformations.\n",
|
20 | 20 | "5. Employ the Tensorflow Model Analysis (TFMA) library for model evaluation.\n",
|
21 | 21 | "\n",
|
22 |
| - "In this lab, you will work with the [Covertype Data Set](https://github.com/jarokaz/mlops-labs/blob/master/datasets/covertype/README.md) and use TFX to analyze, understand, and pre-process the dataset and train, analyze, validate, and deploy a multi-class classification model to predict the type of forest cover from cartographic features.\n", |
| 22 | + "## Introduction\n", |
| 23 | + "\n", |
| 24 | + "In this notebook, you will work with the [Covertype Data Set](https://github.com/jarokaz/mlops-labs/blob/master/datasets/covertype/README.md) and use TFX to analyze, understand, and pre-process the dataset and train, analyze, validate, and deploy a multi-class classification model to predict the type of forest cover from cartographic features.\n", |
23 | 25 | "\n",
|
24 | 26 | "You will utilize **TFX Interactive Context** to work with the TFX components interactivelly in a Jupyter notebook environment. Working in an interactive notebook is useful when doing initial data exploration, experimenting with models, and designing ML pipelines. You should be aware that there are differences in the way interactive notebooks are orchestrated, and how they access metadata artifacts. In a production deployment of TFX on GCP, you will use an orchestrator such as Kubeflow Pipelines, or Cloud Composer. In an interactive mode, the notebook itself is the orchestrator, running each TFX component as you execute the notebook cells. In a production deployment, ML Metadata will be managed in a scalabe database like MySQL, and artifacts in apersistent store such as Google Cloud Storage. In an interactive mode, both properties and payloads are stored in a local file system of the Jupyter host.\n",
|
25 | 27 | "\n",
|
26 |
| - "**Setup Note:**\n", |
27 |
| - "Currently, TFMA visualizations do not render properly in JupyterLab. It is recommended to run this notebook in Jupyter Classic Notebook. To switch to Classic Notebook select *Launch Classic Notebook* from the *Help* menu." |
| 28 | + "**Setup Note**:\n", |
| 29 | + "\n", |
| 30 | + "Currently, TFMA visualizations do not render properly in JupyterLab. It is recommended to run this notebook in Jupyter Classic Notebook. To switch to Classic Notebook select **Launch Classic Notebook** from the **Help** menu." |
28 | 31 | ]
|
29 | 32 | },
|
30 | 33 | {
|
|
142 | 145 | "%pip install --upgrade --user tensorflow_model_analysis==0.25.0"
|
143 | 146 | ]
|
144 | 147 | },
|
| 148 | + { |
| 149 | + "cell_type": "markdown", |
| 150 | + "metadata": {}, |
| 151 | + "source": [ |
| 152 | + "**Restart the kernel by using Kernel > Restart kernel > Restart.**" |
| 153 | + ] |
| 154 | + }, |
145 | 155 | {
|
146 | 156 | "cell_type": "markdown",
|
147 | 157 | "metadata": {},
|
|
151 | 161 | "Set constants, location paths and other environment settings. "
|
152 | 162 | ]
|
153 | 163 | },
|
| 164 | + { |
| 165 | + "cell_type": "code", |
| 166 | + "execution_count": null, |
| 167 | + "metadata": {}, |
| 168 | + "outputs": [], |
| 169 | + "source": [ |
| 170 | + "import absl\n", |
| 171 | + "import os\n", |
| 172 | + "import tempfile\n", |
| 173 | + "import time\n", |
| 174 | + "\n", |
| 175 | + "import tensorflow as tf\n", |
| 176 | + "import tensorflow_data_validation as tfdv\n", |
| 177 | + "import tensorflow_model_analysis as tfma\n", |
| 178 | + "import tensorflow_transform as tft\n", |
| 179 | + "import tfx\n", |
| 180 | + "\n", |
| 181 | + "from pprint import pprint\n", |
| 182 | + "from tensorflow_metadata.proto.v0 import schema_pb2, statistics_pb2, anomalies_pb2\n", |
| 183 | + "from tensorflow_transform.tf_metadata import schema_utils\n", |
| 184 | + "from tfx.components import CsvExampleGen\n", |
| 185 | + "from tfx.components import Evaluator\n", |
| 186 | + "from tfx.components import ExampleValidator\n", |
| 187 | + "from tfx.components import InfraValidator\n", |
| 188 | + "from tfx.components import Pusher\n", |
| 189 | + "from tfx.components import ResolverNode\n", |
| 190 | + "from tfx.components import SchemaGen\n", |
| 191 | + "from tfx.components import StatisticsGen\n", |
| 192 | + "from tfx.components import Trainer\n", |
| 193 | + "from tfx.components import Transform\n", |
| 194 | + "from tfx.components import Tuner\n", |
| 195 | + "from tfx.dsl.components.base import executor_spec\n", |
| 196 | + "from tfx.components.common_nodes.importer_node import ImporterNode\n", |
| 197 | + "from tfx.components.trainer import executor as trainer_executor\n", |
| 198 | + "from tfx.dsl.experimental import latest_blessed_model_resolver\n", |
| 199 | + "from tfx.orchestration import metadata\n", |
| 200 | + "from tfx.orchestration import pipeline\n", |
| 201 | + "from tfx.orchestration.experimental.interactive.interactive_context import InteractiveContext\n", |
| 202 | + "from tfx.proto import evaluator_pb2\n", |
| 203 | + "from tfx.proto import example_gen_pb2\n", |
| 204 | + "from tfx.proto import infra_validator_pb2\n", |
| 205 | + "from tfx.proto import pusher_pb2\n", |
| 206 | + "from tfx.proto import trainer_pb2\n", |
| 207 | + "from tfx.proto.evaluator_pb2 import SingleSlicingSpec\n", |
| 208 | + "\n", |
| 209 | + "from tfx.types import Channel\n", |
| 210 | + "from tfx.types.standard_artifacts import Model\n", |
| 211 | + "from tfx.types.standard_artifacts import HyperParameters\n", |
| 212 | + "from tfx.types.standard_artifacts import ModelBlessing\n", |
| 213 | + "from tfx.types.standard_artifacts import InfraBlessing" |
| 214 | + ] |
| 215 | + }, |
154 | 216 | {
|
155 | 217 | "cell_type": "code",
|
156 | 218 | "execution_count": null,
|
|
1075 | 1137 | "### Visualize evaluation results\n",
|
1076 | 1138 | "You can visualize the evaluation results using the `tfma.view.render_slicing_metrics()` function from TensorFlow Model Analysis library.\n",
|
1077 | 1139 | "\n",
|
1078 |
| - "**Setup Note:** *Currently, TFMA visualizations don't render in JupyterLab. Make sure that you run this notebook in Classic Notebook.*" |
| 1140 | + "**Setup Note**: **Currently, TFMA visualizations don't render in JupyterLab. Make sure that you run this notebook in Classic Notebook.**" |
1079 | 1141 | ]
|
1080 | 1142 | },
|
1081 | 1143 | {
|
|
0 commit comments