Relative Content

Tag Archive for pythonmachine-learningscikit-learnencoding

Leave one out encoding on test set with transform

Context: When preprocessing a data set using sklearn, you use fit_transform on the training set and transform on the test set, to avoid data leakage. Using leave one out (LOO) encoding, you need the target variable value to calculate the encoded value of a feature value. When using the LOO encoder in a pipeline, you can apply it to the training set using the fit_transform function, which accepts the features (X) and the target values (y).