# Kashif: A Chrome Extension for Classifying Arabic Content on Web Pages Using Machine Learning
## 3 Methodology
### Machine Learning Classifiers  
This section details the ML classifiers, including RF, XGBoost, DT, and SVM. For all classifiers, we employed an 80-20 split for training and testing the dataset. Additionally, we utilized grid search algorithm to optimize parameters and achieve the highest possible accuracy. * RF Classifier  
RF is a supervised ML method that works based on the ensemble method, which is based on DTs and can handle classification and regression problems. An ensemble method means an RF algorithm comprises many small DTs called estimators, each of which makes its predictions. The RF method combines the estimators' predictions for a more precise prediction. For classification problems, the RF output is the class majority voting selects. For regression problems, the output is the mean or average prediction of each tree [31]. When using the RF method to solve regression problems, the mean squared error (MSE) can be used [32]. The formula calculates the distance of each node from the predicted actual value, allowing the choice of the branch that suits the forest the most, and it is given in the following equation:  
\[MSE=\frac{1}{X}{\sum}_{i=1}^{X}\left(\mathrm{Yi}-\hat{\mathrm{Yi}}\right)2\]  
where \(X\) is the number of data points, \(\mathrm{Yi}\) is the value returned by the DT, and \(\hat{\mathrm{Yi}}\) is the value of the data point tested at a particular node. When the RF method is used to solve classification problems, \(Gini\) index or information gain (IG) is used. The \(Gini\) of each section on a node is calculated using the probability and the class, indicating which branch is more likely to occur. The formula that calculates the Gini index is given in the following equation [32]:  
\[Gini=1-\sum_{i=1}^{N}(p_{i})^{2}\]  
\(p_{i}\) represents the relative frequency of the class observed in the dataset, and \(N\) represents the number of classes. \(IG\) is another measure to choose the appropriate data split based on each feature's gain. The formula that calculates the \(IG\) is given in the following equation [32]:  
\[Entropy=-\sum_{i=1}^{N}p_{i}*\log 2(p_{i})\] \[IG(parent,child)\] \[=Entropy(parent)-[p1(c1)*Entropy(c1)+p1(c2)\] \[*Entropy(c2)+\cdots]\]  
The hyperparameters and their optimal values for RF are presented in Table 5. The random_state parameter enables us to set a random seed (which is 42) to the random number generation process in the RF, so that, each time we build the model with the same data, we obtain the same one. Moreover, n_estimators represent the number of trees in the forest, which is 1400. The max_features parameter represents the feature number to be considered while determining the optimum split for the tree. If the max_features parameter is set to auto, the tree will use the square root of the feature number as the max_features value. In addition, the max_depth parameter represents the maximum number of levels in each DT, which is 18. The criterion parameter 'entropy' represents the function used to measure a split's quality. * XGBoost Classifier XGBoost is an ensemble technique based on DTs, a type of gradient boosting. It is a supervised learning method based on function approximation through the optimization of specific loss functions and the application of various regularization methods, and it supports parallel processing, handles missing values, offers cache optimization, takes care of outliers to some extent, and has inbuilt cross-validation. XGBoost can be utilized to solve regression and classification problems. The algorithm combines the estimates of a group of smaller, weaker models to predict a target variable accurately. The general equation of the algorithm consists of two parts, training loss and regularization term as follows [33]: \[obj(\theta)=L(\theta)+\Omega(\theta)\] where \(L\) represents the training loss function, and \(\Omega\) represents the regularization parameters. The training loss measures determine how well a model predicts the training data, and MSE is a common choice of \(L\).