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.
The metadata in model_metadata is in
key-value pairs in JSON format. It includes the following:
-
task:stringThe task type specified in the
ML_TRAINquery. The default isclassificationwhen used withML_MODEL_IMPORT. -
notes:stringThe
notesspecified in theML_TRAINquery. It also records any error messages that occur during model training. -
chunks:numberAvailable as of MySQL 9.0.0. The total number of chunks that the model has been split into.
-
format:stringThe 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.0format, and ONNX models are inONNXformat. When importing a model with theML_MODEL_IMPORTroutine, the default isONNXformat. -
n_rows:numberThe number of rows in the training table.
-
status:stringThe status of the model. The default is
Readywhen 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 thenotescolumn. The error message also appears inmodel_metadatanotes.
-
options:JSON object literalThe
optionsspecified in theML_TRAINquery. -
n_columns:numberThe number of columns in the training table.
-
column_names:JSON arrayThe feature columns used to train the model.
-
contamination:numberThe contamination factor for the anomaly detection task. See Anomaly Detection Options to learn more.
-
model_quality:stringThe quality of the model object for classification and regression tasks. For other tasks, this value is
NULL. The value is eitherloworhigh. -
training_time:numberThe time in seconds taken to train the model.
-
algorithm_name:stringThe name of the chosen algorithm.
-
training_score:numberThe cross-validation score achieved for the model by training.
-
build_timestamp:numberA timestamp indicating when the model was created (UNIX epoch time). A model is created when the
ML_TRAINroutine finishes executing. -
hyperparameters:JSON object literalAvailable 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:numberThe number of rows selected by adaptive sampling.
-
training_params:JSON object literalInternal task dependent parameters used during
ML_TRAIN. -
train_table_name:stringThe name of the input table specified in the
ML_TRAINquery. -
model_explanation:JSON object literalThe model explanation generated during training. See Generate Model Explanations.
-
n_selected_columns:numberThe number of columns selected by feature selection.
-
target_column_name:stringThe name of the column in the training table that was specified as the target column.
-
optimization_metric:stringThe optimization metric used for training. See Section 10.2.16, “Optimization and Scoring Metrics” to review available metrics.
-
selected_column_names:JSON arrayThe names of the columns selected by feature selection.
-
training_drift_metric:JSON object literalContains 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:numberThe mean value of drift metrics of all the training data. ≥
0. -
variance:numberThe variance value of drift metrics of all the training data. ≥
0.
Both
meanandvarianceshould be low. -
-
onnx_inputs_info:JSON object literalInformation about the format of the ONNX model inputs. This only applies to ONNX models. See Manage External ONNX Models.
Do not provide
onnx_inputs_infoif the model is not ONNX format. This generates an error.-
data_types_map:JSON object literalThis 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 literalInformation about the format of the ONNX model outputs. This only applies to ONNX models. See Manage External ONNX Models.
Do not provide
onnx_outputs_infoif the model is not ONNX format, or iftaskisNULL. This generates an error.-
predictions_name:stringThis name determines which of the ONNX model outputs is associated with predictions.
-
prediction_probabilities_name:stringThis name determines which of the ONNX model outputs is associated with prediction probabilities.
-
labels_map:JSON object literalThis 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
}
}