Skip to Content
Spark快速大数据分析(第2版)
book

Spark快速大数据分析(第2版)

by Jules S. Damji, Brooke Wenig, Tathagata Das, Denny Lee
November 2021
Intermediate to advanced
340 pages
10h 46m
Chinese
Posts & Telecom Press
Content preview from Spark快速大数据分析(第2版)
262
10
模型的效果如何呢?你会发现部分预测结果可以认为是“接近的”,其他一些可能非常离
谱。(租金为负数?!)接下来我们将定量地评估模型在整个测试集上的预测效果。
10.2.7
 评估模型
至此模型已经构建完成,我们需要评估模型的效果。
spark.ml
中有针对分类、回归、聚
类,以及排名的评估器(
Spark 3.0
引入)
。由于我们的示例是一个回归问题,因此使用
方根误差
root-mean-square error
RMSE
)和
R
2
(读作“
R
方”)来评估模型的表现。
1.
均方根误差
均方根误差是取值范围为
0
到无穷大的指标。越接近
0
说明模型越好。
我们来逐步推导数学公式。
1.
计算真实值
y
i
和预测值
ŷ
i
(读作“
y
帽”,给变量加上“帽”表示对这个变量的预测值)
之间的差值。
误差
ˆ
()
ii
yy=
2.
计算
y
i
ŷ
i
之差的平方,这样正的残差和负的残差不会相互抵消。这称为
平方误差
squared error
SE
)。
平方误差
2
ˆ
()
ii
yy=
3.
对所有数据点的平方误差求和,这称为
误差平方和
sum
of squared error
SSE
)或
残差
平方和
误差平方和
2
1
ˆ
( )
n
ii
i
yy
=
=
4.
然而,误差平方和会随着数据集中记录条数
n
的增长而不断变大,因此我们想使用记录
数将误差平方和规范化。这样就可以得到
均方误差
mean-squared
error
MSE
),这是
解决回归问题的一种常用指标。
均方误差
2
1
1
ˆ
( )
n
ii
i
yy
n
=
=
5.
如果止步于均方误差,那么误差的单位是原始单位的平方。通常我们取均方误差的平方 ...
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

数据驱动力:企业数据分析实战

数据驱动力:企业数据分析实战

Carl Anderson
数据压缩入门

数据压缩入门

Colt McAnlis, Aleks Haecky
解密金融数据

解密金融数据

Justin Pauley

Publisher Resources

ISBN: 9787115576019