## 3 Materials and Methods
### Baseline Particle Classification Methods
#### 3.5.2 Random Forest  
Another baseline method is RF, a supervised ML algorithm that combines the output of multiple decision trees to reach a single result. Together with BDT, it is often used in particle classification, as shown in [62; 63]. Both RF and BDT usually use data sets containing well-known physical parameters as features. In our tests, because of the time constraints needed for L1T selection, the same input applied for NN models was used: raw detector data--that is, HGCAL images.  
RF consists of a large number of decision trees that operate as an ensemble. Each individual tree in the RF declares a class prediction, and the class with the most votes becomes the model's prediction. In the RF learning process, there are two major layers of randomness. The first random component is that RF uses a random (bootstrapped) sample of the original training data set for each individual decision tree. As a result, in the vast majority of cases, the training sets for the trees are different from one another, which reduces the correlation between trees and improves the generalization of the predictions making RF more robust to overfitting [64]. Another layer of randomness is in the (random) selection of the features considered at each node. The method itself is introduced by [PERSON] ([65]), and a detailed method analysis is available in [66]. RF's simple usage and flexibility, together with the possibility to handle classification and regression problems, have contributed to its widespread usage. It is considered to be one of the best off-the-shelf-learning algorithms, requiring almost no tuning, although it enables fine control over the model that is learned. However, it does have some disadvantages compared to other classification methods (like decision trees), which should be kept in mind when interpreting its results and applicability: its models are more complex and harder to interpret (although feature importance can be readily obtained), and due to the stochastic nature of tree building, the structure of the trained model is unpredictable, requiring more time and system resources to train and run.  
An open-source machine learning library for the Python programming language named scikit-learn [67] is used for testing RF classifiers as it provides a robust implementation combining both algorithmic and code optimization. To improve the accuracy of the RF classifier for particular situations, there are parameters that may be tuned. The grid search is used for performing hyper-parameter optimization, employing the next hyperparameter search space:  
* _max_features_: maximum number of features random forest considers splitting a node, with available values 'auto','sqrt', 'log2'. The default value is 'auto'.
* _n-estimators_: the number of trees in the forest, with values 100, 200, 300. Increasing this hyperparameter generally improves the performance of the model. The drawback is italso increases the computational cost of training and predicting. The default value is 100.
* _max_depth_: maximum number of levels in each decision tree, using values 8, 16, 20. The default value is none, which means that nodes are expanded until all leaves are pure or until all leaves contain fewer than 2 samples.  
An additional parameter, criterion, which measures the quality of the split, with values 'gini' and 'entropy', is added to the search space too, and the loss function, which is optimizing the accuracy.