PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Machine Learning/NewsBreak

Derive and implement calibration via temperature scaling

Last updated: Mar 29, 2026

Quick Overview

This Machine Learning question evaluates understanding of model calibration and probabilistic outputs via temperature scaling, requiring formulation of the negative log-likelihood, analytic gradient derivation with respect to a scalar temperature, and coding an optimization to learn that parameter.

  • medium
  • NewsBreak
  • Machine Learning
  • Machine Learning Engineer

Derive and implement calibration via temperature scaling

Company: NewsBreak

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Technical Screen

Given a trained softmax classifier with logits z, derive temperature scaling for probability calibration: define p_i(x; T) = softmax(z_i(x) / T). Formulate the negative log-likelihood on a held-out validation set and derive the gradient with respect to T. Then write Python code to learn T by minimizing this objective (e.g., with gradient descent) and a function that applies the learned T to calibrate new predictions.

Quick Answer: This Machine Learning question evaluates understanding of model calibration and probabilistic outputs via temperature scaling, requiring formulation of the negative log-likelihood, analytic gradient derivation with respect to a scalar temperature, and coding an optimization to learn that parameter.

Related Interview Questions

  • Find Optimal Piecewise Constant Regression Parameters - NewsBreak (medium)
  • Design approach for class imbalance - NewsBreak (hard)
NewsBreak logo
NewsBreak
Aug 9, 2025, 12:00 AM
Machine Learning Engineer
Technical Screen
Machine Learning
2
0

Temperature Scaling for Softmax Calibration

Context

You have a trained multi-class classifier that outputs logits z(x) ∈ R^K for input x (the classifier is fixed; only calibration is learned). Temperature scaling calibrates predicted probabilities as:

p_i(x; T) = softmax(z_i(x) / T)

where T > 0 is a single scalar temperature shared across classes and inputs.

You are given a held-out validation set with logits and true labels, and you must learn T by minimizing negative log-likelihood (NLL).

Task

  1. Write the NLL on the validation set as a function of T.
  2. Derive the gradient of this NLL with respect to T.
  3. Implement Python code that learns T by minimizing this NLL (e.g., gradient descent), and provide a function that applies the learned T to calibrate new predictions.

Solution

Show

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Machine Learning•More NewsBreak•More Machine Learning Engineer•NewsBreak Machine Learning Engineer•NewsBreak Machine Learning•Machine Learning Engineer Machine Learning
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.