ROC curve 그리기 R - ROC curve geuligi R

1 개요[ | ]

R ROC 곡선 겹치기R ROC 곡선 여러 개를 한 도표에 겹쳐서 출력하기

2 예시 1[ | ]

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)

3 예시 2[ | ]

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) 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)

4 같이 보기[ | ]

  • R ROC 곡선
  • R ROCR plot()
  • R 이진분류 모델 비교 구현
  • ROC 곡선

Toplist

최신 우편물

태그