Fit logistic regression and return top features

Read the full interview experience this question came from →

Quick Overview

This question evaluates understanding of binary logistic regression, coefficient-based feature importance, and practical model-fitting considerations such as intercept inclusion and input shape handling.

Fit logistic regression and return top features

Company: Roblox

Role: Data Scientist

Category: Machine Learning

Difficulty: hard

Interview Round: Online Assessment

You are given: - `X`: a 2D numeric array where **each row is a feature** and each column is an observation (shape: `n_features x n_samples`). - `feature_names`: a list of length `n_features`. - `y`: a binary outcome array of length `n_samples` with values in {0, 1}. Task: 1) Fit a (binary) **logistic regression** model to predict `y` from `X`. - Include an intercept. - No regularization unless explicitly stated. 2) Rank features by the absolute value of their fitted coefficients (exclude the intercept). 3) Return the **top 3 feature names** by `|coef|` (break ties by lexicographic order of `feature_names`). Output: - A list of 3 strings (feature names).

Overview: This question evaluates understanding of binary logistic regression, coefficient-based feature importance, and practical model-fitting considerations such as intercept inclusion and input shape handling.

Read the full Roblox Data Scientist interview experience this question came from

Roblox logo
Roblox
Nov 23, 2025
hardData ScientistOnline AssessmentMachine Learning
5
0

You are given:

  • X : a 2D numeric array where each row is a feature and each column is an observation (shape: n_features x n_samples ).
  • feature_names : a list of length n_features .
  • y : a binary outcome array of length n_samples with values in {0, 1}.

Task:

  1. Fit a (binary) logistic regression model to predict y from X .
    • Include an intercept.
    • No regularization unless explicitly stated.
  2. Rank features by the absolute value of their fitted coefficients (exclude the intercept).
  3. Return the top 3 feature names by |coef| (break ties by lexicographic order of feature_names ).

Output:

  • A list of 3 strings (feature names).