コード例 #1
0
def effectiveness_tfidf(relevance_file):
    # TFIDF baseline run
    baseline_run = path.join(path.pardir, "Retrieval", "Retrieval_Model",
                             "TFIDF_Model", "TFIDF_results.json")

    # MAP
    v = mean_average_precision(baseline_run, relevance_file)

    # MRR
    mrr = mean_reciprocal_rank(baseline_run, relevance_file)

    # Precision and Recall
    precision_recall_calculator(baseline_run, relevance_file, "TF_IDF")

    # Precision at rank =5 and rank = 20
    precision_file = path.join(path.dirname(path.abspath(__file__)), "Files",
                               "precision_values_" + "TF_IDF" + ".json")

    precision_at_rank_calculator(precision_file, "TF_IDF")

    values = result_scores["Mean Average Precision"]
    values.append(["TFIDF", v])

    values = result_scores["Mean_Reciprocal_Rank"]
    values.append(["TFIDF", mrr])

    # Stopped TFIDF baseline run
    baseline_run = path.join(path.pardir, "Retrieval", "Retrieval_Model",
                             "TFIDF_Model", "Stopped_TFIDF_results.json")

    # MAP
    v = mean_average_precision(baseline_run, relevance_file)

    # MRR
    mrr = mean_reciprocal_rank(baseline_run, relevance_file)

    # Precision and Recall
    precision_recall_calculator(baseline_run, relevance_file, "TF_IDF_Stopped")

    # Precision at rank =5 and rank = 20
    precision_file = path.join(path.dirname(path.abspath(__file__)), "Files",
                               "precision_values_" + "TF_IDF_Stopped" + ".json")

    precision_at_rank_calculator(precision_file, "TF_IDF_Stopped")

    values = result_scores["Mean Average Precision"]
    values.append(["Stopped_TFIDF", v])

    values = result_scores["Mean_Reciprocal_Rank"]
    values.append(["Stopped_TFIDF", mrr])

    print("MAP, MRR and Precision and Recall generated for TFIDF Model.\n")
コード例 #2
0
def effectiveness_bm25(relevance_file):

    baseline_run = path.join(path.pardir, "Retrieval", "Retrieval_Model",
                             "BM25_Model", "bm25_baseline_results.json")

    # MAP for BM25 baseline run
    v = mean_average_precision(baseline_run, relevance_file)

    # MRR for BM25 baseline run
    mrr = mean_reciprocal_rank(baseline_run, relevance_file)

    # Precision and Recall
    precision_recall_calculator(baseline_run, relevance_file, "BM25")

    # Precision at rank =5 and rank = 20
    precision_file = path.join(path.dirname(path.abspath(__file__)), "Files",
                               "precision_values_" + "BM25" + ".json")

    precision_at_rank_calculator(precision_file, "BM25")

    values = result_scores["Mean Average Precision"]
    values.append(["BM25", v])

    values = result_scores["Mean_Reciprocal_Rank"]
    values.append(["BM25", mrr])

    # BM25 Stopped baseline run
    baseline_run = path.join(path.pardir, "Retrieval", "Retrieval_Model",
                             "BM25_Model", "bm25_stopped_baseline_results.json")

    # MAP
    v = mean_average_precision(baseline_run, relevance_file)

    # MRR
    mrr = mean_reciprocal_rank(baseline_run, relevance_file)

    # Precision and Recall
    precision_recall_calculator(baseline_run, relevance_file, "BM25_Stopped")

    # Precision at rank =5 and rank = 20
    precision_file = path.join(path.dirname(path.abspath(__file__)), "Files",
                               "precision_values_" + "BM25_Stopped" + ".json")

    precision_at_rank_calculator(precision_file, "BM25_Stopped")

    values = result_scores["Mean Average Precision"]
    values.append(["BM25 Stopped", v])

    values = result_scores["Mean_Reciprocal_Rank"]
    values.append(["BM25 Stopped", mrr])

    print("MAP, MRR and Precision and Recall generated for BM25 Model.\n")
コード例 #3
0
def effectiveness_noise_minimized_queries(relevance_file):
    baseline_run = path.join(path.pardir, "Extra_Credit", "Noise_Minimizer",
                             "noise_minimized_bm25_result.json")

    # MAP for BM25 on noise-induced queries baseline run
    v = mean_average_precision(baseline_run, relevance_file)

    # MRR for BM25 on noise-induced queries baseline run
    mrr = mean_reciprocal_rank(baseline_run, relevance_file)

    # Precision and Recall
    precision_recall_calculator(baseline_run, relevance_file, "BM25 on noise-minimized queries")

    # Precision at rank =5 and rank = 20
    precision_file = path.join(path.dirname(path.abspath(__file__)), "Files",
                               "precision_values_" + "BM25 on noise-minimized queries" + ".json")
    precision_at_rank_calculator(precision_file, "BM25 on noise-minimized queries")

    values = result_scores["Mean Average Precision"]
    values.append(["BM25 on noise-minimized queries", v])

    values = result_scores["Mean_Reciprocal_Rank"]
    values.append(["BM25 on noise-minimized queries", mrr])

    print("MAP, MRR and Precision and Recall generated for BM25 on noise-minimized queries Model.\n")
コード例 #4
0
def effectiveness_lucene(relevance_file):
    # Lucene baseline run
    baseline_run = path.join(path.pardir, "Retrieval", "Retrieval_Model",
                             "LuceneSearchEngine", "result_dict.json")

    # MAP
    v = mean_average_precision(baseline_run, relevance_file)

    # MRR
    mrr = mean_reciprocal_rank(baseline_run, relevance_file)

    # Precision and Recall
    precision_recall_calculator(baseline_run, relevance_file, "Lucene")

    # Precision at rank =5 and rank = 20
    precision_file = path.join(path.dirname(path.abspath(__file__)), "Files",
                               "precision_values_" + "Lucene" + ".json")
    precision_at_rank_calculator(precision_file, "Lucene")

    values = result_scores["Mean Average Precision"]
    values.append(["Lucene", v])

    values = result_scores["Mean_Reciprocal_Rank"]
    values.append(["Lucene", mrr])

    print("MAP, MRR and Precision and Recall generated for Lucene Model.\n")
コード例 #5
0
def effectiveness_query_expansion(relevance_file):
    baseline_run = path.join(path.pardir, "Retrieval", "Query_Expansion",
                             "stemmed_baseline_results.json")

    # MAP for Query_Expansion baseline run
    v = mean_average_precision(baseline_run, relevance_file)

    # MRR for Query_Expansion baseline run
    mrr = mean_reciprocal_rank(baseline_run, relevance_file)

    # Precision and Recall
    precision_recall_calculator(baseline_run, relevance_file, "Query_Expansion")

    # Precision at rank =5 and rank = 20
    precision_file = path.join(path.dirname(path.abspath(__file__)), "Files",
                               "precision_values_" + "Query_Expansion" + ".json")
    precision_at_rank_calculator(precision_file, "Query_Expansion")

    result_scores["Mean Average Precision"] = [["Query_expansion", v]]
    result_scores["Mean_Reciprocal_Rank"] = [["Query_expansion", mrr]]

    print("MAP, MRR and Precision and Recall generated for Query Expansion Model.\n")