Eine Digg-ähnliche Homepage des beliebten Inhalten zu drehen, wie Datum als Faktor enthalten?

StackOverflow https://stackoverflow.com/questions/2715941

  •  01-10-2019
  •  | 
  •  

Frage

Ich baue eine erweiterte Bild-Sharing Web-Anwendung. Wie Sie erwarten können, können die Benutzer Bilder hochladen und andere können Kommentare dazu, Abstimmung über ihn und Favorit. Diese Ereignisse werden die Popularität des Bildes bestimmen, welche ich capture in einem „Karma“ ein.

Jetzt möchte ich eine Digg-Homepage wie System zu schaffen, die beliebtesten Bilder zeigt. Es ist einfach, da ich bereits die gewichtete Karma Score. Ich einfach irgendwie auf, dass absteigend zu zeigen, die 20 am meisten geschätzten Bilder.

Der Teil, der fehlt, ist Zeit . Ich mag nicht sehr beliebt Bilder immer auf der Homepage sein. Ich denke, eine einfache Lösung ist es, die Ergebnismenge der letzten 24 Stunden zu beschränken. Aber ich denke auch, dass im Laufe des Tages, um das Bild zu halten Rotation auftreten, Zeit eine Art variabel sein kann, wo seine Offset einen Einfluss auf das Image der hat zu sortieren.

Spezifische Fragen:

  • Werden Sie das einfache Szenario (nur Art für die besten Bilder innerhalb von 24 Stunden) oder der anspruchsvollere eines (verwenden Datetime-Offset im Rahmen der Sortierung)? Wenn Sie die zweite, jede Hilfe auf der mathematischen Lösung dieses Problems beraten?
  • wäre es am besten, einen Liniendienst zu Markenbilder für die Homepage laufen, oder würden Sie eine direkte Abfrage beraten (Ich verwende MySQL)
  • Als zusätzliche Anmerkung, sollte die Homepage Paging unterstützen und an einem ruhigen Tag sollte enthalten Einträge der Tage vor, um sicherzustellen, dass es immer „gefüllt“

Ich bin nicht die Gemeinschaft zu fragen, diesen Algorithmus zu bauen, nur für einige Beratung suchen:)

War es hilfreich?

Lösung

I would go with a function that decreases the "effective karma" of each item after a given amount of time elapses. This is a bit like Eric's method.

Determine how often you want the "effective karma" to be decreased. Then multiply the karma by a scaling factor based on this period.

effective karma = karma * (1 - percentage_decrease)

where percentage_decrease is determined by yourfunction. For instance, you could do

percentage_decrease = min(1, number_of_hours_since_posting / 24)

to make it so the effective karma of each item decreases to 0 over 24 hours. Then use the effective karma to determine what images to show. This is a bit more of a stable solution than just subtracting the time since posting, as it scales the karma between 0 and its actual value. The min is to keep the scaling at a 0 lower bound, as once a day passes, you'll start getting values greater than 1.

However, this doesn't take into account popularity in the strict sense. Tim's answer gives some ideas into how to take strict popularity (i.e. page views) into account.

Andere Tipps

For your first question, I would go with the slightly more complicated method. You will want some "All time favorites" in the mix. But don't go by time alone, go by the number of actual views the image has. Keep in mind that not everyone is going to login and vote, but that doesn't make the image any less popular. An image that is two years old with 10 votes and 100k views is obviously more important to people than an image that is 1 year old with 100 votes and 1k views.

For your second question, yes, you want some kind of caching going on in your front page. That's a lot of queries to produce the entry point into your site. However, much like SO, your type of site will tend to draw traffic to inner pages through search engines .. so try and watch / optimize your queries everywhere.

For your third question, going by factors other than time (i.e. # of views) helps to make sure you always have a full and dynamic page. I'm not sure about paginating on the front page, leading people to tags or searches might be a better strategy.

You could just calculate an "adjusted karma" type field that would take the time into account:

adjusted karma = karma - number of hours/days since posted

You could then calculate and sort by that directly in your query, or you could make it an actual field in the database that you update via a nightly process or something. Personally I would go with a nightly process that updates it since that will probably make it easier to make the algorithm a bit more sophisticated in the future.

This, i've found it, the Lower bound of Wilson score confidence interval for a Bernoulli parameter

Look at this: http://www.derivante.com/2009/09/01/php-content-rating-confidence/

At the second example he explains how to use time as a "freshness factor".

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top