with python - cs50business insider, 2018 "when facebook was founded in 2004, it began with a...

153
Introduction to Artificial Intelligence with Python

Upload: others

Post on 21-Jun-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Introduction to Artificial Intelligence

with Python

Page 2: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Language

Page 3: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Natural Language Processing

Page 4: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Natural Language Processing

• automatic summarization

• information extraction

• language identification

• machine translation

• named entity recognition

• speech recognition

• text classification

• word sense disambiguation

• ...

Page 5: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Syntax

Page 6: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"Just before nine o'clock Sherlock Holmes stepped briskly into the room."

Page 7: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"Just before Sherlock Holmes nine o'clock stepped briskly the room."

Page 8: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"I saw the man on the mountain with a telescope."

Page 9: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Semantics

Page 10: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"Just before nine o'clock Sherlock Holmes stepped briskly into the room."

Page 11: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"Sherlock Holmes stepped briskly into the room just before nine o'clock."

Page 12: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"A few minutes before nine, Sherlock Holmes walked quickly into the room."

Page 13: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"Colorless green ideas sleep furiously."

Page 14: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users
Page 15: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Natural Language Processing

Page 16: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Syntax

Page 17: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

formal grammar

a system of rules for generating sentences in a language

Page 18: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Context-Free Grammar

Page 19: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

N

she

V

saw

V D

the

N

city

Page 20: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

N

she

V

saw

V D

the

N

city

Page 21: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

N → she | city | car | Harry | ...

D → the | a | an | ...

V → saw | ate | walked | ...

P → to | on | over | ...

ADJ → blue | busy | old | ...

Page 22: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

NP → N | D N

Page 23: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

NP → N | D N N

she

NP

Page 24: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

NP → N | D N D

the

N

city

NP

Page 25: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

VP → V | V NP

Page 26: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

V

walked

VP

VP → V | V NP

Page 27: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

D

the

N

city

NPV

saw

V

VP

VP → V | V NP

Page 28: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

S → NP VP

Page 29: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

S → NP VP

D

the

N

city

NPV

saw

V

VPNP

she

S

N

Page 30: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

nltk

Page 31: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

n-gram

a contiguous sequence of n items from a sample of text

Page 32: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

character n-gram

a contiguous sequence of n characters from a sample of text

Page 33: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

word n-gram

a contiguous sequence of n words from a sample of text

Page 34: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

unigram

a contiguous sequence of 1 item from a sample of text

Page 35: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

bigram

a contiguous sequence of 2 items from a sample of text

Page 36: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

trigrams

a contiguous sequence of 3 items from a sample of text

Page 37: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"How often have I said to you that when you have eliminated the impossible whatever remains, however improbable, must be the truth?"

Page 38: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"How often have I said to you that when you have eliminated the impossible whatever remains, however improbable, must be the truth?"

Page 39: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"How often have I said to you that when you have eliminated the impossible whatever remains, however improbable, must be the truth?"

Page 40: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"How often have I said to you that when you have eliminated the impossible whatever remains, however improbable, must be the truth?"

Page 41: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"How often have I said to you that when you have eliminated the impossible whatever remains, however improbable, must be the truth?"

Page 42: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"How often have I said to you that when you have eliminated the impossible whatever remains, however improbable, must be the truth?"

Page 43: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"How often have I said to you that when you have eliminated the impossible whatever remains, however improbable, must be the truth?"

Page 44: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

tokenization

the task of splitting a sequence of characters into pieces (tokens)

Page 45: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

word tokenization

the task of splitting a sequence of characters into words

Page 46: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

sentence tokenization

the task of splitting a sequence of characters into sentences

Page 47: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"Whatever remains, however improbable, must be the truth."

Page 48: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"Whatever remains, however improbable, must be the truth."

["Whatever", "remains,", "however", "improbable,", "must", "be", "the", "truth."]

Page 49: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"Whatever remains, however improbable, must be the truth."

["Whatever", "remains,", "however", "improbable,", "must", "be", "the", "truth."]

Page 50: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"Whatever remains, however improbable, must be the truth."

["Whatever", "remains", "however", "improbable", "must", "be", "the", "truth"]

Page 51: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"Just before nine o'clock Sherlock Holmes stepped briskly into the room."

Page 52: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"Just before nine o'clock Sherlock Holmes stepped briskly into the room."

