Python problem representation

To encapsulate the Friedman-1 feature selection problem, we've created a Python class called Friedman1Test. This class can be found in the friedman.py file, which is located at https://github.com/PacktPublishing/Hands-On-Genetic-Algorithms-with-Python/blob/master/Chapter07/friedman.py.

The main parts of this class are as follows:

  1. The __init__() method of the class creates the dataset, as follows:
self.X, self.y = datasets.make_friedman1(n_samples=self.numSamples,                                      n_features=self.numFeatures,                                     noise=self.NOISE,                                      random_state=self.randomSeed)
  1. Then, it divides the data into two subsets –a training set and a validation set – using the scikit-learn model_selection.train_test_split() method:
self.X_train, self ...

Get Hands-On Genetic Algorithms with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.