PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Machine Learning/NewsBreak

Find Optimal Piecewise Constant Regression Parameters

Last updated: May 2, 2026

Quick Overview

This Machine Learning question evaluates parameter estimation and model selection for a one-split piecewise constant regression model, testing understanding of optimal segment parameter derivation and efficient threshold selection.

  • medium
  • NewsBreak
  • Machine Learning
  • Software Engineer

Find Optimal Piecewise Constant Regression Parameters

Company: NewsBreak

Role: Software Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Technical Screen

Given a dataset of one-dimensional training examples \((x_i, y_i)\) for \(i = 1, \dots, n\), fit a one-split piecewise constant regression model: \[ \hat{y}_i = \begin{cases} b_1, & x_i \le t \\ b_2, & x_i > t \end{cases} \] Find the values of \(b_1\), \(b_2\), and threshold \(t\) that minimize the mean squared error: \[ \frac{1}{n}\sum_{i=1}^{n}(y_i - \hat{y}_i)^2. \] Explain the optimal choice of \(b_1\) and \(b_2\) for a fixed threshold, and describe an efficient algorithm for finding the globally optimal threshold.

Quick Answer: This Machine Learning question evaluates parameter estimation and model selection for a one-split piecewise constant regression model, testing understanding of optimal segment parameter derivation and efficient threshold selection.

Related Interview Questions

  • Derive and implement calibration via temperature scaling - NewsBreak (medium)
  • Design approach for class imbalance - NewsBreak (hard)
NewsBreak logo
NewsBreak
Apr 10, 2026, 12:00 AM
Software Engineer
Technical Screen
Machine Learning
0
0
Loading...

Given a dataset of one-dimensional training examples (xi,yi)(x_i, y_i)(xi​,yi​) for i=1,…,ni = 1, \dots, ni=1,…,n, fit a one-split piecewise constant regression model:

y^i={b1,xi≤tb2,xi>t\hat{y}_i = \begin{cases} b_1, & x_i \le t \\ b_2, & x_i > t \end{cases}y^​i​={b1​,b2​,​xi​≤txi​>t​

Find the values of b1b_1b1​, b2b_2b2​, and threshold ttt that minimize the mean squared error:

1n∑i=1n(yi−y^i)2.\frac{1}{n}\sum_{i=1}^{n}(y_i - \hat{y}_i)^2.n1​∑i=1n​(yi​−y^​i​)2.

Explain the optimal choice of b1b_1b1​ and b2b_2b2​ for a fixed threshold, and describe an efficient algorithm for finding the globally optimal threshold.

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

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

Master your tech interviews with 7,500+ 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.