Skip to content
DeepForgeby svx
All problems
EasyML Fundamentalsml-263

Target Encoding Leakage Check

Problem

Flag a target-encoding leakage risk: return True when the fraction of unique categories exceeds threshold.

Empty input returns False.

Hint

High-cardinality features memorized by target encoding can leak labels.

Test cases

case 1
in: [["a","a","b","b"],0.4]
expected: true
case 2
in: [["a","a","b","b"],0.6]
expected: false
case 3
in: [["a","a","b","b"],0.5]
expected: false
case 4
in: [[],0.4]
expected: false
Starter codePython
def target_encoding_leakage(categories, threshold):
    # Your code here
    pass

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