## 3 Materials and Methods
### Proposed Model
#### 3.2.1 Feature Extraction  
Features are extracted with the developed CNN architecture and images are classified based on these features with XGBoost. For this purpose, the last dense layer of the CNN architecture that performs classification is removed and the features obtained from other layers are given to XGBoost as input. The classification success depends on the features extracted from the CNN model. Therefore, a CNN model that extracts features in a way that provides high classification accuracy has been developed. To understand the contribution of replacing the CNN's fully connected layer with XGBoost, an ablation study was conducted.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Tumor Type** & **Training** & **Testing** \\ \hline Glioma & 1321 & 300 \\ Meningioma & 1339 & 306 \\ Notumor & 1595 & 405 \\ Pituitary & 1457 & 300 \\
**Total** & **5712** & **1311** \\ \hline \hline \end{tabular}
\end{table}
Table 1: Dataset summary.  
Figure 2: Sample images from dataset.  
According to the results of the ablation study, when only CNN was used, the model achieved 97.80% accuracy. When the fully connected layer and XGBoost were added to CNN, the accuracy increased to 98.73%. However, the highest accuracy value of 99.77% was obtained from the model where only CNN and XGBoost were used together. The results show that the highest performance is achieved with the proposed system architecture and that high-level semantic information is preserved and further utilized effectively. Although the performance of the CNN model is improved by stacking the fully connected layer outputs with XGBoost, the most successful results are obtained with the proposed model.  
In Figure 3, the proposed CNN model architecture is displayed. The model consists of three convolution layers (Conv2D) with 32, 64 and 128 filters. Each layer uses a \(3\times 3\) kernel size and the ReLU activation function. While lower-level feature information is extracted with the first convolution layer, more complex patterns and features are extracted with the following convolution layers. After each convolution layer, \(2\times 2\) MaxPooling is implemented to decrease the computational load by reducing the feature maps' dimensions and to increase the model's ability for generalization. The risk of overfitting is reduced by applying a 0.3 dropout after convolution layers and a 0.5 dropout after fully connected layers. The multidimensional feature maps created by the convolution layers are converted to a one-dimensional vector with the flatten layer and transferred to fully connected layers (dense layers). These layers employ the ReLU activation function and have 256 and 128 neurons. The model can compute probabilities between four classes thanks to the last layer's 4-neuron output layer with a softmax activation function. However, this last layer was removed when combining with XGBoost.  
The CNN model is trained using certain parameters. Table 2 lists these parameter values. The Adam algorithm was used for model optimization, and categorical cross-entropy, which works well for classification into several classes, was used as the loss function. Training was performed with 32 batch_size and 50 epochs. The model consists of 6,548,868 parameters.  
Figure 3: Proposed CNN model architecture.