Scoring Algorithms
Jan 21, 2022

    I’ve had a few projects where I wanted to come up with a scoring algorithm. I ususally head down the path or try to multiply averages or up-down ratings some numbers with some weights, and sometimes it works, but I want something that feels better.

    Here’s a Google Sheet I made to play with a few different scoring systems.

    https://docs.google.com/spreadsheets/d/1SFCv5XKfeA41g49DUYZuanoNjPnNzoqEMCsyaaFDpcA/edit?usp=sharing

    Wilson Confidence

    Popular from Evan Miller’s posts, but a bit complicated.

    Laplace Smoothing

    This basically makes an assumption that all the things you’re ranking start with some number of upvotes and downvotes. Greatly simplifies the math required to get a good scoring system going.

    $$rating=\frac{(up + default)}{((up + default) + (down + default))}$$

    You can just plug in a constant for default.

    So for something with no votes, and a default of 7:

    $$rating=\frac{(0 + default)}{((0 + default) + (0 + default))}$$

    $$rating=\frac{default}{(default + default)}$$

    $$rating=\frac{7}{14}$$

    $$rating=0.5$$

    Different default values for up and down votes

    Similar to the Smoothing used above, but uses different default values for up and down votes.

    $$rating=\frac{(up + upAvg)}{((up + upAvg) + (down + downAvg))}$$

    As an example for something with 13 up votes and 2 down votes. We’ll assume everything by default has 4 upvotes and 7 downvotes.

    $$\text{score}=\frac{(up + 4)}{((up + 4) + (down + 7))}$$

    $$\text{score}=\frac{(13 + 4)}{((13 + 4) + (2 + 7))}$$

    $$\text{score}=\frac{17}{26} = 0.6538$$

    See my Cocktail App - Recommendation section for a real example of using this for a scoring application.

    Resources