%ML.TrainedModel
Class %ML.TrainedModel Extends %Persistent [ ClassType = persistent, System = 4 ]
Base class for a trained model
Properties
Model
Property Model As %ML.Model [ Required ];
Base model we trained on
Provider
Property Provider As %String(MAXLEN = 128) [ Required ];
ML Provider that did the training
TrainingRun
Property TrainingRun As %ML.TrainingRun;
Training run
TrainedAt
Property TrainedAt As %TimeStamp [ InitialExpression = {$ZDATETIME($ZTIMESTAMP,3,1,3)}, Required ];
Timestamp for when the model was trained (UTC)
ModelName
Property ModelName As %String(MAXLEN = 275) [ Required ];
Trained Model name, same as the name for the cooresponding Training Run
ModelType
Property ModelType As %String(VALUELIST = ",classification,regression,timeseries");
Model type
ModelInfo
Property ModelInfo As array Of %String(MAXLEN = 1024);
Model information
Triggers
DeleteTrigger
Trigger DeleteTrigger [ Event = DELETE, Foreach = row/object ]
When deleting a TrainedModel, also delete any %ML.ValidationRun and %ML.ValidationMetric objects for this Model
%DeleteTrainedModelTrigger
Trigger %DeleteTrainedModelTrigger [ Event = DELETE, Foreach = row/object ]
When deleting a TrainedModel Purge any cached queries that used this trained model
Methods
%PredictAll
Method %PredictAll(tfn As %Integer, argspos As %List, predpos As %List, probpos As %List = "", expr As %String = "") As %Status
Bulk Predict arguments: tfn - tempfile index argspos - Positions of the WithColumns in the temp rows, $list(column-positions) predpos - Position of the predicted value, $list(result-column-positions) probpos - Position of the probability value, $list(result-column-positions) expr - expression for probability returns: $$$OK on success, otherwise a $$$ERROR(...)
%Begin
Method %Begin() As %Status [ Abstract ]
Begin model operations
%End
Method %End() As %Status [ Abstract ]
End model operations
%Predict
Method %Predict(data As %List, ByRef results As %List) As %Status [ Abstract ]
Predict on an ML model
%Probability
Method %Probability(expr As %String = 1, data As %List, ByRef results As %List) As %Status [ Abstract ]
Predict probability on an ML model Arguments: expr: The argument of PROBABILITY's FOR clause, defaults to 1 data: $List of WITH clause values results: PBR, return value
%ValidateClassifier
Method %ValidateClassifier(query As %String, ByRef validationRun As %ML.ValidationRun, using As %DynamicObject = {$$$NULLOREF}) [ Internal ]
Note: Do not call this method directly. Please refer to the SQL syntax as documented in %ML.Model
This method produces %ML.ValidationMetric records for Precision, Recall, F-Measure and ROC-AUC for this TrainedModel instance. For multi-class classifications, these metrics will be calculated for every predicted field value (category), as well as a micro-average across all target values. For binary classifications, these metrics will only be calculated for the "positive" (1, "true" or "yes") category, or for the first value encountered if no such value is found. Overall Accuracy and ROC-AUC numbers are also saved.
A full implementation is included in this class, so there is no need for providers to override anything unless there's a compelling argument on performance or breadth of supported metrics to do so.
%GetROCAUC
ClassMethod %GetROCAUC(modelName, category, predictedCol, validateTblQuery, Output ROCAUC) As %Status
Compute the area under the ROC curve for a given label category where
modelName is the name of an %ML.TrainedModel object
predictedCol is the name of the label column
tblQuery points to the validation table.
The output is returned in the ROCAUC variable.
ExecQuery
ClassMethod ExecQuery(query, Output tRS As %SQL.StatementResult) As %Status [ Internal ]
Note: Do not call this method directly.
This is a utility method that accepts a SQL query and populates results into a %SQL.Statement object.
%ValidateRegression
Method %ValidateRegression(query As %String, ByRef validationRun As %ML.ValidationRun, using As %DynamicObject = {$$$NULLOREF}) [ Internal ]
Note: Do not call this method directly. Please refer to the SQL syntax as documented in %ML.Model
This method produces %ML.ValidationMetric records for Variance, MSE, RMSE and R� for this TrainedModel instance.
A full implementation is included in this class, so there is no need for providers to override anything unless there's a compelling argument on performance or breadth of supported metrics to do so.
%ValidateTimeseries
Method %ValidateTimeseries(query As %String, ByRef validationRun As %ML.ValidationRun, using As %DynamicObject = {$$$NULLOREF}) [ Internal ]
Note: Do not call this method directly. Please refer to the SQL syntax as documented in %ML.Model
This method produces %ML.ValidationMetric records for Variance, MAPE, for this TrainedModel instance.
A full implementation is included in this class, so there is no need for providers to override anything unless there's a compelling argument on performance or breadth of supported metrics to do so.
%OnBeforeSave
Method %OnBeforeSave(insert As %Boolean) As %Status [ Private, ServerOnly = 1 ]
This callback method is invoked by the %Save method to provide notification that the object is being saved. It is called before any data is written to disk.
insert will be set to 1 if this object is being saved for the first time.
If this method returns an error then the call to %Save will fail.