Exemple #1
0
def manage(arg):
    # arg = sys.argv[1]
    if arg == 'preprocess':
        Channel().process()
    elif arg == 'cf':
        user_cf(2073000)
    elif arg == 'lfm':
        lfm()
    elif arg == 'prank':
        prank(2073000)
    else:
        print('Args must in ["preprocess", "cf", "lfm","prank"].')
    sys.exit()
Exemple #2
0
def manage():
    arg = sys.argv[1]
    if arg == 'preprocess':
        Channel().process()
    elif arg == 'cf':
        user_cf()
    elif arg == 'lfm':
        #lfm()
        print('lfm耗时过长,暂停使用')
    elif arg == 'prank':
        prank()
    else:
        print('Args must in ["preprocess", "cf", "lfm","prank"].')
    sys.exit()
Exemple #3
0
def manage():
    # arg = sys.argv[1]
    arg = 'lfm'
    if arg == 'preprocess':
        Channel().process()
    elif arg == 'itemcf':
        item_cf()
    elif arg == 'cf':
        user_cf()
    elif arg == 'lfm':
        lfm()
    elif arg == 'prank':
        prank()
    else:
        print('Args must in ["preprocess", "cf", "lfm","prank"].')
    sys.exit()
Exemple #4
0
def prankMed():
    userId = request.args.get('userId', default=None, type=int)
    if userId is None:
        abort(404)

    topN = request.args.get('topN', default=10, type=int)

    return jsonify(prank(userId=userId, topItems=topN))
def manage():
    arg = sys.argv[1]
    if arg == 'preprocess':
        Channel().process()
    elif arg == 'excute':
        target = int(sys.argv[2])  # 这里用运行参数代表用户id赋值给target
        result1 = user_cf()
        result2 = lfm(target)
        result3 = prank(target)  #三个result的输出格式为[[str,浮点数],[str,浮点数]......]
        result1 = list(result1)
        result2 = list(result2)
        result3 = list(result3)
        result = []
        count = 0

        for i in result2:
            for j in result3:
                for k in result1:
                    i = list(i)
                    j = list(j)
                    k = list(k)
                    if i[0] == delete_substr_method2(j[0], "item_") == k[0]:
                        result.append(i[0])
                        i[1] = 100
                        j[1] = 100
                        k[1] = 100
                    elif i[0] == delete_substr_method2(j[0], "item_"):
                        result.append(i[0])
                        i[1] = 100
                        j[1] = 100
                    elif k[0] == i[0]:
                        result.append(i[0])
                        k[1] = 100
                        i[1] = 100
                    elif k[0] == delete_substr_method2(j[0], "item_"):
                        result.append(k[0])
                        k[1] = 100
                        j[1] = 100
                    else:
                        for i in result2:
                            for j in result3:
                                for k in result1:
                                    if i[1] != 100:
                                        result.append(i[0])
                                    if j[1] != 100:
                                        result.append(
                                            delete_substr_method2(
                                                j[0], "item_"))
                                    if k[1] != 100:
                                        result.append(k[0])

        with open("recommand_result_" + sys.argv[2] + ".txt",
                  'w',
                  encoding='utf-8') as f:
            for ok in result:
                if count < 10:
                    print(ok)
                    f.write(str(ok) + "\n")
                    count = count + 1
    else:
        print('Args must in ["preprocess", "excute"].')
    sys.exit()
Exemple #6
0
from workflow.lfm_workflow import run as lfm
from workflow.ucf_workflow import run as ucf
from workflow.prank_workflow import run as prank

import sys

params = sys.argv[1]
params = int(params)
params2 = sys.argv[2]

if __name__=='__main__':
    if params2 != '':
        arg = params2
    # lfm模型给用户推荐的商品列表
    if arg == 'lfm':
        lfm(params)
    elif arg == 'ucf':
        ucf(params)
    elif arg == 'prank':
        prank(params)
    else:
        print('对不起,请重新输入模型参数')