Implementing the Genetic Algorithm
GA is one of the variants of the Heuristic Search hyperparameter tuning group (see Chapter 5) that can be implemented by the DEAP package. To show you how we can implement GA with the DEAP package, let’s use the Random Forest classifier model and the same data as in the examples in Chapter 7. The dataset used in this example is the Banking Dataset – Marketing Targets dataset provided on Kaggle (https://www.kaggle.com/datasets/prakharrathi25/banking-dataset-marketing-targets).
The target variable consists of two classes, yes
or no
, indicating whether the client of the bank has subscribed to a term deposit or not. Hence, the goal of training an ML model on this dataset is to identify whether a customer is potentially wanting to subscribe to the term deposit or not. Out of the 16 features provided in the data, there are seven numerical features and nine categorical features. As for the target class distribution, 12% of them are yes...