skrub
skrub copied to clipboard
improve target encoder
A good way of doing target encoding (or impact coding) is to compute the value to encoding in a left out subset of the data, to avoid overfitting, for instance in a cross-validation loop.
The following code (nicely contributed by dataiku) can be adapted: https://gist.github.com/GaelVaroquaux/0d477f34f2e1e8036737a7ac88cce1fc