How to do it...

Let's first import the necessary Python libraries and get the dataset ready:

  1. Import the required Python libraries, functions, and classes:
import pandas as pdimport matplotlib.pyplot as pltfrom sklearn.model_selection import train_test_splitfrom feature_engine.categorical_encoders import OrdinalCategoricalEncoder
  1. Let's load the dataset and divide it into train and test sets:
data = pd.read_csv('creditApprovalUCI.csv')X_train, X_test, y_train, y_test = train_test_split(data,         data['A16'], test_size=0.3, random_state=0)
Note that to encode with integers based on the target with pandas, we need to keep the target in the X_train and X_test datasets.

To better understand the monotonic relationship concept, let's plot the relationship ...

Get Python Feature Engineering Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.