InterviewStack.io LogoInterviewStack.io

Linear and Logistic Regression Implementation Questions

Covers the fundamentals and implementation details of linear regression for continuous prediction and logistic regression for binary or multiclass classification. Candidates should understand model formulation, hypothesis functions, and the intuition behind fitting a line or hyperplane for regression and using a sigmoid or softmax function for classification. Include loss functions such as mean squared error for regression and cross entropy loss for classification, optimization methods including gradient descent and variants, regularization techniques, feature engineering and scaling, metrics for evaluation such as mean absolute error and accuracy and area under curve, and hyperparameter selection and validation strategies. Expect discussion of practical implementation using numerical libraries and machine learning toolkits, trade offs and limitations of each approach, numerical stability, and common pitfalls such as underfitting and overfitting.

MediumTechnical
0 practiced
You have mixed numeric and categorical features with skewed numeric distributions. Describe a feature engineering plan tailored to linear and logistic regression: transformations (log, Box-Cox), handling outliers, adding interaction / polynomial terms, encoding rare categorical values, and how these choices impact interpretability and bias-variance trade-off.
EasyTechnical
0 practiced
Write a Python function using scikit-learn that splits a dataset into train, validation, and test sets while preserving class proportions for a binary classification problem (stratified split). Function signature: stratified_train_val_test_split(X, y, test_size, val_size, random_state). Return (X_train, X_val, X_test, y_train, y_val, y_test).
MediumTechnical
0 practiced
Explain probability calibration for classifiers. Compare Platt scaling and isotonic regression: how they work, strengths and weaknesses, and how to evaluate calibration (calibration curve, Brier score). When would you prefer a parametric method (Platt) versus a non-parametric (isotonic) approach?
HardTechnical
0 practiced
Using PyTorch, implement a single-layer neural network equivalent to sklearn's logistic regression (binary). Show the model definition, training loop using BCEWithLogitsLoss, how to apply L2 regularization via optimizer weight_decay, and how to incorporate class weights. Run a small experiment to show that trained weights are similar to sklearn's LogisticRegression under matching hyperparameters.
MediumTechnical
0 practiced
Design a hyperparameter tuning strategy for linear and logistic regression with hyperparameters: regularization strength (alpha), polynomial feature degree, learning rate, and l1_ratio (elastic net). Explain when to use grid search, random search, or Bayesian optimization and describe how to use nested cross-validation to get an unbiased estimate of generalization performance.

Unlock Full Question Bank

Get access to hundreds of Linear and Logistic Regression Implementation interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.