File size: 1,338 Bytes
bd39f54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import numpy as np
import matplotlib.pyplot as plt
from sklearn.metrics import *
from sklearn.preprocessing import label_binarize

from coding.llh.static.config import Config


def draw_roc_auc_curve_total(input_dict, type):
    plt.figure(figsize=(10, 6))

    if type == "train":
        i = 0
        for label_name, values in input_dict.items():
            fpr = values[0]
            tpr = values[1]
            thresholds = values[2]

            plt.plot(
                fpr,
                tpr,
                "o-",
                color=Config.COLORS[i],
                label=label_name+str(round(auc(fpr, tpr), 2))
            )

            i += 1

        title = "Training roc-auc curve"
        plt.title(title)

    else:
        i = 0
        for label_name, values in input_dict.items():
            fpr = values[0]
            tpr = values[1]
            thresholds = values[2]

            plt.plot(
                fpr,
                tpr,
                "o-",
                color=Config.COLORS[i],
                label=label_name + str(round(auc(fpr, tpr), 2))
            )

            i += 1

        title = "Cross-validation roc-auc curve"
        plt.title(title)

    plt.xlabel("tpr")
    plt.ylabel("fpr")
    plt.legend()

    plt.savefig("./diagram/{}.png".format(title), dpi=300)

    plt.show()