How Hacker News ranking works: scoring, controversy, and penalties (2013)

Hacker News by 14 min read 513x views
How Hacker News ranking works: scoring, controversy, and penalties (2013)

Share Post

The essential equation for Hacker News ranking has been known for years, but questions remained. Does the published code provision the genuine algorithm? Are rankings purely according to votes or do invisible factors arrive into play? Do stories concerning the NSA get pushed downward in the rankings? Why did that famous narrative abruptly disappear from the forefront leaf following you commented on it?

By carefully analyzing the top 60 HN stories for multiple days, I can answer those questions and more. The published equation is mostly accurate. There is much additional tweaking of rankings than you'd expect, alongside 20% of front-page stories getting penalized in assorted ways. Anything alongside "NSA" in the heading is penalized and drops off quickly. A "controversial" narrative gets seriously penalized following hitting 40 comments. This part describes scoring and penalties in detail. [Edit: HN no longer penalizes NSA articles (details).]

How ranking works

Articles are scored according to their upvote score, the period since the part was submitted, and assorted penalties using the following formula: score=\frac{ \left( votes-1 \right) ^{.8}}{ \left( age _{hours} + 2 \right) ^ {1.8}} * penalties

Because the period has a larger exponent than the votes, an article's mark volition eventually autumn to zero, so nothing stays on the forefront leaf too long. This exponent is known as gravity.

You power anticipate that all period you sojourn Hacker News, the stories are scored by the complete equation and sorted to decide their rankings. But for efficiency, stories are individually reranked lone occasionally. When a narrative is upvoted, it is reranked and moved up or downward the catalog to its suitable spot, leaving the another stories unchanged. Thus, the amount of reranking is considerably reduced. There is, however, the possible that a narrative stops getting votes and ends up stuck in a elevated position. To evade this, all 30 seconds among the top 50 stories is randomly selected and reranked. The consequence is that a narrative may be "wrongly" classified for many minutes if it isn't getting votes. In addition, pages can be cached for 90 seconds.

Raw scores and the #1 place on a representative day

The following depiction shows the raw scores (excluding penalties) for the top 60 HN articles throughout the day of November 11. Each row corresponds to an article, colored according to its stance on the page. The red row shows the top part on HN. Note that since of penalties, the part alongside the top raw mark frequently isn't the top article.

Hacker News raw part scores throughout a day. Red row indicates the #1 article. Due to penalties, the #1 part does not continually have the top score.

This diagram shows a few engaging things. The mark for an part shoots up quickly and afterward gradually drops complete many hours. The scoring equation accounts for much of this: an part getting a changeless charge of votes volition highest quickly and afterward gradually descend. But the observed highest is equal faster - this is since articles lean to get a lot of votes in the archetypal hr or two, and afterward the voting charge drops off. Combining these two factors yields the steep curves shown.

There are a few articles all day that mark much complete the rest, alongside alongside a lot of articles in the middle. Some articles mark extremely fine but are unlucky and get stuck rearward a additional famous article. Other articles hit #1 briefly, between the autumn of one and the ascend of another.

Looking at the difference between the part alongside the top raw mark (top of the graph) and the top-ranked part (red line), you can see whenever penalties have been applied. The part Getting website registration entirely wrong hit #1 first in the morning, but was penalized for disagreement and quickly dropped downward the page, letting Linux ate my RAM briefly get the #1 place before Simpsons in CSS overtook it. A bit later, the disagreement penalty was applied to Apple Maps shortly following it reached the #1 spot, causing it to endure its #1 place and quickly autumn downward the rankings. The Snapchat part reached the top of HN but was penalized so heavily at 8:22 am that it dropped off the diagram entirely. Why you should never use MongoDB was hugely famous and would have spent much of the day in the #1 spot, apart from it was quickly penalized and languished about #7. Severing ties alongside the NSA started off alongside a NSA penalty but was so hugely famous it motionless got the #1 spot. However, it was quickly stated an equal bigger penalty, forcing it downward the page. Finally, near the end of the day $4.1m goes missing was penalized. As it turns out, it would have shortly misplaced the #1 place to FTL equal without the penalty.

The green triangles and content display anywhere "controversy" penalties were applied. The blue triangles and content display anywhere articles were penalized into oblivion, dropping off the top 60. Milder penalties are not shown here.

It's apparent that the satisfied of the #1 place on HN isn't "natural", but results from the changeless use of penalties to many articles. It's unclear if these penalties outcome from HN administrators or from flagged articles.

