Back to Practice
#0188

Remove Leakage Features

MediumML25 min20 XP

Problem

Given feature_names and unavailable_names, return feature names that are safe to use.

Why This Matters

Leakage can make a model look excellent offline and fail in production. Feature availability is one of the first checks in real ML work.

Function Signature

def safe_features(feature_names, unavailable_names):

Examples

Example 1
Inputfeatures = ['age','future_payment','city'], unavailable = ['future_payment']
Output['age', 'city']

future_payment is removed because it would not be known at prediction time.

Constraints

  • Return the exact requested result.
  • Handle common edge cases.
  • Keep the solution readable before optimizing.
CodePython
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Core example
Inputfeatures = ['age','future_payment','city'], unavailable = ['future_payment']
Expected['age', 'city']

future_payment is removed because it would not be known at prediction time.

Hidden Test Categories
minimal inputrepeated valueslarger realistic input