calculate_lift: calculate_lift

Description Usage Arguments Value Examples

View source: R/calculate_lift.R

Description

Provides an overview of the binary classification (Yes, No style) model performance and plots the lift plot

Usage

1
2
3
4
5
6
calculate_lift(
  dataWithProbabilityPrediction = pred,
  levelPositive = "yes",
  responseVariable = "y",
  probabilityOfChurning = "pred"
)

Arguments

dataWithProbabilityPrediction

A data set object with predictions (probabilities)

levelPositive

Character, positive categorical true value of the binary outcome variable (e.g., 'Y', 'yes' or 'churned')

responseVariable

Character column indicating the response variable (e.g., 'churn')

probabilityOfChurning

Character column indicating the column, where the prediction probabilities are saves (e.g., 'predictions')

Value

A data frame with the Lift values as compared to the base line performance

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
library(data.table)
library(caret)
library(ranger)
data <- fread("https://raw.githubusercontent.com/just4jin/bank-marketing-prediction/master/data/bank_full.csv")
inx <- createDataPartition(data$y, list = FALSE, p = 0.7)
train <- data[inx, ]
test <- data[-inx, ]
set.seed(23)
model_ranger <- ranger(as.factor(y) ~ ., data = train, probability = TRUE)
pred <- data.table(
  event = test$y,
  pred = predictions(predict(model_ranger, test))[, "yes"]
)

calculate_lift(
  dataWithProbabilityPrediction = pred,
  levelPositive = "yes",
  responseVariable = "event",
  probabilityOfChurning = "pred"
)

Patrikios/liftscores documentation built on Dec. 18, 2021, 6:42 a.m.