iTzMiNOS/BERT-finetuned-multiclass-tweet-sentiment-analysis

Overview

This repository contains a fine-tuned BERT (bert-base-uncased) model for multi-class sentiment analysis of tweets. The model was trained on a labeled dataset of tweets, allowing it to classify text into different sentiment categories.

Model Details

Base Model: bert-base-uncased

Dataset: Custom twitter labeled data

Task: Multi-class sentiment analysis

Fine-Tuning Framework: Hugging Face transformers

Evaluation Metrics: Accuracy, F1-score

Training Process

Data Preparation:

The dataset was split into training (70%), validation (10%), and test (20%) sets.

Text data was tokenized using AutoTokenizer from Hugging Face.

Model Configuration:

Fine-tuned BERT-base-uncased with classification head.

label2id and id2label mappings created for multi-class classification.

Mappings

['joy', 'anger', 'sadness', 'surprised', 'love', 'fear']

Training Parameters:

Epochs: 2

Batch Size: 64

Learning Rate: 2e-5

Weight Decay: 0.01

Evaluation:

Used accuracy and weighted F1-score as performance metrics.

Generated a classification report and confusion matrix.

Inference:

Text classification pipeline created using Hugging Face pipeline.

Example prediction:

text = "I am feeling happy today!"
classifier = pipeline('text-classification', model='iTzMiNOS/BERT-finetuned-multiclass-tweet-sentiment-analysis')
print(classifier(text))

Installation & Usage

Install Dependencies

pip install transformers datasets torch

Load the Model

from transformers import pipeline

classifier = pipeline('text-classification', model='iTzMiNOS/BERT-finetuned-multiclass-tweet-sentiment-analysis')

text = "I am so excited for the weekend!"
result = classifier(text)
print(result)

Evaluate Model Performance

from sklearn.metrics import classification_report, confusion_matrix
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np

# Example test set predictions

y_true = [...]  # Actual labels
y_pred = [...]  # Model predictions

print(classification_report(y_true, y_pred))

cm = confusion_matrix(y_true, y_pred)
plt.figure(figsize=(5,5))
sns.heatmap(cm, annot=True, fmt='d', cmap='Reds')
plt.ylabel("Actual")
plt.xlabel("Predicted")
plt.show()

License

This model is open-source and can be used under the MIT License.

Downloads last month
601
Safetensors
Model size
109M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for iTzMiNOS/BERT-finetuned-multiclass-tweet-sentiment-analysis

Finetuned
(3781)
this model