Without labels, the problem becomes finding structure in the data and identifying observations that do not fit it.
Choosing the number of clusters
Diminishing returns: as number of clusters increase,
WCSS (sum of squared distances between data points and their assigned cluster centroids) decreases
after a certain point, adding more clusters yeild only a small decrease in WCSS, phenonmenon aka deminishing retursn, furhter increasing number of culsters may not improve Clustering quality
Within-cluster squared distances
Computes sum of squared distances between each data point and centroid of cluster to which it is assigned

Anomaly detection
Looking at unlabeled data and determining unusual datapoints
Can be used in fraud detection, quality analysis
Density estimation
e is the constant term that we set
If P(x) <= e
then the sample is anomalous

Gaussian density
x is a number, probability of x is determined by Guassian with mean μ, variance

The model for probability is defined as


Determine anomaly if P(x) < e
K-fold cross-validation
Split data into k equal size partitions
Use k-1 partitions for training data, use 1 partition for validation
Evaluate model performance on validation set
Repeat the training and validation process k times, each time with different partitions for validation set
After completing k rounds, compute average of k metrics to get single performance estimate
Helps in generalising the model
Anomaly detection or supervised learning?
Used when dataset has large number of normal examples and a very small number of anomalous examples (0-20 is common).
It learns patterns of normal data and flags deviations as anomalies, making it more effective at catching new, previously unseen anomalies.
Supervised learning works well when the dataset has a balanced or large number of both normal and anomalous examples. It learns from the labeled examples and can effectively detect known, previously seen anomalies, but may struggle to identify new types of anomalies that differ significantly from the training data.
In manufacturing applications, Anomaly detection is more suitable for finding new, previously unseen defects, while supervised learning is better for identifying known, previously seen defects.