Sort an item by review, adjusted for the number of reviews

Viewed 114

I have a similar problem to this question, where I'd like to sort items, although adjust for the number of reviews. Following the link in the accepted answer leads me to this answer, which proposes an easy solution of adding a few average values to the mean and sorting on this "adjusted mean". However, it also proposes a more rigorous approach of "adding reviews with an average of to each product and tune , using cross validation to maximize some measurement of prediction accuracy. I would start with as the average rating in your whole data set, and play with values of ."

I'm having trouble understanding how to implement this rigorous approach in code. Any pointers would be helpful.

1 Answers

I believe that the more rigorous approach is just referring to manipulating the simpler version, to use specific values that get the desired result you are after.

The simpler approach suggests sorting like this -

    books.sort(
        key=lambda book: mean(book.reviews + [3, 3, 3]),
        reverse=True
    )

Instead, you might do something like this -

books.sort(
    key=lambda book: mean(book.reviews + [μ] * n),
    reverse=True
)

Where μ is the mean rating across all books, and n is the number that you would set, check the result, and then adjust again based on whether the sorting worked the way you wanted it to. (Kind of like a guess and check approach!) The higher the value of n, the the higher the preference towards books with lots of reviews.

Related