Sentiment Analyzer¶
- class vnlp.sentiment_analyzer.sentiment_analyzer.SentimentAnalyzer(model='SPUCBiGRUSentimentAnalyzer', evaluate=False)[source]¶
Main API class for Sentiment Analyzer implementations.
Available models: [‘SPUCBiGRUSentimentAnalyzer’]
In order to evaluate, initialize the class with “evaluate = True” argument. This will load the model weights that are not trained on test sets.
- predict(text: str) int [source]¶
High level user API for discrete Sentiment Analysis prediction.
1: Positive sentiment.
0: Negative sentiment.
- Parameters:
text – Input text.
- Returns:
Sentiment label of input text.
Example:
from vnlp import SentimentAnalyzer sentiment_analyzer = SentimentAnalyzer() sentiment_analyzer.predict("Sipariş geldiğinde biz karnımızı çoktan atıştırmalıklarla doyurmuştuk.") 0
- predict_proba(text: str) float [source]¶
High level user API for probability estimation of Sentiment Analysis.
- Parameters:
text – Input text.
- Returns:
Probability that the input text has positive sentiment.
Example:
from vnlp import SentimentAnalyzer sentiment_analyzer = SentimentAnalyzer() sentiment_analyzer.predict_proba("Sipariş geldiğinde biz karnımızı çoktan atıştırmalıklarla doyurmuştuk.") 0.08
SentencePiece Unigram Context BiGRU Sentiment Analyzer¶
- class vnlp.sentiment_analyzer.spu_context_bigru_sentiment.SPUCBiGRUSentimentAnalyzer(evaluate)[source]¶
SentencePiece Unigram Context Bidirectional GRU Sentiment Analyzer class.
This is a Bidirectional GRU based Sentiment Analyzer that uses SentencePiece Unigram tokenizer and pre-trained Word2Vec embeddings.
It achieves 0.9469 Accuracy, 0.9380 F1 macro score and 0.9147 F1 score (treating class 0 as minority).
For more details about the training procedure, dataset and evaluation metrics, see ReadMe.