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 精通特征工程
特征缩放的效果:从词袋到
tf-idf
57
频词都映射到这个特征,包括训练集中的低频词。这种方法在
3.2.2
节的“罕见词”部分
讨论过。
4.2.3
 使用逻辑回归进行分类
逻辑回归是一种简单的线性分类器。正因为其简单,所以非常适合充当首次试验的分类
器。它对输入特征进行加权组合,然后传递给一个
S
形函数
,这个函数可以平滑地将任何
实数映射为
0
1
之间的一个值,即将实数输入
x
转换为
0
1
之间的一个值。它有一组
参数
w
,表示中点(
0.5
)附近的增长斜率。截距项
b
表示函数输出跨过中点时的输入值。
如果
S
形函数的输出大于
0.5
,逻辑回归分类器就预测一个正分类,否则就预测一个负分
类。通过改变
w
b
,我们可以控制在哪里发生决策变化,以及决策对在该点附近发生的
输入变化做出反应的速度。
4-3
演示了
S
形函数。
S形函数
4-3S 形函数示意图
下面我们在不同的特征集合上建立几个简单逻辑回归分类器,并看看效果(见例
4-4
)。
4-4
 
使用默认参数训练逻辑回归分类器
>>> def simple_logistic_classify(X_tr, y_tr, X_test, y_test, description):
... ### 辅助函数,用来训练逻辑回归分类器,并在测试数据上进行评分。
... m = LogisticRegression().fit(X_tr, y_tr)
... s = m.score(X_test, y_test)
... print ('Test score with', description, ...
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

Kafka权威指南

Kafka权威指南

Neha Narkhede, Gwen Shapira, Todd Palino
精通機器學習

精通機器學習

Aurélien Géron

Publisher Resources

ISBN: 9787115509680