16  Self study - Session 3

CautionStill under construction

This section is still under construction and will be completed in the near future. Please do not go beyond this point for now.

In this session, we will have a look at clustering and anomaly detection applied to the AI4I predictive maintenance dataset from Chapter 13.

In Chapter 13 we have focused on supervised learning (classification) for predicting failures. However, in many real-world industrial scenarios, labeled failure data is scarce or expensive to obtain. Unsupervised methods such as clustering and anomaly detection can help discover hidden patterns and identify unusual behavior without prior labels.

Note

This section will again use the AI4I dataset described in Chapter 13.


16.1 Exercise A: Clustering the AI4I dataset

Exercise 16.1 (k-Means clustering on machine data)  

  1. Load the AI4I dataset and select the continuous sensor features (Air temperature, Process temperature, Rotational speed, Torque, Tool wear).
  2. Use k-Means clustering with different values of \(k\) to cluster the data and the elbow method to determine an appropriate \(k\).
  3. Visualize the clusters using pair plots.
  4. Compare the resulting clusters with the known failure types. Do the clusters align with any specific failure?

16.2 Exercise B: DBSCAN and density-based clustering

Exercise 16.2 (Finding dense regions with DBSCAN)  

  1. Apply DBSCAN to the standardized AI4I features. Experiment with different eps and min_samples values.
  2. DBSCAN can identify outliers as noise points. How many data points are classified as noise?
  3. Visualize the DBSCAN results alongside the k-Means results from the previous exercise.
  4. Discuss: Which algorithm better separates the different failure types? What are the limitations of each approach?

16.3 Exercise C: Anomaly detection

Exercise 16.3 (Detecting anomalous machine behavior)  

  1. Train an isolation forest or one-class SVM on the AI4I data (you can use only the “normal” or non-failure samples as training data).
  2. Predict anomalies on the full dataset and visualize the results.
  3. Compare the detected anomalies with the known failure labels. Do anomalies correspond to specific failure types?
  4. What threshold would you set for an early warning system in a real manufacturing environment?

16.4 Exercise D: Feature spaces and alarm thresholds

Exercise 16.4 (Does the feature space matter?)  

In Exercise C, you treated the anomaly detector as a yes/no decision. Now, use the anomaly score as a continuous ranking and evaluate it quantitatively.

  1. Build three standardized feature sets: (i) the five raw sensor features, (ii) the engineered features power, temp_diff, Tool wear, and strain \(= \text{torque} \cdot \text{tool wear}\), and (iii) the union of both.
  2. For each feature set, fit an isolation forest and a Gaussian mixture model (a distribution-based method, compare Chapter 7) on the non-failure samples only. Use the negative log-likelihood of the Gaussian mixture model as its anomaly score.
  3. For each failure type, compute the average precision (sklearn.metrics.average_precision_score) of the anomaly scores and collect the results in a table (rows: detector and feature set, columns: failure types). Compare against the baseline of a random ranking, which equals the failure rate.
  4. Which failure types can be detected as anomalies, and which cannot? Use the failure descriptions in Section 13.1.7 to explain why a failure is not necessarily an anomaly.
  5. Assume that a missed failure costs 100 times as much as a false alarm. Choose the threshold of your best detector that minimizes the total cost and report how many alarms per 1,000 processes an operator would have to handle. Compare with the threshold you proposed in Exercise C.