Skip to Main Content
Python 机器学习实践:测试驱动的开发方法
book

Python 机器学习实践:测试驱动的开发方法

by Matthew Kirk
January 2018
Intermediate to advanced content levelIntermediate to advanced
211 pages
8h 31m
Chinese
China Machine Press
Content preview from Python 机器学习实践:测试驱动的开发方法
隐马尔可夫模型
99
如前所述,使用 each_char 来实现一个解析器通常是在
Python
语言中最高效的解析
方式。现在我们可以进入更有趣的部分:编写分词器。
编写分词器
至此我们已经准备编写分词器类了。为了完成它我们需要留意以下几方面:
1.
CorpusParser 中读取数据。
2.
存储该数据便于我们计算词频标记等概率。
3.
对标记转移概率矩阵做同样的事情。
我们希望这个类能够告诉我们一个单词以及其标签序列的可能性,并通过一个明文的
句子来判断出最佳的标签序列是什么。
要做到这一点,需要先解决概率问题,然后计算一个标签序列与词序列组合后的概率。
最后,我们将通过维特比算法的实现来解决该问题。
让我们来讨论一下依据上一标签来估算当前标签的概率可能是多少。依据最大似然估
计理论,我们可以知道该概率应该等于两个标签的计数除以之前标签计数。测试如下:
return self
As in the previous chapters, implementing a parser using each_char is generally the
most performant way of parsing things in Python. Now we can get into the much
more interesting part: writing the part-of-speech tagger.
Writing the Part-of-Speech Tagger
At this point ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Python for Bioinformatics

Mastering Python for Bioinformatics

Ken Youens-Clark

Publisher Resources

ISBN: 9787111581666