## 2 Materials and Methods
### Explaining Grammatical Evolution  
Grammatical Evolution (GE) is a form of Evolutionary Algorithm (EA) that mimics the process of biological evolution to seek solutions to problems [35]. Unlike a classical EA, GE integrates genetic algorithms with the rules of formal language theory. User-defined context-free grammars (CFGs) constrain the structure and syntax of the genome, which allows for the generation of solutions with a well-defined structure. The core idea of GE revolves around the process of mapping genotype to phenotype, which is achieved by generating sentences according to a specified grammar. In this process, the genome guides the selection of applicable production rules from the provided grammar. By imposing rules and restrictions through context-free grammars, GE ensures that the solutions adhere to specific syntactic patterns, enhancing their coherence and applicability to the problem domain and offering a framework for shaping and refining solutions, enabling the generation of outputs that align closely with desired specifications and objectives. Each solution is evaluated using a fitness value for a given objective function. There are several implementations of GE algorithms. Notable examples include gramEvol for R; PyNeurGen, PonyGE, and PonyGE2 for Python; GEVA and ECJ for Java; and GELab for Matlab, among others ([[https://en.wikipedia.org/wiki/Grammatical_evolution#Implementations](https://en.wikipedia.org/wiki/Grammatical_evolution#Implementations)]([https://en.wikipedia.org/wiki/Grammatical_evolution#Implementations](https://en.wikipedia.org/wiki/Grammatical_evolution#Implementations)) (accessed on 29 March 2024)). While GE is used primarily to generate variable-length linear genome encodings of computer programs, it can also be employed for symbolic regression tasks and identification of functional dependencies. GE utilizes a CFG defined as \(G=(N,T,P,S)\), where \(N\) is a set of non-terminal symbols, \(T\) is a set of terminal symbols, \(P\) consists of production rules, and \(S\) is the start symbol. Each individual in GE is represented by a chromosome (a string of integers that act as genetic material), guiding the selection of production rules from \(P\) to convert non-terminals to terminals, thus constructing valid mathematical expressions using a modulo operation based on available rule choices. The translation from genotype (chromosome) to phenotype (expression) involves applying the production rules based on gene values, iterating until a complete expression is formed, or the chromosome is exhausted. Fitness is evaluated by how closely these expressions match target outputs (e.g., with MSE). Evolutionary processes including crossover and mutation generate new chromosomes, with selection based on fitness, perpetuating the cycle to evolve increasingly accurate symbolic expressions. The GE approach adds an extra layer of interpretability to the generated solutions. Since each solution must conform to the rules defined in the grammar, it is possible to trace back the decision-making process of the algorithm, providing insights into how specific solutions were constructed. While shallow XAI techniques such as LIME or SHAP can improve the understanding of black-box models by explaining their predictions in specific cases, GE helps in creating inherently interpretable models. GE-based explanations are directly derived from the model itself, without the need for approximation or additional  
Figure 4: Decision tree model. modeling, which may reduce the errors typically associated with the approximations made by post hoc explanations. The flexibility in how models are represented allows for more adaptable and potentially understandable models. The application of GE can be particularly advantageous in domains where the incorporation of expert knowledge into the model is crucial, such as in health care, as user-defined grammars allow for the incorporation of domain-specific constraints and guidelines.