Page 53: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"He was dressed in a sombre yet rich style, in black frock-coat, shining hat, neat brown gaiters, and well-cut pearl-grey trousers."

Page 54: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"He was dressed in a sombre yet rich style, in black frock-coat, shining hat, neat brown gaiters, and well-cut pearl-grey trousers."

Page 55: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"I cannot waste time over this sort of fantastic talk, Sherlock. If you can catch the man, catch him, and let me know when you have done it."

Page 56: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"I cannot waste time over this sort of fantastic talk, Sherlock. If you can catch the man, catch him, and let me know when you have done it."

Page 57: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"I cannot waste time over this sort of fantastic talk, Sherlock. If you can catch the man, catch him, and let me know when you have done it."

Page 58: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"I cannot waste time over this sort of fantastic talk, Sherlock. If you can catch the man, catch him, and let me know when you have done it."

Page 59: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"I cannot waste time over this sort of fantastic talk, Mr. Holmes. If you can catch the man, catch him, and let me know when you have done it."

Page 60: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"I cannot waste time over this sort of fantastic talk, Mr. Holmes. If you can catch the man, catch him, and let me know when you have done it."

Page 61: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"I cannot waste time over this sort of fantastic talk, Mr. Holmes. If you can catch the man, catch him, and let me know when you have done it."

Page 62: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"I cannot waste time over this sort of fantastic talk, Mr. Holmes. If you can catch the man, catch him, and let me know when you have done it."

Page 63: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"I cannot waste time over this sort of fantastic talk, Mr. Holmes. If you can catch the man, catch him, and let me know when you have done it."

Page 64: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"I cannot waste time over this sort of fantastic talk, Mr. Holmes," he said. "If you can catch the man, catch him, and let me know when you have done it."

Page 65: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Markov Models

Page 66: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users
Page 67: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Text Categorization

Page 68: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Inbox Spam

Page 69: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

😀 🙁

Page 70: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"My grandson loved it! So much fun!"

"Product broke after a few days."

"One of the best games I've played in a long time."

"Kind of cheap and flimsy, not worth it."

Page 71: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"My grandson loved it! So much fun!"

"Product broke after a few days."

"One of the best games I've played in a long time."

"Kind of cheap and flimsy, not worth it."

😀

🙁

😀

🙁

Page 72: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"My grandson loved it! So much fun!"

"Product broke after a few days."

"One of the best games I've played in a long time."

"Kind of cheap and flimsy, not worth it."

😀

🙁

😀

🙁

Page 73: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

bag-of-words model

model that represents text as an unordered collection of words

Page 74: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Naive Bayes

Page 75: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Bayes' Rule

= P(b)P(a |b)P(a)

P(b |a)

Page 76: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(Positive)

P(Negative)

Page 77: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(😀)

P(🙁)

Page 78: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"My grandson loved it!"

Page 79: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(😀)

Page 80: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(😀 | "my grandson loved it")

Page 81: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(😀 | "my", "grandson", "loved", "it")

Page 82: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(😀 | "my", "grandson", "loved", "it")

Page 83: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(😀 | "my", "grandson", "loved", "it")

equal to

P("my", "grandson", "loved", "it" | 😀)

P("my", "grandson", "loved", "it")

P(😀)

Page 84: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(😀 | "my", "grandson", "loved", "it")

proportional to

P("my", "grandson", "loved", "it" | 😀)P(😀)

Page 85: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(😀 | "my", "grandson", "loved", "it")

proportional to

P(😀, "my", "grandson", "loved", "it")

Page 86: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(😀 | "my", "grandson", "loved", "it")

naively proportional to

P(😀)P("my" | 😀)P("grandson" | 😀) P("loved" | 😀) P("it" | 😀)

Page 87: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(😀) =number of positive samples

number of total samples

Page 88: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P("loved" | 😀) =number of positive samples with "loved"

number of positive samples

Page 89: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(😀)P("my" | 😀)P("grandson" | 😀) P("loved" | 😀) P("it" | 😀)

😀 🙁

my 0.30 0.20

grandson 0.01 0.02

loved 0.32 0.08

it 0.30 0.40

😀 🙁

0.49 0.51

Page 90: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(😀)P("my" | 😀)P("grandson" | 😀) P("loved" | 😀) P("it" | 😀)

