25
Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU - rijeˇ c postaje obiˇ can broj ? Prof.dr.sc. Mario Essert ([email protected]) Fakultet strojarstva i brodogradnje, Zagreb Osijek, 4. prosinca 2017. M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 1 / 25

Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Embed Size (px)

Citation preview

Page 1: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU- rijec postaje obican broj ?

Prof.dr.sc. Mario Essert ([email protected])

Fakultet strojarstva i brodogradnje, Zagreb

Osijek, 4. prosinca 2017.M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 1 / 25

Page 2: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Sadrzaj:

1 Uvod u jezikoslovnu statistikuRijec kao element skupaStatistika u Python modulimaR-statistikaDohvacanje dokumenata

2 StohastikaNeuvjetovana vjerojatnostUvjetovana vjerojatnostMarkovljevi lanciMonte Carlo metoda

Page 3: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Uvod u jezikoslovnu statistiku Rijec kao element skupa

Statistika u NLP-u

Dokumenti - skupovi rijeci;rijeci - elemenati skupa, brojevi

deskriptivna statistika

distribucije vjerojatnosti i statisticki testovi

metrika uspjesnosti dohvacanja informacije(eng. information retrieval)

pokusi: nadgledano i nenadgledano ucenje

5 super alata: Numpy/Scipy ; Scikit-learn;Pandas; Tensorflow ; R

Poveznice na izvore:

http://www.numpy.org/ i https://www.scipy.org/

https://scikit-learn.org/ i https://www.tensorflow.org/

https://pandas.pydata.org/ i https://www.r-project.org/

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 3 / 25

Page 4: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Uvod u jezikoslovnu statistiku Rijec kao element skupa

Dokumenti (corpora) u sredistu

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 4 / 25

Page 5: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Uvod u jezikoslovnu statistiku Rijec kao element skupa

Rudarenje teksta

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 5 / 25

Page 6: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Uvod u jezikoslovnu statistiku Statistika u Python modulima

Numpy funkcije - deskriptivna statistika

Primjeri iz numpy/scipy + FSB zavrsniradovi iz stohastike:http://www.scipy-lectures.org/http://elte.fsb.hr:8080/markovljevi lancihttp://elte.fsb.hr:8080/monte carlo

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 6 / 25

Page 7: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Uvod u jezikoslovnu statistiku Statistika u Python modulima

Scikit-learn

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 7 / 25

Page 8: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Uvod u jezikoslovnu statistiku Statistika u Python modulima

Pandas funkcije - deskriptivna statistika

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 8 / 25

Page 9: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Uvod u jezikoslovnu statistiku Statistika u Python modulima

Tensorflow - Google’s Machine Intelligence

TensorFlow is an open source software library for numerical computation usingdata flow graphs. Nodes in the graph represent mathematical operations, whilethe graph edges represent the multidimensional data arrays (tensors)communicated between them.

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 9 / 25

Page 10: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Uvod u jezikoslovnu statistiku R-statistika

library(”languageR”)

R. H. Baayen (2007) Analyzing Linguistic Data: A practical introduction tostatistics using R, Cambridge: Cambridge University Press.

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 10 / 25

Page 11: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Uvod u jezikoslovnu statistiku Dohvacanje dokumenata

Precision and recall

Precision is the probability that a (randomly selected) retrieved document isrelevant. Recall is the probability that a (randomly selected) relevant document isretrieved in a search.

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 11 / 25

Page 12: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Uvod u jezikoslovnu statistiku Dohvacanje dokumenata

Pretrazivanje i filtriranje

iz stvari dohvatiti voce

iz voca dohvatiti jabuke

razlikovati jabuke

Dohvatiti jabuke kao:

crveno voce

srednje velicine

Rezultat: PRECISION ⇒ 3/6 = 50% RECALL ⇒ 3/5 = 60%

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 12 / 25

Page 13: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Uvod u jezikoslovnu statistiku Dohvacanje dokumenata

Precision i recall su (najcesce) inverzne velicine

Oslabiti uvjet:

jabuka moze biti i zuta

Rezultat:

PRECISION ⇒ 4/9 = 44.4%RECALL ⇒ 4/5 = 80%

Pojacati uvjet (prema pocetnom):

jabuka smije biti samo male velicine

Rezultat:

PRECISION ⇒ 2/3 = 66.6%RECALL ⇒ 2/5 = 40%

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 13 / 25

Page 14: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Uvod u jezikoslovnu statistiku Dohvacanje dokumenata

”Precision and recall” u NLTK metrici

F-Measure = (2 · 0.706 · 0.678)/(0.706 + 0.678) = 0.692

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 14 / 25

Page 15: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Stohastika Neuvjetovana vjerojatnost

Neuvjetovana vjerojatnost

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 15 / 25

Page 16: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Stohastika Neuvjetovana vjerojatnost

Vjerojatnost za uzimanje dva uzorka

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 16 / 25

Page 17: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Stohastika Neuvjetovana vjerojatnost

Dvije uzastopne rijeci - uvjetovana vjerojatnost

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 17 / 25

Page 18: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Stohastika Uvjetovana vjerojatnost

Uvjetovana vjerojatnost uz asocijativnost

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 18 / 25

Page 19: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Stohastika Uvjetovana vjerojatnost

Put od Bayes-a do Markov-a ,

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 19 / 25

Page 20: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Stohastika Markovljevi lanci

Andrei Andreevich Markov (1856 – 1922)

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 20 / 25

Page 21: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Stohastika Markovljevi lanci

Programski - bez memorije

Tvorba lancaIspis poruke

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 21 / 25

Page 22: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Stohastika Markovljevi lanci

Markovljevi lanci (eng. Markov chain)

A Markov chain process is by definition a random process with different states,where the probability distribution between transitions to a new state is dependentonly on the current state. It is not taking into account any previous states thusthe process has no ”memory”.

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 22 / 25

Page 23: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Stohastika Markovljevi lanci

Programski - s matricom vjerojatnosti

Rezultat

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 23 / 25

Page 24: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Stohastika Monte Carlo metoda

Monte Carlo

https://academo.org/demos/estimating-pi-monte-carlo/

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 24 / 25

Page 25: Predavanje IX. : STATISTIKA U JEZIKOSLOVLJU · PDF fileUvod u jezikoslovnu statistiku Rije c kao element skupa Statistika u NLP-u ... Recall is the probability that a (randomly selected)

Stohastika Monte Carlo metoda

Python program za izracunavanje π

Rezultat:

M.Essert (FSB, Zagreb) Statistika u jezikoslovlju Osijek, 4. prosinca 2017. 25 / 25