■ ROC(Receiver Operating Characteristic) Curve를 그리는 방법을 보여준다.
▶ 예제 코드 (PY)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
import matplotlib.pyplot as pp import numpy as np modelASensitivityNDArray = np.array([1.00, 1.00, 1.00, 1.00, 0.75, 0.50, 0.50, 0.50, 0.50, 0.50, 0.00]) modelASpecificityNDArray = np.array([0.00, 0.16, 0.50, 0.66, 0.66, 0.66, 0.83, 1.00, 1.00, 1.00, 1.00]) modelBSensitivityNDArray = np.array([1.00, 1.00, 0.75, 0.75, 0.50, 0.50, 0.50, 0.50, 0.25, 0.25, 0.00]) modelBSpecificityNDArray = np.array([0.00, 0.33, 0.33, 0.50, 0.50, 0.66, 0.66, 0.83, 0.83, 1.00, 1.00]) pp.title("Receiver Operating Characteristic") pp.xlabel("False Positive Rate(1 - Specificity)") pp.ylabel("True Positive Rate(Sensitivity)") pp.plot(1 - modelASpecificityNDArray, modelASensitivityNDArray, "b", label = "Model A") pp.plot(1 - modelBSpecificityNDArray, modelBSensitivityNDArray, "g", label = "Model B") pp.plot([0, 1], [1, 1], "y--") pp.plot([0, 1], [0, 1], "r--") pp.legend(loc = "lower right") pp.show() |