Reader small image

You're reading from  Hands-On Genetic Algorithms with Python

Product typeBook
Published inJan 2020
Reading LevelIntermediate
PublisherPackt
ISBN-139781838557744
Edition1st Edition
Languages
Right arrow
Author (1)
Eyal Wirsansky
Eyal Wirsansky
author image
Eyal Wirsansky

Eyal Wirsansky is a senior data scientist, an experienced software engineer, a technology community leader, and an artificial intelligence researcher. Eyal began his software engineering career over twenty-five years ago as a pioneer in the field of Voice over IP. He currently works as a member of the data platform team at Gradle, Inc. During his graduate studies, he focused his research on genetic algorithms and neural networks. A notable result of this research is a novel supervised machine learning algorithm that integrates both approaches. In addition to his professional roles, Eyal serves as an adjunct professor at Jacksonville University, where he teaches a class on artificial intelligence. He also leads both the Jacksonville, Florida Java User Group and the Artificial Intelligence for Enterprise virtual user group, and authors the developer-focused artificial intelligence blog, ai4java.
Read more about Eyal Wirsansky

Right arrow

Using the Toolbox class

The second mechanism offered by the DEAP framework is the base.Toolbox class. The Toolbox is used as a container for functions (or operators), and enables us to create new operators by aliasing and customizing existing functions.

For example, suppose we have a function, sumOfTwo(), defined as follows:

def sumOfTwo(a, b):
return a + b

Using toolbox, we can now create a new operator, incrementByFive(), which customizes the sumOfTwo() function as follows:

from deap import base
toolbox= base.Toolbox()
toolbox.register("incrementByFive", sumOfTwo, b=5)

The first argument passed to the register() toolbox function is the desired name (or alias) for the new operator. The second argument is the existing function to be customized. Then, each additional (optional) argument is automatically passed to the customized function whenever we call the new operator...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Hands-On Genetic Algorithms with Python
Published in: Jan 2020Publisher: PacktISBN-13: 9781838557744

Author (1)

author image
Eyal Wirsansky

Eyal Wirsansky is a senior data scientist, an experienced software engineer, a technology community leader, and an artificial intelligence researcher. Eyal began his software engineering career over twenty-five years ago as a pioneer in the field of Voice over IP. He currently works as a member of the data platform team at Gradle, Inc. During his graduate studies, he focused his research on genetic algorithms and neural networks. A notable result of this research is a novel supervised machine learning algorithm that integrates both approaches. In addition to his professional roles, Eyal serves as an adjunct professor at Jacksonville University, where he teaches a class on artificial intelligence. He also leads both the Jacksonville, Florida Java User Group and the Artificial Intelligence for Enterprise virtual user group, and authors the developer-focused artificial intelligence blog, ai4java.
Read more about Eyal Wirsansky