Skip to content

Repository files navigation

🗂️ Consumer Complaint Classification

SimpleRNN • LSTM • GRU • DistilBERT • HuggingFace • TensorFlow • Gradio

A Deep Learning and NLP project that automatically classifies customer complaint narratives into the correct complaint category.

The project compares traditional recurrent neural networks with a fine-tuned Transformer model to determine the best-performing architecture for complaint classification.


🚀 Features

  • Complete NLP preprocessing pipeline
  • Text cleaning and normalization
  • Class balancing
  • Tokenization & Sequence Padding
  • Word Embedding Layer
  • Built and trained from scratch:
    • SimpleRNN
    • LSTM
    • GRU
  • Fine-tuned DistilBERT Transformer
  • Performance comparison between all models
  • Interactive Gradio web application
  • Real-time complaint prediction with confidence scores

🧠 Models

Model Accuracy
SimpleRNN 78.9%
GRU 81.8%
LSTM 82.5%
DistilBERT (Fine-tuned) 85.1%

📂 Dataset

Consumer Complaints Dataset for NLP

Contains real customer complaints from financial services.

Classes include:

  • Credit Reporting
  • Credit Card
  • Debt Collection
  • Mortgages and Loans
  • Retail Banking

🔄 Project Pipeline

Dataset

↓

Text Preprocessing

↓

Class Balancing

↓

Tokenization

↓

Sequence Padding

↓

Embedding Layer

↓

Train Deep Learning Models

↓

Evaluate Performance

↓

Fine-tune DistilBERT

↓

Model Comparison

↓

Gradio Deployment


📊 Evaluation Metrics

  • Accuracy
  • Precision
  • Recall
  • F1-score
  • Classification Report
  • Confusion Matrix

🖥️ Gradio Application

The project includes an interactive Gradio interface that allows users to:

  • Enter a complaint narrative
  • Predict the complaint category
  • Display prediction confidence
  • Compare probabilities across all categories

📸 Application Preview

Home Screen

Prediction Example

---

🛠️ Technologies Used

  • Python
  • TensorFlow / Keras
  • HuggingFace Transformers
  • PyTorch
  • Scikit-learn
  • NLTK
  • NumPy
  • Pandas
  • Matplotlib
  • Seaborn
  • Gradio

📁 Project Structure

Consumer-Complaint-Classification
│
├── consumer-complaint-classification.ipynb
├── gradio_app.py
├── requirements.txt
├── tokenizer.pkl
├── label_encoder.pkl
├── SimpleRNN_model.keras
├── LSTM_model.keras
├── GRU_model.keras
│
└── transformer_complaint_model_final
    ├── config.json
    ├── tokenizer.json
    ├── tokenizer_config.json
    └── model.safetensors

🎯 Results

The Fine-tuned DistilBERT model achieved the highest performance and was selected for deployment in the Gradio application.


🔗 Project Links


👩‍💻 Author

Basmala Khaled

AI Engineer

About

Deep Learning NLP project for consumer complaint classification using SimpleRNN, LSTM, GRU, and a fine-tuned DistilBERT Transformer with an interactive Gradio web application.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages