Skip to Content
Python文本分析
book

Python文本分析

by Jens Albrecht, Sidharth Ramachandran, Christian Winkler
August 2022
Intermediate to advanced
441 pages
11h 26m
Chinese
China Electric Power Press Ltd.
Content preview from Python文本分析
160
|
第
5
章
tfidf = TfidfVectorizer(stop_words=stopwords)
dt = tfidf.fit_transform(headlines["lemmas"].map(str))
dt
输出结果:
<1103663x71921 sparse matrix of type '<class 'numpy.float64'>'
with 5053610 stored elements in Compressed Sparse Row format>
维度降了很多,减少了将近
25000
个。对于新闻标题,还原词形可能并不会丢失任
何信息。但在其他情况下,比如第
11
章的例子中,情况就完全不同了。
特征、维度和准确率
/
召回率
词形还原可以大幅降低词汇量。对于新闻标题而言,时态等并不重要。但是,
在读小说的时候,时态却非常关键。你应该根据实际的情况,认真思考哪种文
本转换或自然语言处理转换更适用。
通过
min_df
和
max_df
降低特征维度的做法也是一把双刃剑。删除频率不高的
特征对语料库有好处,但是如果添加其他文档,就会造成特征太少。
在后续章节中,我们将介绍准确率和召回率,二者是信息获取质量的度量基准。
此外,我们还会通过观察这些指标的影响,来量化降低维度(使用 NLP 和向
量化调整)以及增加维度(比如使用二元语法)的效果。
5.5.6
案例:限定单词类型
我们可以使用前面生成的数据来限定向量化,只考虑名词、形容词和动词,
而介词、动词的变形等包含的信息量都不太。这种操作也可以减少词汇量 ...
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

工程战略的制定

工程战略的制定

Will Larson
Python实用技能学习指南

Python实用技能学习指南

Posts & Telecom Press, Robert Smallshire, Austin Bingham
精益AI

精益AI

Lomit Patel
Excel金融建模

Excel金融建模

Posts & Telecom Press, Shmuel Oluwa

Publisher Resources

ISBN: 9787519864446