😀 🙁

my 0.30 0.20

grandson 0.01 0.02

loved 0.32 0.08

it 0.30 0.40

😀 🙁

0.49 0.51

Page 91: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(😀)P("my" | 😀)P("grandson" | 😀) P("loved" | 😀) P("it" | 😀)

😀 🙁

my 0.30 0.20

grandson 0.01 0.02

loved 0.32 0.08

it 0.30 0.40

😀 🙁

0.49 0.51

😀 0.00014112

Page 92: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(😀)P("my" | 😀)P("grandson" | 😀) P("loved" | 😀) P("it" | 😀)

😀 🙁

my 0.30 0.20

grandson 0.01 0.02

loved 0.32 0.08

it 0.30 0.40

😀 🙁

0.49 0.51

😀 0.00014112

Page 93: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(🙁)P("my" | 🙁)P("grandson" | 🙁) P("loved" | 🙁) P("it" | 🙁)

😀 🙁

my 0.30 0.20

grandson 0.01 0.02

loved 0.32 0.08

it 0.30 0.40

😀 🙁

0.49 0.51

😀 0.00014112

Page 94: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(🙁)P("my" | 🙁)P("grandson" | 🙁) P("loved" | 🙁) P("it" | 🙁)

😀 🙁

my 0.30 0.20

grandson 0.01 0.02

loved 0.32 0.08

it 0.30 0.40

😀 🙁

0.49 0.51

😀 0.00014112

Page 95: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(🙁)P("my" | 🙁)P("grandson" | 🙁) P("loved" | 🙁) P("it" | 🙁)

😀 🙁

my 0.30 0.20

grandson 0.01 0.02

loved 0.32 0.08

it 0.30 0.40

😀 🙁

0.49 0.51

😀 0.00014112🙁 0.00006528

Page 96: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(🙁)P("my" | 🙁)P("grandson" | 🙁) P("loved" | 🙁) P("it" | 🙁)

😀 🙁

my 0.30 0.20

grandson 0.01 0.02

loved 0.32 0.08

it 0.30 0.40

😀 🙁

0.49 0.51

😀 0.00014112🙁 0.00006528

Page 97: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(🙁)P("my" | 🙁)P("grandson" | 🙁) P("loved" | 🙁) P("it" | 🙁)

😀 🙁

my 0.30 0.20

grandson 0.01 0.02

loved 0.32 0.08

it 0.30 0.40

😀 🙁

0.49 0.51

😀 0.6837🙁 0.3163

Page 98: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(🙁)P("my" | 🙁)P("grandson" | 🙁) P("loved" | 🙁) P("it" | 🙁)

😀 🙁

my 0.30 0.20

grandson 0.01 0.02

loved 0.32 0.08

it 0.30 0.40

😀 🙁

0.49 0.51

Page 99: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(🙁)P("my" | 🙁)P("grandson" | 🙁) P("loved" | 🙁) P("it" | 🙁)

😀 🙁

my 0.30 0.20

grandson 0.00 0.02

loved 0.32 0.08

it 0.30 0.40

😀 🙁

0.49 0.51

Page 100: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

P(🙁)P("my" | 🙁)P("grandson" | 🙁) P("loved" | 🙁) P("it" | 🙁)

😀 🙁

my 0.30 0.20

grandson 0.00 0.02

loved 0.32 0.08

it 0.30 0.40

😀 🙁

0.49 0.51

😀 0.00000000🙁 0.00006528

Page 101: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

additive smoothing

adding a value α to each value in our distribution to smooth the data

Page 102: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Laplace smoothing

adding 1 to each value in our distribution: pretending we've seen each value one more time than we actually have

Page 103: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

information retrieval

the task of finding relevant documents in response to a user query

Page 104: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

topic modeling

models for discovering the topics for a set of documents

Page 105: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

term frequency

number of times a term appears in a document

Page 106: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

function words

words that have little meaning on their own, but are used to grammatically connect other words

Page 107: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

function words

am, by, do, is, which, with, yet, ...

Page 108: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

content words

words that carry meaning independently

Page 109: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

content words

algorithm, category, computer, ...

Page 110: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

inverse document frequency

measure of how common or rare a word is across documents

Page 111: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

inverse document frequency

logTotalDocuments

NumDocumentsContaining(word)

