# Model Selection class

The model selection is applied to find a neural network with a topology that minimize the error for new data. There are two ways to obtain an optimal topology, the order selection and the inputs selection.

Order selection algorithms are used to get the optimal number of hidden perceptron in the neural network. Inputs selection algorithms are responsible for finding the optimal subset of inputs.

In this tutorial we are going to use the iris data set to show how to use some of the main methods in ModelSelection class so, before continuing it is advisable to read the previous chapter TrainingStrategy class.

To construct a model selection object associated to 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 on a growing inputs selection algorithm, an incremental order selection algorithm. The next sentence sets a different training strategy.

model_selection.set_inputs_selection_method(ModelSelection::GENETIC_ALGORITHM); model_selection.set_order_selection_method(ModelSelection::SIMULATED_ANNEALING); GeneticAlgorithm* genetic_algorithm = model_selection.get_genetic_algorithm_pointer(); genetic_algorithm->set_population_size(100); SimulatedAnnealingOrder* simulated_annealing = model_selection.get_simulated_annealing_order_pointer(); simulated_annealing ->set_minimum_temperature(0.1);

The most important methods of a model selection are the one that perform the inputs and the order selection. Respectively, the use are as follows:

model_selection.perform_inputs_selection(); model_selection.perform_order_selection();

We can save the above object to a XML file.

```
model_selection.save("model_selection.xml");
```