Sentiment Analysis with TextBlob

Поделиться
HTML-код
  • Опубликовано: 10 янв 2025

Комментарии •

  • @adityas3734
    @adityas3734 3 года назад

    Very useful tutorial.
    It is really helpful and you are really doing very good work🙏
    Thank you very much for providing precise knowledge in a simple way.

  • @zainababdulkareem7167
    @zainababdulkareem7167 2 года назад

    Very useful tutorial, Thank you

  • @khadijaquadri6889
    @khadijaquadri6889 2 года назад

    i have understood your explaination perfectly but i need the dataset for execution please help

  • @mekhla4002
    @mekhla4002 8 месяцев назад

    In 12 is giving error for my dataset. Can you please attach your dataset for reference

  • @samchimaobi3398
    @samchimaobi3398 Год назад

    I love video. I was helpful. I wish to make a request. Can u pls share the file u used in this video.....

  • @dianabarns5046
    @dianabarns5046 3 года назад

    Can you pease help me and tell how you separated negative and positive texts? I don't have such separation in my file(

  • @SwapnilBhole-y5z
    @SwapnilBhole-y5z Год назад

    Thank you it works

  • @precious_orim
    @precious_orim 2 года назад

    Thank you sir for the video. Pls I just wanted to know the best way to classify a data with polarity of exactly. Should it be Positive or Negative because on what I am working on, neutral is not an option

    • @learndatasciencewithpranja7060
      @learndatasciencewithpranja7060  2 года назад

      Thanks for Liking the video
      For deciding the polarity you can use either text Blob or Vader pretrained library. My experience says vader gives better results , but if your data is very specific and you think that it contains some words which are not part of English language and those words are significant in deciding if the sentiment is positive or negative then you need to train your own model

  • @khadijaquadri6889
    @khadijaquadri6889 2 года назад

    can you please give the link for dataset i request please

  • @dianabarns5046
    @dianabarns5046 3 года назад

    okay but what if all i рave is file wuth texy, without label (pos, neg), gow to do the same?

    • @learndatasciencewithpranja7060
      @learndatasciencewithpranja7060  3 года назад

      Hi Diana,
      In the original data set itself Label columns were there...Imagine company launched the product and customers are giving the feedback, so customer write the comments and also give rating ( That is pos or neg)
      so in this data i had the label column...but even if you do not have the label column and users are just writing the comments then also you can do the sentiment analysis just based on the comments and using text blob .
      If you check the code you will see while using the text blob i am not using the labels colum
      Text Blob is inbuild Library Dictionary which is pre trained for sentiment analysis similarly you can also use Vader .
      There is already a video on Vader library link for vader
      (ruclips.net/video/oSaTWvFaNd4/видео.html)
      Hope this explanation helps
      Pranjal

    • @dianabarns5046
      @dianabarns5046 3 года назад

      @@learndatasciencewithpranja7060 thank you so much, but I have one more question. After I am doing step with score/score 1 (12 step) - I have TypeError: The `text` argument passed to `__init__(text)` must be a string, not

    • @dianabarns5046
      @dianabarns5046 3 года назад

      I tried to solve it but nothing helped :(

    • @learndatasciencewithpranja7060
      @learndatasciencewithpranja7060  3 года назад +1

      i am putting the code over here you can use it just after changing the path while reading the file
      from textblob import TextBlob
      amazon = pd.read_csv(r"C:\Users\Pranjal Mishra\Documents\amazonreviews.tsv" , sep = '\t')
      polarity_score = []
      for i in range(0,amazon.shape[0] ):
      score = TextBlob(amazon.iloc[i][1])
      score1 = score.sentiment[0]
      polarity_score.append(score1)
      amazon = pd.concat([amazon, pd.Series(polarity_score)] , axis =1 )
      amazon.rename(columns={amazon.columns[2] :"Sentiment"}, inplace = True )
      amazon.head(10)
      i hope this will help

    • @dianabarns5046
      @dianabarns5046 3 года назад

      @@learndatasciencewithpranja7060 man thank you so much, you helped me, thank you! ^ ^ U saved me

  • @danishpatel8249
    @danishpatel8249 3 года назад

    Great Video, Helpful for clearing concept. 👍
    If you upload notebook on Github then it will really help full for practicing..

    • @learndatasciencewithpranja7060
      @learndatasciencewithpranja7060  3 года назад +2

      Hi Danish,
      My student community already have the code....but i am pasting whole code over here hope that will help you
      import pandas as pd
      import numpy as np
      from textblob import TextBlob
      import matplotlib.pyplot as plt
      from nltk.corpus import stopwords
      text1 = " food made at the resturant was very good"
      blob1 = TextBlob(text1)
      blob1.sentiment
      text2 = "flight was horrible and filled with turbulence"
      blob2 = TextBlob(text2)
      blob2.sentiment
      text3 = "earth revolves around the sun"
      blob3 = TextBlob(text3)
      blob3.sentiment
      ## polarity tells us how positive or negative the comment is
      ## value of polarity is range of -1 to + 1 ( -ve value indicates sentiment is not good)
      ## ( +ve value indicates sentiment is good))
      # value of subjectivitiy relates to wether it is a public opinion or its a factual information(range is 0 to 1)
      from textblob import TextBlob
      amazon = pd.read_csv(r"C:\Users\Pranjal Mishra\Documents\amazonreviews.tsv" , sep = '\t')
      amazon.label.value_counts()
      polarity_score = []
      for i in range(0,amazon.shape[0] ):
      score = TextBlob(amazon.iloc[i][1])
      score1 = score.sentiment[0]
      polarity_score.append(score1)
      amazon = pd.concat([amazon, pd.Series(polarity_score)] , axis =1 )
      amazon.rename(columns={amazon.columns[2] :"Sentiment"}, inplace = True )
      len(amazon[amazon.Sentiment > 0])
      len(amazon[amazon.Sentiment .1])
      from wordcloud import WordCloud
      WordCloud
      cloud = WordCloud(max_words= 50, stopwords=stopwords.words("english") ).generate(str(amazon['review']) )
      plt.figure(figsize= (10 , 10))
      plt.imshow(cloud)
      amazon_postive= amazon[amazon.label == 'pos']
      amazon_postive.shape
      cloud = WordCloud(max_words= 50, stopwords=stopwords.words("english") ).generate(str(amazon_postive['review']) )
      plt.figure(figsize= (10 , 10))
      plt.imshow(cloud)
      amazon_negative = amazon[amazon.label == 'neg']
      amazon_negative.shape
      cloud = WordCloud(max_words= 50, stopwords=stopwords.words("english") ).generate(str(amazon_negative['review']) )
      plt.figure(figsize= (10 , 10))
      plt.imshow(cloud)

    • @danishpatel8249
      @danishpatel8249 3 года назад

      @@learndatasciencewithpranja7060 thank you sir..

    • @jeevanasenthilkumar
      @jeevanasenthilkumar 2 года назад

      @@learndatasciencewithpranja7060 hi sir how can i download the dataset that you have used

    • @learndatasciencewithpranja7060
      @learndatasciencewithpranja7060  2 года назад +1

      Hi Jeeva ,
      These data sets are easily available on net.
      if you are not getting the data yet..share your email id...i will mail all these data sets
      happy learning

    • @jeevanasenthilkumar
      @jeevanasenthilkumar 2 года назад

      @@learndatasciencewithpranja7060 hi sir I want some helps regarding my python project can you please help me ❤️can i mail you?