TensorTonicTensorTonic
Problems
Study PlansProjectsNewInterviewPricingFeedback
Problems
Loading...
1 / 1

Data Drift Detection

MLOps
Easy

Compare a production histogram with a reference histogram using total variation distance. First normalize each list of counts into a probability distribution. Then compute:

DTV(P,Q)=12∑i∣pi−qi∣D_{TV}(P,Q)=\frac{1}{2}\sum_i |p_i-q_i|DTV​(P,Q)=21​i∑​∣pi​−qi​∣

Here, pip_ipi​ and qiq_iqi​ are the normalized probabilities for bin iii. Drift is detected only when the score is strictly greater than the threshold. Return a dictionary containing the score as a float and the drift_detected flag as a Boolean.

Loading visualization...

Examples

Input: reference_counts = [50, 50], production_counts = [55, 45], threshold = 0.1

Output: {"score": 0.05, "drift_detected": false}

Explanation: The absolute probability differences sum to 0.1, so TVD is 0.05.

Input: reference_counts = [50, 50], production_counts = [90, 10], threshold = 0.1

Output: {"score": 0.4, "drift_detected": true}

Hint 1

Divide every bin count by the total count of its histogram.

Hint 2

Sum the absolute differences between matching probabilities, then multiply by one half.

Requirements

  • Normalize both histograms independently
  • Compute total variation distance across corresponding bins
  • Use a strict comparison with the threshold
  • Return the score and drift_detected flag in a dictionary

Constraints

  • Both count lists have the same nonzero length
  • Every count is nonnegative
  • Each histogram has a positive total count
Try Similar Problems
Train Serving SkewMonitoring Metrics SelectionShadow Deployment EvaluationFeature Store LookupRetraining Trigger Design

Sign in to take notes on this problem

Case 1
Case 2

Accepts: array

Accepts: array

Accepts: number

You must run your code first.
PrevNext

Data Drift Detection

MLOps
Easy

Compare a production histogram with a reference histogram using total variation distance. First normalize each list of counts into a probability distribution. Then compute:

DTV(P,Q)=12∑i∣pi−qi∣D_{TV}(P,Q)=\frac{1}{2}\sum_i |p_i-q_i|DTV​(P,Q)=21​i∑​∣pi​−qi​∣

Here, pip_ipi​ and qiq_iqi​ are the normalized probabilities for bin iii. Drift is detected only when the score is strictly greater than the threshold. Return a dictionary containing the score as a float and the drift_detected flag as a Boolean.

Loading visualization...

Examples

Input: reference_counts = [50, 50], production_counts = [55, 45], threshold = 0.1

Output: {"score": 0.05, "drift_detected": false}

Explanation: The absolute probability differences sum to 0.1, so TVD is 0.05.

Input: reference_counts = [50, 50], production_counts = [90, 10], threshold = 0.1

Output: {"score": 0.4, "drift_detected": true}

Hint 1

Divide every bin count by the total count of its histogram.

Hint 2

Sum the absolute differences between matching probabilities, then multiply by one half.

Requirements

  • Normalize both histograms independently
  • Compute total variation distance across corresponding bins
  • Use a strict comparison with the threshold
  • Return the score and drift_detected flag in a dictionary

Constraints

  • Both count lists have the same nonzero length
  • Every count is nonnegative
  • Each histogram has a positive total count
Try Similar Problems
Train Serving SkewMonitoring Metrics SelectionShadow Deployment EvaluationFeature Store LookupRetraining Trigger Design

Sign in to take notes on this problem

Case 1
Case 2

Accepts: array

Accepts: array

Accepts: number

You must run your code first.