ATML Unit2
ATML Unit2
Machine Learning
Unit 2 : Outlier Detection and Dimensionality
Reduction
Text Books:
1. Charu C. Aggarwal, Outlier Analysis, 2nd edition, Springer, 2017
Web references:
https://www.analyticsvidhya.com/blog/2024/03/one-class-svm-for-anomaly-detection/
Outliers
An outlier is a data point that significantly deviates from the rest of the data.
It can be either much higher or much lower than the other data points, and its
presence can have a significant impact on the results of machine learning
algorithms.
They can be caused by measurement or execution errors.
Algorithm
1. Calculate the mean of each cluster
2. Initialize the Threshold value
3. Calculate the distance of the test data from each cluster mean
4. Find the nearest cluster to the test data
5. If (Distance > Threshold) then, Outlier
Outliers
Anomalies
Anomalies are observations or instances that deviate significantly from a
dataset’s normal behavior.
These deviations can manifest in various forms, such as outliers, noise, errors,
or unexpected patterns.
Outlier and novelty detection identify anomalies and abnormal or uncommon
observations.
The One-Class Support Vector Machine (SVM) is a variant of the traditional SVM. It is
specifically tailored to detect anomalies. Its primary aim is to locate instances that
notably deviate from the standard.
SVM revisit
A new regularization parameter C controls the trade-off between maximizing the margin and
minimizing the loss.
As you can see, the difference between the primal problem and the one for the hard margin is
the addition of slack variables. The new slack variables ( in the figure) add flexibility for
misclassifications of the model:
One Class SVM vs Traditional SVM
One-class SVM aims to discover a hyperplane with maximum margin within the
feature space by separating the mapped data from the origin. On a dataset Dn
= {x1, . . . , xn} with xi ∈ X (xi is a feature) and n dimensions:
w.x + b =0 is the decision boundary, and patterns in the data. Fine-tuning gamma is
the slack variables penalize deviations. essential for achieving optimal model
performance.
Kernel functions play a crucial role in One-Class SVM by allowing the algorithm to
operate in higher-dimensional feature spaces without explicitly computing the
transformations.
These kernels map the original input space into a higher-dimensional space, where
data points become linearly separable or exhibit more distinct patterns, facilitating
learning.
One Class SVM
In One-Class SVM, the margin represents the region where most of the data points
belonging to the target class lie.
Maximizing the margin is crucial for One-Class SVM as it helps generalize new data
points well and improves the model’s robustness.
In One-Class SVM, support vectors are the data points from the target class closest
to the decision boundary.
These support vectors play a significant role in determining the shape and
orientation of the decision boundary and, thus, in the overall performance of the
One-Class SVM model.
One Class SVM
The plots allow us to visually inspect the performance of the One-Class SVM models in detecting
outliers in the Wine dataset. By comparing the results of hard margin and soft margin One-Class
SVM models, we can observe how the choice of margin setting (nu parameter) affects outlier
detection.
The hard margin model with a very small nu value (0.01) likely results in a more
conservative decision boundary. It tightly wraps around the majority of the data points and
potentially classifies fewer points as outliers.
Conversely, the soft margin model with a larger nu value (0.35) likely results in a more
flexible decision boundary. Thus allowing for a wider margin and potentially capturing more