Record Class AnomalyModel
java.lang.Object
java.lang.Record
smile.model.AnomalyModel
- Record Components:
algorithm- the algorithm name.schema- the schema of input data (without response variable).formula- the model formula.detector- the underlying anomaly detector (IsolationForest,LOF, orSVM).threshold- the anomaly decision threshold.transform- optional feature preprocessing transform; may benull.- the model metadata tags.
- All Implemented Interfaces:
Serializable, Model
public record AnomalyModel(String algorithm, StructType schema, Formula formula, Serializable detector, double threshold, Transform transform, Properties tags)
extends Record
implements Model, Serializable
The anomaly detection model.
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionAnomalyModel(String algorithm, StructType schema, Formula formula, Serializable detector, double threshold, Properties tags) Constructs an anomaly detection model without a preprocessing transform.AnomalyModel(String algorithm, StructType schema, Formula formula, Serializable detector, double threshold, Transform transform, Properties tags) Creates an instance of aAnomalyModelrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thealgorithmrecord component.detector()Returns the value of thedetectorrecord 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.boolean[]Predicts whether each observation in a data frame is an anomaly.booleanPredicts whether a single observation is an anomaly using the model's threshold.schema()Returns the value of theschemarecord component.double[]Computes the anomaly or decision scores for a data frame.doubleComputes the anomaly or decision score for a single observation.tags()Returns the value of thetagsrecord component.doubleReturns the value of thethresholdrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thetransformrecord component.
-
Constructor Details
-
AnomalyModel
public AnomalyModel(String algorithm, StructType schema, Formula formula, Serializable detector, double threshold, Properties tags) Constructs an anomaly detection model without a preprocessing transform.- Parameters:
algorithm- the algorithm name.schema- the schema of input data (without response variable).formula- the model formula.detector- the underlying anomaly detector.threshold- the anomaly decision threshold.tags- the model metadata tags.
-
AnomalyModel
public AnomalyModel(String algorithm, StructType schema, Formula formula, Serializable detector, double threshold, Transform transform, Properties tags) Creates an instance of aAnomalyModelrecord class.- Parameters:
algorithm- the value for thealgorithmrecord componentschema- the value for theschemarecord componentformula- the value for theformularecord componentdetector- the value for thedetectorrecord componentthreshold- the value for thethresholdrecord componenttransform- the value for thetransformrecord componenttags- the value for thetagsrecord component
-
-
Method Details
-
score
Computes the anomaly or decision score for a single observation.- Parameters:
x- the input tuple.- Returns:
- the anomaly or decision score.
-
score
Computes the anomaly or decision scores for a data frame.- Parameters:
data- the input data frame.- Returns:
- the anomaly or decision scores.
-
predict
Predicts whether a single observation is an anomaly using the model's threshold.- Parameters:
x- the input tuple.- Returns:
trueif the observation is predicted as an anomaly.
-
predict
Predicts whether each observation in a data frame is an anomaly.- Parameters:
data- the input data frame.- Returns:
- an array of anomaly flags.
-
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
algorithm
-
schema
Returns the value of theschemarecord component. -
formula
-
detector
-
threshold
-
transform
-
tags
Returns the value of thetagsrecord component.
-