V
V
Valera Dobroman2020-06-14 00:29:00
Algorithms
Valera Dobroman, 2020-06-14 00:29:00

How to manage post appearance probabilities (rating, sorting, "recommended")?

Main question:
(total number of likes 266,
total number of views: 2199,
total number of posts # 10)
TEMPLATE
(post # - number of likes, number of views)
0 -20, 65
1 - 15 , 200
2 - 10, 20
3 - 40, 150
4 - 35, 89
5 - 30, 100
6 - 22, 80
7 - 12, 15
8 - 50, 980
9 - 32, 500
You need to show 5 posts, but the condition is ;
- The selection of posts should be random.
- There should be a preference for posts with a large number of likesand its ratio with views should also be quite large, but at the same time there should be a small chance of showing posts with fewer likes and views.
In short, how do you make one site slightly less likely to appear and another slightly more likely to appear?

Additional question
How to create such an algorithm (samples of random posts, but with a preference for a higher rating) in PHP?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hint000, 2020-06-14
@Valera221

1. read this question How to select a random item from a list based on its weight? , there Nikolai Panaitov gave a good, suitable answer, and this contains 70% of the answer to your question.
2. as a post weight try:

w=c+a*Log(1+лайков[пост])+b*Log(1+просмотров[пост])

3. In this formula, the coefficients a>=0, b>=0, c>=0are the "adjustment knobs" for your selection. The more a, the stronger the impact of likes, the more b, the stronger the impact of views, the more c, the more "equal opportunities for all."

N
Ninazu, 2020-06-14
@Ninazu

Depends on where you store this data and in what form.
For example, for MySQL, you can specify the sort sequence in ORDER BY

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question