Page 112: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

tf-idf

ranking of what words are important in a document by multiplying term frequency (TF) by inverse document frequency (IDF)

Page 113: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Semantics

Page 114: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

information extraction

the task of extracting knowledge from documents

Page 115: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users later, the social network has taken over most aspects of our personal and professional lives, and is fast becoming the dominant communication platform of the future."

Harvard Business Review, 2011

"Remember, back when Amazon was founded in 1994, most people thought his idea to sell books over this thing called the internet was crazy. A lot of people had never even hard of the internet."

Business Insider, 2018

Page 116: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users later, the social network has taken over most aspects of our personal and professional lives, and is fast becoming the dominant communication platform of the future."

Harvard Business Review, 2011

"Remember, back when Amazon was founded in 1994, most people thought his idea to sell books over this thing called the internet was crazy. A lot of people had never even hard of the internet."

Business Insider, 2018

Page 117: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users later, the social network has taken over most aspects of our personal and professional lives, and is fast becoming the dominant communication platform of the future."

Harvard Business Review, 2011

"Remember, back when Amazon was founded in 1994, most people thought his idea to sell books over this thing called the internet was crazy. A lot of people had never even hard of the internet."

Business Insider, 2018

Page 118: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

When {company} was founded in {year},

Page 119: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

WordNet

Page 120: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Word Representation

Page 121: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users
Page 122: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"He wrote a book."

he [1, 0, 0, 0]

wrote [0, 1, 0, 0]

a [0, 0, 1, 0]

book [0, 0, 0, 1]

Page 123: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

one-hot representation

representation of meaning as a vector with a single 1, and with other values as 0

Page 124: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"He wrote a book."

he [1, 0, 0, 0]

wrote [0, 1, 0, 0]

a [0, 0, 1, 0]

book [0, 0, 0, 1]

Page 125: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"He wrote a book."

he [1, 0, 0, 0, 0, 0, 0, 0, ...]

wrote [0, 1, 0, 0, 0, 0, 0, ...]

a [0, 0, 1, 0, 0, 0, 0, 0, ...]

book [0, 0, 0, 1, 0, 0, 0, ...]

Page 126: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"He wrote a book."

"He authored a novel."

wrote [0, 1, 0, 0, 0, 0, 0, 0, 0]

authored [0, 0, 0, 0, 1, 0, 0, 0, 0]

book [0, 0, 0, 0, 0, 0, 1, 0, 0]

novel [0, 0, 0, 0, 0, 0, 0, 0, 1]

Page 127: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

distribution representation

representation of meaning distributed across multiple values

Page 128: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"He wrote a book."

he [-0.34, -0.08, 0.02, -0.18, 0.22, ...]

wrote [-0.27, 0.40, 0.00, -0.65, -0.15, ...]

a [-0.12, -0.25, 0.29, -0.09, 0.40, ...]

book [-0.23, -0.16, -0.05, -0.57, ...]

Page 129: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

"You shall know a word by the company it keeps."

J. R. Firth, 1957

Page 130: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

for he ate

Page 131: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

for breakfast he ate

Page 132: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

for lunch he ate

Page 133: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

for dinner he ate

Page 134: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

for he ate

Page 135: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

word2vec

model for generating word vectors

Page 136: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

skip-gram architecture

neural network architecture for predicting context words given a target word

Page 137: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

target word

context word

Page 138: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

target word

context word

Page 139: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

target word

context word

Page 140: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

breakfast

lunch

dinner

book

novel

memoir

Page 141: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

breakfast

lunchdinner

book

novel

memoir

Page 142: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

king - man

king

man

king - man

woman

Page 143: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

king - man

king

man

king - man

woman

queen

Page 144: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Language

Page 145: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Artificial Intelligence

Page 146: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Search

O

X X

O X

Page 147: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Knowledge

P → Q

QP

Page 148: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Uncertainty

Page 149: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Optimization

Page 150: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

LearningInbox

Spam

Page 151: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Neural Networks

Page 152: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Language

NP

NP PP

ADJ N P N

artificial

intelligence

with

python

Page 153: with Python - CS50Business Insider, 2018 "When Facebook was founded in 2004, it began with a seemingly innocuous mission: to connect friends. Some seven years and 800 million users

Introduction to Artificial Intelligence

with Python