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文本分析
解释文本分类器
223
LIME
软件模块适用
scikit-learn
中的线性支持向量机,但不能用于内核更复杂的
机器学习模型。图形表示非常好,但并不直接适合演示。因此,下面我们来介绍
ELI5
,这是另一种实现,而且可以克服这些问题。
7.5
案例:使用
ELI5
介绍分类结果
ELI5
的意思是“
Explain Like I
m 5
”,也就是说“解释得简单点,你就
当我只有五岁”。
ELI5
是另一种流行的机器学习解释软件库,也使用了
LIME
算法。由于这个库可用于非线性
SVM
,并且拥有不同的
API
,因此下面我们
来简要地介绍一下,并展示如何在我们的示例中使用它。
ELI5
需要经过
libsvm
训练的模型,然而我们的
SVC
模型并不是这样的模型。好消
息是,训练
SVM
的速度非常快,因此我们可以使用相同的数据创建一个新的分类器,
只不过这一次我们需要使用基于
libsvm
的模型,然后再检查其表现。你可能还记得
6
章的分类报告,它很好地总结了模型的质量。
from sklearn.linear_model import SGDClassifier
svm = SGDClassifier(loss='hinge', max_iter=1000, tol=1e-3, random_state=42)
svm.fit(X_train_tf, Y_train)
Y_pred_svm = svm.predict(X_test_tf)
print(classification_report(Y_test, Y_pred_svm))
输出结果: ...
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

精益AI

精益AI

Lomit Patel
构建知识图谱

构建知识图谱

Jesus Barrasa, Jim Webber
写给系统管理员的Python脚本编程指南

写给系统管理员的Python脚本编程指南

Posts & Telecom Press, Ganesh Sanjiv Naik

Publisher Resources

ISBN: 9787519864446