Am new to ML and working on a dataset with lot of categorical variables with high cardinality.
I observed that in lot of tutorials for encoding like here, the encoding is applied after the train and test split.
Can I check why is it done so?
Why can't we apply the encoding even before the train test split?
Can't we apply the encoding to the full dataset and after encoding, split it into train and test sets?
What difference does it make?