text_plain_output_1.png
from sklearn.feature_extraction.text import CountVectorizer

from sklearn.naive_bayes import MultinomialNB

import nltk

import pandas as pd

nltk.download('stopwords')
stop_words_english = nltk.corpus.stopwords.words('english')

train_path = '/kaggle/input/emotion-classification-nlp/emotion-labels-train.csv'
validation_path = '/kaggle/input/emotion-classification-nlp/emotion-labels-val.csv'
test_path = '/kaggle/input/emotion-classification-nlp/emotion-labels-test.csv'

train_pd = pd.read_csv(train_path)
validation_pd = pd.read_csv(validation_path)
test_pd = pd.read_csv(test_path)

all_train_data = pd.concat([train_pd, validation_pd, test_pd], ignore_index=True)

vectorizer_train = CountVectorizer(stop_words=stop_words_english)

xall = vectorizer_train.fit_transform(all_train_data['text'])
yall = all_train_data['label']

voc = vectorizer_train.get_feature_names_out()

clf = MultinomialNB()

clf.fit(xtrain, ytrain)

ypred = clf.predict(xtest)

test_sentence = "I don't know what's going on in this world, but all you know is that connection will bring freedom. Although we live in an unknown world, the existence of a woman who burns heaven is the cause of all beauty."

words_of_sentence = nltk.word_tokenize(test_sentence)

words_of_sentence = [w_ for w_ in words_of_sentence if w_ not in stop_words_english]

transform_test = vectorizer_train.transform(words_of_sentence)

pred_test = clf.predict(transform_test)

print(f'PREDICTION:\n\n{pred_test[0]}')