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

wrong structure for logistic regression confidence intervals #156

Closed
topepo opened this issue Feb 26, 2019 · 2 comments · Fixed by #157
Closed

wrong structure for logistic regression confidence intervals #156

topepo opened this issue Feb 26, 2019 · 2 comments · Fixed by #157

Comments

@topepo
Copy link
Member

topepo commented Feb 26, 2019

library(tidymodels)
#> ── Attaching packages ───────────────────────────────────────────────────────────────── tidymodels 0.0.2 ──
#> ✔ broom     0.5.1          ✔ purrr     0.3.0     
#> ✔ dials     0.0.2          ✔ recipes   0.1.4     
#> ✔ dplyr     0.8.0.1        ✔ rsample   0.0.4     
#> ✔ ggplot2   3.1.0          ✔ tibble    2.0.1     
#> ✔ infer     0.4.0          ✔ yardstick 0.0.2     
#> ✔ parsnip   0.0.1.9000
#> ── Conflicts ──────────────────────────────────────────────────────────────────── tidymodels_conflicts() ──
#> ✖ purrr::discard() masks scales::discard()
#> ✖ dplyr::filter()  masks stats::filter()
#> ✖ dplyr::lag()     masks stats::lag()
#> ✖ recipes::step()  masks stats::step()

data("lending_club")

lending_club <-
  lending_club %>%
  slice(1:200) 

log_reg <-
  logistic_reg() %>%
  set_engine("glm") %>%
  fit(Class ~ log(funded_amnt) + int_rate, data = lending_club)

predict(log_reg, lending_club %>% slice(1:7) %>% dplyr::select(-Class), type = "prob")
#> # A tibble: 7 x 2
#>   .pred_bad .pred_good
#>       <dbl>      <dbl>
#> 1   0.0511       0.949
#> 2   0.0706       0.929
#> 3   0.0500       0.950
#> 4   0.0499       0.950
#> 5   0.00185      0.998
#> 6   0.0166       0.983
#> 7   0.00441      0.996

predict(log_reg, lending_club %>% slice(1:7) %>% dplyr::select(-Class), type = "conf_int")
#> # A tibble: 7 x 2
#>   .pred_lower .pred_upper
#>         <dbl>       <dbl>
#> 1       0.896       0.976
#> 2       0.813       0.975
#> 3       0.883       0.980
#> 4       0.897       0.976
#> 5       0.975       1.000
#> 6       0.944       0.995
#> 7       0.971       0.999

Created on 2019-02-25 by the reprex package (v0.2.1)

@topepo
Copy link
Member Author

topepo commented Feb 26, 2019

same for stan engine too

topepo added a commit that referenced this issue Feb 26, 2019
@github-actions
Copy link

github-actions bot commented Mar 8, 2021

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant