Model Selection class

The model selection is applied to find a neural network with a topology that minimizes the error for new data. There are two ways to obtain an optimal topology: neurons selection and input selection.

Neurons selection algorithms are used to get the optimal number of neurons in the neural network’s hidden perceptron layer. Input selection algorithms are responsible for finding the optimal subset of inputs.

As we did in the previous sections, we will continue working with the iris data set, which can be downloaded from the DataSet class chapter. Before continuing, it is also advisable to read the previous chapter, TrainingStrategy class.

To construct a model selection object associated with a training strategy object, we do the following:

ModelSelection model_selection(&training_strategy);

where training_strategy is the training strategy object.

The default model selection consists of a growing inputs selection algorithm or an incremental neurons selection algorithm. The next sentence allows us to change this.

model_selection.set_inputs_selection_method(ModelSelection::GENETIC_ALGORITHM);
model_selection.set_neurons_selection_method(ModelSelection::GROWING_NEURONS);
GeneticAlgorithm* genetic_algorithm = model_selection.get_genetic_algorithm_pointer();
genetic_algorithm->set_individuals_number(100);
GrowingNeurons* growing_neurons = model_selection.get_growing_neurons_pointer();
growing_neurons ->set_maximum_selection_failures(3);

The most important methods of model selection are the ones that perform the inputs and the neurons selection. Respectively, they are called as follows:

model_selection.perform_inputs_selection();
model_selection.perform_neurons_selection();

We can save the above object to a XML file.

model_selection.save("model_selection.xml");

If you need more information about ModelSelection class visit ModelSelection Class Reference.