Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

Large-Scale Text Classification using Apache Spark

A scalable Big Data Analytics project that performs large-scale text classification and sentiment analysis on Amazon customer reviews using Apache Spark, Spark MLlib, Spark SQL, and Apache Hive. The project demonstrates distributed data processing, machine learning, and real-time sentiment prediction on a multi-gigabyte dataset containing millions of customer reviews.


📌 Project Overview

With the rapid growth of e-commerce platforms, millions of customer reviews are generated every day. Processing such massive textual data using traditional machine learning techniques becomes computationally expensive and inefficient.

This project leverages Apache Spark's distributed computing capabilities to efficiently process, analyze, and classify customer reviews into Positive and Negative sentiments. The system incorporates text preprocessing, TF-IDF feature extraction, Logistic Regression classification, Spark SQL analytics, Hive integration, and a real-time prediction module.


🚀 Features

  • Multi-GB Amazon Review Dataset
  • Distributed Data Processing using Apache Spark
  • Text Preprocessing
  • TF-IDF Feature Extraction
  • Logistic Regression Classification
  • Spark SQL Analytics
  • Apache Hive Integration
  • Real-Time Sentiment Prediction
  • Performance Evaluation using Accuracy, Precision, Recall, and F1-Score
  • Scalable Big Data Architecture

🛠 Technologies Used

  • Python
  • Apache Spark
  • Spark MLlib
  • Spark SQL
  • Apache Hive
  • Google Colab
  • Pandas
  • Matplotlib

📂 Dataset

The project utilizes multiple Amazon Review datasets merged into a single large-scale dataset.

Product Categories

  • Electronics
  • Books
  • Movies & TV
  • Sports & Outdoors
  • Home & Kitchen

Dataset Statistics

Category Records
Electronics 1,689,188
Books 8,898,041
Movies & TV 1,697,533
Sports & Outdoors 1,296,785
Home & Kitchen 5,518,682
Total 19,100,229+ Reviews

⚙️ Workflow

Amazon Review Dataset
          │
          ▼
Data Ingestion (Apache Spark)
          │
          ▼
Text Preprocessing
(Tokenization & Stopword Removal)
          │
          ▼
TF-IDF Feature Extraction
          │
          ▼
Logistic Regression Model
          │
          ▼
Sentiment Classification
          │
          ▼
Spark SQL Analytics
          │
          ▼
Hive Storage
          │
          ▼
Real-Time Prediction

📖 Methodology

Data Ingestion

  • Load multi-GB Amazon review datasets.
  • Merge multiple product categories.
  • Store data using Spark DataFrames.

Text Preprocessing

  • Remove null values.
  • Tokenize review text.
  • Remove stop words.

Feature Extraction

  • Apply TF-IDF.
  • Convert text into numerical feature vectors.

Model Training

  • Train Logistic Regression using Spark MLlib.
  • Perform binary sentiment classification.

Analytics

  • Execute distributed SQL queries using Spark SQL.
  • Analyze review statistics and prediction distributions.

Real-Time Prediction

  • Accept new review text.
  • Predict sentiment instantly.

📊 Spark SQL Analytics

The following analytical queries were performed:

  • Rating Distribution
  • Sentiment Distribution
  • Average Rating
  • Prediction Count

Example:

SELECT prediction, COUNT(*)
FROM reviews
GROUP BY prediction;

📈 Evaluation Metrics

The model was evaluated using:

  • Accuracy
  • Precision
  • Recall
  • F1-Score

🎯 Why Apache Spark?

Compared to traditional machine learning techniques, Apache Spark provides:

  • Distributed Processing
  • In-Memory Computation
  • Faster Execution
  • Scalability
  • Fault Tolerance
  • Efficient Processing of Millions of Records
  • Integrated Machine Learning Library
  • Built-in SQL Analytics

📁 Project Structure

Large-Text-Classification/
│
├── Dataset/
├── notebooks/
├── models/
├── outputs/
├── README.md
└── requirements.txt

💡 Future Enhancements

  • Transformer-based models (BERT, RoBERTa)
  • Apache Kafka Streaming
  • Spark Structured Streaming
  • Multi-class Sentiment Classification
  • Multilingual Text Classification
  • Cloud Deployment (AWS/Azure/GCP)
  • Interactive Dashboards (Power BI/Tableau)

📚 References

  • Apache Spark Documentation
  • Spark MLlib Documentation
  • Spark SQL Documentation
  • Amazon Review Dataset
  • Spark NLP Documentation

👨‍💻 Authors

Developed as a Big Data Analytics project demonstrating large-scale text classification using Apache Spark and distributed machine learning.

About

Scalable large-scale text classification and sentiment analysis on 19M+ Amazon reviews using Apache Spark, Spark MLlib, Spark SQL, TF-IDF, Logistic Regression, and Hive.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages