최신판 |
당신의 편집 |
2번째 줄: |
2번째 줄: |
| ;ROCR plot() | | ;ROCR plot() |
|
| |
|
| ==기본형==
| |
| <source lang='r' run> | | <source lang='r' run> |
| library(ROCR) | | library(ROCR) |
9번째 줄: |
8번째 줄: |
| perf = performance( pred, "tpr", "fpr" ) | | perf = performance( pred, "tpr", "fpr" ) |
| plot( perf ) | | plot( perf ) |
| </source>
| |
|
| |
|
| ==여러 개 겹치기==
| |
| <source lang='r' run>
| |
| 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)
| |
| </source>
| |
| <source lang='r' run>
| |
| 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)
| |
| </source>
| |
|
| |
| ==알록달록==
| |
| <source lang='r' run>
| |
| 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)
| |
| </source>
| |
| <source lang='r' run>
| |
| 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)) | | par(bg="lightblue", mai=c(1.2,1.5,1,1)) |
| plot(perf, main="ROCR fingerpainting toolkit", colorize=TRUE, | | plot(perf, main="ROCR fingerpainting toolkit", colorize=TRUE, |
78번째 줄: |
20번째 줄: |
| ==같이 보기== | | ==같이 보기== |
| * [[R plot()]] | | * [[R plot()]] |
| * [[R ROC 곡선 겹치기]]
| |
| * [[ROC 곡선]] | | * [[ROC 곡선]] |
|
| |
|
85번째 줄: |
26번째 줄: |
|
| |
|
| [[분류: R ROCR]] | | [[분류: R ROCR]] |
| [[분류: R 차트]]
| |