Pneumonia is a lung infection that can be detected through chest X-ray images. Manual diagnosis requires radiological expertise and time, thus an accurate automated method is needed. This study aims to compare the performance of two image classification algorithms, Convolutional Neural Network (CNN) and Random Forest (RF), in detecting pneumonia. The dataset used was obtained from Kaggle, consisting of 5,863 X-ray images categorized into three classes: bacterial pneumonia, viral pneumonia, and normal. Preprocessing steps include image resizing, normalization, and data augmentation. The CNN model was built using multiple convolutional and pooling layers, while RF utilized numerical features derived from histograms and texture. The CNN model demonstrated superior performance, achieving 92.4% accuracy, 93.1% precision, 91.6% recall, and 92.3% F1-score, compared to 82.7%, 80.3%, 85.1%, and 82.6% for Random Forest, respectively. Although CNN offers better accuracy, RF excels in interpretability. In conclusion, CNN is more effective for image-based pneumonia classification, yet RF remains relevant in applications requiring transparent decision-making. Potential biases, such as class imbalance and limited demographic representation in the dataset, could influence model performance and generalizability across different patient populations.