Frecency algorithm

Frecency is a score given to each unique URI in Places, encompassing bookmarks, history and tags. This score is determined by the amount of revisitation, the type of those visits, how recent they were, and whether the URI was bookmarked or tagged.

The word "frecency" itself is a combination of the words "frequency" and "recency."

  • The default frecency value for all valid entries is -1. Places with this value can show up in autocomplete results.
  • Invalid places have a frecency value of zero, and will not show up in autocomplete results. Examples of invalid places are "place:" queries, and unvisited livemark feed entries.

The frecency calculation process

For the 10 most recent visits (where 10 is determined by places.frecency.numVisits):
.. Determine percentage bonus for type of visit (ie: the "transition type"):
.... 0 (places.frecency.embedVisitBonus)
.... 120 (places.frecency.linkVisitBonus)
.... 200 (places.frecency.typedVisitBonus)
.... 140 (places.frecency.bookmarkVisitBonus)
.... 0 (places.frecency.downloadVisitBonus)
.... 0 (places.frecency.permRedirectVisitBonus)
.... 0 (places.frecency.tempRedirectVisitBonus)
.... 0 (places.frecency.defaultVisitBonus)
.. Determine weight, based on how recent the visit was:
.... 100 (places.frecency.firstBucketWeight, 4 days bucket size, in places.frecency.firstBucketCutoff)
.... 70 (places.frecency.secondBucketWeight, 14 days bucket size, in places.frecency.secondBucketCutoff)
.... 50 (places.frecency.thirdBucketWeight, 31 days bucket size, in places.frecency.thirdBucketCutoff)
.... 30 (places.frecency.fourthBucketWeight, 90 days bucket size, in places.frecency.fourthBucketCutoff)
.... 10 (places.frecency.defaultBucketWeight, bucket size in places.frecency.defaultBucketCutoff)
.. Points for each sampled visit = (bonus / 100.0) * weight
Final frecency score for visited URI = ceiling(total visit count * sum of points for sampled visits / number of sampled visits)

Example

This is an example of a frecency calculation for a URI that is bookmarked and has been visited twice recently (once yesterday, and once last week by clicking a link), and two other times more than 90 days ago:

0 Default score
+140 100 * (140/100.0) - First bucket weight and bookmarked bonus
+84 70 * (120/100.0) - Second bucket weight and followed-link bonus
+14 10 * (140/100.0) - Fifth bucket weight and bookmarked bonus
+14 10 * (140/100.0) - Fifth bucket weight and bookmarked bonus
--
252 (4 * 252 / 4) - Final frecency score

Notes

  • The number of sampled visits is min(10 most recent visits pref, total visit counts).
  • The total visit count includes embedded, undefined, etc visits (does not exclude invalid or embedded visits).

Developer notes

There are various development notes you can read about Places that may offer additional insights:

History

  • The initial algorithm design was by Mike Connor and Seth Spitzer.
  • The initial implementation was done by Seth and Dietrich Ayala.
  • Further features and refinement by Ed Lee (implemented adaptive matching and most of the character restrictors), Marco Bonardo and Shawn Wilsher.
  • The latter two later ported all of the code from C++ to JavaScript.