Submissions that get automatically penalized

Some submissions get automatically penalized according to the title, and others get penalized according to the domain. It appears that any part alongside NSA in the heading gets an automatic penalty of .4. I looked for another words causing automatic penalties, specified as awesome, bitcoin, and bubble but they do not appear to get penalized. I observed that many websites appear to automatically 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 genuine catalog is longer. (This is distinct from "banned" sites, which were listed at one point.

One interesting theory by eterm is that news from famous sources gets submitted in parallel by multiple group resulting in additional upvotes than the part "merits". Automatically penalizing famous websites would assistance counteract this effect.

The effect of penalties

Using the scoring formula, the effect of a penalty can be computed. If an part gets a penalty aspect of .4, this is equal to all ballot lone counting as .3 votes. Alternatively, the part volition autumn in ranking 66% faster than normal. A penalty aspect of .1 corresponds to all ballot counting as .05 votes, or the part dropping at 3.6 times the normal rate. Thus, a penalty aspect of .4 has a important impact, and .1 is extremely severe.

Controversy In command to forestall flamewars on Hacker News, articles alongside "too many" comments volition get heavily penalized as "controversial". In the published code, the contro-factor function kicks in for any article alongside additional than 20 comments and additional comments than upvotes. Such an part is scaled by (votes/comments)^2. However, the genuine equation is distinct - it is energetic for any article alongside additional comments than upvotes and at smallest 40 comments. Based on empirical data, I doubtful the exponent is 3, fairly than 2 but haven't proven this. The disagreement penalty can have a abrupt and catastrophic consequence on an article's ranking, causing an part to be classified extremely one infinitesimal and disappear whenever it hits 40 comments. If you've wondered why a famous part abruptly vanishes from the forefront page, disagreement is a apt cause. For example, Why the Chromebook pundits are out of contact alongside reality dropped from #5 to #22 the instant it hit 40 comments, and Show HN: Get your health records from any doctor' was at #17 but disappeared from the top 60 entirely on hitting 40 comments.

My methodology

I crawled the /news and /news2 pages all infinitesimal (staying under the 2 pages per infinitesimal guideline). I parsed the (somewhat ugly) HTML alongside Beautiful Soup, processed the results alongside a big heap of Python scripts, and graphed results alongside the incomprehensible but mighty matplotlib. The essential idea rearward the inspection is to create raw scores using the equation and afterward appearance for anomalies. At a item in period (e.g. 11/09 8:46), we can compute the raw scores on the top 10 stories:

2.802 Pyret: A new programming tongue 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 accord that the community can't read 0.785 S.F. programmers build substitute 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 several demos 0.805 ISO 1 0.483 Shopify accepts Bitcoin. 0.452 Show HN: Understand closures 

Note that three of the top 10 articles are classified lesser than expected from their score: The NY Times, Marelle and ISO 1. Since The NY Times is classified between articles alongside 1.407 and 0.785, its penalty aspect can be computed as between .47 and .85. Likewise, the another penalties must be .87 to .93, and .60 to .82. I observed that most stories are classified according to their score, and the exceptions are consistently classified much lower, indicating a penalty. This indicates that the scoring equation in use matches the published code. If the equation were different, for case the gravity exponent were larger, I'd anticipate to see stories drift out of their "expected" ranking as their votes or age increased, but I never saw this.

This method shows the beingness of a penalty and gives a range for the penalty, but determining the exact penalty is difficult. You can appearance at the range complete period and anticipation that it converges to a sole value. However, multiple sources of error disorder this up. First, the neighboring articles may additionally have penalties applied, or be scored alternatively (e.g. job postings). Second, since articles are not continually reranked, an part may be out of location temporarily. Third, the penalty on an part may alter complete time. Fourth, the reported ballot figure may differ from the genuine ballot figure since "bad" votes get suppressed. The outcome is that I've been capable to decide approximate penalties, but there is a fair bit of numerical instability.

Penalties complete a day

The following chart shows the calculated penalties complete the way of a day. Each row shows a particular article. It should commencement off at 1 (no penalty), and afterward autumn to a penalty flat whenever a penalty is applied. The row ends whenever the part drops off the top 60, which can be fairly shortly following the penalty is applied. There appear to be penalties of 0.2 and 0.4, as fine as a lot in the 0.8-0.9 range. It looks akin a lot of penalties are applied at 9am (when moderators arrive?), alongside additional throughout the day. I'm experimenting alongside distinct algorithms to enhance the chart since it is beautiful noisy.
On average, concerning 20% of the articles on the forefront leaf have been penalized, during 38% of the articles on the second leaf have been penalized. (The forefront leaf charge is lesser since penalized articles are small apt to be on the forefront page, benevolent of by definition.) There is a lot additional penalization going on than you power expect.

Here's a catalog of the articles on the forefront leaf on 11/11 that were penalized. (This excludes articles that would have been there if they weren't penalized.) This catalog is much longer than I expected; scroll for the complete list.

