Sentiment_Analysis_of_songs_using_NLP_and_SVM

share link

by bidura dot icon Updated: Jul 8, 2023

technology logo
technology logo

Guide Kit Guide Kit  

DESCRIPTION

Aim:

The aim of this project is to analyze the sentiment of a song to be positive, negative or neutral based on its lyrics.

Procedure:

The songs lyrics in the form of text is first pre-processed using nltk library. The various steps such as punctuation removal,tokenization, stop-word removal, etc is done. From nltk sentiment analyzer is imported and it is used to detect the sentiment of the song lyrics. The sentiments are stored in the form of labels. The dataset is then split into training and testing data. They are converted to bad-of-words and tfidf sparse matrix is created using the bag-of-words vector. Then sklearn's svm model is imported. The svm model is fitted/trained with the training data tfidf sparse matrix and it predicts labels using testing data tfidf sparse matrix. On evaluation of the model using a classification report, the accuracy was found to be 82%.

Testing Method:

2 songs with their lyrics were taken and sentiment analysis library was used to label their actual sentiments.

Then the svm model was used to predict their sentiments.

The 2 outcomes were similar.

Future Enhancements:

To improve model accuracy

To use different classification models such as Naive_Bayes classifier (Multinomialnb)


DEPENDANT LIBRARIES

scikit-learnby scikit-learn

Python doticonstar image 54584 doticonVersion:1.2.2doticon
License: Permissive (BSD-3-Clause)

scikit-learn: machine learning in Python

Support
    Quality
      Security
        License
          Reuse

            scikit-learnby scikit-learn

            Python doticon star image 54584 doticonVersion:1.2.2doticon License: Permissive (BSD-3-Clause)

            scikit-learn: machine learning in Python
            Support
              Quality
                Security
                  License
                    Reuse

                      nltkby nltk

                      Python doticonstar image 12020 doticonVersion:Currentdoticon
                      License: Permissive (Apache-2.0)

                      NLTK Source

                      Support
                        Quality
                          Security
                            License
                              Reuse

                                nltkby nltk

                                Python doticon star image 12020 doticonVersion:Currentdoticon License: Permissive (Apache-2.0)

                                NLTK Source
                                Support
                                  Quality
                                    Security
                                      License
                                        Reuse

                                          pandasby pandas-dev

                                          Python doticonstar image 38689 doticonVersion:v2.0.2doticon
                                          License: Permissive (BSD-3-Clause)

                                          Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more

                                          Support
                                            Quality
                                              Security
                                                License
                                                  Reuse

                                                    pandasby pandas-dev

                                                    Python doticon star image 38689 doticonVersion:v2.0.2doticon License: Permissive (BSD-3-Clause)

                                                    Flexible and powerful data analysis / manipulation library for Python, providing labeled data structures similar to R data.frame objects, statistical functions, and much more
                                                    Support
                                                      Quality
                                                        Security
                                                          License
                                                            Reuse

                                                              GITHUB REPOSITORY LINK

                                                              https://github.com/Bidura/OpenWeaver2.


                                                              this link consists of the '.ipynb' file as well as '.csv' files that were used

                                                              SCREENSHOTS

                                                              CODE




                                                              OUTPUT






                                                              See similar Kits and Libraries