Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIFT curve #87

Open
MathieuMarauri opened this issue Nov 22, 2021 · 2 comments
Open

LIFT curve #87

MathieuMarauri opened this issue Nov 22, 2021 · 2 comments

Comments

@MathieuMarauri
Copy link

Hello,

I was wondering if there is a way to plot the LIFT curve associated with a binary classification model. It is possible to plot ROC curves using autoplot() but I could not find a way to plot LIFT curves.

Best regards,
Mathieu

@MathieuMarauri
Copy link
Author

Here is the code I used to make the Lift curve if it can be of any help.

library(ggplot2)
library(mlr3)
library(mlr3viz)
library(purrr)

task = tsk("spam")
learner = lrn("classif.rpart", predict_type = "prob")
object = learner$train(task)$predict(task)
# Part that could be included in the autoplot function
pred = object$clone(deep = TRUE)
tab = data.table(prob = seq(from = 0, to = 1, by = 0.01))
result = purrr::map_dfr(tab$prob, function(p) {
  pred$set_threshold(p)$score(list(
    msr('classif.tpr'), 
    msr('classif.tp'), 
    msr('classif.fp')
  ))
})
result = as.data.table(result)[, pp := (classif.tp + classif.fp) / length(pred$response)]
ggplot(
  data = result,
  mapping = aes_string(x = "pp", y = "classif.tpr")
) +
  geom_line() +
  labs(
    x = 'Positive rate',
    y = 'Sensibility',
    title = 'Lift curve'
  )

@pat-s
Copy link
Member

pat-s commented May 30, 2022

@MathieuMarauri Thanks!
Sounds like we could easily support this. I've never used a LIFT curve so far but it seems to be similar to ROC and not too complicated to implement.

@mllg What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants