TensorTonic
Problems
Isotonic Regression Calibration
Metrics & Evaluation
Hard

Fit a nondecreasing calibration mapping with the Pool Adjacent Violators algorithm. First sort calibration pairs by probability. Start with one block per binary label and repeatedly merge adjacent blocks whenever the earlier block mean exceeds the later block mean. Assign each point its final block mean.

This minimizes:

∑i=1n(yi−ci)2\sum_{i=1}^{n}(y_i-c_i)^2i=1∑n​(yi​−ci​)2

subject to:

c1≤c2≤⋯≤cnc_1\le c_2\le\cdots\le c_nc1​≤c2​≤⋯≤cn​

Here, yiy_iyi​ is the sorted calibration label and cic_ici​ is its fitted value. For each new probability, clamp outside the calibration range and linearly interpolate between neighboring fitted points inside the range. Return a list of calibrated probabilities in the original new-probability order.

Loading visualization...

Examples

Input: cal_labels = [0, 0, 1, 1], cal_probs = [0.1, 0.3, 0.7, 0.9], new_probs = [0.5]

Output: [0.5]

Explanation: The fitted values remain [0, 0, 1, 1], and 0.5 lies halfway between probabilities 0.3 and 0.7.

Input: cal_labels = [0, 1, 0, 1], cal_probs = [0.1, 0.4, 0.6, 0.9], new_probs = [0.2, 0.5, 0.8]

Output: [0.166667, 0.5, 0.833333]

Hint 1

Represent each PAV block by its label sum and point count.

Hint 2

After fitting, use binary search or a linear scan to find neighboring calibration probabilities.

Requirements

  • Sort calibration labels together with their probabilities
  • Fit nondecreasing values with adjacent-block merging
  • Clamp values outside the calibration range
  • Linearly interpolate values inside the range

Constraints

  • Calibration labels are zero or one
  • Calibration probabilities are distinct values between zero and one
  • At least two calibration pairs are provided
  • New probabilities lie between zero and one
Try Similar Problems
Compute ROC Curve from ScoresHardCompute Accuracy, Precision, Recall, F1MediumExpected Calibration ErrorMediumBinary Log Loss per Sample in PythonEasyLogistic Regression Training LoopMediumFit Elo Ratings from Pairwise VotesHardK-Fold Split (Indices Only)HardCompute Mean Average Precision (mAP)HardEvaluation Metrics (BLEU, ROUGE)MediumAUC-ROC from ScratchMediumA/B Test SignificanceMediumArea Under the ROC Curve via Trapezoidal RuleMedium
Scratchpad

Accepts: array

Accepts: array

Accepts: array

You must run your code first.
Isotonic Regression Calibration

Isotonic Regression Calibration

Metrics & Evaluation
Hard

Fit a nondecreasing calibration mapping with the Pool Adjacent Violators algorithm. First sort calibration pairs by probability. Start with one block per binary label and repeatedly merge adjacent blocks whenever the earlier block mean exceeds the later block mean. Assign each point its final block mean.

This minimizes:

∑i=1n(yi−ci)2\sum_{i=1}^{n}(y_i-c_i)^2i=1∑n​(yi​−ci​)2

subject to:

c1≤c2≤⋯≤cnc_1\le c_2\le\cdots\le c_nc1​≤c2​≤⋯≤cn​

Here, yiy_iyi​ is the sorted calibration label and cic_ici​ is its fitted value. For each new probability, clamp outside the calibration range and linearly interpolate between neighboring fitted points inside the range. Return a list of calibrated probabilities in the original new-probability order.

Loading visualization...

Examples

Input: cal_labels = [0, 0, 1, 1], cal_probs = [0.1, 0.3, 0.7, 0.9], new_probs = [0.5]

Output: [0.5]

Explanation: The fitted values remain [0, 0, 1, 1], and 0.5 lies halfway between probabilities 0.3 and 0.7.

Input: cal_labels = [0, 1, 0, 1], cal_probs = [0.1, 0.4, 0.6, 0.9], new_probs = [0.2, 0.5, 0.8]

Output: [0.166667, 0.5, 0.833333]

Hint 1

Represent each PAV block by its label sum and point count.

Hint 2

After fitting, use binary search or a linear scan to find neighboring calibration probabilities.

Requirements

  • Sort calibration labels together with their probabilities
  • Fit nondecreasing values with adjacent-block merging
  • Clamp values outside the calibration range
  • Linearly interpolate values inside the range

Constraints

  • Calibration labels are zero or one
  • Calibration probabilities are distinct values between zero and one
  • At least two calibration pairs are provided
  • New probabilities lie between zero and one
Try Similar Problems
Compute ROC Curve from ScoresHardCompute Accuracy, Precision, Recall, F1MediumExpected Calibration ErrorMediumBinary Log Loss per Sample in PythonEasyLogistic Regression Training LoopMediumFit Elo Ratings from Pairwise VotesHardK-Fold Split (Indices Only)HardCompute Mean Average Precision (mAP)HardEvaluation Metrics (BLEU, ROUGE)MediumAUC-ROC from ScratchMediumA/B Test SignificanceMediumArea Under the ROC Curve via Trapezoidal RuleMedium
Scratchpad

Accepts: array

Accepts: array

Accepts: array

You must run your code first.
Problems
Loading...
1 / 1