Ejemplo n.º 1
0
def _recommend(cfg: dict):
    top_n = cfg['top_n']
    cfg_model, cfg_dataset = cfg['model'], cfg['dataset']
    cfg_results = cfg['results']

    _, col_files = cfg_dataset['cols']
    x_df = utils \
        .read_csv(cfg_dataset['path'], usecols=cfg_dataset['cols']) \
        .pipe(utils.to_list_of_strings, col=col_files)
    model_recommender = model.deserialize(cfg_model['path'])

    y_df = model.recommend(model_recommender,
                           x_df,
                           cfg_dataset['cols'],
                           top_n=top_n)

    if cfg_results.get('save', True):
        utils.save_csv(cfg_results['out'], y_df)
Ejemplo n.º 2
0
def root(id=None):
    count = request.query.count
    if count != '':
        count = int(count)
    else:
        count = 10

    if id is None:
        id = model_.id_to_article_id[0]

    matrix_id = model_.article_id_to_id[id]
    recommendations = model.recommend(model_, matrix_id, count)

    # for id, distance in recommendations:
    #     print('{} => {}: {}'.format(model_.id_to_article_id[matrix_id],
    #                                 model_.id_to_article_id[id], distance))

    items = [model_.id_to_article_id[id] for id, _ in recommendations]
    return ','.join(items) + '\n'
Ejemplo n.º 3
0
    def __init__(self):
        self.run = recommend()
        self.run.read_from_file('data/literature_data.txt')

        self.result = list()
Ejemplo n.º 4
0
async def song_recommend(song_id: int):
    
    #make recommendations
    #by default, no. of recs is 10 
    recs = recommend(item_id = song_id)
    return recs