Model Selection class

Model selection is used to find a neural network topology that minimizes error on new data. Two ways to obtain an optimal topology are neuron selection and input selection.

Neuron selection algorithms aim to determine the optimal number of neurons in the neural network’s hidden perceptron layer, while input selection algorithms aim to determine the optimal subset of inputs.

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

To construct a model selection object associated with a training strategy object, we write:

// Initialize model selection
ModelSelection model_selection(&training_strategy);

The default model selection consists of a growing input or incremental neuron selection algorithm. The following sentence allows us to change this:

// Configure model selection strategies

model_selection.set_inputs_selection_method(
    ModelSelection::InputsSelectionMethod::GENETIC_ALGORITHM
);

model_selection.set_neurons_selection_method(
    ModelSelection::NeuronsSelectionMethod::GROWING_NEURONS
);

GeneticAlgorithm* genetic_algorithm =
    model_selection.get_genetic_algorithm();
genetic_algorithm->set_individuals_number(100);

GrowingNeurons* growing_neurons =
    model_selection.get_growing_neurons();
growing_neurons->set_maximum_selection_failures(3);

The main methods of model selection are those that perform input and neuron selection. To call them, we use:

// Run input and neuron selection
model_selection.perform_input_selection();
model_selection.perform_neurons_selection();

We can save the above object to an XML file.

// Save model selection configuration
model_selection.save("model_selection.xml");

For more information on the ModelSelection Class visit the ModelSelection Class Reference.