The model_metadata
column in the model
catalog allows you to view detailed information on trained
models. For example, you can view the algorithm used to train
the model, the columns in the training table, and values for
the model explanation.
When you run the
ML_MODEL_IMPORT
routine, the
imported table has a model_metadata
column
that stores the metadata for the table. If you import a model
from a table, model_metadata
stores the
name of the database and table. If you import a model object,
model_metadata
stores a JSON_OBJECT that
contains key-value pairs of the metadata See
Section 10.2.4, “ML_MODEL_IMPORT” to learn more.
The default value for model_metadata
is
NULL
.
This topic has the following sections.
model_metadata
contains the following
metadata as key-value pairs in JSON format:
-
task:
string
The task type specified in the
ML_TRAIN
query. The default isclassification
when used withML_MODEL_IMPORT
. -
notes:
string
The
notes
specified in theML_TRAIN
query. It also records any error messages that occur during model training. -
chunks:
number
Available as of MySQL 9.0.0. The total number of chunks that the model has been split into.
-
format:
string
The model can be in one of the following formats (MySQL 9.0.0 and later):
HWMLv1.0
HWMLv2.0
ONNXv1.0
ONNXv2.0
For MySQL 8.4.0 and earlier, MySQL HeatWave AutoML models are in
HWMLv1.0
format, and ONNX models are inONNX
format. When importing a model with theML_MODEL_IMPORT
routine, the default isONNX
format. -
n_rows:
number
The number of rows in the training table.
-
status:
string
The status of the model. The default is
Ready
when used withML_MODEL_IMPORT
.Creating
: The model is being created.Ready
: The model is trained and active.Error
: Either training was canceled or an error occurred during training. Any error message appears in thenotes
column. The error message also appears inmodel_metadata
notes
.
-
options:
JSON object literal
The
options
specified in theML_TRAIN
query. -
n_columns:
number
The number of columns in the training table.
-
column_names:
JSON array
The feature columns used to train the model.
-
contamination:
number
The contamination factor for the anomaly detection task. See Anomaly Detection Options to learn more.
-
model_quality:
string
The quality of the model object for classification and regression tasks. For other tasks, this value is
NULL
. The value is eitherlow
orhigh
. -
training_time:
number
The time in seconds taken to train the model.
-
algorithm_name:
string
The name of the chosen algorithm.
-
training_score:
number
The cross-validation score achieved for the model by training.
-
build_timestamp:
number
A timestamp indicating when the model was created (UNIX epoch time). A model is created when the
ML_TRAIN
routine finishes executing. -
hyperparameters:
JSON object literal
Available as of MySQL 9.4.0. The hyperparameters of the selected algorithm for the model. For models trained for topic modeling, this value is empty since the topic modeling task does not involve hyperparameters.
-
n_selected_rows:
number
The number of rows selected by adaptive sampling.
-
training_params:
JSON object literal
Internal task dependent parameters used during
ML_TRAIN
. -
train_table_name:
string
The name of the input table specified in the
ML_TRAIN
query. -
model_explanation:
JSON object literal
The model explanation generated during training. See Generate Model Explanations.
-
n_selected_columns:
number
The number of columns selected by feature selection.
-
target_column_name:
string
The name of the column in the training table that was specified as the target column.
-
optimization_metric:
string
The optimization metric used for training. See Section 10.2.16, “Optimization and Scoring Metrics” to review available metrics.
-
selected_column_names:
JSON array
The names of the columns selected by feature selection.
-
training_drift_metric:
JSON object literal
Contains data drift information about the training data, see: Section 6.9.8, “Analyze Data Drift”. This only applies to classification, regression, and anomaly detection (as of MySQL 9.3.2) models.
-
mean:
number
The mean value of drift metrics of all the training data. ≥
0
. -
variance:
number
The variance value of drift metrics of all the training data. ≥
0
.
Both
mean
andvariance
should be low. -
-
onnx_inputs_info:
JSON object literal
Information about the format of the ONNX model inputs. This only applies to ONNX models. See Manage External ONNX Models.
Do not provide
onnx_inputs_info
if the model is not ONNX format. This generates an error.-
data_types_map:
JSON object literal
This maps the data type of each column to an ONNX model data type. The default value is:
JSON_OBJECT("tensor(int64)": "int64", "tensor(float)": "float32", "tensor(string)": "str_")
-
-
onnx_outputs_info:
JSON object literal
Information about the format of the ONNX model outputs. This only applies to ONNX models. See Manage External ONNX Models.
Do not provide
onnx_outputs_info
if the model is not ONNX format, or iftask
isNULL
. This generates an error.-
predictions_name:
string
This name determines which of the ONNX model outputs is associated with predictions.
-
prediction_probabilities_name:
string
This name determines which of the ONNX model outputs is associated with prediction probabilities.
-
labels_map:
JSON object literal
This maps prediction probabilities to predictions, known as labels.
-
You can query the model metadata in the model catalog with
the following command. Replace user1
with
your own user name.
mysql> SELECT JSON_PRETTY(model_metadata) FROM ML_SCHEMA_user1.MODEL_CATALOG\G
*************************** 1. row ***************************
JSON_PRETTY(model_metadata): {
"task": "classification",
"notes": null,
"chunks": 1,
"format": "HWMLv2.0",
"n_rows": 4521,
"status": "Ready",
"options": {
"task": "classification",
"model_explainer": "permutation_importance",
"prediction_explainer": "permutation_importance"
},
"n_columns": 16,
"column_names": [
"age",
"job",
"marital",
"education",
"default1",
"balance",
"housing",
"loan",
"contact",
"day",
"month",
"duration",
"campaign",
"pdays",
"previous",
"poutcome"
],
"contamination": null,
"model_quality": "high",
"training_time": 95.27952575683594,
"algorithm_name": "XGBClassifier",
"training_score": -0.22748015820980072,
"build_timestamp": 1751312812,
"hyperparameters": {
"booster": "gbtree",
"max_depth": 2,
"reg_alpha": 0.0,
"reg_lambda": 5.62341325190349,
"n_estimators": 50,
"learning_rate": 0.0001,
"min_child_weight": 0
},
"n_selected_rows": 3176,
"training_params": {
"recommend": "ratings",
"force_use_X": false,
"recommend_k": 3,
"remove_seen": true,
"ranking_topk": 10,
"lsa_components": 100,
"ranking_threshold": 1,
"feedback_threshold": 1
},
"train_table_name": "bank_marketing.bank_marketing_train",
"model_explanation": {
"permutation_importance": {
"age": 0.0,
"day": 0.0,
"job": 0.0,
"loan": -0.0009,
"month": 0.0194,
"pdays": 0.0134,
"balance": 0.0,
"contact": 0.0099,
"housing": 0.005,
"marital": 0.0,
"campaign": 0.0,
"default1": 0.0,
"duration": 0.0706,
"poutcome": 0.0169,
"previous": 0.0077,
"education": 0.0
}
},
"n_selected_columns": 8,
"target_column_name": "y",
"optimization_metric": "neg_log_loss",
"selected_column_names": [
"contact",
"duration",
"housing",
"loan",
"month",
"pdays",
"poutcome",
"previous"
],
"training_drift_metric": {
"mean": 0.3065,
"variance": 0.3748
}
}