Hello, Codeforces! As you know, most modern services actively use recommendation systems (e.g. instagram feed, tik-tok, personalized offers in banks, recommendations in shipping offers and marketplaces). I thought it would be interesting to do something similar with problems on codeforces, to make it easier to find interesting tasks for the user and simplify the compilation of personal workouts and mashups. Here is my recommendation system of tasks on Codeforces
The way the system works now looks like this: $$$\newline$$$ 1. For each user I calculate a vector of solved tasks tags (i.e. for each possible tag, the number of tasks with that tag solved by the user).$$$\newline$$$ 2. Normalize this vector. Let's call the result $$$\mathbf{u} = \frac{\sum\limits_{p \in \text{solved}} \mathbf{t}_p}{\left| \sum\limits_{p \in \text{solved}} \mathbf{t}_p \right|}$$$ $$$\newline$$$ 3. For each unsolved problem $$$i$$$ we take its binary tag vector $$$t_i$$$ and calculate the cosine similarity: $$$\text{sim}_i = \frac{\mathbf{t}_i \cdot \mathbf{u}}{|\mathbf{t}_i| \, |\mathbf{u}|} = \frac{\mathbf{t}_i \cdot \mathbf{u}}{|\mathbf{t}_i|}$$$ $$$\newline$$$ 4. For each problem we calculate its popularity: $$$\text{pop_norm} = \frac{\text{pop} - \text{pop}_{\min}}{\text{pop}_{\max} - \text{pop}_{\min}}$$$ where task popularity(pop) is the number of AC solutions, $$$\text{pop}_{\min}$$$ — the number of AC solutions for the task with the lowest number of solutions, $$$\text{pop}_{\max}$$$ — the number of AC solutions for the task with the highest number of solutions.$$$\newline$$$ 5. We consider that the user is more comfortable solving tasks close to his own rating: we use a Gaussian function: $$$\text{score}_{\text{rating}} = \exp\left( -\frac{(r_{\text{task}} - r_{\text{user}})^2}{2\sigma^2} \right), \quad \sigma = 0.3 \cdot r_{\text{user}}$$$ $$$\newline$$$ 6. We rank the tasks by the total rating equal to: $$$\alpha \times sim_i + \beta \times \text{pop_norm}_i + \gamma \times \text{score}_{raiting}$$$
The project is an opensource project, you can find all the source code in the repository. I am open to suggestions for improvement! Contributions are welcome! Feel free to open issues or submit pull requests!







