How Hacker News rating actually works: scoring, controversy, and penalties
Does the revealed code give the true algorithm?
Are rankings purely primarily based on votes or do invisible elements come into play?
Do tales concerning the NSA get pushed down within the rankings? Why did that standard story all of a sudden disappear from the entrance web page after you commented on it?
By fastidiously analyzing the highest 60 HN tales for a number of days, I can reply these questions and extra.
The revealed system is usually correct.
There is rather more tweaking of rankings than you’d anticipate, with 20% of front-page tales getting penalized in varied methods. Anything with “NSA” within the title is penalized and drops off shortly. A “controversial” story will get severely penalized after hitting 40 feedback. This article describes scoring and penalties intimately. [Edit: HN no longer penalizes NSA articles (details).]
How rating works
Articles are scored primarily based on their upvote rating, the time because the article was submitted, and varied penalties utilizing the next formula:
Because the time has a bigger exponent than the votes, an article’s rating will finally drop to zero, so nothing stays on the entrance web page too lengthy. This exponent is called gravity.
You would possibly anticipate that each time you go to Hacker News, the tales are scored by the above system and sorted to find out their rankings. But for effectivity, tales are individually reranked solely sometimes. When a narrative is upvoted, it’s reranked and moved up or down the record to its applicable spot, leaving the opposite tales unchanged. Thus, the quantity of reranking is considerably lowered. There is, nonetheless, the chance {that a} story stops getting votes and finally ends up caught in a excessive place. To keep away from this, each 30 seconds one of many prime 50 tales is randomly chosen and reranked. The consequence is {that a} story could also be “wrongly” ranked for a lot of minutes if it is not getting votes.
In addition, pages could be cached for 90 seconds.
Raw scores and the #1 spot on a typical day
The following picture reveals the uncooked scores (excluding penalties) for the highest 60 HN articles all through the day of November 11. Each line corresponds to an article, coloured in response to its place on the web page.
The purple line reveals the highest article on HN. Note that due to penalties, the article with the highest uncooked rating usually is not the highest article.
This chart reveals a couple of fascinating issues. The rating for an article shoots up quickly after which slowly drops over many hours. The scoring system accounts for a lot of this: an article getting a relentless charge of votes will peak shortly after which regularly descend. But the noticed peak is even sooner – it’s because articles are inclined to get a whole lot of votes within the first hour or two, after which the voting charge drops off. Combining these two elements yields the steep curves proven.
There are a couple of articles every day that rating a lot above the remaining, together with a whole lot of articles within the center. Some articles rating very properly however are unfortunate and get caught behind a extra standard article. Other articles hit #1 briefly, between the autumn of 1 and the climb of one other.
Looking on the distinction between the article with the highest uncooked rating (prime of the graph) and the top-ranked article (purple line), you’ll be able to see when penalties have been utilized.
The article Getting website registration completely wrong hit #1 early within the morning, however was penalized for controversy and quickly dropped down the web page, letting Linux ate my RAM briefly get the #1 spot earlier than Simpsons in CSS overtook it.
A bit later, the controversy penalty was utilized to Apple Maps shortly after it reached the #1 spot, inflicting it to lose its #1 spot and quickly drop down the rankings.
The Snapchat article reached the highest of HN however was penalized so closely at 8:22 am that it dropped off the chart totally.
Why you should never use MongoDB was massively standard and would have spent a lot of the day within the #1 spot, besides it was quickly penalized and languished round #7.
Severing ties with the NSA began off with a NSA penalty however was so massively standard it nonetheless bought the #1 spot. However, it was shortly given a fair larger penalty, forcing it down the web page. Finally, close to the tip of the day $4.1m goes missing was penalized. As it seems, it could have quickly misplaced the #1 spot to FTL even with out the penalty.
The inexperienced triangles and textual content present the place “controversy” penalties had been utilized. The blue triangles and textual content present the place articles had been penalized into oblivion, dropping off the highest 60. Milder penalties should not proven right here.
It’s clear that the content material of the #1 spot on HN is not “pure”, however outcomes from the fixed utility of penalties to many articles. It’s unclear if these penalties outcome from HN directors or from flagged articles.
Submissions that get robotically penalized
Some submissions get robotically penalized primarily based on the title, and others get penalized primarily based on the area.
It seems that any article with NSA within the title will get an automated penalty of .4. I appeared for different phrases inflicting automated penalties, similar to superior, bitcoin, and bubble however they don’t appear to get penalized.
I noticed that many web sites seem to robotically get a penalty of .25 to .8:
arstechnica.com, businessinsider.com, easypost.com, github.com, imgur.com, medium.com, quora.com, qz.com, reddit.com, rt.com, stackexchange.com, theguardian.com, theregister.com, theverge.com, torrentfreak.com, youtube.com. I’m certain the precise record is longer. (This is separate from “banned” websites, which had been listed at one level.
One interesting theory by eterm is that information from standard sources will get submitted in parallel by a number of folks leading to extra upvotes than the article “deserves”. Automatically penalizing standard web sites would assist counteract this impact.
The influence of penalties
Using the scoring system, the influence of a penalty could be computed. If an article will get a penalty issue of .4, that is equal to every vote solely counting as .3 votes. Alternatively, the article will drop in rating 66% sooner than regular. A penalty issue of .1 corresponds to every vote counting as .05 votes, or the article dropping at 3.6 instances the conventional charge. Thus, a penalty issue of .4 has a major influence, and .1 may be very extreme.
Controversy
In order to forestall flamewars on Hacker News, articles with “too many” feedback will get closely penalized as “controversial”.
In the revealed code, the contro-factor operate kicks in for any publish with greater than 20 feedback and extra feedback than upvotes. Such an article is scaled by (votes/feedback)^2. However, the precise system is completely different – it’s energetic for any publish with extra feedback than upvotes and at the least 40 feedback. Based on empirical information, I believe the exponent is 3, quite than 2 however have not confirmed this.
The controversy penalty can have a sudden and catastrophic impact on an article’s rating, inflicting an article to be ranked extremely one minute and vanish when it hits 40 feedback. If you’ve got questioned why a preferred article all of a sudden vanishes from the entrance web page, controversy is a possible trigger.
For instance,
Why the Chromebook pundits are out of touch with reality dropped from #5 to #22 the second it hit 40 feedback, and
Show HN: Get your health records from any doctor’ was at #17 however vanished from the highest 60 totally on hitting 40 feedback.
My methodology
I crawled the /information and /news2 pages each minute (staying underneath the two pages per minute guideline). I parsed the (considerably ugly) HTML with Beautiful Soup, processed the outcomes with an enormous pile of Python scripts, and graphed outcomes with the incomprehensible however highly effective matplotlib.
The fundamental thought behind the evaluation is to generate uncooked scores utilizing the system after which search for anomalies. At a cut-off date (e.g. 11/09 8:46), we will compute the uncooked scores on the highest 10 tales:
2.802 Pyret: A brand new programming language from the creators of Racket 1.407 The Big Data Brain Drain: Why Science is in Trouble 1.649 The NY Times endorsed a secretive commerce settlement that the general public cannot learn 0.785 S.F. programmers construct various to HealthCare.gov (warning: autoplay video) 0.844 Marelle: logic programming for devops 0.738 Sprite Lamp 0.714 Why Teenagers Are Fleeing Facebook 0.659 NodeKnockout is in Full Tilt. Checkout some demos 0.805 ISO 1 0.483 Shopify accepts Bitcoin. 0.452 Show HN: Understand closures
Note that three of the highest 10 articles are ranked decrease than anticipated from their rating: The NY Times, Marelle and ISO 1. Since The NY Times is ranked between articles with 1.407 and 0.785, its penalty issue could be computed as between .47 and .85. Likewise, the opposite penalties have to be .87 to .93, and .60 to .82.
I noticed that the majority tales are ranked in response to their rating, and the exceptions are constantly ranked a lot decrease, indicating a penalty. This signifies that the scoring system in use matches the revealed code. If the system had been completely different, as an example the gravity exponent had been bigger, I’d anticipate to see tales drift out of their “anticipated” rating as their votes or age elevated, however I by no means noticed this.
This approach reveals the existence of a penalty and provides a spread for the penalty, however figuring out the precise penalty is troublesome. You can have a look at the vary over time and hope that it converges to a single worth. However, a number of sources of error mess this up. First, the neighboring articles may have penalties utilized, or be scored in a different way (e.g. job postings). Second, as a result of articles should not consistently reranked, an article could also be misplaced briefly. Third, the penalty on an article could change over time. Fourth, the reported vote rely could differ from the precise vote rely as a result of “dangerous” votes get suppressed. The result’s that I’ve been in a position to decide approximate penalties, however there’s a good bit of numerical instability.
Penalties over a day
The following graph reveals the calculated penalties over the course of a day. Each line reveals a selected article. It ought to begin off at 1 (no penalty), after which drop to a penalty degree when a penalty is utilized. The line ends when the article drops off the highest 60, which could be pretty quickly after the penalty is utilized. There appear to be penalties of 0.2 and 0.4, in addition to rather a lot within the 0.8-0.9 vary. It seems like a whole lot of penalties are utilized at 9am (when moderators arrive?), with extra all through the day. I’m experimenting with completely different algorithms to enhance the graph since it’s fairly noisy.

On common, about 20% of the articles on the entrance web page have been penalized, whereas 38% of the articles on the second web page have been penalized. (The entrance web page charge is decrease since penalized articles are much less prone to be on the entrance web page, sort of by definition.) There is much more penalization happening than you would possibly anticipate.
Here’s an inventory of the articles on the entrance web page on 11/11 that had been penalized. (This excludes articles that would have been there in the event that they weren’t penalized.) This record is for much longer than I anticipated; scroll for the total record.
Facebook Publications,
Bill Gates: What I Learned in the Fight Against Polio,
McCain says NSA chief Keith Alexander ‘should resign or be fired’,
You are not a software engineer,
What is a y-combinator?,
Typhoon Haiyan kills 10,000 in Philippines,
To Persuade People, Tell Them a Story,
Tetris and The Power Of CSS,
Microsoft Research Publications,
Moscow subway sells free tickets for 30 sit-ups,
The secret world of cargo ships,
These weeks in Rust,
Empty-Stomach Intelligence,
Getting website registration completely wrong,
The Six Most Common Species Of Code,
Amazon to Begin Sunday Deliveries, With Post Office’s Help,
Linux ate my RAM,
Simpsons in CSS,
Apple maps: how Google lost when everyone thought it had won,
Docker and Go: why did we decide to write Docker in Go?,
Amazon Code Ninjas,
Last Doolittle Raiders make final toast,
Linux Voice – A new Linux magazine that gives back,
Want to download anime? Just made a program for that,
Commit 15 minutes to explain to a stranger why you love your job.,
Why You Should Never Use MongoDB,
Show HN: SketchDeck – build slides faster,
Zero to Peanut Butter Docker Time in 78 Seconds,
NSA’s Surveillance Powers Extend Far Beyond Counterterrorism,
How Sentry’s Open Source Service Was Born,
Real World OCaml,
Show HN: Get your health records from any doctor,
Why the Chromebook pundits are out of touch with reality,
Towards a More Modular Future for JavaScript Libraries,
Why is virt-builder written in OCaml?,
IOS: End of an Era,
The craziest things you can plug into your iPhone’s audio jack,
RFC: Replace Java with Go in default languages,
Show HN: Find your health plan on Health Sherpa,
Web Latency Benchmark: A new kind of browser benchmark,
Why are Amazon, Facebook and Yahoo copying Microsoft’s stack ranking system?,
Severing Ties with the NSA,
Doctor performs surgery using Google Glass,
Duplicity + S3: Easy, cheap, encrypted, automated full-disk backups,
Bitcoin’s UK future looks bleak,
Amazon Redshift’s New Features,
You’re only getting the nice feedback,
Software is Easy, Hardware is of Medium Difficulty,
Facebook Warns Users After Adobe Breach,
International Space Station Infected With USB Stick Malware,
Tidbit: Client-Side Bitcoin Mining,
Go: “I have already used the name for *MY* programming language”,
Multi-Modal Drone: Fly, Swim & Drive,
The Daily Go Programming Newspaper,
“We have no food, we need water and other things to survive.”,
Introducing the Humble Store,
The Six Most Common Species Of Code,
$4.1m goes missing as Chinese bitcoin trading platform GBL vanishes,
Could Bitcoin Be More Disruptive than the Internet?,
Apple Store is updating.
The code for the scoring system
The Arc supply code for a model of the HN server is available, in addition to an updated scoring formula:
(= gravity* 1.8 timebase* 120 front-threshold* 1
nourl-factor* .4 lightweight-factor* .17 gag-factor* .1)
(def frontpage-rank (s (o scorefn realscore) (o gravity gravity*))
(* (/ (let base (- (scorefn s) 1)
(if (> base 0) (expt base .8) base))
(expt (/ (+ (item-age s) timebase*) 60) gravity))
(if (no (in s!sort 'story 'ballot)) .8
(clean s!url) nourl-factor*
(mem 'bury s!keys) .001
(* (contro-factor s)
(if (mem 'gag s!keys)
gag-factor*
(light-weight s)
lightweight-factor*
1)))))
In case you do not learn Arc code, the above snippet defines a number of constants: gravity* = 1.8, timebase* = 120 (minutes), and so on. It then defines a way frontpage-rank that ranks a narrative s primarily based on its upvotes (realscore) and age in minutes (item-age).
The penalty issue is outlined by an if with a number of instances. If the article shouldn’t be a ‘story’ or ‘ballot’, the penalty issue is .8. Otherwise, if the URL discipline is clean (Ask HN, and so on.) the issue is nourl-factor*. If the story has been flagged as ‘bury’, the dimensions issue is 0.001 and the article is ranked into oblivion. Finally, the default case combines the controversy issue and the gag/light-weight issue.
The controversy issue contro-factor is meant to suppress articles which might be resulting in flamewars, and is mentioned extra later.
The subsequent issue hits an article flagged as a gag (joke) with a heavy worth of .1, and a “light-weight” article with an element of .17. The precise penalty system seems to be rather more complicated than what seems within the revealed code.
Conclusion
An article’s place on the Hacker News residence web page is not the meritocracy primarily based on upvotes that you simply would possibly anticipate.
By fastidiously analyzing the articles that seem on the Hacker News web page, we will be taught an ideal deal concerning the scoring system in use. While upvotes are the plain issue controlling rankings, there’s additionally a fancy “penalty” system inflicting articles to be ranked decrease or disappear totally. This is not simply stopping spam, however impacts many very fashionable articles. And if an article has extra feedback than votes, do not add your remark to it or you might kill it off totally!
See dialogue on Hacker News.
Update (11/18): article on penalties is penalized
Ironically, this text was penalized on Hacker News. Minutes after reaching the entrance web page, a heavy 0.2 penalty was utilized to the article, forcing it off the entrance web page. The black line within the graph beneath reveals the place of this text on Hacker News. You can see the sharp drop when the penalty was utilized. The grey line reveals the place the article would have been ranked with out the penalty. Without the penalty, the article would have been within the #5 spot, however with the penalty it by no means made it again onto the entrance web page (positions 1-30). The decrease inexperienced line reveals the uncooked rating of this text. (11/26: I’m informed that the penalty was as a result of the “voting ring detection” triggered erroneously.)



