MySQL 9.3 Reference Manual Including MySQL NDB Cluster 9.3
This class encapsulates the classification task as described in
Training a Model.
Classifier
supports methods for loading,
training, and unloading models, predicting labels, calculating
probabilities, producing explainers, and related tasks.
An instance of Classifier
has three
accessible properties, listed here:
metadata
(Object
):
Model metadata stored in the model catalog. See
Model Metadata.
trainOptions
(Object
):
The training options specified in the constructor.
You can obtain an instance of Classifier
by
invoking its constructor, shown here:
Signature
new ml.Classifier( Stringname
[, ObjecttrainOptions
] )
Arguments
name
(String
): Unique identifier for this
Classifier
.
trainOptions
(Object
)
(optional): Training options; these
are the same as the training options used with
sys.ML_TRAIN
.
Return type
An instance of Classifier
.
It is also possible to obtain a
Classifier
by invoking
ml.load()
. See
ml.load(), for more information.
Trains and loads a new classifier. This method acts as a
wrapper for both sys.ML_TRAIN
and sys.ML_MODEL_LOAD
, but is
specific to the HeatWave AutoML classification task.
Signature
Classifier.train( TabletrainData
, StringtargetColumnName
)
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.
targetColumnName
(String
): Name of the target column
containing ground truth values. The type used for this
column cannot be TEXT
.
Return type
None.
An alias for
train()
, and
identical to it in all respects save the method name. See
Classifier.train(), for more
information.
This method predicts labels; it has two variants, one of which
predicts labels from data found in the indicated table and
stores them in an output table; this is a wrapper for
sys.ML_PREDICT_TABLE
. The other
variant of this method acts as 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 of
predict()
are shown here.
Predicts labels and saves them in the specified output table.
Signature
Classifier.predict( TabletestData
, TableoutputTable
[, Objectoptions
] )
Arguments
testData
(Table
): Table
containing test data.
outputTable
(Table
): Table in which to store
labels. The content and format of the output is the same
as that generated by ML_PREDICT_TABLE
.
options
(Object
)
(optional): Set of options in JSON
format. See ML_PREDICT_TABLE,
for more information.
Return type
None. (Inserts into
outputTable
; see
ML_PREDICT_ROW.)
Predicts a label for a single sample of data, and returns it. See ML_PREDICT_ROW, for more information.
Signature
String Classifier.predict(
Object sample
)
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.
Return type
String
. See the documentation for
ML_PREDICT_ROW
for more
information.
Obtains the probabilities for all classes of the passed sample
data. Like the single-argument version of
predict()
, this
method is a wrapper for
sys.ML_PREDICT_ROW
, but unlike
predict()
,
predictProba()
returns the probabilities
only.
Signature
Classifier.predict(
Object sample
)
Arguments
sample
(Object
): Sample data, in the form of a
JSON object. As with the single-argument version of
Classifier.predict()
,
this argument must contain members that were used for
training; extra members may be included, but these are
ignored during prediction.
Return type
Object
. The probabilities for the
sample data, in JSON format.
Returns the score for the test data in the indicated table and column. For possible metric values and their effects, see Optimization and Scoring Metrics.
This method serves as a JavaScript wrapper for
sys.ML_SCORE
.
Signature
score( TabletestData
, StringtargetColumnName
, Stringmetric
[, Objectoptions
] )
Arguments
testData
(Table
): Table
containing test data to be scored; this 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 the metrics compatible with AutoML
classification.
options
(Object
)
(optional): A set of options in JSON
format. See the description of
ML_SCORE
for more
information.
Return type
Number
.
Given a Table
containing a
labeled, trained dataset and the name of a table column
containing ground truth values, this method returns the newly
trained explainer.
This method serves as a wrapper for the HeatWave AutoML
sys.ML_EXPLAIN
routine; see the
description of that routine for further information.
Signature
explain( Tabledata
, StringtargetColumnName
[, Objectoptions
] )
Arguments
data
(Table
): A table
containing trained data.
targetColumnName
(String
): The name of the column
containing ground truth values.
options
(Object
)
(optional): A set of optional
parameters, in JSON format.
Return type
None. Adds a model explainer to the model catalog; see ML_EXPLAIN, for more information.
Returns an explainer for this classifier, if one exists.
Signature
Object Classifier.getExplainer()
Arguments
None.
Return type
Object
Unloads the model. This method is a wrapper for
sys.ML_MODEL_UNLOAD
.
Signature
Classifier.unload()
Arguments
None.
Return type
undefined