Comment on page
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.
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.
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)
You can generate and download CSV files of model data records.
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 setting
TONIC_S3_BUCKET_FOR_SYNTHETIC_DATA_CSVS. For more information, go to Configuring environment settings.
The generated file cannot be larger than 1GB. Tonic automatically truncates the generated file if needed to stay within the limit.
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.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.
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.
To download a generated file, in the file list, click the file name.
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.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. Tonic generates and downloads the Jupyter notebook file.
Last modified 1mo ago