Documentation Home
MySQL 9.2 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 40.8Mb
PDF (A4) - 40.9Mb
Man Pages (TGZ) - 259.6Kb
Man Pages (Zip) - 366.9Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb


27.3.9.4 Forecaster Class

This class encapsulates the forecasting task as described in Forecasting. Forecaster supports methods for loading, training, and unloading models, predicting labels, and related tasks.

Each instance of Forecaster has three accessible properties, listed here:

  • name (String): The model name.

  • metadata (Object): Model metadata stored in the model catalog. See Model Metadata.

  • trainOptions (Object): The training options that were specified in the constructor when creating this instance.

Forecaster Constructor

You can obtain an instance of Forecaster by invoking its constructor, shown here:

Signature

  • Press CTRL+C to copy
    new ml.Forecaster( String name[, Object trainOptions] )

Arguments

  • name (String): Unique identifier for this Forecaster.

  • trainOptions (Object) (optional): Training options; these are the same as the training options used with sys.ML_TRAIN.

Return type

  • An instance of Forecaster.

Forecaster was added in MySQL 9.2.0.

Forecaster.train()

Trains and loads a new forecast. This method acts as a wrapper for both sys.ML_TRAIN and sys.ML_MODEL_LOAD, but is specific to HeatWave AutoML forecasting.

Signature

  • Press CTRL+C to copy
    Forecaster.train( Table trainData, String index, Array[String] endogenousVariables[, Array[String] exogenousVariables] )

Arguments

  • trainData (Table): A Table containing a training dataset. The table must not take up more than 10 GB space, or hold more than 100 million rows or more than 1017 columns.

  • index (String): Name of the target column containing ground truth values. This must not be a TEXT column.

  • endogenousVariables (Array[String]): The name or names of the column or columns to be forecast.

  • exogenousVariables (Array[String]): The name or names of the column or columns of independent, predictive variables, and have not been forecast.

Return type

Forecaster.fit()

An alias for train(), and identical to it in all respects save the method name. See Forecaster.train(), for more information.

Forecaster.predict()

This method predicts labels, and has two variants, one of which predicts labels from data found in the indicated table and stores them in an output table; this variant of predict() acts as a JavaScript wrapper for sys.ML_PREDICT_TABLE. The other variant of this method is a wrapper for sys.ML_PREDICT_ROW, and predicts a label for a single set of sample data and returns it to the caller. Both versions are shown here.

Version 1

Predicts labels, saving them in the output table specified by the user.

Signature

  • Press CTRL+C to copy
    Forecaster.predict( Table testData, Table outputTable[, Object options] )

Arguments

  • testData (Table): Table containing test data.

  • outputTable (Table): Table in which to store labels. The output written to the table uses the same content and format as that generated by the AutoML ML_PREDICT_TABLE routine.

  • options (Object) (optional): Set of options in JSON format. For more information, see ML_PREDICT_TABLE.

Return type

  • None. (Inserts into a target table.)

Version 2

Predicts a label for a single sample of data, and returns it. See ML_PREDICT_ROW, for more information about type and format of the value returned.

Signature

  • Press CTRL+C to copy
    String Forecaster.predict( Object sample )

Arguments

  • sample (Object): Sample data containing members that were used for training; extra members may be included but are ignored during prediction.

Return type

Forecaster.score()

Returns the score for the test data in the indicated table and column, using the specified metric. For possible metric values and their effects, see Optimization and Scoring Metrics.

score() is a JavaScript wrapper for sys.ML_SCORE.

Signature

  • Press CTRL+C to copy
    score( Table testData, String targetColumnName, String metric[, Object options] )

Arguments

  • testData (Table): Table which contains the test data. The table must contain the same columns as the training dataset.

  • targetColumnName (String): Name of the target column containing ground truth values.

  • metric (String): Name of the scoring metric. See Optimization and Scoring Metrics, for information about metrics which can be used for HeatWave AutoML forecasting.

  • options (Object) (optional): A set of options in JSON key-value format. For more information, see ML_SCORE.

Return type

  • Number.

Forecaster.unload()

Unloads the model. This method is a wrapper for sys.ML_MODEL_UNLOAD; see the description of this routine in the HeatWave AutoML documentation for more information.

Signature

  • Press CTRL+C to copy
    Forecaster.unload()

Arguments

  • None.

Return type

  • None.