Exporting a model

You can export a trained model to a Jupyter notebook, export generated model data to a CSV file, or copy a code snippet that you can use as a starting point for your own Jupyter notebook.

Displaying the Export Model panel

To display the Export Model panel for a completed training job:
  1. 1.
    On the Models view, click the model to export from.
  2. 2.
    On the model details view, click the Export option for the training job to use for the export.
The Export model panel contains the code snippet, CSV download, and Jupyter notebook export options. If you didn't previously install the data science libraries, it also provides the command to do that.

Exporting a code snippet for a trained model

Tonic provides a code snippet that you can use as a starting point to create your own Jupyter notebooks.
The results include:
  • Sample source data
  • The resulting synthetic data
  • Visualizations to compare the source data to the synthetic data, to help you to analyze the quality of the synthetic data
On the Export model panel, the Code Snippet section contains the snippet.
Code Snippet section of the Export model panel
The template contains the following code. Values in <> are populated automatically by the values from your Tonic instance and model.
import pandas as pd
import numpy as np
from tonic_api.api import TonicApi
tonic = TonicApi("<Tonic instance>", "[API Token]")
workspace = tonic.get_workspace("<workspace ID>")
model = workspace.get_trained_model_by_training_job_id("<training job ID>")
sample = model.sample(100)

Exporting a generated CSV file of model data

You can generate and download CSV files of model data records.

Configuring the S3 bucket where Tonic stores the generated files

Tonic stores generated files for 14 days in an S3 bucket that you choose. You configure the S3 bucket as the value of the environment variable TONIC_S3_BUCKET_FOR_SYNTHETIC_DATA_CSVS. See Setting environment variables.

Limit on the file size

The generated file cannot be larger than 1GB. Tonic automatically truncates the generated file if needed to stay within the limit.

Generating a file

On the Export model panel, under Download synthetic data directly to a CSV, to generate a new file:
Download to CSV section of the Export model panel
  1. 1.
    Under How many rows, enter the number of rows of data to generate for the file.
  2. 2.
    Optionally, under Random Seed, enter a seed value to use for the data generation.
    Providing a seed value guarantees a consistent set of results every time you generate a CSV file. Without the seed value, the result set is random.
  3. 3.
    Click Generate CSV.
Tonic generates the file and saves it to the configured S3 bucket. It also adds the file to the list of previously generated files. The list displays up to 10 previously generated files.

Downloading a file

To download a generated file, in the file list, click the file name.

Exporting a model to a Jupyter notebook

You can export a trained model to a Jupyter notebook file. You can then use the notebook to analyze the model.
From the Export model panel, to export a model to a Jupyter notebook file:
Export Jupyter Notebook section of the Export model panel
  1. 1.
    Under Export Jupyter Notebook, from the Choose API Token drop-down list, choose the API token to use to access the model data.
  2. 2.
    Click Download Notebook. Tonic generates and downloads the Jupyter notebook file.