Exporting a model

Required workspace permission: Configure, train, and export models

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. On the Models view, click the model to export from.

  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 Structural 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.

The template contains the following code. Values in <> are populated automatically by the values from your Structural 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 Structural stores the generated files

Structural stores generated files for 14 days in an S3 bucket that you choose. You configure the S3 bucket as the value of the environment setting TONIC_S3_BUCKET_FOR_SYNTHETIC_DATA_CSVS. For more information, go to Configuring environment settings.

Limit on the file size

The generated file cannot be larger than 1GB. Structural 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:

  1. Under How many rows, enter the number of rows of data to generate for the file.

  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. Click Generate CSV.

Structural 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:

  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. Click Download Notebook. Structural generates and downloads the Jupyter notebook file.

Last updated