Esempio n. 1
0
def create_vector_user(id_user_func, removedGameID):
    clearVector(vector)
    usr_local = userVector(str(id_user_func), vector, str(removedGameID))
    print("Calculating vector {0}".format(usr_local))
    usr_local.calculateUserVector(VectorDict)
    usr_local.createObjDir()
    return usr_local
Esempio n. 2
0
def content_recommendation(userID):
    ownedGames = src.owned_game_list(userID)
    current_usr = userVector(str(userID))
    sorted_gameplay = current_usr.playTime
    if not sorted_gameplay:
        exit()
    game_Ids = src.load_gameIds()
    for key in sorted_gameplay.keys():
        sorted_gameplay[key] = float(sorted_gameplay[key])
    sorted_gameplay = {
        k: v
        for k, v in sorted(current_usr.playTime.items(),
                           key=lambda item: item[1],
                           reverse=True)
    }
    results = content_recom.show_rec(game_Ids[str(list(sorted_gameplay)[0])])
Esempio n. 3
0
def content_eval():
    randomUser, removedGameID = choose_random_user()

    current_usr = userVector(randomUser.userId)
    sorted_gameplay = current_usr.playTime
    game_Ids = load_gameIds()
    for key in sorted_gameplay.keys():
        sorted_gameplay[key] = float(sorted_gameplay[key])
    sorted_gameplay = {k: v for k, v in
                       sorted(current_usr.playTime.items(), key=lambda item: item[1], reverse=True)}
    try:
        results = content_recom.show_rec(game_Ids[str(list(sorted_gameplay)[0])], 15, True)
    except (KeyError, IndexError) as er:
        print(er)
    results = process_results(results)
    for index in range(len(results)):
        results[index] = findID(results[index])
    if str(removedGameID) in results:
        print('Content Eval: game found!')
        return 1
    else:
        print('Content Eval: game not found!')
        return 0
Esempio n. 4
0
def content_recom_chooser(user_id, ownedGames):
    content_chooser_layout = [[sg.Text('Choose Option', justification='center')],
                              [sg.Button('I choose my Destiny', key='user_choice'), sg.VerticalSeparator(pad=None),
                               sg.Button('Destiny chooses for me', key='stats')]]
    content_chooser_window = sg.Window('Choose!', content_chooser_layout)
    content_chooser_event, content_chooser_value = content_chooser_window.read()
    if content_chooser_event is 'stats':
        current_usr = userVector(str(user_id))
        sorted_gameplay = current_usr.playTime
        if not sorted_gameplay:
            sg.Popup('Error', 'Destiny Failed! Not enough data!')
            content_chooser_window.close()
            content_recom_chooser(user_id, ownedGames)
        game_Ids = src.load_gameIds()
        for key in sorted_gameplay.keys():
            sorted_gameplay[key] = float(sorted_gameplay[key])
        sorted_gameplay = {k: v for k, v in
                           sorted(current_usr.playTime.items(), key=lambda item: item[1], reverse=True)}
        results = content_recom.show_rec(game_Ids[str(list(sorted_gameplay)[0])])
        content_chooser_window.close()
        user_results_window([game_Ids[str(list(sorted_gameplay)[0])]], results, user_id)
    if content_chooser_event is 'user_choice':
        content_chooser_window.close()
        contet_recom_window(user_id, ownedGames)
Esempio n. 5
0
    with open('backupData/vectorData.pickle', mode='wb') as p:
        print('Pickle Data does not exists, Creating Data! ..')
        VectorDict = create_vectors()
        pickle.dump(VectorDict, p)
else:
    with open('backupData/vectorData.pickle', mode='rb') as p:
        print('Pickle Data Exists. Loading !!')
        VectorDict = pickle.load(p)

# region Create user vectors and store them in file user_Vector
userVectors = dict()
if not os.path.isfile("Vectors_data/user_vector.csv") or False:
    counter, total = 0, len(user_ids)
    for id_user in user_ids:
        clearVector(vector)
        usr = userVector(id_user, vector)
        print("Calculating vector {0}".format(usr))
        usr.calculateUserVector(VectorDict)
        usr.createObjDir()
        create_Vector_csv(usr, "user_vector", False)
        userVectors[id_user] = copy.deepcopy(usr)
        print("Progress: {0}/{1}".format(counter, total))
        counter += 1


def create_vector_user(id_user_func, removedGameID):
    clearVector(vector)
    usr_local = userVector(str(id_user_func), vector, str(removedGameID))
    print("Calculating vector {0}".format(usr_local))
    usr_local.calculateUserVector(VectorDict)
    usr_local.createObjDir()
