Skip to content
CampusEduX

Problem 3: Remove Low-Variance Features

Easypython
Learn the Concept: Feature Selection

Problem Description

Write a Python program that identifies and removes any numeric column whose variance is below a given threshold.

Input

A DataFrame with numeric columns, and a variance threshold value.

Output

The DataFrame with low-variance columns removed, and a list of which columns were dropped.

Constraints

  • Threshold will be a small positive number (e.g., 0.01).

Example Input

text
{"a": [1,1,1,1], "b": [10,20,30,40]}, threshold=0.01

Example Output

text
Dropped columns: ['a'] Remaining columns: ['b']

Concepts Covered

.var(), conditional column filtering.

Related Problems

  • Problem 1: Compute and Display a Correlation Matrix
    Easy · python
    Solve Problem
  • Problem 2: Identify Features Most Correlated with the Target
    Easy · python
    Solve Problem
  • Problem 4: Drop One of Two Highly Correlated Features
    Easy · python
    Solve Problem

Input (stdin)

Output

Run your code to see output here...