Skip to content
sentiment-analysis
Menu

Understanding the scores

Every call to analyze() returns a Result with a label and four numbers. This page explains where they come from.

$result = Sentiment::analyze('VADER is smart, handsome, and funny.');

$result->compound; // 0.8316
$result->positive; // 0.746
$result->neutral;  // 0.254
$result->negative; // 0.0
$result->label;    // Label::Positive

Compound

compound is the one number to use when you want a single score. It runs from -1 (extremely negative) to +1 (extremely positive), rounded to four decimals.

It is computed in three steps:

  1. Every word found in the lexicon contributes its valence (-4 to +4), adjusted by the rules below.
  2. The valences are summed.
  3. The sum is normalized so it always lands between -1 and +1. Long, strongly worded text approaches the limits but never passes them.

Because of that last step, a compound of 0.5 does not mean “50% positive”. Read it as a position on a scale: close to 0 is neutral, close to ±1 is emphatic.

Positive, neutral and negative

positive, neutral and negative are ratios between 0 and 1, rounded to three decimals. They show how the text splits between positive signal, negative signal and everything else, and they add up to about 1.

For VADER is smart, handsome, and funny., 74.6% of the signal is positive, none is negative, and the remaining 25.4% is neutral (words with no sentiment, such as VADER and is).

These ratios are not probabilities. A text that is mostly neutral words with one mildly positive word can have a high neutral and still a clearly positive compound. Use them to see how a text is built, and use compound (or the label) to decide.

Label

The Label is derived from compound and the threshold:

Condition Label
compound >= threshold (and above 0) Label::Positive
compound <= -threshold (and below 0) Label::Negative
anything else Label::Neutral

The default threshold is 0.05, the value recommended by the VADER authors.

What changes a score

The model does not just add up word values. These rules shape the result:

Rule Example Effect
Negation not good Flips and softens the word
Intensifier very good, extremely bad Strengthens the word
Dampener kind of good, slightly bad Weakens the word
ALL CAPS this is GREAT Strengthens the shouted word
Exclamation marks great!!! Adds emphasis, up to 4 marks
Question marks great??? Adds a little emphasis
Contrast good food but terrible service The part after “but” weighs more
Emoticons and emoji :), ❤️, 😠 Count as sentiment words

For example, these English texts are in increasing order of positivity: not good, good, very good, VERY good!!!.

Indonesian has the same rules plus intensifiers that come after the word (bagus banget), contrast words such as tapi and namun, and informal negations such as gak. See Languages.

Examples

TextLabelCompoundPosNeuNeg
This package is awesome!Englishpositive0.65880.5940.4060.000
The movie was good.Englishpositive0.44040.4920.5080.000
The movie was not good.Englishnegative-0.34120.0000.6240.376
It isn't bad at all.Englishpositive0.43100.4160.5840.000
The service was extremely good.Englishpositive0.49270.4440.5560.000
The service was kind of good.Englishpositive0.38320.3430.6570.000
The plot was good, but the ending was terrible.Englishnegative-0.49390.1490.5340.317
I LOVE this phone.Englishpositive0.71250.6220.3780.000
The concert was great!!!Englishpositive0.71630.6240.3760.000
Thanks for the help :)Englishpositive0.82250.8110.1890.000
Loved the show 😍Englishpositive0.78450.5800.4200.000
Worst day ever 😭Englishnegative-0.80200.0000.3570.643
The meeting is at 3 pm.Englishneutral0.00000.0001.0000.000
Filmnya bagus banget!Indonesianpositive0.62300.6710.3290.000
Makanannya enak sekali.Indonesianpositive0.58490.6550.3450.000
Pelayanannya tidak ramah.Indonesiannegative-0.35700.0000.4460.554
Tempatnya nyaman tapi harganya mahal.Indonesiannegative-0.12800.2670.4000.333
Aku BENCI antrean panjang!!!Indonesiannegative-0.68170.0000.3940.606
Hotelnya lumayan, tapi kamarnya kotor.Indonesiannegative-0.64280.1620.3240.514
Kamera hp ini keren parah 😍Indonesianpositive0.77780.4920.5080.000
Besok rapat jam 3 sore.Indonesianneutral0.00000.0001.0000.000

Tips

  • Classify with the label, rank with compound.
  • Empty or whitespace-only text gives all zeros and a neutral label.
  • Text with no known words is neutral. The model only knows what its lexicon knows; add your own words for domain slang.
  • Long text is better analyzed sentence by sentence. See Long text.

Edit this page on GitHub