In this paper, we propose an evolutionary approach to the design of output codes for multiclass pattern recognition problems. This approach has the advantage of taking into account the different aspects that are relevant for a code matrix to achieve a good performance. We define a fitness function made up of five terms that refer to overall classifier accuracy, binary classifiers' accuracy, classifiers' diversity, minimum Hamming distance among codewords, and margin of classification. These five factors have not been considered together in previous works. We perform a study of these five terms to obtain a fitness function with three of them. We test our approach on 27 datasets from the UCI Machine Learning Repository, using three different base learners: C4.5, neural networks, and support vector machines. We show a better performance than most of the current standard methods, namely, randomly generated codes with approximately equal random split, codes designed using a CHC al...