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.
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
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
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
@@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
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
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)
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
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.
Thanks Aditya for liking the video..
Very useful tutorial, Thank you
i have understood your explaination perfectly but i need the dataset for execution please help
In 12 is giving error for my dataset. Can you please attach your dataset for reference
I love video. I was helpful. I wish to make a request. Can u pls share the file u used in this video.....
Can you pease help me and tell how you separated negative and positive texts? I don't have such separation in my file(
Thank you it works
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
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
can you please give the link for dataset i request please
okay but what if all i рave is file wuth texy, without label (pos, neg), gow to do the same?
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
@@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
I tried to solve it but nothing helped :(
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
@@learndatasciencewithpranja7060 man thank you so much, you helped me, thank you! ^ ^ U saved me
Great Video, Helpful for clearing concept. 👍
If you upload notebook on Github then it will really help full for practicing..
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)
@@learndatasciencewithpranja7060 thank you sir..
@@learndatasciencewithpranja7060 hi sir how can i download the dataset that you have used
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
@@learndatasciencewithpranja7060 hi sir I want some helps regarding my python project can you please help me ❤️can i mail you?