Skip to Main Content
Spark高级数据分析(第2版)
book

Spark高级数据分析(第2版)

by Sandy Ryza, Uri Laserson, Sean Owen, Josh Wills
June 2018
Beginner to intermediate content levelBeginner to intermediate
246 pages
6h 57m
Chinese
Posts & Telecom Press
Content preview from Spark高级数据分析(第2版)
音乐推荐和
Audioscrobbler
数据集
47
val model = new ALS().
setSeed(Random.nextLong()).
setImplicitPrefs(true).
setRank(10).
setRegParam(0.01).
setAlpha(1.0).
setMaxIter(5).
setUserCol("user").
setItemCol("artist").
setRatingCol("count").
setPredictionCol("prediction").
fit(trainData)
使用随机种子。
这样我们就构建了一个带有默认配置
ALSModel
模型。这个操作可能要花费几分钟或者
更长时间,具体时间取决于所用的集群。有些机器学习模型最终可能只有几个参数或系
数,相比之下,我们这里使用的模型是巨大的。对于每个用户和产品,模型都包含一个有
10
个值的特征向量。在本章的示例中,总共有超过
170
万个特征向量。模型用两个不同的
DataFrame
,它们分别表示“用户
-
特征”和“产品
-
特征”这两个大型矩阵。
你看到的结果会有些不同,原因是最终的模型取决于初始特征向量,而这些初始特征向量
是随机选择的。然而,
MLlib
ALS
模型和其他组件默认设置了固定的随机种子,每次都
会做出相同的随机选择。这一点和其他库不一样,在默认情况下,一般库的随机元素通常
不是固定的。所以,在这里和以后使用
MLlib
时,需要使用
setSeed(Random.nextLong()) ...
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.
Start your free trial

You might also like

大数据项目管理:从规划到实现

大数据项目管理:从规划到实现

Ted Malaska, Jonathan Seidman
管理Kubernetes

管理Kubernetes

Brendan Burns, Craig Tracey

Publisher Resources

ISBN: 9787115482525