3-1 Please calculate the classification error, sensitivity, and specificity of \(\hat{g}(x)\) under c = 0.5.

c = 0.5 的情況下 f(x) 分類如下

obs1 obs2 obs3 obs4 obs5 obs6
y 0.0 1.0 0.0 1.0 1.0 1.0
f(x) 0.0 0.0 0.0 1.0 1.0 1.0

classification error = 1/6 = 0.1667

sensitivity = 3/4 = 0.75

specificity = 1-0/2 = 1


3-2 You may find that c = 0.5 and c = 0.6 yield the same sensitivity and specificity on the given data. How many ”real distinct” c’s can be found here? Please also describe the characteristics of these ”real distinct” c’s.

\(0.4<c<0.7\) 的情況下,結果都會跟 c = 0.5 時一致,故會得到相同的 sensitivity and specificity。

由於原本的 data 顯示在 f(x)=0.4 的項會歸類到 0.0,而 f(x)=0.7 歸類到 1.0,而中間沒有其他值,故落在此區間的常數 c 都會得到相同的 sensitivity and specificity。


3-3 Please draw the ROC curve of \(\hat{f}(x)\) without using advanced packages (you may first calculate the values of TP rate and FP rate under all possible c’s and then plot these values of TP and FP in the figure).

假設 c = 0.0, 0.1,…,1.0

plot(x = list(0,0.5,0.5,0.5,1,1,1,1,1,1,1),y = list(1,1,0.75,0.75,0.75,0.75,0.75,0.5,0.25,0,0),type = "l",xlab = "specificity",ylab = "sensitivity",xlim = c(1.0,0.0))


3-4 Please calculate the area under the ROC curve (AUC) without using advanced packages.

由上圖可算出線下面積 = 0.50.75+0.51=0.875