Book Image

Scala for Machine Learning

By : Patrick R. Nicolas
Book Image

Scala for Machine Learning

By: Patrick R. Nicolas

Overview of this book

Table of Contents (20 chapters)
Scala for Machine Learning
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Implementation


As mentioned earlier, the genetic operators are independent of the problem to be solved. Let's implement all the components of the reproduction cycle. The fitness function and the encoding scheme are highly domain specific.

In accordance with the principles of object-oriented programming, the software architecture defines the genetic operators using a top-down approach: starting with the population, then each chromosome, and down to each gene.

Software design

The implementation of the genetic algorithm uses a design that is similar to the template for classifiers (refer to the Design template for classifier section in the Appendix A, Basic Concepts).

The key components of the implementation of the genetic algorithm are as follows:

  • The Population class defines the current set of solution candidates or chromosomes.

  • The GASolver class implements the GA solver and has two components: a configuration object of the GAConfig type and the initial population. This class implements an explicit...