Skip to content

Cs944612/Emotion-Detection-using-CNN

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Emotion Detection using CNN for NLP

📌 Project Overview

This project demonstrates how to use Convolutional Neural Networks (CNNs) for emotion classification from text data—a Natural Language Processing (NLP) task. The model is trained to recognize emotions such as joy, sadness, anger, fear, love, and surprise from short sentences.

🎯 Objectives

  • Preprocess text data (tokenization, padding)
  • Use an Embedding layer to convert words into dense vectors
  • Build a CNN-based model to capture local patterns in text
  • Train and evaluate the model on the dataset
  • Visualize performance and analyze metrics like accuracy, precision, recall, and F1-score

📂 Dataset

🛠 Tools & Libraries

  • Python
  • TensorFlow / Keras
  • NumPy & Pandas
  • Matplotlib
  • scikit-learn

🚀 How CNN fits into NLP

         ┌───────────────────────┐
         │     Text Data (NLP)   │
         │ (sentences, words...) │
         └────────────┬──────────┘
                      │
                      ▼
         ┌───────────────────────┐
         │     Preprocessing     │
         │ (tokenization,        │
         │  padding, embedding)  │
         └────────────┬──────────┘
                      │
                      ▼
         ┌───────────────────────┐
         │   CNN Model (Conv1D)  │
         │  - Convolution        │
         │  - Pooling            │
         │  - Dense Layers       │
         └────────────┬──────────┘
                      │
                      ▼
         ┌───────────────────────┐
         │   Predicted Emotion   │
         │ (joy, anger, etc.)    │
         └───────────────────────┘

📊 Exploratory Data Analysis (EDA)

  • Analyzes distribution of emotion labels (class balance)
  • Inspects sentence lengths
  • Visualizes frequent words (word clouds)

🏗️ Model Architecture

  • Embedding Layer: Converts tokenized words to dense vectors
  • Conv1D Layer: Captures local n-gram patterns in text
  • GlobalMaxPooling1D: Reduces sequence to fixed-length
  • Dense Layers: Final classification

📈 Training & Evaluation

  • Model trained on the training set, validated on the validation set, and tested on the test set.
  • Performance evaluated using metrics: accuracy, precision, recall, F1-score
  • Training history plotted for visualization

📋 Results

  • The trained CNN model achieves strong accuracy on emotion classification tasks.
  • Metrics and visualizations help interpret model performance and common confusions between emotions.

About

This project applies Convolutional Neural Networks (CNNs) to a Natural Language Processing (NLP) task: classifying emotions from text data.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors