A wind farm fits a row of strain gauges along every turbine blade. Cracks are rare and nobody has ever labelled one, so the team trained an autoencoder on months of gauge readings from blades in good condition. Each reading is a short list of strain values, and the autoencoder returns its rebuilt version of it.
The plan is the one from the lesson: a reading the model cannot rebuild well is something it has never seen, so it earns a visit from an inspector. The only open question is how badly rebuilt counts as badly, and the team answers it with a held-out set of healthy readings the model was not trained on.
A reading's error is its reconstruction loss: subtract the rebuilt reading from the original position by position, square, and average over the positions. Compute the error of every healthy reading; if is the mean of those errors and their standard deviation, the alarm threshold is
Task: write flag_anomalies(healthy, healthy_rebuilt, incoming, incoming_rebuilt, k).
healthy holds the held-out normal readings and healthy_rebuilt their reconstructions. The threshold is built from these alone.incoming holds new readings and incoming_rebuilt their reconstructions. An incoming reading is flagged when its error is strictly greater than the threshold.[threshold, flagged]: the threshold rounded to 4 decimal places, then a list of the 0-based positions of the flagged incoming readings in increasing order (empty if none). Compare errors against the unrounded threshold.Nothing in this procedure has ever seen a cracked blade. The monitor works because the autoencoder only learned to rebuild healthy strain patterns well; it has no idea what a crack looks like, and it does not need one.