OneClassSVM<T>
Models & Types · AiDotNet.AnomalyDetection.Linear
Implements One-Class SVM for novelty/outlier detection using the RBF kernel.
Inheritance: ModelBase<T, Matrix<T>, Vector<T>> → AnomalyDetectorBase<T> → OneClassSVM<T>
Implements: IGeneratedParameterRegistrar<T>
For Beginners
One-Class SVM learns a “boundary” around your normal data points. New points that fall outside this boundary are considered outliers. It’s like drawing a flexible shape around your data - anything outside the shape is unusual.
How It Works
The algorithm works by:
- Mapping data to a high-dimensional space using the RBF (Radial Basis Function) kernel
- Finding a hyperplane that separates most data points from the origin
- Points far from this hyperplane (on the wrong side) are outliers
When to use: One-Class SVM is particularly effective for:
- Novelty detection (training only on “normal” data)
- When you have a clear notion of what “normal” looks like
- Data with complex, non-linear boundaries
Industry Standard Defaults:
- Nu: 0.1 (upper bound on outlier fraction)
- Gamma: Auto-detect (1/n_features)
- Max iterations: 1000
- Tolerance: 1e-3
Reference: Schölkopf, B., Platt, J. C., Shawe-Taylor, J., Smola, A. J., and Williamson, R. C. (2001). “Estimating the Support of a High-Dimensional Distribution.” Neural Computation.
Constructors
| Constructor | Summary |
|---|---|
OneClassSVM(double nu, double gamma, int maxIterations, double tolerance, double contamination, int randomSeed) |
Creates a new One-Class SVM anomaly detector. |
Properties
| Property | Summary |
|---|---|
double Gamma { get; } |
Gets the gamma parameter for the RBF kernel. |
double Nu { get; } |
Gets the nu parameter (upper bound on outlier fraction). |
int NumSupportVectors { get; } |
Gets the number of support vectors after fitting. |
Methods
| Method | Summary |
|---|---|
Vector<T> ScoreAnomalies(Matrix<T> X) |
|
void Fit(Matrix<T> X) |