Documentation Home
MySQL AI
Download this Manual
PDF (US Ltr) - 1.4Mb
PDF (A4) - 1.4Mb


4.7.4 View Model Details

To view the details for the models in your model catalog, query the MODEL_CATALOG table.

Before You Begin

View Details for Your Models

The following example queries model_id, model_handle, and model_owner, train_table_name from the model catalog. Replace user1 with your own user name.

mysql> SELECT model_id, model_handle, model_owner, train_table_name FROM ML_SCHEMA_user1.MODEL_CATALOG;
+----------+--------------------------------------------+-------------+-------------------------------------------+
| model_id | model_handle                               | model_owner | train_table_name                          |
+----------+--------------------------------------------+-------------+-------------------------------------------+
|        1 | regression_use_case                        | root        | regression_data.house_price_training      |
|        2 | forecasting_use_case                       | root        | forecasting_data.electricity_demand_train |
|        3 | anomaly_detection_semi_supervised_use_case | root        | anomaly_data.credit_card_train            |
|        4 | anomaly_detection_log_use_case             | root        | anomaly_log_data.training_data            |
|        5 | recommendation_use_case                    | root        | recommendation_data.training_dataset      |
|        6 | topic_modeling_use_case                    | root        | topic_modeling_data.movies                |
+----------+--------------------------------------------+-------------+-------------------------------------------+

Where:

  • model_id is a unique numeric identifier for the model.

  • model_owner is the user that created the model.

  • model_handle is the handle by which the model is called.

  • ML_SCHEMA_user1.MODEL_CATALOG is the fully qualified name of the MODEL_CATALOG table. The schema is named for the owning user.

The output displays details from only a few MODEL_CATALOG table columns. For other columns you can query, see The Model Catalog.

View Model Explanations

The ML_EXPLAIN routine generates model explanations and stores them in the model catalog. See Generate Model Explanations to learn more.

A model explanation helps you identify the features that are most important to the model overall. Feature importance is presented as an attribution value. A positive value indicates that a feature contributed toward the prediction. A negative value can have different interpretations depending on the specific model explainer used for the model. For example, a negative value for the permutation importance explainer means that the feature is not important.

To view a model explanation, you can query the model_explanation column from the model catalog by referencing the model handle. Review how to Query the Model Handle.

mysql> SELECT column FROM ML_SCHEMA_user name.MODEL_CATALOG where model_handle='model_handle';

The following example queries one of the model handles and views the model explanation for that model. Optionally, use JSON_PRETTY to view the output in an easily readable format.

mysql> SELECT JSON_PRETTY(model_explanation) FROM ML_SCHEMA_user1.MODEL_CATALOG where model_handle='census_model';
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| JSON_PRETTY(model_explanation)                                                                                                                                                                                                                                                                                                                                                                           |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
  "permutation_importance": {
    "age": 0.0305,
    "sex": 0.0023,
    "race": 0.0017,
    "fnlwgt": 0.0025,
    "education": 0.0013,
    "workclass": 0.0043,
    "occupation": 0.0229,
    "capital-gain": 0.0495,
    "capital-loss": 0.0156,
    "relationship": 0.0267,
    "education-num": 0.0371,
    "hours-per-week": 0.0142,
    "marital-status": 0.0267,
    "native-country": 0.0
  }
} |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.0447 sec)

Where:

  • ML_SCHEMA_user1.MODEL_CATALOG is the fully qualified name of the MODEL_CATALOG table. The schema is named for the user that created the model.

  • census_data.census_train_user1_1744548610842 is the model handle. See Work with Model Handles.

The output displays feature importance values for each column by using the permutation_importance model explainer.

Alternatively, you can query the model explanation by using the valid session variable for the model handle. Optionally, use JSON_PRETTY to view the output in an easily readable format.

mysql> SELECT JSON_PRETTY(model_explanation) FROM ML_SCHEMA_admin.MODEL_CATALOG where model_handle=@census_model;
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| JSON_PRETTY(model_explanation)                                                                                                                                  |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
  "permutation_importance": {
    "age": 0.0305,
    "sex": 0.0023,
    "race": 0.0017,
    "fnlwgt": 0.0025,
    "education": 0.0013,
    "workclass": 0.0043,
    "occupation": 0.0229,
    "capital-gain": 0.0495,
    "capital-loss": 0.0156,
    "relationship": 0.0267,
    "education-num": 0.0371,
    "hours-per-week": 0.0142,
    "marital-status": 0.0267,
    "native-country": 0.0
  }
} |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.0447 sec)

See Work with Model Handles to learn more.

What's Next