I have a dataset of 50000 observations with columns of high cardinality. The best way to encode them is with mean encoding, then to use regularization. I will use CV rather than smoothing. But when I see people use it, they use it on train and test set.
Should I first split my dataset into train and test set and then encode or can I encode directly from the beginning on my full dataset?
If I should split the data into train and test set first, can someone tell me why?