Documentation Home
MySQL 9.4 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 41.2Mb
PDF (A4) - 41.3Mb
Man Pages (TGZ) - 262.8Kb
Man Pages (Zip) - 368.8Kb
Info (Gzip) - 4.1Mb
Info (Zip) - 4.1Mb


27.3.10.1 AnomalyDetector Class

This class encapsulates the anomaly detection task as described inDetect Anomalies.AnomalyDetector supports methods for loading, training, and unloading models, predicting labels, calculating probabilities, and related tasks.

AnomalyDetector provides the following accessible properties:

  • name (String): The model name.

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

  • trainOptions (Object): The training options specified in the constructor when creating an instance ofAnomalyDetector.

AnomalyDetector Constructor

TheAnomalyDetector class constructor is shown here:

AnomalyDetector class constructor

  • new ml.AnomalyDetector(  Stringname[,   ObjecttrainOptions])

Arguments

  • name (String): Unique identifier for thisAnomalyDetector.

  • trainOptions (Object) (optional): Training options; the same as the training options which can be used withsys.ML_TRAIN.

Return type

  • An instance ofAnomalyDetector.

AnomalyDetector.train()

Trains and loads a new anomaly detector. This method acts as a wrapper for bothsys.ML_TRAIN andsys.ML_MODEL_LOAD, but is specific to MySQL HeatWave AutoML anomaly detection.

Signature

  • AnomalyDetector.train(  TabletrainData,   StringtargetColumnName)

Arguments

  • trainData (Table): ATable 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.

  • targetColumnName (String): Name of the target column containing ground truth values. The type used for this column cannot beTEXT.

Return type

  • None.

AnomalyDetector.fit()

An alias fortrain(), and identical to it in all respects other than name. SeeAnomalyDetector.train(), for more information.

AnomalyDetector.predict()

This method predicts labels, acting as a wrapper forsys.ML_PREDICT_ROW.

Predicts a label for a single sample of data, and returns the label. SeeML_PREDICT_ROW, for more information.

Signature

  • String AnomalyDetector.predict(  Objectsample[,  Objectoptions])

Arguments

  • sample (Object): Sample data. This argument must contain members that were used for training; extra members may be included, but these are ignored during prediction.

  • options (Object) (optional): Set of one of more options.

Return type

  • String.

AnomalyDetector.score()

This method serves as a JavaScript wrapper forsys.ML_SCORE, returning the score for the test data in the specified table and column. For possible metrics, seeOptimization and Scoring Metrics.

Signature

  • score(  TabletestData,  StringtargetColumnName,   Stringmetric[,   Objectoptions])

Arguments

  • testData (Table): Table containing test data to be scored; 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 to use. SeeOptimization and Scoring Metrics, for information about metrics which can be used for AutoML anomaly detection.

  • options (Object) (optional): A set of options in JSON object format. See the description ofML_SCORE for more information.

Return type

  • Number.

AnomalyDetector.unload()

This method is a wrapper forsys.ML_MODEL_UNLOAD, and Unloads the model.

Signature

  • AnomalyDetector.unload()

Arguments

  • None.

Return type

  • None.