Skip to Main Content
Hadoop数据分析
book

Hadoop数据分析

by Benjamin Bengfort, Jenny Kim
April 2018
Intermediate to advanced content levelIntermediate to advanced
229 pages
6h 19m
Chinese
Posts & Telecom Press
Content preview from Hadoop数据分析
机器学习
159
始,将它与使用其他训练参数组合的模型进行对比来评估结果,确定最佳拟合模型:
# rank是模型中隐语义因子的数量
# num_iterations是迭代次数
# lambda指定ALS中的正则化参数
rank = 8
num_iterations = 8
lambda = 0.1
现在使用 ALS.train() 方法创建模型,该方法接受评分元组的训练
RDD
和我们的训
练参数:
# 使用训练数据、已配置的rank和迭代参数训练模型
model = ALS.train(training, rank, num_iterations, lambda)
# 使用验证集评估经过训练的模型
print "The model was trained with rank = %d, lambda = %.1f, and %d iterations.
\n" % \
(rank, lambda, num_iterations)
在详细日志记录模式下运行
train()
方法时要小心,此操作需要进行几次
RDD
投影和操作,因此可能会有长达几分钟的日志滚动。
模型一旦被创建,就使用均方根误差(
root mean squared error
RMSE
)来计算每个模型
的误差。
RMSE
是拥有实际评分的所有用户的
实际评分
-
预测评级
^2
的平均值的平
方根
5
我们的推荐程序也可以相应地实现
RMSE
计算:
def compute_rmse(model, data, n):
"""
计算RMSE,或 者 ...
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

Kudu:构建高性能实时数据分析存储系统

Kudu:构建高性能实时数据分析存储系统

Jean-Marc Spaggiari, Mladen Kovacevic, Brock Noland, Ryan Bosshart
Java并发编程实战

Java并发编程实战

Brian Goetz, Tim Peierls
面向机器学习的自然语言标注

面向机器学习的自然语言标注

James Pustejovsky, Amber Stubbs

Publisher Resources

ISBN: 9787115479648