Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Anomaly Detection for Furnace Data

HardPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Anomaly Detection for Furnace Data. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Ati's Furnace Monitoring surface receives temperature readings from a titanium melting furnace in chronological order. Implement a robust anomaly detector that identifies readings whose deviation from nearby temperatures is unusually large, without allowing isolated extreme values to distort the baseline.

For each reading at index i, examine up to radius readings immediately before and after it, excluding the reading itself. Compute the neighborhood median and its median absolute deviation, or MAD. A reading is anomalous when its absolute deviation from the neighborhood median is greater than threshold * 1.4826 * MAD. If the MAD is zero, mark the reading anomalous when it differs from the neighborhood median. Return anomalous indices in ascending order.

Formal Specification

Input is readings, a nonempty list of numbers, radius, a positive integer, and threshold, a positive number. The output is a list of integer indices. At the boundaries, use all available neighbors. The input is already ordered by time.

Constraints

  • 3 <= len(readings) <= 200000
  • 1 <= radius <= 500
  • 0 < threshold <= 20
  • -10000 <= readings[i] <= 10000
  • Readings may contain integers or floating-point values

Function Signature

def detect_temperature_anomalies(readings, radius, threshold):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output