Esempio n. 6
0
def user_exists_window():
    main_layout_existing_user = [[sg.Text('Steam Data Set Recommendation', justification='center')],
                                 [sg.Button('Existing User', key='existingUserButton', disabled=True),
                                  sg.VerticalSeparator(pad=None),
                                  sg.Button('New User', key='NewUserButton', disabled=True)],
                                 [sg.Combo(
                                     read_user_ids('/Users/tzvip/PycharmProjects/steamRec/steamData/game_purchase.dat'),
                                     size=(20, 1), key='UserChoice'), sg.Button('Submit')],
                                 # TODO: disable typing in combo list
                                 [sg.Radio('Feature Recommendation', 'selection', key='feature'),
                                  sg.Radio('Content Recommendation', 'selection', key='content'),
                                  sg.Radio('Similar User', 'selection', key='userSim')],
                                 [sg.Radio('Hybrid Recommendation', 'selection', key='hybrid', default=True)],
                                 [sg.Image('analyze.png', key='image', visible=False)]]
    main_window_existing_user = sg.Window('Steam Data Set Recommendation', main_layout_existing_user, )
    main_window_event_existing_user, main_window_values_existing_user = main_window_existing_user.read()
    while main_window_values_existing_user['UserChoice'] == '':
        sg.Popup('Error', 'Must choose user ID')
        main_window_event_existing_user, main_window_values_existing_user = main_window_existing_user.read()
    main_window_existing_user.FindElement('image').Update('analyze.png', visible=True)
    main_window_existing_user.refresh()
    if main_window_values_existing_user['feature'] is True:
        userID = main_window_values_existing_user['UserChoice']
        owned_games, results = src.recommend(userID)
        main_window_existing_user.close()
        user_results_window(owned_games, results, userID)
    if main_window_values_existing_user['content'] is True:
        userID = main_window_values_existing_user['UserChoice']
        owned_games = src.owned_game_list(userID)
        main_window_existing_user.close()
        content_recom_chooser(userID, owned_games)
    if main_window_values_existing_user['userSim'] is True:
        userID = main_window_values_existing_user['UserChoice']
        pairs = create_recommend_pairs()
        recom = src.owned_game_list(pairs[userID])
        myGames = src.owned_game_list(userID)
        recom = check_similar_games(myGames, recom)
        main_window_existing_user.close()
        user_results_window(myGames, recom, userID,
                            '| Recommendation by the user with the same taste: ' + str(pairs[userID]))
    if main_window_values_existing_user['hybrid'] is True:
        # Feature Recommendation
        userID = main_window_values_existing_user['UserChoice']
        owned_games, results_feature = src.recommend(userID)
        # Content Recommendation
        current_usr = userVector(str(userID))
        sorted_gameplay = current_usr.playTime
        if not sorted_gameplay:
            sg.Popup('Error', 'Destiny Failed! Not enough data!')
        game_Ids = src.load_gameIds()
        for key in sorted_gameplay.keys():
            sorted_gameplay[key] = float(sorted_gameplay[key])
        sorted_gameplay = {k: v for k, v in
                           sorted(current_usr.playTime.items(), key=lambda item: item[1], reverse=True)}
        results_content = content_recom.show_rec(game_Ids[str(list(sorted_gameplay)[0])])
        # Similar Users Recommendation
        pairs = create_recommend_pairs()
        recom = src.owned_game_list(pairs[userID])
        myGames = src.owned_game_list(userID)
        recom = check_similar_games(myGames, recom)
        # ===== Results analysis =====
        final_results = dict()
        alpha_content = 1
        beta_feature = 0.65
        gamma_similar = 1
        # Content results
        for _ in range(len(results_content)):
            score = float(results_content[_][results_content[_].find('Score'):].split(':')[1]) * alpha_content
            gameName = results_content[_][2:results_content[_].find('Score')].strip()
            final_results[gameName] = score
        # Feature results
        for _ in range(len(results_feature)):
            score = float(results_feature[_][results_feature[_].find('Score'):].split(':')[1]) * beta_feature
            gameName = results_feature[_][2:results_feature[_].find('Score')].strip()
            if gameName in final_results:
                final_results[gameName] = final_results[gameName] + score
            else:
                final_results[gameName] = score
        # Similar user recommendation
        for game in recom:
            if game[2:] in final_results:
                final_results[game[2:]] = final_results[game[2:]] + gamma_similar
        final_results = {k: v for k, v in sorted(final_results.items(), key=lambda item: item[1], reverse=True)}  # Sort the dict ascending values
        final_rec_list = check_similar_games(owned_games, list(final_results), True)
        final_rec_sort_dict = dict()
        for elem in final_rec_list:
            final_rec_sort_dict[elem] = final_results[elem]
        final_rec_sort_dict = {k: v for k, v in sorted(final_rec_sort_dict.items(), key=lambda item: item[1], reverse=True)}  # Sort the dict ascending values
        final_rec_list.clear()
        final_rec_list = list(final_rec_sort_dict)
        for _ in range(len(final_rec_list)):
            final_rec_list[_] = final_rec_list[_] + ' | Score:' + str(final_rec_sort_dict[final_rec_list[_]])
        main_window_existing_user.close()
        user_results_window(owned_games, final_rec_list, userID)