Saving an AutoAI generated notebook (Beta)

If you want to view the code that created a particular model pipeline, or interact with the model programmatically, you can save a model pipeline as a notebook.

Note: this feature is offered as a tech preview and is subject to change.

You have two options for saving a pipeline as a notebook:

  • WML notebook - Work with a trained model in an annotated notebook. You can review and update the code, view visualization, and deploy the model with Watson Machine Learning.
  • AutoAI_lib notebook - View the Scikit-Learn source code for the trained model in a notebook. Does not require Watson Machine Learning.

To save a pipeline as a notebook:

  1. Complete your AutoAI experiment.
  2. Select the pipeline you want to save in the leaderboard, and choose Save as WML notebook or AutoAI_lib notebook from the action menu for the pipeline.
  3. Name your notebook, add an optional description, and save it.

Your notebook is added to the containing project as a new notebook asset. You can run, deploy, and score the notebook as you would any notebook model.

What is saved with the notebook

AutoAI saves a representation of the saved pipeline by replacing the optimization steps with the transformers that AutoAI has configured. The code is based on an scikit-learn library. In the notebook, you can view:

  • Annotated code with comments highlighting the pipeline hierarchy and the transformations applied for each step.
  • Holdout scoring and cross-validation of the training data, with the underlying changes to some transformers in AutoAI libraries
  • Markdown cells that you can edit in the notebook editor.

For example, at the top of the notebook, you can review the libraries used to create the pipeline:

import sklearn
import xgboost
import lightgbm
from sklearn.cluster import FeatureAgglomeration
import numpy
from numpy import nan, dtype, mean
import autoai_libs
from autoai_libs.sklearn.custom_scorers import CustomScorers
import sklearn.ensemble
from autoai_libs.cognito.transforms.transform_utils import TExtras, FC
from autoai_libs.transformers.exportable import * # temporary
from autoai_libs.utils.exportable_utils import * # temporary
from sklearn.pipeline import Pipeline

After you save a pipeline as a notebook, you can review the steps used to compose the pipeline. For more information on the estimators, or algorithms, and transformers that are applied to your data to create the pipeline, refer to Implementation details.

Create a sample notebook

To see for yourself what an AutoAI-generated notebook looks like:

  1. Follow the steps in Building an AutoAI model from sample data.
  2. After the experiment runs, choose a pipeline, then click Save as notebook.
  3. Name and save the notebook.
  4. Open the resulting notebook in the notebook editor and review the code.

Reviewing the code

The Python client methods used in the WML notebook are documented as part of the Watson Machine Learning Python client. You can access a reference to all of the Python commands for Watson Machine Learning here: Watson Machine Learning Python client library

For an example of a WML notebook, see this annotated notebook sample in the Gallery. Note that this sample shows an auto-generated notebook but it also demonstrates using the Watson Machine Learning Python client to initiate training.