An Explainable and Reproducible Lightweight Machine Learning Framework for SMS Spam Detection Using TF-IDF and Linear Support Vector Classification
Abstract
The continued use of short message service (SMS) for personal, institutional and transactional communication has made mobile messaging a persistent target for unsolicited advertising, social engineering and fraud-oriented content. This paper presents a reproducible and explainable lightweight machine learning framework for binary SMS spam detection. The framework integrates a fixed text-preprocessing sequence, term frequency-inverse document frequency (TF-IDF) representation, comparative classifier evaluation, ablation analysis and post-hoc model interpretation. Five supervised learning models were examined on the SMS Spam Collection dataset: Multinomial Naive Bayes, Logistic Regression, Linear Support Vector Classification, Random Forest and XGBoost. The dataset contained 5,572 labelled messages, including 4,825 ham and 747 spam instances, and was evaluated using a stratified 80:20 train-test split with a fixed random seed. The strongest verified configuration used unigram and bigram TF-IDF features without stop-word removal and a Linear Support Vector Classifier, producing 98.57% accuracy, 97.84% precision, 91.28% recall and 94.44% F1-score. Unlike studies that report only aggregate accuracy, this work analyses the precision-recall trade-off, confusion-matrix behaviour and representative error cases. Explainability is incorporated through SHAP LinearExplainer applied to the LinearSVC decision-function margin, supported by feature-weight inspection. The results indicate that a carefully configured sparse-text linear classifier remains a competitive, transparent and computationally modest baseline for SMS spam filtering, although broader validation on contemporary multilingual and adversarial message streams is necessary before real-world deployment.