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 chart in ggplot #656

Closed
spedygiorgio opened this issue May 12, 2017 · 3 comments
Closed

lift chart in ggplot #656

spedygiorgio opened this issue May 12, 2017 · 3 comments

Comments

@spedygiorgio
Copy link

@spedygiorgio spedygiorgio commented May 12, 2017

Is would be possible to have lift charts in ggplot2? Current the old, legacy, lattice package is used.

@topepo
Copy link
Owner

@topepo topepo commented Jun 9, 2017

Here is a temlate that I'll clean up for the next release:

set.seed(1)
simulated <- data.frame(obs = factor(rep(letters[1:2], each = 100)),
                        perfect = sort(runif(200), decreasing = TRUE),
                        random = runif(200))

lift2 <- lift(obs ~ random + perfect, data = simulated)

xyplot(lift2, auto.key = list(columns = 2))

lines1 <- data.frame(x1 = 0, x2 = 100, y1 = 0, y2 = 100)
lines2 <- data.frame(x1 = 0, x2 = lift2$pct, y1 = 0, y2 = 100)
lines3 <- data.frame(x1 = lift2$pct, x2 = 100, y1 = 100, y2 = 100)

ggplot(lift2$data) +
  geom_segment(data = lines1, 
               aes(x = x1, y = y1, xend = x2, yend = y2),
               alpha = .2, lty = 2) + 
  geom_segment(data = lines2, 
               aes(x = x1, y = y1, xend = x2, yend = y2),
               alpha = .2, lty = 2) +   
  geom_segment(data = lines3, 
               aes(x = x1, y = y1, xend = x2, yend = y2),
               alpha = .2, lty = 2) +
  geom_line(aes(x = CumTestedPct, y = CumEventPct, col = liftModelVar))   
topepo added a commit that referenced this issue Jul 24, 2017
@topepo
Copy link
Owner

@topepo topepo commented Jul 24, 2017

Take a look at the changes I checked in and feel free to make suggestions.

@spedygiorgio
Copy link
Author

@spedygiorgio spedygiorgio commented Jul 24, 2017

@topepo, I will have a look in the next two days

@topepo topepo closed this Aug 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.