1 개요[ | ]
- ROCR plot()
2 기본형[ | ]
R
Copy
library(ROCR)
data(ROCR.simple)
pred = prediction( ROCR.simple$predictions, ROCR.simple$labels )
perf = performance( pred, "tpr", "fpr" )
plot( perf )
Loading
3 여러 개 겹치기[ | ]
R
Copy
library(ROCR)
data(ROCR.simple)
pred1 = prediction( ROCR.simple$predictions, ROCR.simple$labels )
pred2 = prediction(abs(ROCR.simple$predictions + rnorm(length(ROCR.simple$predictions), 0, 0.1)), ROCR.simple$labels)
perf1 = performance(pred1, "tpr", "fpr")
perf2 = performance(pred2, "tpr", "fpr")
plot(perf1)
plot(perf2, add = TRUE)
Loading
R
Copy
set.seed(42) # 랜덤값 고정
df = infert
df = df[,c("age","parity","induced","spontaneous","case")]
# 데이터 분할
library(caret, quietly=T)
idx = createDataPartition(df$case, list=F, p=0.8)
Train = df[ idx,]
Test = df[-idx,]
library(neuralnet)
model1 = neuralnet(case ~ age + parity + induced + spontaneous, Train, hidden=2)
Test$pred1 = predict(model1, Test, type="class")
library(C50)
Train$case = factor(Train$case)
model2 = C5.0(case ~ age + parity + induced + spontaneous, Train)
Test$pred2 = predict(model2, Test, type="prob")[,2]
library(ROCR, warn.conflicts=F)
pred1 = ROCR::prediction(Test$pred1, Test$case)
pred2 = ROCR::prediction(Test$pred2, Test$case)
pref1 = performance(pred1, "tpr", "fpr")
pref2 = performance(pred2, "tpr", "fpr")
plot(pref1, col="red")
plot(pref2, col="blue", add=T)
Loading
4 알록달록[ | ]
R
Copy
library(ROCR)
data(ROCR.simple)
pred1 = prediction( ROCR.simple$predictions, ROCR.simple$labels )
pred2 = prediction(abs(ROCR.simple$predictions + rnorm(length(ROCR.simple$predictions), 0, 0.1)), ROCR.simple$labels)
perf1 = performance(pred1, "tpr", "fpr")
perf2 = performance(pred2, "tpr", "fpr")
plot(perf1, colorize = TRUE)
plot(perf2, add = TRUE, colorize = TRUE)
Loading
R
Copy
library(ROCR)
data(ROCR.simple)
pred = prediction( ROCR.simple$predictions, ROCR.simple$labels )
perf = performance( pred, "tpr", "fpr" )
par(bg="lightblue", mai=c(1.2,1.5,1,1))
plot(perf, main="ROCR fingerpainting toolkit", colorize=TRUE,
xlab="Mary's axis", ylab="", box.lty=7, box.lwd=5,
box.col="gold", lwd=17, colorkey.relwidth=0.5, xaxis.cex.axis=2,
xaxis.col='blue', xaxis.col.axis="blue", yaxis.col='green', yaxis.cex.axis=2,
yaxis.at=c(0,0.5,0.8,0.85,0.9,1), yaxis.las=1, xaxis.lwd=2, yaxis.lwd=3,
yaxis.col.axis="orange", cex.lab=2, cex.main=2)
Loading
5 같이 보기[ | ]
6 참고[ | ]
편집자 Jmnote
로그인하시면 댓글을 쓸 수 있습니다.