<filename>data_process/plot.py<gh_stars>0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# author： 11360
# datetime： 2021/6/3 23:40 
import matplotlib.pyplot as plt
import pickle


def plot_neg(is_tetrahedron, neg_lst):
    tetrahedron_neg_lst = []
    not_tetrahedron_neg_lst = []
    for i in range(len(is_tetrahedron)):
        if is_tetrahedron[i]:
            tetrahedron_neg_lst.append(neg_lst[i])
        else:
            not_tetrahedron_neg_lst.append(neg_lst[i])
    tetrahedron_neg_lst.sort()
    not_tetrahedron_neg_lst.sort()
    print(len(tetrahedron_neg_lst))
    print(len(not_tetrahedron_neg_lst))
    tp_plus_fn = len(tetrahedron_neg_lst)
    plt.figure()
    precision_lst = []
    recall_lst = []
    for i in range(len(tetrahedron_neg_lst)):
        yuzhi = tetrahedron_neg_lst[i]
        print("yuzhi = ", yuzhi)
        # tp_lst = [neg for neg in tetrahedron_neg_lst if neg <= yuzhi]
        recall = (i + 1) / (tp_plus_fn)
        fp_lst = [neg for neg in not_tetrahedron_neg_lst if neg <= yuzhi]
        print("fp_lst = ", fp_lst)
        print("len(fp_lst) = ", len(fp_lst))
        precision = (i + 1) / (i + 1 + len(fp_lst))
        precision_lst.append(precision)
        recall_lst.append(recall)
    plt.plot(recall_lst, precision_lst)
    plt.xlabel("recall")
    plt.ylabel("precision")
    plt.show()
    print("min_neg = ", min(tetrahedron_neg_lst))
    print("max_neg = ", max(tetrahedron_neg_lst))
    print("min_neg = ", min(not_tetrahedron_neg_lst))
    print("max_neg = ", max(not_tetrahedron_neg_lst))


if __name__ == "__main__":
    with open("neg_lst.pkl", "rb") as f:
        neg_lst = pickle.load(f)
    with open("is_tetrahedron.pkl", "rb") as f:
        is_tetrahedron = pickle.load(f)
    plot_neg(is_tetrahedron, neg_lst)

