-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
31 lines (26 loc) · 991 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import psycopg2
import pandas as pd
import pathlib
from DataIO.DBtoCSV import *
from Model.ItemSimilarityModel import *
from Model.UserRecommendation import *
from Predict.Recommend import *
import random
def printListOfItems(listOfItem):
for item in listOfItem:
print(str(listOfItem.index(item) + 1) + '. ' + item + '\n')
validUsers = list(recommendationDict.keys())
userProductNameDict = loadUserProductNameDict()
while(True):
print('Press ctrl + c or cmd + c to quit')
print('\nTry userID ' + str(random.choice(validUsers)) + '\n')
try:
userId = int(input('Enter a user ID: '))
except (NameError, ValueError):
print(str(userId) + ' is not valid')
continue
print('\nUser ' + str(userId) + ' has purchased:\n')
printListOfItems(getUserProductNames(userId, userProductNameDict))
print('\nUser ' + str(userId) + ' will see:\n')
printListOfItems(getRecommendationList(userId, recommendationDict, 10, 1))
print('\n')