示例#1
0
Hamming_loss_5 = round(Hamming_loss_5, 5)
Hamming_loss_10 = np.mean(Hamming_loss_10)
Hamming_loss_10 = round(Hamming_loss_10, 5)
Hamming_loss_15 = np.mean(Hamming_loss_15)
Hamming_loss_15 = round(Hamming_loss_15, 5)

print("ndcg@1: ", nDCG_1)
print("ndcg@3: ", nDCG_3)
print("ndcg@5: ", nDCG_5)
print("Hamming Loss@5: ", Hamming_loss_5)
print("Hamming Loss@10: ", Hamming_loss_10)
print("Hamming Loss@15: ", Hamming_loss_15)

####### example-based evaluation ########
# calculate example-based evaluation
example_based_measure_5 = example_based_evaluation(test_mesh, top_5_mesh)
print("EMP@5, EMR@5, EMF@5")
for em in example_based_measure_5:
    print(em, ",")

example_based_measure_10 = example_based_evaluation(test_mesh, top_10_mesh)
print("EMP@10, EMR@10, EMF@10")
for em in example_based_measure_10:
    print(em, ",")

example_based_measure_15 = example_based_evaluation(test_mesh, top_15_mesh)
print("EMP@15, EMR@15, EMF@15")
for em in example_based_measure_15:
    print(em, ",")

######## label-based evaluation #######
示例#2
0
Hamming_loss_20 = np.mean(Hamming_loss_20)
Hamming_loss_20 = round(Hamming_loss_20, 5)

print("ndcg@1: ", nDCG_1)
print("ndcg@3: ", nDCG_3)
print("ndcg@5: ", nDCG_5)
print("Hamming Loss@10: ", Hamming_loss_10)
print("Hamming Loss@20: ", Hamming_loss_20)

###### example-based evaluation
# convert binary label back to orginal ones
top_10_labels = mlb.inverse_transform(top_10_pred)
top_20_labels = mlb.inverse_transform(top_20_pred)

# calculate example-based evaluation
example_based_measure_10 = example_based_evaluation(test_mesh, top_10_labels)
print("EMP@10, EMR@10, EMF@10")
for em in example_based_measure_10:
    print(em, ",")

example_based_measure_20 = example_based_evaluation(test_mesh, top_20_labels)
print("EMP@20, EMR@20, EMF@20")
for em in example_based_measure_20:
    print(em, ",")

# label-based evaluation
label_measure_10 = perf_measure(test_labels, top_10_pred)
print("MaP@10, MiP@10, MaF@10, MiF@10: ")
for measure in label_measure_10:
    print(measure, ",")