We have a Elo rating system (such as, as following) for the players in a video game and want to convert it to 5 star rating ranging from [3.00, 5.00]. The conversion should maintain the following four constraints. That is we want to make sure, the rating are 'well distributed' among players.
Example Elo rating and the required converted five star rating:
elo_ratings = [1295, 1497, 1014, 967, 1021, 1034, 1162, 1198, 1374, 1242, 1292, 1096, 1339, 1365, 1188, 1075, 1344, 1040, 1334, 1513, 1362, 1038, 1177, 1190, 1583, 1551, 1558, 1245, 1202, 1285, 1171, 1223, 1274, 1514, 950]
#ranging from 3 to 5
five_star_ratings = [3.52, 4.10, 3.2, ...]
Can anyone help or provide some information on the math or implementation?
You can use a couple of functions in numpy for this - np.percentile and np.interp.
import numpy as np
elo_ratings = [1295, 1497, 1014, 967, 1021, 1034, 1162, 1198, 1374, 1242, 1292, 1096, 1339, 1365, 1188, 1075, 1344, 1040, 1334, 1513, 1362, 1038, 1177, 1190, 1583, 1551, 1558, 1245, 1202, 1285, 1171, 1223, 1274, 1514, 950]
rankings = [3.0, 3.5, 4.0, 4.95, 5.0]
boundaries = np.percentile(elo_ratings, [0, 25, 50, 75, 100])
ratings = np.interp(elo_ratings, boundaries, rankings)
>>> ratings
array([4.4536036 , 4.98130435, 3.17877095, 3.04748603, 3.19832402,
3.23463687, 3.6460177 , 3.80530973, 4.95456522, 4. ,
4.42792793, 3.40782123, 4.83018018, 4.9526087 , 3.76106195,
3.34916201, 4.87297297, 3.25139665, 4.78738739, 4.98478261,
4.95195652, 3.24581006, 3.71238938, 3.7699115 , 5. ,
4.99304348, 4.99456522, 4.02567568, 3.82300885, 4.36801802,
3.68584071, 3.9159292 , 4.27387387, 4.985 , 3. ])