Slide 1

Slide 1 text

Natural Language Processing with /swɪft/ Ayaka Nonaka @ayanonagon

Slide 2

Slide 2 text

SPAM spam sp@M $PAM spam sp@m SP4M $p@m sp@M SPAM spam sp@M $PAM spam sp@m SP4M $p@m sp@M

Slide 3

Slide 3 text

Spam or Ham?

Slide 4

Slide 4 text

URGENT - HELP ME DISTRIBUTE MY $15 MILLION TO CHARITY IN SUMMARY:- I have 15,000,000.00 (fifteen million) U.S. Dollars and I want you to assist me in distributing the money to charity organizations. I agree to reward you with part of the money for your assistance, kindness and participation in this Godly project. This mail might come to you as a surprise and the temptation to ignore it as unserious could come into your mind but please consider it a divine wish and accept it with a deep sense of humility.

Slide 5

Slide 5 text

See you at Natural Language Processing in Swift with Ayaka Nonaka of Venmo Swift Language User Group (San Francisco + Silicon Valley) Invite 1 friend Simply forward this email to a friend and have them join the Meetup.

Slide 6

Slide 6 text

Forming a new startup and need an iOS developer to partner with and join me on this new, exciting venture. This startup will be the next “big thing” in social media, creating a new way for users to connect with one another, essentially creating its own niche among facebook, twitter and foursquare. If interested please contact the information below. XXXX XXXX [email protected] XXX XXX XXXX

Slide 7

Slide 7 text

Naive Bayes Classifier

Slide 8

Slide 8 text

Bayes’ theorem

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

Probability of – & ⷁ ?

Slide 11

Slide 11 text

Probability of – & ⷁ ? = Probability of – × Probability of ⷁ given –

Slide 12

Slide 12 text

Probability of – & ⷁ ? = Probability of – = 1/4 × Probability of ⷁ given –

Slide 13

Slide 13 text

Probability of – & ⷁ ? = Probability of – = 1/4 × Probability of ⷁ given – = 1/13

Slide 14

Slide 14 text

Probability of – & ⷁ ? = Probability of – = 1/4 × Probability of ⷁ given – = 1/13 = 1/52

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

• 30 emails of a total of 50 are spam • 20 out of the total 50 contain the word SODIUM • 15 of the emails that contain the word SODIUM are spam

Slide 20

Slide 20 text

• 30 emails of a total of 50 are spam • 20 out of the total 50 contain the word SODIUM • 15 of the emails that contain the word SODIUM are spam What’s the probability that an email is spam given that it contains the word SODIUM?

Slide 21

Slide 21 text

• 30 emails of a total of 50 are spam • 20 out of the total 50 contain the word SODIUM • 15 of the emails that contain the word SODIUM are spam What’s the probability that an email is spam given that it contains the word SODIUM?

Slide 22

Slide 22 text

• 30 emails of a total of 50 are spam • 20 out of the total 50 contain the word SODIUM • 15 of the emails that contain the word SODIUM are spam

Slide 23

Slide 23 text

• 30 emails of a total of 50 are spam • 20 out of the total 50 contain the word SODIUM • 15 of the emails that contain the word SODIUM are spam • 15 out of the total 50 contain the word CHOLESTEROL • 10 of the emails that contain the word CHOLESTEROL are spam

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

• 30 emails of a total of 50 are spam • 20 out of the total 50 contain the word SODIUM • 15 of the emails that contain the word SODIUM are spam • 15 out of the total 50 contain the word CHOLESTEROL • 10 of the emails that contain the word CHOLESTEROL are spam

Slide 29

Slide 29 text

• 30 emails of a total of 50 are spam • 20 out of the total 50 contain the word SODIUM • 15 of the emails that contain the word SODIUM are spam • 15 out of the total 50 contain the word CHOLESTEROL • 10 of the emails that contain the word CHOLESTEROL are spam

Slide 30

Slide 30 text

• 30 emails of a total of 50 are spam • 20 out of the total 50 contain the word SODIUM • 15 of the emails that contain the word SODIUM are spam • 15 out of the total 50 contain the word CHOLESTEROL • 10 of the emails that contain the word CHOLESTEROL are spam

Slide 31

Slide 31 text

• 30 emails of a total of 50 are spam • 20 out of the total 50 contain the word SODIUM • 15 of the emails that contain the word SODIUM are spam • 15 out of the total 50 contain the word CHOLESTEROL • 10 of the emails that contain the word CHOLESTEROL are spam

Slide 32

Slide 32 text

Throw in another word, .

Slide 33

Slide 33 text

Naive Bayes Classifier

Slide 34

Slide 34 text

Naive?

Slide 35

Slide 35 text

Assume conditional independence!

Slide 36

Slide 36 text

Assume conditional independence and are conditionally independent.

Slide 37

Slide 37 text

Assume conditional independence and are conditionally independent.

Slide 38

Slide 38 text

• 30 emails of a total of 50 are spam • 20 out of the total 50 contain the word SODIUM • 15 of the emails that contain the word SODIUM are spam • 15 out of the total 50 contain the word CHOLESTEROL • 10 of the emails that contain the word CHOLESTEROL are spam

Slide 39

Slide 39 text

• 30 emails of a total of 50 are spam • 20 out of the total 50 contain the word SODIUM • 15 of the emails that contain the word SODIUM are spam • 15 out of the total 50 contain the word CHOLESTEROL • 10 of the emails that contain the word CHOLESTEROL are spam

Slide 40

Slide 40 text

• 30 emails of a total of 50 are spam • 20 out of the total 50 contain the word SODIUM • 15 of the emails that contain the word SODIUM are spam • 15 out of the total 50 contain the word CHOLESTEROL • 10 of the emails that contain the word CHOLESTEROL are spam

Slide 41

Slide 41 text

• 30 emails of a total of 50 are spam • 20 out of the total 50 contain the word SODIUM • 15 of the emails that contain the word SODIUM are spam • 15 out of the total 50 contain the word CHOLESTEROL • 10 of the emails that contain the word CHOLESTEROL are spam

Slide 42

Slide 42 text

• 30 emails of a total of 50 are spam • 20 out of the total 50 contain the word SODIUM • 15 of the emails that contain the word SODIUM are spam • 15 out of the total 50 contain the word CHOLESTEROL • 10 of the emails that contain the word CHOLESTEROL are spam

Slide 43

Slide 43 text

• 30 emails of a total of 50 are spam • 20 out of the total 50 contain the word SODIUM • 15 of the emails that contain the word SODIUM are spam • 15 out of the total 50 contain the word CHOLESTEROL • 10 of the emails that contain the word CHOLESTEROL are spam

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

vs.

Slide 46

Slide 46 text

No content

Slide 47

Slide 47 text

No content

Slide 48

Slide 48 text

No content

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

Slide 52

Slide 52 text

NSLinguisticTagger

Slide 53

Slide 53 text

NSLinguisticTagger • Lemmatization • Part of speech tagging • Language detection

Slide 54

Slide 54 text

Swift Playgrounds

Slide 55

Slide 55 text

bit.ly/swiftnbc (Swift 1.2)

Slide 56

Slide 56 text

NLTK nltk.org

Slide 57

Slide 57 text

Parsimmon github.com/ayanonagon/ Parsimmon

Slide 58

Slide 58 text

??? @ayanonagon

Slide 59

Slide 59 text

No content