Implement GLM Training and Prediction from an Explicit Family and Link
Company: Quantbot Technologies
Role: Data Scientist
Category: Machine Learning
Difficulty: hard
Interview Round: Online Assessment
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?
```hint 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.
```
### What a Strong Answer Covers
- A correct GLM formulation and explicit family/link assumptions.
- A training loss and optimizer consistent with that model, including numerical stability.
- Prediction semantics, validation, convergence checks, and boundaries of the chosen implementation.
### 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?
Overview: Explain a from-scratch generalized linear model through family and link selection, consistent loss and gradients, numerical stability, and prediction semantics.