What does OneHotEncoder(handle_unknown='ignore') do at transform time when it meets a category never seen during fit?
Correct answer
B. It encodes that row as all zeros instead of raising an error
15 views
B. It encodes that row as all zeros instead of raising an error
15 views
Unknown category handling matters in production, because live data contains levels the training set never saw. The default handle_unknown='error' raises, while 'ignore' produces an all-zero row, which most linear models read as the reference level. Grouping rare levels before fitting, or using a hashing encoder, avoids the problem entirely.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is B? Ask here and get an explanation.