## 3 Methodology
### Modelling
#### 3.4.1 Decision Tree  
The Decision Tree algorithm begins by using a collection of examples to construct a tree-like structure designed to classify new cases. Each example is defined by a set of attributes, which may be numeric or categorical, and is assigned a label indicating its class.  
In the Decision Tree model, each internal node performs a test on an attribute, and the result of this test determines the path to follow. If the test outcome is true, the case moves to the left branch; if false, it moves to the right branch. The leaf nodes of the tree represent class labels rather than further tests [41].  
Figure 4: Target variable “Complaint (Y/N)” distribution in the studied dataset.  
In this study, the implementation of the Decision Tree model involved careful tuning of hyperparameters and selecting appropriate values for exploration during the tuning process. The model was implemented using the R programming language, specifically through the \(rpart\) package, which provides tools for fitting and analysing classification and regression problems [42]. This package offers robust functionality for handling various types of variables, including categorical and continuous data, and includes mechanisms to control the complexity of the resulting tree model through parameters that facilitate the pruning of unnecessary branches.  
One of the tuned hyperparameters was the splitting criterion, denoted as \(split\) in the package. The options for the splitting criteria were limited to Information Gain and the Gini index. The Decision Tree model developed here using Information Gain as the splitting criterion can be seen as a hybrid of the ID3 and C4.5 algorithms. This is because it combines the Information Gain criterion from ID3 with the capability to handle various variable types and the built-in pruning mechanism of C4.5.  
The complexity parameter (\(cp\)) was another hyperparameter tuned in the model. This parameter acts as a threshold to determine whether a split improves the overall accuracy sufficiently to justify its inclusion. To identify the optimal value for \(cp\), a range from 0.001 to 0.01 was tested, with increments of 0.001. Pruning, guided by the complexity parameter, is essential for preventing overfitting by reducing the complexity of the tree and ensuring better generalization to unseen data.  
The final hyperparameter tuned in the Decision Tree model was \(minbucket\), which specifies the minimum number of observations required in any terminal leaf node. This parameter determines when to cease splitting a node based on the number of observations it contains. Together with the \(cp\) parameter, \(minbucket\) helps control the complexity of the tree and mitigate overfitting. During the tuning process, \(minbucket\) was tested across a range of values from 2 to 100, with increments of 1 (one). Additionally, the \(minsplit\) parameter, which defines the minimum number of observations needed in a node for a split to be attempted, was set to three times the value of \(minbucket\).  
In Table 9, the hyperparameters that were tuned in the Decision Tree model are presented, along with the range of values that were tested for each parameter.