performance_bin: 비닝된 변수의 성능 진단

Description Usage Arguments Details Value See Also Examples

Description

performance_bin()은 이항 분류 모델에 대한 비닝된 변수의 성능을 평가하기 위해 메트릭을 계산합니다.

Usage

1
performance_bin(y, x, na.rm = FALSE)

Arguments

y

문자 또는 숫자, 정수, 인수. 이진 응답 변수(0, 1) 변수는 0과 1의 요소만을 포함해야 합니다. 단, 2개의 수준을 가진 요소의 경우, 계산 과정에서 타입 변환이 수행됩니다.

x

정수 또는 인수, 문자. 최소 2개의 다른 값이어야 하며, Inf는 허용되지 않습니다.

na.rm

logical. 결측값을 제거해야 하는지 여부를 나타내는 논리값

Details

이 함수는 dplyr 패키지의 mutate, 혹은 transmute 함수와 사용하면 효율적으로 데이터를 비닝할 수 있습니다.

Value

"performance_bin" 클래스 객체. data.frame의 값은 다음과 같습니다.

"performance_bin" 클래스의 속성은 다음과 같습니다.

See Also

summary.performance_bin, plot.performance_bin, binning_by.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 예제를 위한 데이터 생성
heartfailure2 <- heartfailure

set.seed(123)
heartfailure2[sample(seq(NROW(heartfailure2)), 5), "creatinine"] <- NA

# 타깃 변수를 0(음)과 1(양)로 변경
heartfailure2$death_event_2 <- ifelse(heartfailure2$death_event %in% "Yes", 1, 0)

# creatinine에서 platelets_bin으로 비닝
breaks <- c(0,  1,  2, 10)
heartfailure2$creatinine_bin <- cut(heartfailure2$creatinine, breaks)

# 비닝된 변수의 성능 진단
perf <- performance_bin(heartfailure2$death_event_2, heartfailure2$creatinine_bin)
perf
summary(perf)

# plot(perf)

# 비닝된 변수의 성능 진단 (NA 제외)
perf <- performance_bin(heartfailure2$death_event_2, heartfailure2$creatinine_bin, na.rm = TRUE)
perf
summary(perf)

# plot(perf)

bit2r/kodlookr documentation built on Dec. 19, 2021, 9:49 a.m.