Why the Climate Corporation Sold Itself to Monsanto, 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 application 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 liberated tickets for 30 sit-ups, The concealed earth of cargo ships, These weeks in Rust, Empty-Stomach Intelligence, Getting website registration entirely 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 misplaced whenever everyone idea it had won, Docker and Go: why did we decide to compose Docker in Go?, Amazon Code Ninjas, Last Doolittle Raiders create final toast, Linux Voice - A new Linux mag that gives back, Want to download anime? Just made a program for that, Commit 15 minutes to explain to a alien why you affection 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 contact alongside 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 alongside Go in default languages, Show HN: Find your health scheme on Health Sherpa, Web Latency Benchmark: A new benevolent of browser benchmark, Why are Amazon, Facebook and Yahoo copying Microsoft's stack ranking system?, Severing Ties alongside the NSA, Doctor performs operation using Google Glass, Duplicity + S3: Easy, cheap, encrypted, automated full-disk backups, Bitcoin's UK forthcoming looks bleak, Amazon Redshift's New Features, You're lone 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 h2o and another things to survive.", Introducing the Humble Store, The Six Most Common Species Of Code, $4.1m goes missing as Chinese bitcoin selling phase GBL vanishes, Could Bitcoin Be More Disruptive than the Internet?, Apple Store is updating.

The code for the scoring formula

The Arc origin code for a type of the HN server is available, as fine as 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 basis (- (scorefn s) 1) (if (> basis 0) (expt basis .8) base)) (expt (/ (+ (item-age s) timebase*) 60) gravity)) (if (no (in s!type 'story 'poll)) .8 (blank s!url) nourl-factor* (mem 'bury s!keys) .001 (* (contro-factor s) (if (mem 'gag s!keys) gag-factor* (lightweight s) lightweight-factor* 1))))) 

In case you don't peruse Arc code, the complete snippet defines multiple constants: gravity* = 1.8, timebase* = 120 (minutes), etc. It afterward defines a method frontpage-rank that ranks a narrative s according to its upvotes (realscore) and age in minutes (item-age). The penalty aspect is defined by an if alongside multiple cases. If the part is not a 'story' or 'poll', the penalty aspect is .8. Otherwise, if the URL site is blank (Ask HN, etc.) the aspect is nourl-factor*. If the narrative has been flagged as 'bury', the measure aspect is 0.001 and the part is classified into oblivion. Finally, the default case combines the disagreement aspect and the gag/lightweight factor. The disagreement aspect contro-factor is intended to suppress articles that are foremost to flamewars, and is discussed additional later.

The next aspect hits an part flagged as a gag (joke) alongside a dense value of .1, and a "lightweight" part alongside a aspect of .17. The genuine penalty scheme appears to be much additional complex than what appears in the published code.

Conclusion

An article's stance on the Hacker News residence leaf isn't the meritocracy according to upvotes that you power expect. By carefully examining the articles that appear on the Hacker News page, we can study a awesome agreement concerning the scoring equation in use. While upvotes are the apparent aspect controlling rankings, there is additionally a complex "penalty" scheme causing articles to be classified lesser or disappear entirely. This isn't fair preventing spam, but affects many extremely famous articles. And if an part has additional comments than votes, don't add your comment to it or you may slay it off entirely! See conversation on Hacker News.


Update (11/18): part on penalties is penalized

Ironically, this part was penalized on Hacker News. Minutes following reaching the forefront page, a dense 0.2 penalty was applied to the article, forcing it off the forefront page. The dreary row in the chart below shows the stance of this part on Hacker News. You can see the keen autumn whenever the penalty was applied. The gray row shows anywhere the part would have been classified without the penalty. Without the penalty, the part would have been in the #5 spot, but alongside the penalty it never made it rear onto the forefront leaf (positions 1-30). The lesser green row shows the raw mark of this article. (11/26: I'm told that the penalty was since the "voting circle detection" triggered erroneously.)
This part was penalized shortly following reaching the forefront leaf of Hacker News


Other Article Hacker News
↑
Close Right Ads
Close Left Ads