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
55
>>> twobiz_reviews = twobiz_reviews[['business_id',
... 'name',
... 'stars_y',
... 'text',
... 'categories']]
# 创建目标列——夜店类型的商家为True,否则为False
>>> two_biz_reviews['target'] = \
... twobiz_reviews.apply(lambda x: 'Nightlife' in x['categories'],
... axis=1)
4.2.1
 创建分类数据集
下面看看能否通过点评数据区分出一个商家是餐馆还是夜店。为了节省训练时间,我们可以
取点评数据的一个子集。在这个例子中,两类商家的点评数量相差很大,这称为
类别不平衡
数据集
。不平衡数据集的建模有些问题,因为模型会将大部分努力用于拟合优势类别。因为
在两个类别中我们都有很多数据,所以解决这个问题的一种好的做法是对优势类别(餐馆)
进行下采样,使它的数量与劣势类别(夜店)基本相当。下面是一个示例流程。
(1)
对夜店点评数据进行
10%
的随机抽样
,对餐馆点评数据进行
2.1%
的随机抽样(选择这
样的比例可以使两个类别的抽样数据基本相当)。
(2)
按照
70/30
的比例将这个数据集划分为训练集和测试集
。在这个例子中,训练集有
29
264
条点评数据,测试集有
12 542
条点评数据。
(3)
训练数据包含
46 924
个唯一单词,这就是词袋表示法的特征数量。 ...
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