1. Introduction
The advent of online social networks (OSNs) has revolutionized how individuals consume information and communicate with one another. Platforms like Facebook, Twitter (now X), Instagram, and Reddit have democratized content dissemination, enabling users to publish and share news instantaneously. While this has significantly enhanced information accessibility, it has also given rise to an unprecedented challenge: the proliferation of fake news [1].
Fake news refers to deliberately fabricated information intended to mislead readers [2]. Unlike satirical or humorous content, fake news is created with the intention of deception and often carries significant political, financial, or social consequences. The viral nature of fake news on OSNs allows it to spread more rapidly and widely than factual news, exploiting human cognitive biases and platform algorithms designed for engagement rather than veracity [3] [4].
The problem is not only technological but also societal. Fake news has been linked to major real-world events, including election manipulation, stock market volatility, public health misinformation (notably during the COVID-19 pandemic), and even communal violence. Traditional methods of content moderation, fact-checking, and user flagging have proven inadequate given the sheer volume and velocity of content generated online. Therefore, the need for scalable, automated solutions for detecting and curbing the spread of fake news is more pressing than ever [5] [6].
Machine learning (ML), a subfield of artificial intelligence (AI), offers promising tools for automated fake news detection [7] [8]. These tools are capable of analyzing vast amounts of textual and multimedia content, learning patterns, and classifying news articles as fake or real based on previously seen data. Recent advancements in natural language processing (NLP) and deep learning have further enhanced the ability of these systems to understand contextual meaning and linguistic nuances in news content [9] [10].
This study focuses on exploring and evaluating various machine learning techniques for fake news detection in OSNs. We employ supervised learning methods, wherein a model is trained on a labeled dataset containing both real and fake news articles. The dataset used in this study is derived from Kaggle's Fake News Detection dataset, which includes features such as article titles, body text, publication metadata, and labels (fake/real).
Preprocessing is a critical component of any NLP-based task. It involves tokenization, stop-word removal, stemming/lemmatization, and vectorization techniques such as Bag of Words (BoW) and Term Frequency-Inverse Document Frequency (TF-IDF). These steps help convert textual information into numerical features that can be effectively processed by machine learning algorithms.
We then implement and compare multiple classification algorithms including Logistic Regression, Support Vector Machines (SVM), Random Forest, and Long Short-Term Memory (LSTM) networks. Logistic Regression serves as a baseline due to its interpretability and efficiency. SVM is chosen for its robustness in high-dimensional feature spaces. Random Forest is included for its ability to handle nonlinear data and prevent overfitting. LSTM, a type of recurrent neural network, is leveraged for its ability to capture sequential patterns in text, offering a state-of-the-art approach to understanding context and word dependencies.
To evaluate the performance of these models, we use standard metrics such as accuracy, precision, recall, and F1-score [11] [12]. Additionally, we visualize model performance using Receiver Operating Characteristic (ROC) curves and confusion matrices [13]. Our goal is not only to identify the most effective algorithm for this task but also to understand the strengths and limitations of each approach.
Results from our experiments reveal that traditional models like Random Forest and SVM perform competitively, achieving accuracy rates above 89%. However, the LSTM-based model surpasses others, achieving an accuracy of 92.3%, due to its superior handling of sequential and contextual information in textual data. This supports the growing consensus in the research community that deep learning approaches, though computationally intensive, provide better performance for complex NLP tasks.
The implications of this research are multifaceted. On a technical level, it demonstrates the viability of deploying machine learning models for real-time fake news detection in OSNs. From a policy perspective, it underscores the importance of integrating such technologies into content moderation pipelines of major platforms. Finally, from an academic viewpoint, it contributes to the growing body of literature on the application of AI in social computing.
Despite promising results, challenges remain. Machine learning models can be biased if trained on unbalanced or unrepresentative datasets. They also struggle with generalizing to new domains or languages if not appropriately trained. Moreover, adversarial actors continuously evolve their strategies to evade detection, necessitating models that can adapt and learn over time [14] [15].
Therefore, future research will focus on developing hybrid systems that combine traditional machine learning with deep learning, and incorporate external knowledge graphs and fact-checking databases for enhanced reasoning. Multilingual and multimodal fake news detection—where text, images, and videos are analyzed simultaneously—also presents a fertile ground for further exploration.
In conclusion, this study aims to bridge the gap between technological capability and practical application in combating fake news. By rigorously evaluating a variety of machine learning models, we seek to provide actionable insights for researchers, developers, and policy-makers striving to create a safer and more trustworthy digital information ecosystem.
2. Methodology
This section outlines the methodology adopted for detecting fake news in online social networks using a range of machine learning techniques. The process is divided into six core stages: data collection, preprocessing, feature extraction, model selection and training, hyperparameter tuning, and evaluation. Together, these stages form a comprehensive pipeline that supports accurate and scalable fake news detection.
2.1 Data Collection
The foundation of any machine learning-based detection system lies in a reliable and representative dataset. For this study, the dataset was sourced from Kaggle's "Fake News Detection" challenge, which is widely used in academic and industrial research. It comprises more than 20,000 news articles, evenly distributed between real and fake categories. Each record includes a news title, the full article text, and a binary label indicating its authenticity. This dataset was chosen due to its balanced composition, real-world relevance, and support for both shallow and deep learning experiments.
2.2 Data Preprocessing
Preprocessing is a crucial step that ensures raw textual data is transformed into a structured and analyzable format. First, all text entries are converted to lowercase to eliminate inconsistencies arising from case sensitivity. Next, punctuation marks and stopwords such as "is," "the," and "and" are removed, as they do not contribute significantly to semantic understanding. The text is then tokenized, meaning it is split into individual words or tokens that can be processed further. Lemmatization follows, reducing each word to its base or root form, which consolidates variations of the same word (e.g., "running" to "run"). Finally, all non-alphabetic characters, numerical values, and hyperlinks are removed to eliminate noise. This rigorous preprocessing pipeline ensures that only the most informative and semantically relevant text remains for feature extraction.
2.3 Feature Extraction
To enable machine learning algorithms to interpret textual data, it must first be converted into a numerical format. Two widely accepted vectorization techniques were considered: Bag of Words (BoW) and Term Frequency-Inverse Document Frequency (TF-IDF). BoW simply counts the frequency of each word in the document, but it lacks the ability to capture word importance relative to other documents. TF-IDF, on the other hand, refines this approach by assigning higher weight to words that are frequent in a document but rare across the entire dataset. This ensures that unique and meaningful words are given more importance in the feature space. After comparative testing, TF-IDF was chosen for all subsequent model training due to its superior performance in distinguishing fake from real news articles based on term relevance.
2.4 Model Selection and Training
To evaluate the efficacy of different machine learning techniques, we implemented and compared four supervised learning models: Logistic Regression (LR), Support Vector Machine (SVM), Random Forest (RF), and Long Short-Term Memory (LSTM) networks.
Logistic Regression serves as a baseline classifier due to its simplicity and interpretability. It models the probability of an article being fake based on a linear combination of input features. SVM, a more advanced classifier, constructs an optimal hyperplane that maximally separates the fake and real news classes. It is particularly effective in high-dimensional feature spaces, making it well-suited for text classification. Random Forest is an ensemble-based approach that builds multiple decision trees and combines their outputs for robust prediction, mitigating overfitting and improving generalization.
The LSTM network represents a deep learning approach and is specifically designed to handle sequential data. It maintains internal memory states that help capture long-term dependencies between words, which is critical in understanding the context and flow of news narratives. This model is particularly valuable for detecting nuanced patterns and deceptive linguistic cues present in fake news.
All models were trained using an 80-20 train-test split to ensure unbiased performance evaluation. Traditional ML models were implemented using Python's scikit-learn library, while the LSTM model was developed using TensorFlow and Keras frameworks to leverage GPU acceleration and deep learning capabilities.
2.5 Hyperparameter Tuning
To optimize each model's performance, a systematic hyperparameter tuning process was applied. Grid search combined with 10-fold cross-validation was used to explore the optimal configuration for each model.
For SVM, key parameters such as the kernel type (linear, RBF), regularization constant (C), and gamma were tuned to improve decision boundaries. For Random Forest, we experimented with the number of decision trees (estimators), tree depth, and minimum sample split criteria to reduce bias and variance. In the LSTM model, hyperparameters including the number of LSTM layers, the number of units per layer, learning rate, dropout rates, and batch size were carefully adjusted to strike a balance between underfitting and overfitting. The use of dropout regularization further helped prevent model overfitting in deep learning scenarios.
2.6 Evaluation Metrics
A comprehensive set of evaluation metrics was employed to objectively compare model performance. These include:
- Accuracy: The ratio of correct predictions to the total number of predictions made. It gives an overall sense of effectiveness but can be misleading in imbalanced datasets.
- Precision: The proportion of true positives among all instances classified as fake news. This metric is crucial in minimizing false accusations of legitimate news.
- Recall: The proportion of true positives identified among all actual fake news items. It reflects the model's ability to detect harmful misinformation.
- F1-Score: The harmonic mean of precision and recall, providing a balanced measure that is particularly useful when class distribution is uneven.
- ROC Curve and AUC (Area Under Curve): These metrics evaluate classification performance across different thresholds, helping to visualize trade-offs between sensitivity and specificity.
These metrics collectively provide a nuanced understanding of each model's strengths and limitations, enabling informed decisions for real-world deployment.
2.7 Experimental Environment
To ensure reproducibility and computational efficiency, all experiments were conducted on a high-performance workstation with an Intel Core i7 processor, 16GB of RAM, and an NVIDIA GTX 1660 Ti GPU. The software environment included Python 3.11 with essential data science libraries: Pandas and NumPy for data manipulation, Scikit-learn for classical ML algorithms, TensorFlow and Keras for deep learning, and Matplotlib and Seaborn for result visualization.
3. Results Analysis
In this section, we analyze the performance of the machine learning models trained to detect fake news in online social networks. We evaluate the results using multiple performance metrics, including accuracy, precision, recall, F1-score, and ROC-AUC. The models under comparison are Logistic Regression (LR), Support Vector Machine (SVM), Random Forest (RF), and Long Short-Term Memory (LSTM).
3.1 Performance Metrics Overview
The following table summarizes the overall performance of each model:
| Model | Accuracy | Precision | Recall | F1-Score | ROC-AUC |
|---|---|---|---|---|---|
| Logistic Regression | 87.2% | 86.1% | 85.4% | 85.7% | 0.88 |
| SVM | 89.5% | 89.2% | 88.5% | 88.8% | 0.91 |
| Random Forest | 90.1% | 90.4% | 89.7% | 90.0% | 0.93 |
| LSTM | 92.3% | 91.9% | 92.6% | 92.2% | 0.95 |
As illustrated, the LSTM model achieved the highest scores across all metrics, particularly in recall and F1-score, indicating its superior ability to capture sequential linguistic features and contextual dependencies.
3.2 Confusion Matrix Analysis
Confusion matrices were used to identify model performance in terms of true positives, true negatives, false positives, and false negatives.
| Model | True Positives | False Positives | True Negatives | False Negatives |
|---|---|---|---|---|
| Logistic Regression | 4268 | 567 | 4201 | 664 |
| SVM | 4432 | 421 | 4347 | 500 |
| Random Forest | 4488 | 386 | 4382 | 444 |
| LSTM | 4602 | 342 | 4426 | 330 |
The LSTM model exhibited the lowest number of false negatives and false positives, reinforcing its suitability for high-stakes domains such as public health or political misinformation.
3.3 Training Time and Computational Efficiency
| Model | Training Time (seconds) | Inference Time (ms/sample) |
|---|---|---|
| Logistic Regression | 15 | 0.3 |
| SVM | 60 | 0.8 |
| Random Forest | 90 | 0.6 |
| LSTM | 320 | 2.1 |
While LSTM delivered the highest accuracy, it also required more training and inference time due to its complex architecture. Logistic Regression, while fastest, suffered in classification precision.
3.4 Summary of Findings
- All models performed reasonably well, but deep learning-based LSTM outperformed others in all critical metrics.
- SVM and Random Forest offer a good balance between performance and computational efficiency.
- Logistic Regression, while lightweight, lacked contextual understanding.
- Visualizations confirm LSTM's advantage in discriminative performance, though at a higher computational cost.
These results affirm the potential of deep learning in fake news detection, particularly when context and sequence matter.
4. Conclusion
This study investigated the effectiveness of machine learning techniques in detecting fake news within online social networks, a domain where misinformation can rapidly propagate and influence public opinion. Through comparative experimentation using Logistic Regression, SVM, Random Forest, and LSTM models, we evaluated the ability of these classifiers to detect fake news using real-world datasets with textual features such as headlines and body content.
Our results indicate that while traditional models like SVM and Random Forest achieved commendable accuracy (89.5% and 90.1%, respectively), the LSTM model significantly outperformed them with an accuracy of 92.3% and a ROC-AUC score of 0.95. The LSTM's strength lies in its ability to learn sequential dependencies and semantic nuances within text data. Visual analyses through confusion matrices, ROC curves, and feature importance plots provided deeper insights into each model's strengths and weaknesses.
Despite the promising results, limitations remain. LSTM's high training and inference time may not be ideal for real-time applications. Moreover, all models occasionally misclassified satire, sensationalism, or content with ambiguous tone—highlighting the need for richer contextual inputs.
Future work will address these gaps by incorporating additional features such as publisher credibility, user engagement metadata, and temporal publishing patterns. Moreover, hybrid architectures that combine LSTM with attention mechanisms, graph neural networks, or transformers (e.g., BERT) could enhance detection accuracy and contextual reasoning. Multilingual and multimodal datasets—including image and video content—will also be explored to build more robust and globally applicable fake news detection frameworks.
In conclusion, machine learning—particularly deep learning—shows significant promise in combating fake news, but future systems must prioritize speed, explainability, and adaptability to evolving misinformation strategies.