Skip to content

A ๐—ง๐—ฒ๐˜…๐˜ ๐—˜๐—บ๐—ผ๐˜๐—ถ๐—ผ๐—ป ๐—–๐—น๐—ฎ๐˜€๐˜€๐—ถ๐—ณ๐—ถ๐—ฒ๐—ฟ is an AI model that analyzes text to detect and classify emotions like ๐—ต๐—ฎ๐—ฝ๐—ฝ๐—ถ๐—ป๐—ฒ๐˜€๐˜€ ๐Ÿ˜Š, ๐˜€๐—ฎ๐—ฑ๐—ป๐—ฒ๐˜€๐˜€ ๐Ÿ˜ข, ๐—ฎ๐—ป๐—ด๐—ฒ๐—ฟ ๐Ÿ˜ , and ๐˜€๐˜‚๐—ฟ๐—ฝ๐—ฟ๐—ถ๐˜€๐—ฒ ๐Ÿ˜ฒ. It's used in sentiment analysis, customer feedback, and social media monitoring to understand and respond to emotions more effectively.

License

Notifications You must be signed in to change notification settings

Vaibhav-kesarwani/Text_Emotion_Classifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

19 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Text Emotion Classifier

Project Overview

The Text Emotion Classifier is a machine learning project that aims to detect and classify emotions in text data. The model uses deep learning techniques to process textual input and identify the underlying emotion, such as happiness, sadness, anger, or surprise. This project can be used for sentiment analysis, social media monitoring, customer feedback processing, and more.

Dataset

The dataset used in this project is a labeled text dataset where each entry consists of a text sample and its corresponding emotion label. The dataset is stored in a train.txt file with the following structure:

  • Text: The input text string.
  • Emotions: The associated emotion label (e.g., "happy", "sad", "angry", etc).
  • Dataset link: Kaggle link

An example of the data structure:

I am feeling great today!;happy
This is so frustrating and annoying.;angry

The data file train.txt should be placed in the root directory of the project.

Installation

To run this project locally, you'll need to have Python installed. Follow these steps to set up the environment:

  1. Clone the Repository:
git clone https://github.com/Vaibhav-kesarwani/Text_Emotion_Classifier.git
cd Text_Emotion_Classifier
  1. Create a Virtual Environment (optional but recommended):
python -m venv venv
source venv/bin/activate  # On Windows use `venv\Scripts\activate`
  1. Install Required Packages: Install the dependencies by running:
pip install -r requirements.txt

Usage

Running the Project

To run the Text Emotion Classifier, follow these steps:

  1. Prepare the Dataset: Ensure that your train.txt file is in the root directory. This file should contain the text data and corresponding emotion labels, separated by a semicolon (;).

  2. Run the Script: Execute the main script to load the data and perform emotion classification:

python main.ipynb
  1. Output: The script will print the first few rows of the dataset to the console, showing the text samples and their associated emotion labels.

Model Training

The model training is performed within the main.ipynb script, which processes the text data, tokenizes it, and trains a Sequential model using Keras. You can modify the model architecture, training parameters, or the data processing steps within this script.

# Define the model
model = Sequential()
model.add(Embedding(input_dim = len(tokenizer.word_index) + 1, output_dim=128, input_length=max_length))
model.add(Flatten())
model.add(Dense(units=128, activation="relu"))
model.add(Dense(units=len(one_hot_labels[0]), activation="softmax"))

model.compile(optimizer="adam", loss="categorical_crossentropy", metrics=["accuracy"])
model.fit(xtrain, ytrain, epochs=10, batch_size=32, validation_data=(xtest, ytest))

Prediction

After training the model, you can use it to predict emotions from new text inputs. Implement the prediction logic in a separate script or extend main.ipynb to include a prediction function.

File Structure

Here is an overview of the project directory structure:

Text_Emotion_Classifier/
โ”‚
โ”œโ”€โ”€ val.txt                    # This the previous version of the test data set
โ”œโ”€โ”€ test.txt                   # Test Data set in this file for the train.txt
โ”œโ”€โ”€ train.txt                  # The dataset file containing text and emotion labels
โ”œโ”€โ”€ main.py                    # Main script to run the emotion classifier
โ”œโ”€โ”€ requirements.txt           # List of dependencies
โ”œโ”€โ”€ README.md                  # Project documentation
โ””โ”€โ”€ LICENSE                    # Project license

Contributing

Contributions are welcome! If you'd like to contribute to this project, please follow these steps:

  • Fork the repository & Star the repository
  • Create a new branch (git checkout -b feature)
  • Make your changes
  • Commit your changes (git commit -am 'Add new feature')
  • Push to the branch (git push origin feature)
  • Create a new Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

  1. Tensorflow
  2. Pandas
  3. Keras
  4. Kaggle
  5. NumPy

Contact

If you have any questions or suggestions, feel free to reach out to me at :

  1. GitHub
  2. Linkedin
  3. Twitter
  4. Portfolio

Happy Coding! FireStar

About

A ๐—ง๐—ฒ๐˜…๐˜ ๐—˜๐—บ๐—ผ๐˜๐—ถ๐—ผ๐—ป ๐—–๐—น๐—ฎ๐˜€๐˜€๐—ถ๐—ณ๐—ถ๐—ฒ๐—ฟ is an AI model that analyzes text to detect and classify emotions like ๐—ต๐—ฎ๐—ฝ๐—ฝ๐—ถ๐—ป๐—ฒ๐˜€๐˜€ ๐Ÿ˜Š, ๐˜€๐—ฎ๐—ฑ๐—ป๐—ฒ๐˜€๐˜€ ๐Ÿ˜ข, ๐—ฎ๐—ป๐—ด๐—ฒ๐—ฟ ๐Ÿ˜ , and ๐˜€๐˜‚๐—ฟ๐—ฝ๐—ฟ๐—ถ๐˜€๐—ฒ ๐Ÿ˜ฒ. It's used in sentiment analysis, customer feedback, and social media monitoring to understand and respond to emotions more effectively.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published