Record Class ClassificationModel
java.lang.Object
java.lang.Record
smile.model.ClassificationModel
- Record Components:
algorithm- the algorithm name.schema- the schema of input data (without response variable).formula- the model formula.classifier- the classification model.train- the training metrics.validation- the cross-validation metrics.test- the test metrics.- the model metadata tags.
- All Implemented Interfaces:
Serializable, Model
public record ClassificationModel(String algorithm, StructType schema, Formula formula, DataFrameClassifier classifier, ClassificationMetrics train, ClassificationMetrics validation, ClassificationMetrics test, Properties tags)
extends Record
implements Model, Serializable
The classification model.
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionClassificationModel(String algorithm, StructType schema, Formula formula, DataFrameClassifier classifier, ClassificationMetrics train, ClassificationMetrics validation, ClassificationMetrics test, Properties tags) Creates an instance of aClassificationModelrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thealgorithmrecord component.Returns the value of theclassifierrecord component.final booleanIndicates whether some other object is "equal to" this one.formula()Returns the value of theformularecord component.final inthashCode()Returns a hash code value for this object.Performs batch inference over a data frame.infer(DataFrame data, boolean probability, boolean explain, KernelSHAP.Options options) Performs batch inference over a data frame with customKernelSHAP.Options.Performs inference on a single tuple.infer(Tuple x, boolean probability, boolean explain, KernelSHAP.Options options) Performs inference on a single tuple with customKernelSHAP.Options.booleanisOnline()Returns true if this model supports online learning updates.intReturns the number of classes.intModel inference.intModel inference.schema()Returns the value of theschemarecord component.double[][]Computes SHAP values for the input tuple.double[][]shap(Tuple x, KernelSHAP.Options options) Computes SHAP values for the input tuple with customKernelSHAP.Options.booleanReturns true if this model supports SHAP feature explanations.tags()Returns the value of thetagsrecord component.test()Returns the value of thetestrecord component.final StringtoString()Returns a string representation of this record class.train()Returns the value of thetrainrecord component.voidOnline updates the model with a single observation.voidOnline updates the classification model with a new training instance.Returns the value of thevalidationrecord component.
-
Constructor Details
-
ClassificationModel
public ClassificationModel(String algorithm, StructType schema, Formula formula, DataFrameClassifier classifier, ClassificationMetrics train, ClassificationMetrics validation, ClassificationMetrics test, Properties tags) Creates an instance of aClassificationModelrecord class.- Parameters:
algorithm- the value for thealgorithmrecord componentschema- the value for theschemarecord componentformula- the value for theformularecord componentclassifier- the value for theclassifierrecord componenttrain- the value for thetrainrecord componentvalidation- the value for thevalidationrecord componenttest- the value for thetestrecord componenttags- the value for thetagsrecord component
-
-
Method Details
-
predict
Model inference.- Parameters:
x- the input tuple.- Returns:
- the prediction.
-
predict
Model inference.- Parameters:
x- the input tuple.posteriori- a posteriori probabilities on output.- Returns:
- the prediction.
-
numClasses
public int numClasses()Returns the number of classes.- Returns:
- the number of classes.
-
isOnline
-
update
-
update
Online updates the classification model with a new training instance.- Parameters:
x- the input tuple.y- the class label.
-
supportsShap
public boolean supportsShap()Description copied from interface:ModelReturns true if this model supports SHAP feature explanations.- Specified by:
supportsShapin interfaceModel- Returns:
- true if SHAP explanations are supported.
-
shap
-
shap
Description copied from interface:ModelComputes SHAP values for the input tuple with customKernelSHAP.Options. -
infer
Description copied from interface:ModelPerforms inference on a single tuple. -
infer
Description copied from interface:ModelPerforms inference on a single tuple with customKernelSHAP.Options. -
infer
Description copied from interface:ModelPerforms batch inference over a data frame. -
infer
public Prediction[] infer(DataFrame data, boolean probability, boolean explain, KernelSHAP.Options options) Description copied from interface:ModelPerforms batch inference over a data frame with customKernelSHAP.Options. -
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
algorithm
-
schema
Returns the value of theschemarecord component. -
formula
-
classifier
Returns the value of theclassifierrecord component.- Returns:
- the value of the
classifierrecord component
-
train
-
validation
Returns the value of thevalidationrecord component.- Returns:
- the value of the
validationrecord component
-
test
-
tags
Returns the value of thetagsrecord component.
-