Skip to Content
精通特征工程
book

精通特征工程

by Alice Zheng, Amanda Casari
April 2019
Intermediate to advanced
172 pages
4h 39m
Chinese
Posts & Telecom Press
Content preview from 精通特征工程
34
3
3.1
 元素袋
将自然文本转换为扁平向量
不管是建立机器学习模型,还是构建特征,既简单又可以解释的结果自然是非常好的。简
单的事情很容易尝试,相对于复杂的特征和模型,可解释的特征和模型更易于调试。虽然
简单明了的特征不一定会得到最准确的模型,但从简单开始并且仅在绝对必要的时候才添
加复杂性总是没错的。
对于文本数据,我们可以从一个单词数量的统计列表开始,这称为词袋(
bag-of-words
BoW
)。这个单词数量列表并不试图找出有意义的实体,比如
Emma
raven
(乌鸦)。但
这两个单词在我们的示例文本中被提及了多次,它们出现的次数远高于那些随机出现的
单词,比如“
hello
”。对于像文档分类这样的简单任务来说,单词数量统计通常就够用了。
这种技术还可以用于信息提取,它的目标是提取出一组与查询文本相关的文档。这两种任
务都可以凭借单词级别的特征圆满地完成,因为特定词是否存在于文档中这个指标可以很
好地标识文档的主题内容。
3.1.1
 词袋
在词袋特征化中,一篇文本文档被转化为一个计数向量。(向量就是
n
个数值的集合。)这
个计数向量包含词汇表中所有可能出现的单词。如果某个单词(比如“
aardvark
”)在文档
中出现了
3
次,那么特征向量在对应于这个单词的位置就有一个计数值
3
。如果词汇表中
的某个单词没有出现在文档中,那么它的计数值就是
0
。例如,文本“
it is a puppy and it is
extremely cute
”具有图
3-1
中的词袋表示。
原始文本 词袋向量
it is a puppy ...
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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

精通機器學習

精通機器學習

Aurélien Géron

Publisher Resources

ISBN: 9787115509680