title: How to provide most relevant results with Multiple Factor Weighted Sorting
body: <p>I need to provide a weighted sort on 2+ factors, ordered by "relevancy".  However, the factors aren't completely isolated, in that I want one or more of the factors to affect the "urgency" (weight) of the others.</p>
  
  <p>Example:  contributed content (<em>articles</em>) can be up-/down-voted, and thus have a rating; they have a post date, and they're also tagged with categories.  Users write the articles and can vote, and may or may not have some kind of ranking themselves (expert, etc).  Probably similar to StackOverflow, right?</p>
  
  <p>I want to provide each user with a list of articles grouped by tag but sorted by "relevancy", where <em>relevancy</em> is calculated based on the rating and age of the article, and possibly affected by the ranking of the author.  I.E. a highly ranked article that was written several years ago may not necessarily be as relevant as a medium ranked article written yesterday.  And maybe if an article was written by an expert it would be treated as more relevant than one written by "Joe Schmoe".</p>
  
  <p>Another good example would be <a href="https://stackoverflow.com/questions/8661118/need-help-maximizing-3-factors-in-multiple-similar-objects-and-ordering-appropr/8759877#8759877" title="Maximizing 3 factors and ordering appropriately">assigning hotels a "meta score" comprised of price, rating, and attractions</a>.</p>
  
  <p>My question is, what is the best algorithm for multiple factor sorting?  This may be a duplicate of <a href="https://stackoverflow.com/questions/8661118/need-help-maximizing-3-factors-in-multiple-similar-objects-and-ordering-appropr/8759877#8759877" title="Maximizing 3 factors and ordering appropriately">that question</a>, but I'm interested in a generic algorithm for any number of factors (a more reasonable expectation is 2 - 4 factors), preferably a "fully-automatic" function that I don't have to tweak or require user input, and I can't parse linear algebra and eigenvector wackiness.</p>
  
  <hr>
  
  <p>Possibilities I've found so far:</p>
  
  <p><em>Note: <code>S</code> is the "sorting score"</em></p>
  
  <ol>
  <li><strong>"Linearly weighted"</strong> - use a function like: <code>S = (w<sub>1</sub> * F<sub>1</sub>) + (w<sub>2</sub> * F<sub>2</sub>) + (w<sub>3</sub> * F<sub>3</sub>)</code>, where <code>w<sub>x</sub></code> are arbitrarily assigned weights, and <code>F<sub>x</sub></code> are the values of the factors.  You'd also want to normalize <code>F</code> (i.e. <code>F<sub>x_n</sub> = F<sub>x</sub> / F<sub>max</sub></code>).  I think this is kinda how <a href="https://stackoverflow.com/questions/817998/how-to-sort-search-results-on-multiple-fields-using-a-weighting-function" title="Question re: Lucene sorting algorithm">Lucene search works</a>.</li>
  <li><strong>"Base-N weighted"</strong> - more like grouping than weighting, it's just a linear weighting where weights are increasing multiples of base-10 (a similar principle to <a href="http://coding.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/" rel="noreferrer" title="specificity of CSS explained">CSS selector specificity</a>), so that more important factors are significantly higher:  <code>S = 1000 * F<sub>1</sub> + 100 * F<sub>2</sub> + 10 * F<sub>3</sub> ...</code>.</li>
  <li><strong>Estimated True Value (ETV)</strong> - this is apparently what <a href="http://www.seomoz.org/blog/build-your-own-weighted-sort" rel="noreferrer" title="Explanation of ETV">Google Analytics introduced in their reporting</a>, where the value of one factor influences (<em>weights</em>) another factor - the consequence being to sort on more "statistically significant" values.  The link explains it pretty well, so here's just the equation:  <code>S = (F<sub>2</sub> / F<sub>2_max</sub> * F<sub>1</sub>) + ((1 - (F<sub>2</sub> / F<sub>2_max</sub>)) * F<sub>1_avg</sub>)</code>, where <code>F<sub>1</sub></code> is the "more important" factor ("bounce rate" in the article), and <code>F<sub>2</sub></code> is the "significance modifying" factor ("visits" in the article).</li>
  <li><strong>Bayesian Estimate</strong> - looks really similar to ETV, this is how IMDb calculates their rating.  See <a href="https://stackoverflow.com/questions/1411199/what-is-a-better-way-to-sort-by-a-5-star-rating" title="What is a better way to sort 5-star rating">this StackOverflow post for explanation</a>; equation: <code>S = (F<sub>2</sub> / (F<sub>2</sub>+F<sub>2_lim</sub>)) * F<sub>1</sub> + (F<sub>2_lim</sub> / (F<sub>2</sub>+F<sub>2_lim</sub>)) × F<sub>1_avg</sub></code>, where <code>F<sub>x</sub></code> are the same as #3, and <code>F<sub>2_lim</sub></code> is the minimum threshold limit for the "significance" factor (i.e. any value less than X shouldn't be considered).</li>
  </ol>
  
  <p>Options #3 or #4 look really promising, since you don't really have to choose an arbitrary weighting scheme like you do in #1 and #2, but the problem is how do you do this for more than two factors?</p>
  
  <p>I also came across the <a href="https://stackoverflow.com/questions/1880597/sorting-by-weighted-rating-in-sql" title="Sorting by weighted rating">SQL implementation for a two-factor weighting algorithm</a>, which is basically what I'll need to write eventually.</p>