Skip to content
DeepForgeby svx
All problems
MediumML Fundamentalsml-316

Data Leakage Correlation Flags

Problem

Flag features whose correlation with the target is high on the training split but collapses on the test split. A feature i is flagged when abs(train_corrs[i]) >= min_train_corr and abs(train_corrs[i]) - abs(test_corrs[i]) >= min_gap. Return the sorted indices, comparing only up to the shorter input; empty input returns [].

Hint

A strong training correlation that vanishes out of sample is a classic leakage signature.

Test cases

case 1
in: [[0.9,0.2,0.75],[0.1,0.3,0.7],0.7,0.1]
expected: [0]
case 2
in: [[0.95,0.85,0.6],[0.2,0.8,0.1],0.5,0.2]
expected: [0,2]
case 3
in: [[0.5],[0.5],0.6,0]
expected: []
case 4
in: [[],[],0.5,0.1]
expected: []
Starter codePython
def leakage_flags(train_corrs, test_corrs, min_train_corr, min_gap):
    # Your code here
    pass

4 test cases · run your code against them in the editor