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 精通特征工程
分类变量:自动化时代的数据计数
69
5-4:线性回归系数
x
1
x
2
x
3
b
one-hot
编码
166.67 666.67
-
833.33 3333.33
虚拟编码
0 500
-
1000 3500
5.1.3
 效果编码
另一种分类变量编码是
效果编码
。效果编码与虚拟编码非常相似,区别在于参照类是用全
部由
-
1
组成的向量表示的,参见表
5-5
5-5:表示3个城市的分类变量的效果编码
e
1
e
2
San Francisco 1 0
New York 0 1
Seattle
-
1
-
1
效果编码与虚拟编码非常相似,但它的线性回归模型更容易解释。例
5-2
演示了使用效果
编码作为输入的情况。截距项表示目标变量的整体均值,各个系数表示了各个类别的均
值与整体均值之间的差。(这称为类别或水平的
主效果
,效果编码的名称就是由此而来。)
one-hot
编码实际上也可以得到同样的截距和系数,但它的每个城市都有一个线性系数。在
效果编码中,没有单独的特征来表示参照类,所以参照类的效果需要单独计算,它是所有
其他类别的系数的相反数之和。(参见
UCLA IDRE
网站上的“
FAQ: What is effect coding?
以获得更多详细信息。)
5-2
 
使用效果编码的线性回归
>>> effect_df = dummy_df.copy()
>>> effect_df.ix[3:5, ['city_SF', 'city_Seattle']] = -1.0
>>> effect_df
Rent city_SF city_Seattle
0 3999 ...
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