What this book covers
Chapter 1, An Introduction to Genetic Algorithms, introduces the basics and theory of genetic algorithms, drawing parallels with Darwinian evolution. It contrasts these algorithms with traditional ones, discussing their advantages, limitations, and practical applications. The chapter concludes by highlighting scenarios where genetic algorithms are particularly effective.
Chapter 2, Understanding the Key Components of Genetic Algorithms, provides a comprehensive exploration of genetic algorithms, starting with an outline of a genetic algorithm’s basic flow. It then explores its core components and progresses to examine real coded genetic algorithms while covering advanced concepts such as elitism, niching, and sharing. It concludes with insights into the art of problem-solving using genetic algorithms.
Chapter 3, Using the DEAP Framework, introduces the DEAP framework (a versatile tool for solving real-world problems with genetic algorithms), guides you through its main modules, and demonstrates how to construct essential genetic algorithm components. This is demonstrated by programming a solution to the OneMax problem, followed by experiments with different settings of the genetic algorithm, revealing the impact of various modifications.
Chapter 4, Combinatorial Optimization, explores the application of genetic algorithms in combinatorial optimization while providing Python-based solutions using the DEAP framework. Key optimization problems covered include the Knapsack, Traveling Salesman, and Vehicle Routing problems. Additionally, the chapter discusses genotype-to-phenotype mapping and the balance between exploration and exploitation.
Chapter 5, Constraint Satisfaction, starts by defining the concept of constraint satisfaction and its relevance to search problems and combinatorial optimization. It then presents practical examples of these problems and their solutions using the DEAP framework. Key problems explored include the N-Queen, nurse scheduling, and graph coloring problems. Additionally, it explores the distinction between hard and soft constraints and their integration into the solution process.
Chapter 6, Optimizing Continuous Functions, explores the application of genetic algorithms in optimizing continuous search spaces, using real number-based genetic operators and DEAP framework tools. This chapter presents Python-based solutions for optimizing functions such as the Eggholder, Himmelblau’s, and Simionescu’s functions, incorporating techniques such as niching and sharing, and addressing constraints.
Chapter 7, Enhancing Machine Learning Models Using Feature Selection, explains the use of genetic algorithms to enhance supervised machine learning models through feature selection. It begins with an introduction to machine learning, focusing on regression and classification tasks, and discusses the benefits of feature selection in improving model performance. The chapter then demonstrates the use of genetic algorithms in identifying key features in a test regression problem and in optimizing a classification model using the Zoo dataset by isolating the most effective features.
Chapter 8, Hyperparameter Tuning of Machine Learning Models, explores the enhancement of supervised machine learning models through genetic algorithm-based hyperparameter tuning. After introducing hyperparameter tuning and the grid search concept in machine learning, it uses the Wine dataset and the adaptive boosting classifier as case studies. The chapter compares conventional grid search with a genetic algorithm-driven grid search for hyperparameter tuning, concluding with an attempt to further refine results using a direct genetic algorithm approach.
Chapter 9, Architecture Optimization of Deep Learning Networks, focuses on enhancing artificial neural network-based models through genetic algorithm-driven optimization of network architecture. It begins with an introduction to neural networks and deep learning, followed by a case study using the Iris dataset and the Multilayer Perceptron classifier. The chapter demonstrates network architecture optimization through a genetic algorithm-based solution and extends this approach to include simultaneous optimization of network architecture and model hyperparameters.
Chapter 10, Reinforcement Learning with Genetic Algorithms, illustrates the application of genetic algorithms in reinforcement learning, using two benchmark environments from the Gymnasium toolkit. It begins with an overview of reinforcement learning and an introduction to the Gymnasium toolkit and its Python interface. The focus then shifts to tackling the MountainCar and CartPole environments, developing genetic algorithm-based solutions for these specific challenges.
Chapter 11, Natural Language Processing, dives into the intersection of genetic algorithms and NLP. It introduces NLP and word embeddings and demonstrates their use in a Semantle-like mystery-word game where a genetic algorithm guesses the mystery word. The chapter also examines n-grams and document classification, employing genetic algorithms to select a concise and efficient feature subset, thereby enhancing understanding of the classifier’s functionality.
Chapter 12, Explainable AI, Causality, and Counterfactuals with Genetic Algorithms, investigates the use of genetic algorithms for generating “what if” scenarios in explainable AI and causality, emphasizing counterfactual analysis. It introduces these fields and the concept of counterfactuals, followed by a practical application of the German Credit Risk dataset using genetic algorithms, uncovering valuable insights through counterfactual analysis.
Chapter 13, Accelerating Genetic Algorithms – the Power of Concurrency, explores enhancing genetic algorithms’ performance using concurrency, focusing on multiprocessing. It discusses the benefits of applying concurrency and demonstrates it through Python’s built-in functionalities as well as an external library. Various multiprocessing approaches are tested on a CPU-intensive variant of the OneMax problem, evaluating the performance improvements achieved.
Chapter 14, Beyond Local Resources – Scaling Genetic Algorithms in the Cloud, expands on enhancing genetic algorithm performance through a client-server model, using asynchronous I/O and cloud-based server computations on AWS Lambda. It discusses the split-architecture benefits, applies it to the OneMax problem, and guides through deploying a Flask server and an asyncio client, culminating in AWS Lambda deployment to showcase cloud-enhanced genetic algorithm efficiency.
Chapter 15, Evolutionary Image Reconstruction with Genetic Algorithms, explores genetic algorithms in image processing, focusing on reconstructing images with semi-transparent polygons. It starts with an overview of image processing in Python and explains creating images from scratch with polygons and calculating image differences. It concludes with developing a genetic algorithm-based program to reconstruct a famous painting using polygons, examining the evolutionary process and results.
Chapter 16, Other Evolutionary and Bio-Inspired Computation Techniques, introduces a variety of problem-solving and optimization techniques related to genetic algorithms. It covers genetic programming, NeuroEvolution of Augmenting Topologies (NEAT), and particle swarm optimization, demonstrating each through problem-solving Python programs. The chapter concludes with an overview of several other related computation paradigms.