Comparison of Decision Tree and K-Nearest Neighbors for Ad Click Prediction
摘要
Ad click prediction is essential for optimizing digital advertising, particularly in targeted campaigns where identifying user engagement is critical. This study investigates the performance of K-Nearest Neighbors (K-NN) and Decision Tree classifiers on a highly imbalanced dataset, where clicks are rare compared to non-clicks. While both models achieved high overall accuracy (89% for K-NN, 83% for Decision Tree), their performance on the minority class was limited. To address class imbalance, a downsampling strategy was applied to the training set while keeping the test set distribution unchanged, allowing for performance evaluation under realistic conditions. This approach led to a trade-off: overall accuracy decreased slightly, but minority class detection improved—Decision Tree recall rose from 0.12 to 0.19, and K-NN from 0.01 to 0.05. In both balanced and imbalanced training scenarios, the Decision Tree consistently outperformed K-NN in detecting the minority class.