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.
To display the Export Model panel for a completed training job:
- 1.On the Models page, click the model to export from.
- 2.On the model details page, 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.
Djinn 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 Djinn 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.
Djinn 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 in the Tonic documentation.
The generated file cannot be larger than 1GB. Djinn 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.
Djinn 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.