Exemple #1
0
def evaluate(model, test_dataset, N):
    """
    评估模型
    :param N: 推荐的商品个数
    :param K: 搜索邻近的用户个数
    :return: 精确率(precision), 召回率(recall)
    """
    recommens = model.recommend_users(test_dataset.keys(), N=N)

    recall = metric.recall(recommends=recommens, tests=test_dataset)
    precision = metric.precision(recommends=recommens, tests=test_dataset)

    return precision, recall
def evaluate(model, train_dataset, test_dataset, N):
    """
    评估模型
    :param N: 推荐的商品个数
    :param K: 搜索邻近的用户个数
    :return: 精确率(precision), 召回率(recall)
    """
    recommens = model.recommend_users(test_dataset.keys(), N=N)
    all_items = lastfm_reader.get_all_items(train_dataset, test_dataset)

    recall = metric.recall(recommends=recommens, tests=test_dataset)
    precision = metric.precision(recommends=recommens, tests=test_dataset)
    coverage = metric.coverage(recommends=recommens, all_items=all_items)

    return precision, recall, coverage
Exemple #3
0
def evaluate(model, test_dataset, N, K=None):
    """
    评估模型
    :param N: 推荐的商品个数
    :param K: 搜索邻近的用户个数
    :return: 精确率(precision), 召回率(recall)
    """
    test_dataset = delicious_reader.get_all_items(test_dataset)

    recommens = model.recommend_users(test_dataset.keys(), N=N, K=K)

    recall = metric.recall(recommends=recommens, tests=test_dataset)
    precision = metric.precision(recommends=recommens, tests=test_dataset)

    return precision, recall
Exemple #4
0
def evaluate(model, train_dataset, test_dataset, N, K):
    """
    评估模型
    :param N: 推荐的商品个数
    :param K: 搜索邻近的用户个数
    :return: 精确率(precision), 召回率(recall), 覆盖率(coverage)
    """
    recommens = model.recommend_users(test_dataset.keys(), N=N, K=K)
    all_items = movielen_reader.get_all_items(train_dataset, test_dataset)
    item_popularity = train_popularity(train_dataset)

    recall = metric.recall(recommends=recommens, tests=test_dataset)
    precision = metric.precision(recommends=recommens, tests=test_dataset)
    coverage = metric.coverage(recommends=recommens, all_items=all_items)
    popularity = metric.popularity(item_popular=item_popularity,
                                   recommends=recommens)

    return precision, recall, coverage, popularity