-
Notifications
You must be signed in to change notification settings - Fork 7
/
modeling.html
915 lines (667 loc) · 24.6 KB
/
modeling.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
<!DOCTYPE html>
<html>
<head>
<title>Text Modeling</title>
<meta charset="utf-8">
<meta name="author" content="Julia Silge | Deming Conference | 4 Dec 2018" />
<link href="libs/remark-css/default.css" rel="stylesheet" />
<script src="https://use.fontawesome.com/5235085b15.js"></script>
<link rel="stylesheet" href="css/xaringan-themer.css" type="text/css" />
<link rel="stylesheet" href="css/footer_plus.css" type="text/css" />
</head>
<body>
<textarea id="source">
layout: true
<div class="my-footer"><span>bit.ly/silge-deming-2</span></div>
---
class: inverse, center, middle
background-image: url(figs/p_and_p_cover.png)
background-size: cover
# Text Modeling
<img src="figs/blue_jane.png" width="150px"/>
### USING TIDY PRINCIPLES
.large[Julia Silge | Deming Conference | 4 Dec 2018]
---
## Let's install some packages
```r
install.packages(c("tidyverse",
"tidytext",
"gutenbergr",
"stm",
"glmnet"))
```
---
class: right, middle
<img src="figs/blue_jane.png" width="150px"/>
# Find me at...
<a href="http://twitter.com/juliasilge"><i class="fa fa-twitter fa-fw"></i>&nbsp; @juliasilge</a><br>
<a href="http://github.com/juliasilge"><i class="fa fa-github fa-fw"></i>&nbsp; @juliasilge</a><br>
<a href="https://juliasilge.com"><i class="fa fa-link fa-fw"></i>&nbsp; juliasilge.com</a><br>
<a href="https://tidytextmining.com"><i class="fa fa-book fa-fw"></i>&nbsp; tidytextmining.com</a><br>
<a href="mailto:[email protected]"><i class="fa fa-paper-plane fa-fw"></i>&nbsp; [email protected]</a>
---
class: right, inverse, middle
background-image: url(figs/p_and_p_cover.png)
background-size: cover
# TIDYING AND CASTING
<h1 class="fa fa-check-circle fa-fw"></h1>
---
background-image: url(figs/tmwr_0601.png)
background-size: 900px
---
class: inverse
background-image: url(figs/p_and_p_cover.png)
background-size: cover
# Two powerful NLP techniques
--
- .large[Topic modeling]
--
- .large[Text classification]
---
class: inverse
background-image: url(figs/p_and_p_cover.png)
background-size: cover
# Topic modeling
- .large[Each DOCUMENT = mixture of topics]
--
- .large[Each TOPIC = mixture of words]
---
class: top
background-image: url(figs/top_tags-1.png)
background-size: 800px
---
class: center, middle, inverse
background-image: url(figs/p_and_p_cover.png)
background-size: cover
# GREAT LIBRARY HEIST 🕵️♂️
---
## **Downloading your text data**
```r
library(tidyverse)
library(gutenbergr)
titles <- c("Twenty Thousand Leagues under the Sea",
"The War of the Worlds",
"Pride and Prejudice",
"Great Expectations")
books <- gutenberg_works(title %in% titles) %>%
gutenberg_download(meta_fields = "title")
books
```
```
## # A tibble: 51,663 x 3
## gutenberg_id text title
## <int> <chr> <chr>
## 1 36 The War of the Worlds The War of the…
## 2 36 "" The War of the…
## 3 36 by H. G. Wells [1898] The War of the…
## 4 36 "" The War of the…
## 5 36 "" The War of the…
## 6 36 " But who shall dwell in these worlds… The War of the…
## 7 36 " inhabited? . . . Are we or they … The War of the…
## 8 36 " World? . . . And how are all thi… The War of the…
## 9 36 " KEPLER (quoted in The Anatomy … The War of the…
## 10 36 "" The War of the…
## # ... with 51,653 more rows
```
---
## **Someone has torn your books apart!** 😭
```r
by_chapter <- books %>%
group_by(title) %>%
mutate(chapter = cumsum(str_detect(text,
regex("^chapter ",
ignore_case = TRUE)))) %>%
ungroup() %>%
filter(chapter > 0) %>%
unite(document, title, chapter)
by_chapter
```
```
## # A tibble: 51,602 x 3
## gutenberg_id text document
## <int> <chr> <chr>
## 1 36 CHAPTER ONE The War of the …
## 2 36 "" The War of the …
## 3 36 THE EVE OF THE WAR The War of the …
## 4 36 "" The War of the …
## 5 36 "" The War of the …
## 6 36 No one would have believed in the last y… The War of the …
## 7 36 century that this world was being watche… The War of the …
## 8 36 intelligences greater than man's and yet… The War of the …
## 9 36 men busied themselves about their variou… The War of the …
## 10 36 scrutinised and studied, perhaps almost … The War of the …
## # ... with 51,592 more rows
```
---
## **Can we put them back together?**
```r
library(tidytext)
word_counts <- by_chapter %>%
* unnest_tokens(word, text) %>%
anti_join(get_stopwords(source = "smart")) %>%
count(document, word, sort = TRUE)
word_counts
```
```
## # A tibble: 111,650 x 3
## document word n
## <chr> <chr> <int>
## 1 Great Expectations_57 joe 88
## 2 Great Expectations_7 joe 70
## 3 Pride and Prejudice_18 mr 66
## 4 Great Expectations_17 biddy 63
## 5 Great Expectations_27 joe 58
## 6 Great Expectations_38 estella 58
## 7 Great Expectations_2 joe 56
## 8 Great Expectations_23 pocket 53
## 9 Great Expectations_15 joe 50
## 10 Great Expectations_18 joe 50
## # ... with 111,640 more rows
```
---
## **Can we put them back together?**
```r
words_sparse <- word_counts %>%
* cast_sparse(document, word, n)
class(words_sparse)
```
```
## [1] "dgCMatrix"
## attr(,"package")
## [1] "Matrix"
```
---
## **Train a topic model**
Use a sparse matrix or a `quanteda::dfm` object as input
```r
library(stm)
topic_model <- stm(words_sparse, K = 4,
verbose = FALSE, init.type = "Spectral")
summary(topic_model)
```
```
## A topic model with 4 topics, 193 documents and a 18360 word dictionary.
```
```
## Topic 1 Top Words:
## Highest Prob: mr, elizabeth, mrs, darcy, bennet, miss, jane
## FREX: elizabeth, darcy, bennet, bingley, wickham, collins, lydia
## Lift: wickham, nephew, phillips, brighton, meryton, bourgh, mend
## Score: elizabeth, darcy, bennet, bingley, wickham, jane, lydia
## Topic 2 Top Words:
## Highest Prob: captain, nautilus, sea, nemo, ned, conseil, land
## FREX: nautilus, nemo, ned, conseil, canadian, ocean, seas
## Lift: vanikoro, indian, d'urville, reefs, scotia, shark's, solidification
## Score: nautilus, nemo, ned, conseil, canadian, ocean, captain
## Topic 3 Top Words:
## Highest Prob: mr, joe, miss, time, pip, looked, herbert
## FREX: joe, pip, herbert, wemmick, havisham, estella, biddy
## Lift: towel, giv, whimple, meantersay, jew, rot, barnard's
## Score: joe, wemmick, pip, jaggers, havisham, estella, herbert
## Topic 4 Top Words:
## Highest Prob: people, martians, man, time, black, men, night
## FREX: martians, martian, woking, mars, curate, pine, ulla
## Lift: martians, mars, curate, shepperton, henderson, hood, ripley
## Score: martians, martian, woking, cylinder, curate, ulla, pine
```
---
## **Exploring the output of topic modeling**
.large[Time for tidying!]
```r
chapter_topics <- tidy(topic_model, matrix = "beta")
chapter_topics
```
```
## # A tibble: 73,440 x 3
## topic term beta
## <int> <chr> <dbl>
## 1 1 joe 8.69e-104
## 2 2 joe 3.03e-139
## 3 3 joe 1.21e- 2
## 4 4 joe 3.28e- 19
## 5 1 mr 1.90e- 2
## 6 2 mr 1.91e- 4
## 7 3 mr 1.22e- 2
## 8 4 mr 1.15e- 45
## 9 1 biddy 3.21e- 80
## 10 2 biddy 3.84e-149
## # ... with 73,430 more rows
```
---
## **Exploring the output of topic modeling**
```r
top_terms <- chapter_topics %>%
group_by(topic) %>%
top_n(10, beta) %>%
ungroup() %>%
arrange(topic, -beta)
top_terms
```
```
## # A tibble: 40 x 3
## topic term beta
## <int> <chr> <dbl>
## 1 1 mr 0.0190
## 2 1 elizabeth 0.0141
## 3 1 mrs 0.00886
## 4 1 darcy 0.00881
## 5 1 bennet 0.00694
## 6 1 miss 0.00674
## 7 1 jane 0.00652
## 8 1 bingley 0.00607
## 9 1 time 0.00493
## 10 1 good 0.00480
## # ... with 30 more rows
```
---
## **Exploring the output of topic modeling**
```r
top_terms %>%
mutate(term = reorder(term, beta)) %>%
ggplot(aes(term, beta, fill = factor(topic))) +
geom_col(show.legend = FALSE) +
facet_wrap(~ topic, scales = "free") +
coord_flip()
```
---
![](modeling_files/figure-html/unnamed-chunk-10-1.png)<!-- -->
---
## **How are documents classified?**
```r
chapters_gamma <- tidy(topic_model, matrix = "gamma",
document_names = rownames(words_sparse))
chapters_gamma
```
```
## # A tibble: 772 x 3
## document topic gamma
## <chr> <int> <dbl>
## 1 Great Expectations_57 1 0.000792
## 2 Great Expectations_7 1 0.00340
## 3 Pride and Prejudice_18 1 1.000
## 4 Great Expectations_17 1 0.0480
## 5 Great Expectations_27 1 0.000367
## 6 Great Expectations_38 1 0.00110
## 7 Great Expectations_2 1 0.000531
## 8 Great Expectations_23 1 0.432
## 9 Great Expectations_15 1 0.000565
## 10 Great Expectations_18 1 0.000277
## # ... with 762 more rows
```
---
## **How are documents classified?**
```r
chapters_parsed <- chapters_gamma %>%
separate(document, c("title", "chapter"),
sep = "_", convert = TRUE)
chapters_parsed
```
```
## # A tibble: 772 x 4
## title chapter topic gamma
## <chr> <int> <int> <dbl>
## 1 Great Expectations 57 1 0.000792
## 2 Great Expectations 7 1 0.00340
## 3 Pride and Prejudice 18 1 1.000
## 4 Great Expectations 17 1 0.0480
## 5 Great Expectations 27 1 0.000367
## 6 Great Expectations 38 1 0.00110
## 7 Great Expectations 2 1 0.000531
## 8 Great Expectations 23 1 0.432
## 9 Great Expectations 15 1 0.000565
## 10 Great Expectations 18 1 0.000277
## # ... with 762 more rows
```
---
## **How are documents classified?**
```r
chapters_parsed %>%
mutate(title = reorder(title, gamma * topic)) %>%
ggplot(aes(factor(topic), gamma)) +
geom_boxplot() +
facet_wrap(~ title)
```
---
![](modeling_files/figure-html/unnamed-chunk-14-1.png)<!-- -->
---
class: center, middle, inverse
background-image: url(figs/p_and_p_cover.png)
background-size: cover
# GOING FARTHER 🚀
---
## Tidying model output
### Which words in each document are assigned to which topics?
- .large[`augment()`]
- .large[Add information to each observation in the original data]
---
background-image: url(figs/stm_video.png)
background-size: 850px
---
## **Using stm**
- .large[Document-level covariates]
```r
topic_model <- stm(words_sparse, K = 0, init.type = "Spectral",
prevalence = ~s(Year),
data = covariates,
verbose = FALSE)
```
- .large[Use functions for `semanticCoherence()`, `checkResiduals()`, `exclusivity()`, and more!]
- .large[Check out http://www.structuraltopicmodel.com/]
- .large[See [my recent blog post](https://juliasilge.com/blog/evaluating-stm/) for how to choose `K`, the number of topics]
---
background-image: url(figs/model_diagnostic-1.png)
background-position: 50% 50%
background-size: 950px
---
# Stemming?
.large[Advice from [Schofield & Mimno](https://mimno.infosci.cornell.edu/papers/schofield_tacl_2016.pdf)]
.large["Comparing Apples to Apple: The Effects of Stemmers on Topic Models"]
---
class: right, middle
<h1 class="fa fa-quote-left fa-fw"></h1>
<h2> Despite their frequent use in topic modeling, we find that stemmers produce no meaningful improvement in likelihood and coherence and in fact can degrade topic stability. </h2>
<h1 class="fa fa-quote-right fa-fw"></h1>
---
class: right, middle, inverse
background-image: url(figs/p_and_p_cover.png)
background-size: cover
# TEXT CLASSIFICATION
<h1 class="fa fa-balance-scale fa-fw"></h1>
---
## **Downloading your text data**
```r
library(tidyverse)
library(gutenbergr)
titles <- c("The War of the Worlds",
"Pride and Prejudice")
books <- gutenberg_works(title %in% titles) %>%
gutenberg_download(meta_fields = "title") %>%
mutate(document = row_number())
books
```
```
## # A tibble: 19,504 x 4
## gutenberg_id text title document
## <int> <chr> <chr> <int>
## 1 36 The War of the Worlds The War of t… 1
## 2 36 "" The War of t… 2
## 3 36 by H. G. Wells [1898] The War of t… 3
## 4 36 "" The War of t… 4
## 5 36 "" The War of t… 5
## 6 36 " But who shall dwell in these… The War of t… 6
## 7 36 " inhabited? . . . Are we o… The War of t… 7
## 8 36 " World? . . . And how are … The War of t… 8
## 9 36 " KEPLER (quoted in The A… The War of t… 9
## 10 36 "" The War of t… 10
## # ... with 19,494 more rows
```
---
## **Making a tidy dataset**
.large[Use this kind of data structure for EDA! 💅]
```r
library(tidytext)
tidy_books <- books %>%
* unnest_tokens(word, text) %>%
group_by(word) %>%
filter(n() > 10) %>%
ungroup
tidy_books
```
```
## # A tibble: 159,707 x 4
## gutenberg_id title document word
## <int> <chr> <int> <chr>
## 1 36 The War of the Worlds 1 the
## 2 36 The War of the Worlds 1 war
## 3 36 The War of the Worlds 1 of
## 4 36 The War of the Worlds 1 the
## 5 36 The War of the Worlds 3 by
## 6 36 The War of the Worlds 6 but
## 7 36 The War of the Worlds 6 who
## 8 36 The War of the Worlds 6 shall
## 9 36 The War of the Worlds 6 in
## 10 36 The War of the Worlds 6 these
## # ... with 159,697 more rows
```
---
## **Cast to a sparse matrix**
.large[And build a dataframe with a response variable]
```r
sparse_words <- tidy_books %>%
count(document, word, sort = TRUE) %>%
* cast_sparse(document, word, n)
books_joined <- data_frame(document = as.integer(rownames(sparse_words))) %>%
left_join(books %>%
select(document, title))
```
---
## **Train a glmnet model**
```r
library(glmnet)
library(doMC)
registerDoMC(cores = 8)
is_jane <- books_joined$title == "Pride and Prejudice"
model <- cv.glmnet(sparse_words, is_jane, family = "binomial",
parallel = TRUE, keep = TRUE)
```
---
## **Tidying our model**
.large[Tidy, then filter to choose some lambda from glmnet output]
```r
library(broom)
coefs <- model$glmnet.fit %>%
tidy() %>%
filter(lambda == model$lambda.1se)
Intercept <- coefs %>%
filter(term == "(Intercept)") %>%
pull(estimate)
```
---
## **Tidying our model**
```r
classifications <- tidy_books %>%
inner_join(coefs, by = c("word" = "term")) %>%
group_by(document) %>%
summarize(Score = sum(estimate)) %>%
mutate(Probability = plogis(Intercept + Score))
classifications
```
```
## # A tibble: 16,007 x 3
## document Score Probability
## <int> <dbl> <dbl>
## 1 1 -2.41 0.101
## 2 3 0.216 0.610
## 3 6 1.86 0.890
## 4 7 -1.05 0.305
## 5 8 -1.29 0.258
## 6 9 -0.535 0.424
## 7 13 -0.252 0.495
## 8 15 -5.66 0.00435
## 9 19 0.393 0.651
## 10 21 -2.41 0.101
## # ... with 15,997 more rows
```
---
## **Understanding our model**
```r
coefs %>%
group_by(estimate > 0) %>%
top_n(10, abs(estimate)) %>%
ungroup %>%
ggplot(aes(fct_reorder(term, estimate), estimate, fill = estimate > 0)) +
geom_col(show.legend = FALSE) +
coord_flip()
```
---
![](modeling_files/figure-html/unnamed-chunk-23-1.png)<!-- -->
---
## **ROC**
```r
comment_classes <- classifications %>%
left_join(books %>%
select(title, document), by = "document") %>%
mutate(Correct = case_when(title == "Pride and Prejudice" ~ TRUE,
TRUE ~ FALSE))
roc <- comment_classes %>%
arrange(desc(Probability)) %>%
mutate(TPR = cumsum(Correct) / sum(Correct),
FPR = cumsum(!Correct) / sum(!Correct),
FDR = cummean(!Correct))
```
---
## **ROC**
```r
roc %>%
arrange(Probability)
```
```
## # A tibble: 16,007 x 8
## document Score Probability title Correct TPR FPR FDR
## <int> <dbl> <dbl> <chr> <lgl> <dbl> <dbl> <dbl>
## 1 3963 -14.8 0.000000479 The War of the Wo… FALSE 1 1 0.337
## 2 4127 -13.3 0.00000204 The War of the Wo… FALSE 1 1.000 0.337
## 3 6431 -13.0 0.00000293 The War of the Wo… FALSE 1 1.000 0.337
## 4 2863 -12.7 0.00000374 The War of the Wo… FALSE 1 0.999 0.336
## 5 2570 -12.7 0.00000401 The War of the Wo… FALSE 1 0.999 0.336
## 6 2628 -12.4 0.00000513 The War of the Wo… FALSE 1 0.999 0.336
## 7 4177 -12.1 0.00000670 The War of the Wo… FALSE 1 0.999 0.336
## 8 6042 -12.1 0.00000700 The War of the Wo… FALSE 1 0.999 0.336
## 9 2704 -12.1 0.00000725 The War of the Wo… FALSE 1 0.999 0.336
## 10 1698 -11.9 0.00000849 The War of the Wo… FALSE 1 0.998 0.336
## # ... with 15,997 more rows
```
---
![](modeling_files/figure-html/unnamed-chunk-26-1.png)<!-- -->
---
## **AUC for model**
```r
roc %>%
summarise(AUC = sum(diff(FPR) * na.omit(lead(TPR) + TPR)) / 2)
```
```
## # A tibble: 1 x 1
## AUC
## <dbl>
## 1 0.991
```
---
## **Misclassifications**
Let's talk about misclassifications. Which documents here were incorrectly predicted to be written by Jane Austen?
```r
roc %>%
* filter(Probability > .8, !Correct) %>%
sample_n(10) %>%
inner_join(books %>%
select(document, text)) %>%
select(Probability, text)
```
```
## # A tibble: 10 x 2
## Probability text
## <dbl> <chr>
## 1 0.977 should be prepared. It seems to me that it should be poss…
## 2 0.842 certain further details which, although they were not all …
## 3 0.903 the innkeeper, she would, I think, have urged me to stay in
## 4 0.915 particular. Micro-organisms, which cause so much disease …
## 5 0.860 "\"There won't be any more blessed concerts for a million …
## 6 0.885 She turned without a word--they were both panting--and the…
## 7 0.826 decorum were necessarily different from ours; and not only…
## 8 0.894 her.
## 9 0.911 "\"Half a mile, you say?\" said he."
## 10 0.963 I cannot but regret, now that I am concluding my story, ho…
```
---
## **Misclassifications**
Let's talk about misclassifications. Which documents here were incorrectly predicted to *not* be written by Jane Austen?
```r
roc %>%
* filter(Probability < .2, Correct) %>%
sample_n(10) %>%
inner_join(books %>%
select(document, text)) %>%
select(Probability, text)
```
```
## # A tibble: 10 x 2
## Probability text
## <dbl> <chr>
## 1 0.184 is so violent, that it would be the death of half the good…
## 2 0.164 I was never more annoyed! The insipidity, and yet the nois…
## 3 0.177 glancing over it, said, in a colder voice:
## 4 0.140 occasional appearance of some trout in the water, and talk…
## 5 0.155 "as I sit by the fire.\""
## 6 0.159 road, the house standing in it, the green pales, and the l…
## 7 0.195 half-a-mile, and then found themselves at the top of a con…
## 8 0.0206 window that he wore a blue coat, and rode a black horse.
## 9 0.191 struck with the action of doing a very gallant thing, and …
## 10 0.113 the happiest of men.
```
---
background-image: url(figs/tmwr_0601.png)
background-position: 50% 70%
background-size: 750px
## **Workflow for text mining/modeling**
---
background-image: url(figs/lizzieskipping.gif)
background-position: 50% 55%
background-size: 750px
# **Go explore real-world text!**
---
class: left, middle
<img src="figs/blue_jane.png" width="150px"/>
# Thanks!
<a href="http://twitter.com/juliasilge"><i class="fa fa-twitter fa-fw"></i>&nbsp; @juliasilge</a><br>
<a href="http://github.com/juliasilge"><i class="fa fa-github fa-fw"></i>&nbsp; @juliasilge</a><br>
<a href="https://juliasilge.com"><i class="fa fa-link fa-fw"></i>&nbsp; juliasilge.com</a><br>
<a href="https://tidytextmining.com"><i class="fa fa-book fa-fw"></i>&nbsp; tidytextmining.com</a><br>
<a href="mailto:[email protected]"><i class="fa fa-paper-plane fa-fw"></i>&nbsp; [email protected]</a>
Slides created with [**remark.js**](http://remarkjs.com/) and the R package [**xaringan**](https://github.com/yihui/xaringan)
</textarea>
<script src="https://remarkjs.com/downloads/remark-latest.min.js"></script>
<script>var slideshow = remark.create({
"highlightStyle": "github",
"highlightLines": true,
"countIncrementalSlides": false,
"ratio": "16:9"
});
if (window.HTMLWidgets) slideshow.on('afterShowSlide', function (slide) {
window.dispatchEvent(new Event('resize'));
});
(function() {
var d = document, s = d.createElement("style"), r = d.querySelector(".remark-slide-scaler");
if (!r) return;
s.type = "text/css"; s.innerHTML = "@page {size: " + r.style.width + " " + r.style.height +"; }";
d.head.appendChild(s);
})();</script>
<script>
(function() {
var i, text, code, codes = document.getElementsByTagName('code');
for (i = 0; i < codes.length;) {
code = codes[i];
if (code.parentNode.tagName !== 'PRE' && code.childElementCount === 0) {
text = code.textContent;
if (/^\\\((.|\s)+\\\)$/.test(text) || /^\\\[(.|\s)+\\\]$/.test(text) ||
/^\$\$(.|\s)+\$\$$/.test(text) ||
/^\\begin\{([^}]+)\}(.|\s)+\\end\{[^}]+\}$/.test(text)) {
code.outerHTML = code.innerHTML; // remove <code></code>
continue;
}
}
i++;
}
})();
</script>
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://cdn.bootcss.com/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML';
if (location.protocol !== 'file:' && /^https?:/.test(script.src))
script.src = script.src.replace(/^https?:/, '');
document.getElementsByTagName('head')[0].appendChild(script);
})();
</script>
</body>
</html>