# Bayesian Ranking for Rated Items

DevFeed: [Bayesian Ranking for Rated Items](<https://devfeed.tech/articles/bayesian-ranking-for-rated-items-40408.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2017/03/13/bayesian-ranking-for-rated-items/>)

Published: 2017-03-13T09:00:49Z

Content type: tutorial

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [recommendation systems](<https://devfeed.tech/topics/recommendation-systems.md>), [Statistics](<https://devfeed.tech/topics/statistics.md>), [Python](<https://devfeed.tech/topics/python.md>), [Data Science](<https://devfeed.tech/topics/data-science.md>)

Tags: [catalog](<https://devfeed.tech/tags/catalog.md>), [conjugate-prior](<https://devfeed.tech/tags/conjugate-prior.md>), [dirichlet-distribution](<https://devfeed.tech/tags/dirichlet-distribution.md>), [display](<https://devfeed.tech/tags/display.md>), [distribution](<https://devfeed.tech/tags/distribution.md>), [inference](<https://devfeed.tech/tags/inference.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [probability-theory](<https://devfeed.tech/tags/probability-theory.md>), [python](<https://devfeed.tech/tags/python.md>), [ranking](<https://devfeed.tech/tags/ranking.md>), [sorting](<https://devfeed.tech/tags/sorting.md>), [statistics](<https://devfeed.tech/tags/statistics.md>)

## AI overview

This article explains how to rank items with discrete user ratings using a Bayesian model with a Dirichlet prior. It presents a Python solution for estimating an item's expected rating from observed ratings, prior beliefs, and a utility function.

## Source excerpt

Problem: You have a catalog of items with discrete ratings (thumbs up/thumbs down, or 5-star ratings, etc.), and you want to display them in the "right" order. Solution: In Python ''' score: [int], [int], [float] -> float Return the expected value of the rating for an item with known ratings specified by `ratings`, prior belief specified by `rating_prior`, and a utility function specified by `rating_utility`, assuming the ratings are a multinomial distribution and the prior belief is a Dirichlet distribution.