Data Science
for Public Leaders
Class 06: Harnessing Insights from Text Data: Introduction to Text Mining and Natural Language Processing
Where we were:
Introduction to neural networks and machine vision/audio, and how they facilitate the collection and processing of data previously unsuitable for policy analysis
Where we are:
Introduction to natural language processing, and how it also facilitates the processing of text data previously unsuitable for policy analysis
Where we’re going:
Mid-semester check-in, followed by our unit on how predictive analytics can support valuable policy targeting
Class Overview
3
Text, Text, Everywhere...
At each station: For the provided policy area (e.g., health), work with your partners to brainstorm any “naturally accumulating” text documents in that policy area. Write any ideas you come up with on the sheet!
It may help to think about the sort of forms, statements, paperwork, etc. that are involved in the normal functioning of policy processes in that area.
...But Not a Measure to Regress
(c/o ChatterMill)
Introduction to Dictionary and Lexical Methods: Topic Modeling w/ Quinn et al. (2010)
6
Introduction to Dictionary and Lexical Methods: Topic Modeling w/ Quinn et al. (2010)
7
Introduction to Dictionary and Lexical Methods: Topic Modeling w/ Quinn et al. (2010)
8
Introduction to Dictionary and Lexical Methods: Topic Modeling w/ Quinn et al. (2010)
9
Introduction to Dictionary and Lexical Methods: Topic Modeling w/ Quinn et al. (2010)
10
Introduction to Dictionary and Lexical Methods: Topic Modeling w/ Quinn et al. (2010)
11
Introduction to Dictionary and Lexical Methods: Topic Modeling w/ Quinn et al. (2010)
12
Topic Modeling Algorithm in a Nutshell:
Introduction to Dictionary and Lexical Methods: Topic Modeling w/ Quinn et al. (2010)
13
spatula
carpet
veteran
animals
neuroscience
Topic 1
Introduction to Dictionary and Lexical Methods: Topic Modeling w/ Quinn et al. (2010)
14
spatula
military
veteran
animals
neuroscience
Topic 1
Introduction to Dictionary and Lexical Methods: Topic Modeling w/ Quinn et al. (2010)
15
spatula
military
veteran
animals
service
Topic 1
Introduction to Dictionary and Lexical Methods: Topic Modeling w/ Quinn et al. (2010)
16
Introduction to Dictionary and Lexical Methods: Topic Modeling w/ Quinn et al. (2010)
17
Introduction to Dictionary and Lexical Methods: Topic Modeling w/ Quinn et al. (2010)
18
Introduction to Dictionary and Lexical Methods: Topic Modeling w/ Quinn et al. (2010)
19
Introduction to Dictionary and Lexical Methods: Topic Modeling w/ Quinn et al. (2010)
20
Introduction to Dictionary and Lexical Methods: Topic Modeling w/ Quinn et al. (2010)
21
We should always be keeping in mind:
In small groups, discuss:
A Small Aside: Word Embeddings
24
Word Embedding Algorithm in a Nutshell:
A Small Aside: Word Embeddings
25
Word | Concept 1 (“movement”) | Concept 2 | Concept 3 | Concept 4 |
Ran | 1.0 | | | |
Walked | 1.0 | | | |
A Small Aside: Word Embeddings
26
Word | Concept 1 (“movement”) | Concept 2 (“speed”) | Concept 3 | Concept 4 |
Ran | 1.0 | 0.4 | | |
Walked | 1.0 | 0.2 | | |
A Small Aside: Word Embeddings
27
Word | Concept 1 (“movement”) | Concept 2 (“speed”) | Concept 3 | Concept 4 |
Ran | 1.0 | 0.4 | | |
Walked | 1.0 | 0.2 | | |
Sprinted | 1.0 | 0.5 | | |
A Small Aside: Word Embeddings
28
Word | Concept 1 (“movement”) | Concept 2 (“speed”) | Concept 3 (“human”) | Concept 4 |
Ran | 1.0 | 0.4 | 1.0 | |
Walked | 1.0 | 0.2 | 1.0 | |
Sprinted | 1.0 | 0.5 | 0.8 | |
A Small Aside: Word Embeddings
29
Word | Concept 1 (“movement”) | Concept 2 (“speed”) | Concept 3 (“human”) | Concept 4 |
Ran | 1.0 | 0.4 | 1.0 | |
Walked | 1.0 | 0.2 | 1.0 | |
Sprinted | 1.0 | 0.5 | 0.8 | |
Trot | 1.0 | 0.3 | 0.4 | |
A Small Aside: Word Embeddings
30
Word | Concept 1 (“movement”) | Concept 2 (“speed”) | Concept 3 (“human”) | Concept 4 (“yummy”) |
Ran | 1.0 | 0.4 | 1.0 | 0.0 |
Walked | 1.0 | 0.2 | 1.0 | 0.0 |
Sprinted | 1.0 | 0.5 | 0.8 | 0.0 |
Trot | 1.0 | 0.3 | 0.4 | 0.0 |
A Small Aside: Word Embeddings
31
Word | Concept 1 (“movement”) | Concept 2 (“speed”) | Concept 3 (“human”) | Concept 4 (“yummy”) |
Ran | 1.0 | 0.4 | 1.0 | 0.0 |
Walked | 1.0 | 0.2 | 1.0 | 0.0 |
Sprinted | 1.0 | 0.5 | 0.8 | 0.0 |
Trot | 1.0 | 0.3 | 0.4 | 0.0 |
Asparagus | 0.0 | 0.0 | 0.0 | 0.2 |
Drive-through | 0.7 | 0.1 | 0.3 | 0.8 |
A Small Aside: Word Embeddings
32
Word | Concept 5 (“royalty”) | Concept 6 (“male”) | Concept 7 (“female”) | Concept 8 (“leader”) |
King | 1.0 | 1.0 | 0.0 | 1.0 |
- | ||||
Man | 0.0 | 1.0 | 0.0 | 0.0 |
+ | ||||
Woman | 0.0 | 0.0 | 1.0 | 0.0 |
= | ||||
Queen | 1.0 | 0.0 | 1.0 | 1.0 |
A Small Aside: Word Embeddings
33
Word | Concept 5 (“royalty”) | Concept 6 (“male”) | Concept 7 (“female”) | Concept 8 (“leader”) |
King | 1.0 | 1.0 | 0.0 | 1.0 |
- | ||||
Man | 0.0 | 1.0 | 0.0 | 0.0 |
+ | ||||
Woman | 0.0 | 0.0 | 1.0 | 0.0 |
= | ||||
Queen | 1.0 | 0.0 | 1.0 | 1.0 |
Break
When we come back: The (Likely) Future of NLP: Transformers
The (Likely) Future of NLP: Transformers
The (Likely) Future of NLP: Transformers
The Transformer Architecture in a Nutshell:
The (Likely) Future of NLP: Transformers
The (Likely) Future of NLP: Transformers
The (Likely) Future of NLP: Transformers
https://transformer.huggingface.co/doc/gpt2-large
The (Likely) Future of NLP: Transformers
https://transformer.huggingface.co/doc/gpt2-large
Cautions and Concerns with NLP
Cautions and Concerns with NLP
Ultimately, we need to always be asking:
Cautions and Concerns with NLP
Ultimately, we need to always be asking:
In small groups: Pick either the Quinn et al. or Fesler et al. paper. How would you answer the above questions?
Possible Uses of NLP
44
Possible Uses of NLP
45
In small groups: Pick one of the text data sources we identified earlier in class. What’s a relevant question those data could be used and processed to answer?
Class Overview
46
Unit Overview
47