Skip to content

Commit 87b9ec6

Browse files
committed
Update vignette, README (+ typo)
1 parent 658eb3c commit 87b9ec6

File tree

4 files changed

+30
-18
lines changed

4 files changed

+30
-18
lines changed

R/bind_log_odds.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
#' unregularized <- gear_counts %>%
7878
#' bind_log_odds(vs, gear, n, uninformative = TRUE, unweighted = TRUE)
7979
#'
80-
#' # these logs odd will be farther from zero
80+
#' # these log odds will be farther from zero
8181
#' # than the regularized estimates
8282
#' unregularized
8383
#'

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -85,19 +85,19 @@ bigram_log_odds <- bigram_counts %>%
8585

8686
bigram_log_odds %>%
8787
arrange(-log_odds_weighted)
88-
#> # A tibble: 328,495 x 5
89-
#> book bigram n alpha log_odds_weighted
90-
#> <fct> <chr> <int> <int> <dbl>
91-
#> 1 Mansfield Park sir thomas 287 287 28.3
92-
#> 2 Pride & Prejudice mr darcy 243 243 27.7
93-
#> 3 Emma mr knightley 269 269 27.5
94-
#> 4 Emma mrs weston 229 229 25.4
95-
#> 5 Sense & Sensibility mrs jennings 199 199 25.2
96-
#> 6 Persuasion captain wentworth 170 170 25.1
97-
#> 7 Mansfield Park miss crawford 215 215 24.5
98-
#> 8 Persuasion mr elliot 147 147 23.3
99-
#> 9 Emma mr elton 190 190 23.1
100-
#> 10 Emma miss woodhouse 162 162 21.3
88+
#> # A tibble: 328,495 x 4
89+
#> book bigram n log_odds_weighted
90+
#> <fct> <chr> <int> <dbl>
91+
#> 1 Mansfield Park sir thomas 287 28.3
92+
#> 2 Pride & Prejudice mr darcy 243 27.7
93+
#> 3 Emma mr knightley 269 27.5
94+
#> 4 Emma mrs weston 229 25.4
95+
#> 5 Sense & Sensibility mrs jennings 199 25.2
96+
#> 6 Persuasion captain wentworth 170 25.1
97+
#> 7 Mansfield Park miss crawford 215 24.5
98+
#> 8 Persuasion mr elliot 147 23.3
99+
#> 9 Emma mr elton 190 23.1
100+
#> 10 Emma miss woodhouse 162 21.3
101101
#> # … with 328,485 more rows
102102
```
103103

man/bind_log_odds.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vignettes/tidy_log_odds.Rmd

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,24 @@ gear_counts <- mtcars %>%
101101
gear_counts
102102
```
103103

104-
Now we can use `bind_log_odds()` to find the weighted log odds for each number of gears and engine shape.
104+
Now we can use `bind_log_odds()` to find the weighted log odds for each number of gears and engine shape. First, let's use the default empirical Bayes prior. It regularizes the values.
105105

106106
```{r dependson="gear_counts"}
107-
gear_counts %>%
107+
regularized <- gear_counts %>%
108108
bind_log_odds(vs, gear, n)
109+
110+
regularized
109111
```
110112

111113
For engine shape `vs = 0`, having three gears has the highest weighted log odds while for engine shape `vs = 1`, having four gears has the highest weighted log odds. This dataset is small enough that you can look at the count data and see how this is working.
112-
More importantly, you can notice that this approach is useful both in the initial motivating example of text data but also more generally whenever you have counts in some kind of groups or sets and you want to find what feature is more likely to come from a group, compared to the other groups.
114+
115+
Now, let's use the uninformative prior, and compare to the unweighted log odds. These log odds will be farther from zero than the regularized estimates.
116+
117+
```{r dependson="gear_counts"}
118+
unregularized <- gear_counts %>%
119+
bind_log_odds(vs, gear, n, uninformative = TRUE, unweighted = TRUE)
120+
121+
unregularized
122+
```
123+
124+
Most importantly, you can notice that this approach is useful both in the initial motivating example of text data but also more generally whenever you have counts in some kind of groups or sets and you want to find what feature is more likely to come from a group, compared to the other groups.

0 commit comments

Comments
 (0)