This section describes how to generate predictions for a table of data with topic modeling.
Connect to your HeatWave Database System.
Complete the steps to train the model with topic modeling. See Section 3.13.1, “Training a Model with Topic Modeling”.
To generate predictions on a table with topic modeling:
-
Use the
ML_MODEL_LOAD
routine to load the model with topic modeling:mysql> CALL sys.ML_MODEL_LOAD(@topic_modeling, NULL);
-
Use the
ML_PREDICT_TABLE
routine to generate predictions with topic modeling:mysql> CALL sys.ML_PREDICT_TABLE('schema_name.input_table_name', @topic_modeling, 'schema_name.output_table_name', NULL);
Where:
schema_name
is the database name that contains the table. Update this with the appropriate database.`input_table_name`
is the input table that contains the training dataset. Update this with the appropriate input table.@topic_modeling
is the session variable that contains the model handle. Update this as needed.`output_table_name`
is the output table that will have the predictions. No existing table can have the same name.The target column argument is set to
NULL
because topic modeling is an unsupervised task and does not need labeled data to train the model.
Once the output table of predictions is generated:
The output table will have the same columns as the input table with the added column of
ml_results
The
ml_results
JSON object literal contains the array of word groups that represent the trained text.Every row in
ml_results
has predictions and every prediction has the new keytags
which has the generated word groups.
To modify the number of word groups in the ml_results
column, you can set the topk
option. This
option must be an integer greater or equal to one.
The following example generates predictions on a table with
topic modeling and uses the topk
option
to limit the number of word groups to five:
mysql> CALL sys.ML_PREDICT_TABLE('schema_name.input_table_name', @topic_modeling,
'schema_name.output_table_name',JSON_OBJECT('topk', 5));