User Tools

Site Tools


compilers:nlp_sentiment_analysis
Return to Home page

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
compilers:nlp_sentiment_analysis [2021/08/13 14:32]
pietro [Comparison]
compilers:nlp_sentiment_analysis [2021/08/13 17:18] (current)
zioskenz
Line 213: Line 213:
 For example, the review "The item I bought is really really good" will be evaluated as positive since the average sentiment of the words is positive. \\ \\ For example, the review "The item I bought is really really good" will be evaluated as positive since the average sentiment of the words is positive. \\ \\
 In the real implementation, the logarithm of the likelihood and prior has been used since they provide smaller values without modifying the meaning of the value. When hundreds of thousands of data feeds the algorithm is crucial not to work with reasonable values. This lead to the use of a different formula with respect to the one shown above, since the properties of the logarithms can be exploited. The prior will be called //logprior// and will be computed in this way: In the real implementation, the logarithm of the likelihood and prior has been used since they provide smaller values without modifying the meaning of the value. When hundreds of thousands of data feeds the algorithm is crucial not to work with reasonable values. This lead to the use of a different formula with respect to the one shown above, since the properties of the logarithms can be exploited. The prior will be called //logprior// and will be computed in this way:
-{{  https://www.skenz.it/repository/compilers/ass/NLP_sentiment_analysis/logprior.jpg?300  }}+{{  https://www.skenz.it/repository/compilers/ass/NLP_sentiment_analysis/logprior.jpg?600  }}
 Then the likelihood of a word becomes //loglikelihood// and is computed using this formula: Then the likelihood of a word becomes //loglikelihood// and is computed using this formula:
-{{  https://www.skenz.it/repository/compilers/ass/NLP_sentiment_analysis/loglikelihood.jpg?300  }}+{{  https://www.skenz.it/repository/compilers/ass/NLP_sentiment_analysis/loglikelihood.jpg?600  }}
 Eventually, to evaluate the polarity of a review is computed by summing the loglikelihood of each word that composes the review. Eventually, to evaluate the polarity of a review is computed by summing the loglikelihood of each word that composes the review.
-{{  https://www.skenz.it/repository/compilers/ass/NLP_sentiment_analysis/polarity.jpg?300  }}+{{  https://www.skenz.it/repository/compilers/ass/NLP_sentiment_analysis/polarity.jpg?600  }}
  
 Since this is a supervised algorithm there is the need of dividing the dataset into training and testing classes. This is done after the call to //loadReviews()//. The first 24343 positive and negative reviews are used as training while as shown before the last 50 are used to test the model. Then the frequency dictionary is created and then the model is tested using the function //train_naive_bayes()// which returns the prior and the likelihood. Finally, each test review is used to evaluate the algorithm using //naive_bayes_predict()//. Since this is a supervised algorithm there is the need of dividing the dataset into training and testing classes. This is done after the call to //loadReviews()//. The first 24343 positive and negative reviews are used as training while as shown before the last 50 are used to test the model. Then the frequency dictionary is created and then the model is tested using the function //train_naive_bayes()// which returns the prior and the likelihood. Finally, each test review is used to evaluate the algorithm using //naive_bayes_predict()//.

If you found any error, or if you want to partecipate to the editing of this wiki, please contact: admin [at] skenz.it

You can reuse, distribute or modify the content of this page, but you must cite in any document (or webpage) this url: https://www.skenz.it/compilers/nlp_sentiment_analysis?do=diff
/web/htdocs/www.skenz.it/home/data/pages/compilers/nlp_sentiment_analysis.txt ยท Last modified: 2021/08/13 17:18 by zioskenz