コード例 #1
0
def choose_random_user(minGames=10):
    user_ids = list(userIds("steamData/game_purchase.dat"))
    randomID = int(random.choice(user_ids))
    usr = userVectorData(str(randomID), game_Ids)
    while len(usr.gamePurchasedIds) < 10:
        randomID = int(random.choice(user_ids))
        usr = userVectorData(str(randomID), game_Ids)
    removedGameID_local = choose_random_game(usr)
    return usr, removedGameID_local
コード例 #2
0
def recommend_similar_user():
    updateMatrix, current_user, remove_game = create_new_user_vector_matrix()
    results = create_recommend_pairs_eval(updateMatrix)
    matched_user_id = int(results[float(current_user)])
    usr = userVectorData(str(matched_user_id), game_Ids)
    if str(remove_game) in usr.gameNames.keys():
        print('Similar user: game removed Found!')
        return 1
    else:
        print('Similar user: game not Found!')
        return 0
コード例 #3
0
def recommend(userId, top=5):
    usr = userVectorData(str(userId), game_Ids)
    owned_games = usr.print_Owned_games()
    usr.loadUsrVector('Vectors_data/user_vector.csv')
    results = usr.calculate(VectorDict)
    results_list = list()
    for i in range(top):
        results_list.append(
            str(i + 1) + ' ' + game_Ids[str(results[i][0])] + ' Score:' +
            str(results[i][1]))
    return owned_games, results_list
コード例 #4
0
def run_feature_testing(numberOfTests=5):
    final_report = list()
    local_sum = 0
    for _ in range(numberOfTests):
        randomUser, removedGameID = choose_random_user()
        localUser = create_vector_user(randomUser.userId, removedGameID)
        usr = userVectorData(str(randomUser.userId), game_Ids)
        usr.usrVector = copy.deepcopy(localUser.vector)
        res = float(recommend_eval(usr, removedGameID))
        local_sum += res
        print('Test Num: {0} | Rec Score: {1}'.format(_, res))
        final_report.append((_, res))
    print('==== Final Report Feature Evaluation')
    print(final_report)
    result = local_sum / numberOfTests
    print(result)
コード例 #5
0
def owned_game_list(UserID):
    usr = userVectorData(str(UserID), game_Ids)
    owned_games = usr.print_Owned_games()
    return owned_games