MySQL HeatWave User Guide  /  ...  /  ML_MODEL_IMPORT

3.11.3 ML_MODEL_IMPORT

Running the ML_MODEL_IMPORT routine imports a pre-trained model in ONNX (Open Neural Network Exchange) format into the model catalog. After import, all the HeatWave AutoML routines can be used with the ONNX model. ML_MODEL_IMPORT is available as of MySQL 8.0.31.

Models in ONNX format (.onnx) cannot be loaded directly into a MySQL table. They require string serialization and conversion to Base64 binary encoding. Before running ML_MODEL_IMPORT, follow the instructions in Section 3.10.2, “Importing ONNX Models” to carry out the required pre-processing and then load the model into a temporary table for import to MySQL HeatWave.

ML_MODEL_IMPORT Syntax

mysql> CALL sys.ML_MODEL_IMPORT (model_object, model_metadata, 
          model_handle_variable);

ML_MODEL_IMPORT parameters:

  • model_object: The preprocessed ONNX model object, which must be string serialized and BASE64 encoded. Follow the instructions in Section 3.10.2, “Importing ONNX Models” to do this.

  • model_metadata: An optional JSON object containing key-value pairs with model metadata. Use NULL if you do not want to specify model metadata. For ONNX models, you can add the following optional model metadata:

    training_score: any real number including zero

    The cross-validation score achieved for the model by training.

    task: string

    The task type for the model - classification, regression, or forecasting.

    n_rows: integer greater than 0

    The number of rows in the training table.

    n_columns: integer greater than 0

    The number of columns in the training table.

    algorithm_name: string

    The name of the chosen algorithm.

    training_time: float greater than 0

    The time in seconds taken to train the model.

    target_column_name: string

    The name of the target column in the training table.

    train_table_name: string

    The name of the training table.

    column_names: JSON object

    A JSON object containing a list of the column names in the training table.

    notes: string

    Your own notes on the model.

  • model_handle: The model handle for the ONNX model. The model is stored in the model catalog under this name and accessed using it. Specify a model handle that does not already exist in the model catalog.

Syntax Examples

  • This example imports an ONNX model without specifying metadata:

    mysql> CALL sys.ML_MODEL_IMPORT(@onnx_encode, NULL, 'onnx_test');