Slick23
Slick23

Reputation: 5907

Ranking algorithm in a rails app

We have a model in our ralis app whose objects are assigned a score based on positive user actions. We'll call them products for simplicity sake. If a user likes a product or buys a product or views a product, the score is incremented at various weights (a like might be worth more than a view, two views in the span of 30 seconds might be worth more than three views spread over an hour, etc.)

We'd like to use these scores to help sort and rank products, say for a popular products list, but for various reasons -- using the straight ranking is going to unevenly favor older products, since they'll have more time to amass a higher score.

My question is, how to normalize the scores between new and old products. I thought about dividing the products score by a unit of time, say the number of days it's been in existence, but am worried that will cut down the older products too much. Any thoughts on the best way to fairly normalize the scores between the old and new products?

I'm also considering an example of a bayesian rating system I found in another question:

rating = ((avg_num_votes * avg_rating) + (product_num_votes * product_rating)) / (avg_num_votes + product_num_votes)

Where theavg numbers are calculated by looking at the scores across all products that have more than one vote (or in our case, a positive action). This might not be the best way, because we don't have a negative rating in our system and it doesn't take time into consideration at all.

Upvotes: 3

Views: 576

Answers (1)

Thomas Guillory
Thomas Guillory

Reputation: 5729

Your question reminds me the concept of Exponential Discounting Cash Flow in finance.

The concept is the following : 100$ in two years worth less than 100$ in one year, which worth less than 100$ now, ...

I think that we can make a good comparison here : a product of yesterday worth more that a product of the day before but less than a product of today.

The formula is simple :

Vn = V0 * (1-t)^n

with V0 the initial value (the real number of positives votes), t a discount rate (you have to fix it, like 10%) and n the time passed (for example n days). Thus a product will lose 10% of his value each day (but 10% of the precedent day, not of the initial value).

You can also see Hyperbolic discounting that is closer of your try. The formula can be sometyhing like that I guess :

Vn = V0 * (1/(1+k*n))

An other approach, simpler, but crudest : linear discounting. You can simply give an initial value for the scores, like 1000 and each day, you decrement all scores by 1 (or an other constant).

Vn = V0 - k*n

Upvotes: 3

Related Questions