Q: Algorithm to determine quality of an article I am working on a project that requires me to parse news articles and determine the best among them. I figured out that to determine the quality of an article, I would need three main parameters: Length of an article, facebook shares/ retweets and the time since the article was posted.
The problem I am facing now is how do I put together all three parameters in a mathematical function and come-up with a score for each of the articles? The score assigned to each one of them would help me rank the articles and show it to the users.
Also let me know if there is any other parameter that I need to consider in determining the quality.

A: I'm not sure what the exact nature of your project is but this task is very hard to do accurately. How do you take into account the fact that articles that are shared/liked most are often the ones that are most polarizing. Number of likes/shares is also clearly influenced by how popular the news-site is. I would think that any kind of automated text analysis will not be accurate enough and could be easily abused. Your best bet then is to look for indicative proxies such as:


*

*Reputability of the site as measured by ranking in google search results

*Popularity of the site as measured by traffic

*Number of facebook likes/shares as you mentioned

*Number of places on the internet that linked to the article.


Since a dataset that contains article grades will be hard to come by you probably won't be able to do any kind of statistic analysis. Instead you'll just have to make up a formula and weigh the parameters with your best judgement. To back this up a little bit maybe hand grade  a few articles and see what different formulas give you.

A: What you desire is stunning easy to achieve. You have to kinds of data, that your are interested in: increasing and decreasing data. Increasing data is considered as "good", well, as long as it increases. Decreasing data is considered as "better" the nearer it is to zero.
It turns out that all of the four datasets are simple integers:
increasing data


*

*shares: positive integer s \in N_0 (every integer from zero to infinity)

*retweets: positive integer r \in N_0
decreasing data
For decreasing data you want to use the absolute value as a metric:


*

*Let t_0 be the timestamp (unix or so) of the article.

*Let T be the current timestamp.

*Let l_0 denote the length of an article considered as "best".

*Let L denote the actual length of the article.


Then:


*

*time: |t_0 - T| the better the nearer to zero

*length: |l_0 - L| the better the nearer to zero


since the absolute value are positive integers it follows:
|l_0 - L| + |t_0 - T| is nearer to zero as |t_0 - T| and |l_0 - L| are nearer to zero.
The same is true for the increasing numbers.
So, the more likely an article is to be of the "correct" length and new, the nearer this number is to zero.
conclusion
the quotient of an increasing number over a decreasing is itself increasing. Think about it: the smaller the denominator the bigger the quotient. The bigger the numerator the bigger the quotient.
That means: If considered as "better" the quotient
(s+r) / (|l_0 - L| + |t_0 - T|)
rises.
This is not necessarily an integer anymore.
Enhancement
You can soften the rise of shares and retweets, so the score becomes little more "natural" by using ln.
ln(s+r) / (|l_0 - L| + |t_0 - T|)
You could use expto soften the denominator:
ln(s+r) / exp(-(|l_0 - L| + |t_0 - T|))
