Ranking algorithm based on user's voting (II.) Reddit

Source: Internet
Author: User
Tags in python

Last time, I introduced the hacker News ranking algorithm. It is characterized by the user can only vote in favour of the vote, but many sites also allow users to vote against. In other words, in addition to praise, you can also give an article for a bad comment.

Reddit is the largest online community in the United States, where each post has an up and down arrow, which expresses "aye" and "objection" respectively. The user clicks to vote, Reddit calculates the newest "hot article List" according to the result of the vote.

How can we combine the pro and negative votes to figure out the most popular articles for some time? If article A has 100 votes in favour, 5 votes against, article B has 1000 votes in favour of, 950 votes against, who should be in front of the list?

The Reddit program is open source and is written in Python language. The code for the ranking algorithm is roughly as follows:

This code takes into account a number of factors such as:

(1) Post's new and old degree T

t = Posting time-December 8, 2005 7:46:43

The unit of T is a second, calculated with a Unix timestamp. It is not difficult to see that once the post is published, T is fixed value, will not change with time, and the new posts, T value larger. As for December 8, 2005, it should be the time when Reddit was established.

(2) The difference between the vote and the negative X

x = Pro Vote-Negative

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.