Skip to Content
Python机器学习手册:从数据预处理到深度学习
book

Python机器学习手册:从数据预处理到深度学习

by Chris Albon
July 2019
Intermediate to advanced
365 pages
8h 13m
Chinese
Publishing House of Electronics Industry
Content preview from Python机器学习手册:从数据预处理到深度学习
188
11
模型评估
ols.score(features_test, target_test)
0.63536207866746675
讨论
DummyRegressor
允许我们创建一个简单的模型,以此作为基准和实际的模型进行对比。
我们通常用这种方法来模拟某个产品或系统中已有的原始预测系统。例如,一个产品将
“所有新用户都会在第一个月消费
100
美元”这条规则硬编码到其预测系统中,而忽视
了用户的所有特征。如果我们将这个假设编码到基准模型中,就能将机器学习方法的优
势具体地展现出来。
DummyRegressor
使用
strategy
参数设置所使用的预测方法,可选的方法包括训练集的
均值或者中位数。此外,如果将
strategy
设置成
constant
并使用
constant
参数,则模
型对所有样本的预测结果都会是一个常数
#
创建一个将所有样本预测为
20
DummyRegressor
clf = DummyRegressor(strategy='constant', constant=20)
clf.fit(features_train, target_train)
#
计算模型的得分
clf.score(features_test, target_test)
-0.065105020293257265
默认情况下,
score
方法返回的是决定系数(
R-squared
R
2
得分):
Discussion
DummyRegressor allows us to create a ...
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

精通特征工程

精通特征工程

Alice Zheng, Amanda Casari
精通機器學習

精通機器學習

Aurélien Géron
Python数据分析基础

Python数据分析基础

Clinton W. Brownley

Publisher Resources

ISBN: 9787121369629