Class SVM<T>
java.lang.Object
smile.model.svm.KernelMachine<T>
smile.anomaly.SVM<T>
- Type Parameters:
T- the data type of model input objects.
- All Implemented Interfaces:
Serializable
One-class support vector machines for novelty detection.
One-class SVM relies on identifying the smallest hypersphere
consisting of all the data points. Therefore, it is sensitive to outliers.
If the training data is not contaminated by outliers, the model is best
suited for novelty detection.
The KernelMachine.score(Object) method (inherited from KernelMachine)
returns the raw decision function value: positive values indicate
inliers (normal observations) and negative values indicate
anomalies. This convention is the opposite of IsolationForest,
where higher scores signal anomalies.
References
- B. Schölkopf, J. Platt, J. Shawe-Taylor, A. J. Smola, and R. C. Williamson. Estimating the support of a high-dimensional distribution. Neural Computation, 2001.
- Jia Jiong and Zhang Hao-ran. A Fast Learning Algorithm for One-Class Support Vector Machine. ICNC 2007.
- See Also:
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionSVM(MercerKernel<T> kernel, T[] vectors, double[] weight, double b) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> SVM<T> fit(T[] x, MercerKernel<T> kernel) Fits a one-class SVM.static <T> SVM<T> fit(T[] x, MercerKernel<T> kernel, SVM.Options options) Fits a one-class SVM.booleanPredicts whether a sample is an anomaly.double[]Returns the decision function values for an array of samples.
-
Constructor Details
-
SVM
Constructor.- Parameters:
kernel- Kernel function.vectors- The support vectors.weight- The weights of instances.b- The intercept;
-
-
Method Details
-
fit
Fits a one-class SVM.- Type Parameters:
T- the data type.- Parameters:
x- training samples.kernel- the kernel function.- Returns:
- the model.
-
fit
Fits a one-class SVM.- Type Parameters:
T- the data type.- Parameters:
x- training samples.kernel- the kernel function.options- the hyperparameters.- Returns:
- the model.
-
score
Returns the decision function values for an array of samples. Positive values indicate inliers; negative values indicate anomalies.- Parameters:
x- the samples.- Returns:
- the decision function values.
-
predict
Predicts whether a sample is an anomaly. A sample is considered an anomaly when its decision function value is belowthreshold. Usethreshold = 0.0for the natural SVM decision boundary.- Parameters:
x- the sample.threshold- the decision value threshold below which the sample is declared an anomaly.- Returns:
trueif the sample is predicted as an anomaly.
-