Skip to content

piroo8/Aps360

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Aps360

Final Code is in Final_Gen Folder and linked below as well

Twitter Sentiment Analysis Readme

This repository contains the code and necessary instructions to perform sentiment analysis on Twitter data using a Convolutional Neural Network (CNN). The code is implemented in Python and utilizes various libraries such as nltk, emoji, pandas, and torch.

Prerequisites

Before running the code, ensure that you have the following prerequisites:

  1. Google Colab: This code is designed to be run on Google Colab, a cloud-based Jupyter notebook environment.

  2. Dataset: Prepare your training and validation datasets in CSV format, containing at least the following columns: 'sentiment' and 'tweet'.

  3. GPU: A GPU is highly recommended for faster training times.

Getting Started

Follow these steps to get started with the sentiment analysis code:

  1. Open the provided Google Colab link: Twitter Sentiment Analysis Colab.

  2. Make a copy of the Colab notebook: Go to "File" > "Save a copy in Drive" to make your own copy.

  3. Upload your datasets: Replace the file paths for train_path and val_path with the paths to your training and validation datasets in the Colab notebook.

Running the Code

The provided code performs the following steps:

  1. Data Preprocessing:

    • Remove NaN values and empty rows.
    • Encode sentiment labels as integers (0: Negative, 1: Neutral, 2: Positive).
    • Clean and preprocess tweets by removing URLs, mentions, hashtags, emojis, etc.
  2. Model Building and Training:

    • Define a CNN architecture for sentiment analysis.
    • Train the model using the training dataset.
    • Tune hyperparameters (learning rate, dropout, optimizer) using hyperopt.
  3. Model Evaluation:

    • Evaluate the trained model on the validation dataset.
    • Display the confusion matrix and accuracy for each sentiment class.
  4. Predicting on Unseen Data:

    • Preprocess and clean unseen data.
    • Use the trained model to predict sentiment labels for the unseen data.
    • Display the confusion matrix and accuracy for the unseen data.

Customization

Feel free to customize the code for your specific needs:

  • Adjust hyperparameters: Modify hyperparameters such as learning rate, dropout rate, optimizer, and number of epochs to experiment with different settings.

  • Model architecture: You can modify the CNN architecture by changing the number of convolutional layers, filters, and fully connected layers.

  • Data preprocessing: Customize the data preprocessing steps to better fit your dataset's characteristics.

Conclusion

This readme provides an overview of the Twitter sentiment analysis code available in the provided Colab notebook. Follow the steps to upload your datasets, run the code, and customize it as needed for your sentiment analysis tasks. If you have any questions or need further assistance, feel free to reach out.

About

Project-Tweet

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors