Skip to content
Quantoros

Why can TargetEncoder.fittransform(X, y) differ from fit(X, y).transform(X) on training rows?

Classic MLLevel: AdvancedCross-fitted target encoding

Why can TargetEncoder.fit_transform(X, y) differ from fit(X, y).transform(X) on training rows?

Hints
  • Ask whether a row contributes to its own encoding.
  • Training and inference encodings need different construction.

Answer

This answer is part of mentoring

Advanced questions come with a full breakdown and a mock interview with a working quant researcher. The first call is free.

Source and licence: scikit-learn 1.7.2 — preprocessing · BSD-3-Clause · answer: Quantoros editorial

Related questions