Train and evaluate logistic model with regularization

Quick Overview

This question evaluates proficiency in supervised binary classification with logistic regression, implementation of L1 and L2 regularization, data preprocessing (missingness checks and standardization), hyperparameter selection via cross-validation, and model evaluation using ROC AUC and threshold-dependent metrics.

Train and evaluate logistic model with regularization

Company: Atlassian

Role: Data Scientist

Category: Machine Learning

Difficulty: medium

Interview Round: Technical Screen

You have two CSVs: training set x and test set x_test. Each has 7 columns: the first is the binary outcome y ∈ {0,1}; the next 6 are continuous features f1–f6. Using either Python (scikit-learn) or R (glmnet), write code to: (1) Load data (X_train = columns 2–7 of x; y_train = column 1; X_test = columns 2–7 of x_test; y_test = column 1). (2) Perform basic diagnostics: missingness, summary stats, feature scaling, and a correlation/collinearity check (report any |r| ≥ 0.8). (3) Fit a baseline logistic regression, then regularized models with L1 (Lasso) and L2 (Ridge). Use cross-validation to select the penalty strength (C in sklearn or lambda in glmnet). (4) Report metrics on the held-out test set: ROC AUC (required) and at least one threshold-dependent metric (e.g., F1 at the threshold maximizing Youden’s J on the validation fold). (5) Compare models, justify the chosen regularization, and identify the most important features (non-zero for L1 or largest absolute standardized coefficients for L2). (6) Provide the final predicted probabilities for X_test and a confusion matrix at your selected threshold.

Overview: This question evaluates proficiency in supervised binary classification with logistic regression, implementation of L1 and L2 regularization, data preprocessing (missingness checks and standardization), hyperparameter selection via cross-validation, and model evaluation using ROC AUC and threshold-dependent metrics.

|Home/Machine Learning/Atlassian
Atlassian logo
Atlassian
Oct 13, 2025
mediumData ScientistTechnical ScreenMachine Learning
5
0

Binary Classification with Logistic Regression and Regularization

Data

  • Two CSVs: a training set x and a test set x_test .
  • Each has 7 columns:
    • Column 1: binary outcome y ∈ {0, 1}.
    • Columns 2–7: six continuous features f1–f6.

Task

Using Python (scikit-learn) or R (glmnet), do the following:

  1. Load data
    • X_train = columns 2–7 of x ; y_train = column 1 of x .
    • X_test = columns 2–7 of x_test ; y_test = column 1 of x_test .
  2. Basic diagnostics
    • Check missingness by column.
    • Provide summary statistics for features.
    • Standardize features.
    • Compute pairwise feature correlations; report any |r| ≥ 0.8.
  3. Modeling
    • Fit a baseline logistic regression (no regularization).
    • Fit regularized models with L1 (Lasso) and L2 (Ridge) penalties.
    • Use cross-validation to select penalty strength (C in scikit-learn or lambda in glmnet).
  4. Evaluation on held-out test set
    • Report ROC AUC (required).
    • Report at least one threshold-dependent metric (e.g., F1) at the threshold that maximizes Youden’s J, selected on validation folds.
  5. Model comparison and interpretation
    • Compare baseline, L1, and L2 models and justify the chosen regularization.
    • Identify the most important features:
      • L1: non-zero coefficients.
      • L2: features with largest absolute standardized coefficients.
  6. Outputs
    • Final predicted probabilities for X_test.
    • Confusion matrix on X_test at the selected threshold.
Loading comments...