Implement GLM Training and Prediction from an Explicit Family and Link
Quantbot TechnologiesData Scientist · Online AssessmentLast updated
Explain a from-scratch generalized linear model through family and link selection, consistent loss and gradients, numerical stability, and prediction semantics.
Explain how you would implement training and prediction for a generalized linear model (GLM) from scratch. Define the model, objective, optimization procedure, and prediction behavior for one explicitly chosen illustrative family and link function.
Constraints
The response distribution, link, input schema, regularization, and numerical tolerances are not specified. Clarify them before claiming a unique executable implementation. Use your chosen GLM as an example rather than implying that the original task required logistic regression, linear regression, or another particular family.
Clarifying Questions
- What is the target's domain, and which distribution and link are required?
- Is an intercept included, and is regularization part of the objective?
- Are predictions expected as conditional means, probabilities, or thresholded labels?
- What convergence, initialization, and invalid-input behavior should be supported?
Hints
Hint 1
Connect the three GLM components: Identify the response family, the linear predictor, and the link between that predictor and the conditional mean before deriving an update.
Follow-up questions
- How would changing the response family change the loss and allowable predictions?
- What behavior would you expect from unregularized logistic regression on separable data?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.