warchildmd / game2vec

TensorFlow implementation of word2vec applied on https://www.kaggle.com/tamber/steam-video-games dataset, using both CBOW and Skip-gram.
70 stars 6 forks source link

random_multinomial_choice() function seems not right #2

Closed fuxuemingzhu closed 5 years ago

fuxuemingzhu commented 6 years ago

I am confused about the random_multinomial_choice() function in your train_cbow_weighted.py file. The condition of if sentence seems not right.. More likely, if y>=x: should be here. In my opinion, if the play time of a game is quite bigger, this game should be return. Am I right? Waiting for your reply.

And here is your code.

def random_multinomial_choice(tuples):
    x = random.random()
    total = sum([hours for _, hours in tuples])
    for game, hours in tuples:
        y = hours / total
        if y <= x:
            return game
        x -= y
    return tuples[-1][0]