Hands-On Genetic Algorithms with Python Apply Genetic Algorithms to Solve Real-World AI and Machine Learning Problems
Written by Eyal Wirsansky, a senior data scientist and AI researcher with over 25 years of experience and a research background in genetic algorithms and neural networks, Hands-On Genetic Algorithms with Python offers expert insights and practical knowledge to master genetic algorithms. After an int...
Otros Autores: | |
---|---|
Formato: | Libro electrónico |
Idioma: | Inglés |
Publicado: |
Birmingham, England :
Packt Publishing
2024.
|
Edición: | Second edition |
Materias: | |
Ver en Biblioteca Universitat Ramon Llull: | https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009840468906719 |
Tabla de Contenidos:
- Cover
- Title page
- Copyright and credits
- Contributors
- Table of Contents
- Preface
- Part 1: The Basics of Genetic Algorithms
- Chapter 1: An Introduction to Genetic Algorithms
- What are genetic algorithms?
- Darwinian evolution
- The genetic algorithms analogy
- The theory behind genetic algorithms
- The schema theorem
- Differences from traditional algorithms
- Population-based
- Genetic representation
- Fitness function
- Probabilistic behavior
- Advantages of genetic algorithms
- Global optimization
- Handling complex problems
- Handling a lack of mathematical representation
- Resilience to noise
- Parallelism
- Continuous learning
- Limitations of genetic algorithms
- Special definitions
- Hyperparameter tuning
- Computationally intensive
- Premature convergence
- No guaranteed solution
- Use cases for genetic algorithms
- Summary
- Further reading
- Chapter 2: Understanding the Key Components of Genetic Algorithms
- The basic flow of a genetic algorithm
- Creating the initial population
- Calculating the fitness
- Applying selection, crossover, and mutation
- Checking the stopping conditions
- Selection methods
- Roulette wheel selection
- Stochastic universal sampling
- Rank-based selection
- Fitness scaling
- Tournament selection
- Crossover methods
- Single-point crossover
- Two-point and k-point crossover
- Uniform crossover
- Crossover for ordered lists
- Mutation methods
- Flip-bit mutation
- Swap mutation
- Inversion mutation
- Scramble mutation
- Real-coded genetic algorithms
- Blend crossover
- Simulated binary crossover
- Real mutation
- Understanding elitism
- Niching and sharing
- Serial niching versus parallel niching
- The art of solving problems using genetic algorithms
- Summary
- Further reading
- Part 2: Solving Problems with Genetic Algorithms.
- Chapter 3: Using the DEAP Framework
- Technical requirements
- Python version
- Using a virtual environment
- Installing the necessary libraries
- Introduction to DEAP
- Using the creator module
- Creating the Fitness class
- Creating the Individual class
- Using the Toolbox class
- Creating genetic operators
- Creating the population
- Calculating the fitness
- The OneMax problem
- Solving the OneMax problem with DEAP
- Choosing the chromosome
- Calculating the fitness
- Choosing the genetic operators
- Setting the stopping condition
- Implementing with DEAP
- Using built-in algorithms
- The Statistics object
- The algorithm
- The logbook
- Running the program
- Adding the hall of fame feature
- Experimenting with the algorithm's settings
- Population size and number of generations
- Crossover operator
- Mutation operator
- Selection operator
- Summary
- Further reading
- Chapter 4: Combinatorial Optimization
- Technical requirements
- Search problems and combinatorial optimization
- Solving the knapsack problem
- The Rosetta Code knapsack 0-1 problem
- Solution representation
- Python problem representation
- Genetic algorithm solution
- Solving the TSP
- TSPLIB benchmark files
- Solution representation
- Python problem representation
- Genetic algorithm solution
- Improving the results with enhanced exploration and elitism
- Solving the VRP
- Solution representation
- Python problem representation
- Genetic algorithm solution
- Summary
- Further reading
- Chapter 5: Constraint Satisfaction
- Technical requirements
- Constraint satisfaction in search problems
- Solving the N-Queens problem
- Solution representation
- Python problem representation
- Genetic algorithms solution
- Solving the nurse scheduling problem
- Solution representation
- Hard constraints versus soft constraints.
- Python problem representation
- Genetic algorithms solution
- Solving the graph coloring problem
- Solution representation
- Using hard and soft constraints for the graph coloring problem
- Python problem representation
- Genetic algorithms solution
- Summary
- Further reading
- Chapter 6: Optimizing Continuous Functions
- Technical requirements
- Chromosomes and genetic operators for real numbers
- Using DEAP with continuous functions
- Optimizing the Eggholder function
- Optimizing the Eggholder function with genetic algorithms
- Improving the speed with an increased mutation rate
- Optimizing Himmelblau's function
- Optimizing Himmelblau's function with genetic algorithms
- Using niching and sharing to find multiple solutions
- Simionescu's function and constrained optimization
- Constrained optimization with genetic algorithms
- Optimizing Simionescu's function using genetic algorithms
- Using constraints to find multiple solutions
- Summary
- Further reading
- Part 3: Artificial Intelligence Applications of Genetic Algorithms
- Chapter 7: Enhancing Machine Learning Models Using Feature Selection
- Technical requirements
- Supervised machine learning
- Classification
- Regression
- Supervised learning algorithms
- Feature selection in supervised learning
- Selecting the features for the Friedman-1 regression problem
- Solution representation
- Python problem representation
- Genetic algorithms solution
- Selecting the features for classifying the Zoo dataset
- Python problem representation
- Genetic algorithms solution
- Summary
- Further reading
- Chapter 8: Hyperparameter Tuning of Machine Learning Models
- Technical requirements
- Hyperparameters in machine learning
- Hyperparameter tuning
- The Wine dataset
- The adaptive boosting classifier.
- Tuning the hyperparameters using conventional versus genetic grid search
- Testing the classifier's default performance
- Running the conventional grid search
- Running the genetic-algorithm-driven grid search
- Tuning the hyperparameters using a direct genetic approach
- Hyperparameter representation
- Evaluating the classifier accuracy
- Tuning the hyperparameters using genetic algorithms
- Dedicated libraries
- Summary
- Further reading
- Chapter 9: Architecture Optimization of Deep Learning Networks
- Technical requirements
- ANNs and DL
- MLP
- DL and convolutional NNs
- Optimizing the architecture of a DL classifier
- The Iris flower dataset
- Representing the hidden layer configuration
- Evaluating the classifier's accuracy
- Optimizing the MLP architecture using genetic algorithms
- Combining architecture optimization with hyperparameter tuning
- Solution representation
- Evaluating the classifier's accuracy
- Optimizing the MLP's combined configuration using genetic algorithms
- Summary
- Further reading
- Chapter 10: Reinforcement Learning with Genetic Algorithms
- Technical requirements
- Reinforcement learning
- Genetic algorithms and reinforcement learning
- Gymnasium
- The env interface
- Solving the MountainCar environment
- Solution representation
- Evaluating the solution
- The Python problem representation
- Genetic algorithms solution
- Solving the CartPole environment
- Controlling the CartPole with a neural network
- Solution representation and evaluation
- The Python problem representation
- A genetic algorithm solution
- Summary
- Further reading
- Chapter 11: Natural Language Processing
- Technical requirements
- Understanding NLP
- Word embeddings
- Word embeddings and genetic algorithms
- Finding the mystery word using genetic algorithms
- Python implementation.
- Document classification
- N-grams
- Selecting a subset of n-grams
- Using genetic algorithms to search for a fixed-size subset
- Python implementation
- Summary
- Further reading
- Chapter 12: Explainable AI, Causality, and Counterfactuals with Genetic Algorithms
- Technical requirements
- Unlocking the black box - XAI
- Unraveling cause and effect - causality in AI
- What-if scenarios - counterfactuals
- Genetic algorithms in counterfactual analysis - navigating alternative scenarios
- The German Credit Risk dataset
- Exploring counterfactual scenarios for credit risk prediction
- The Applicant class
- The CreditRiskData class
- Counterfactuals with genetic algorithms
- The genetic algorithm solution
- More "what-if" scenarios
- Extending to other datasets
- Summary
- Further reading
- Part 4: Enhancing Performance with Concurrency and Cloud Strategies
- Chapter 13: Accelerating Genetic Algorithms - the Power of Concurrency
- Technical requirements
- Long runtimes in real-world genetic algorithms
- Parallelizing genetic algorithms
- Multithreading
- Multiprocessing
- Back to the OneMax problem
- A baseline benchmark program
- Simulating computational intensity
- Multiprocessing using the Pool class
- Increasing the number of processes
- Multiprocessing using the SCOOP library
- Distributed computing with SCOOP
- Summary
- Further reading
- Chapter 14: Beyond Local Resources - Scaling Genetic Algorithms in the Cloud
- Technical requirements
- The next level in genetic algorithm performance -embracing a client-server architecture
- Implementing a client-server model
- Using a separate environment
- Revisiting the One-Max problem, yet again
- Creating the server component
- Creating the client component
- Running the asynchronous client
- Using a production-grade app server.
- Using the Gunicorn server.