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 精通特征工程
简单而又奇妙的数值
13
>>> pd.qcut(large_counts, 4, labels=False)
array([1, 2, 3, 0, 0, 1, 1, 2, 2, 3, 3, 0, 0, 2, 1, 0, 3], dtype=int64)
# 计算实际的分位数值
>>> large_counts_series = pd.Series(large_counts)
>>> large_counts_series.quantile([0.25, 0.5, 0.75])
0.25 122.0
0.50 926.0
0.75 8286.0
dtype: float64
2.3
 对数变换
上一节简要地介绍了通过取计数值的对数将数据映射到指数宽度分箱的方法。这一节,我
们深入地研究一下这种方法。
对数函数是指数函数的反函数,它的定义是
log
a
(
a
x
) =
x
,其中
a
是个正的常数,
x
可以是
任意正数。因为
a
0
= 1
,所以有
log
a
(1) = 0
。这意味着对数函数可以将
(0, 1)
这个小区间中
的数映射到
(
-
, 0)
这个包括全部负数的大区间上。函数
log
10
(
x
)
可以将区间
[1, 10]
映射到
[0, 1]
,将
[10, 100]
映射到
[1, 2]
,以此类推。换言之,对数函数可以对大数值的范围进行
压缩,对小数值的范围进行扩展。
x
越大,
log(
x
)
增长得越慢。
通过查看对数函数的图形(见图
2-6
),可以更好地理解上面的内容。注意一下横轴上从
100
1000
x
值是如何被压缩到纵轴上从
2.0 ...
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