Skip to content
C

Problem 2: Observe Lasso Zeroing Out Coefficients

Easypython

Problem Description

Write a Python program that trains a Lasso model with a sufficiently high alpha value on a dataset with some irrelevant features, and identifies which coefficients were shrunk to exactly zero.

Input

A dataset with some clearly irrelevant features (e.g., random noise).

Output

The learned coefficients, and which ones equal zero.

Constraints

  • At least one feature should be essentially random/irrelevant.

Example Input

text
(A dataset with 1 relevant feature and 1 random/irrelevant feature)

Example Output

text
Coefficients: [2.5, 0.0] Zeroed-out features: [1]

Concepts Covered

Lasso, coefficient inspection, automatic feature selection.

Input (stdin)

Output

Run your code to see output here...