Sobes.tech
Middle — Senior

What is One-Class SVM?

sobes.tech AI

Answer from AI

One-Class SVM is a machine learning algorithm used for anomaly detection and outlier detection. It is trained on data from a single class (usually normal examples) and attempts to define a boundary that separates this data from all other possible data.

The main idea is to find a region in the feature space where normal data is concentrated, and classify new objects as normal if they fall within this region, or as anomalies if they are outside.

Applications:

  • Fraud detection
  • Equipment monitoring
  • Unusual behavior detection

Example of usage in Python with scikit-learn library:

from sklearn.svm import OneClassSVM

# Training data (normal examples)
X_train = [[0, 0], [1, 1], [0.5, 0.5], [1, 0]]

# Create model
model = OneClassSVM(gamma='auto').fit(X_train)

# Test new data
X_test = [[0, 0], [2, 2]]
pred = model.predict(X_test)  # 1 — normal, -1 — anomalies
print(pred)

Thus, One-Class SVM helps identify objects that significantly differ from the training set.