Spark mmlib开发中遇到的问题

1.问题1 SparkContext初始化失败,master URL 没找到
Using Spark’s default log4j profile: org/apache/spark/log4j-defaults.properties
17/03/01 20:22:00 INFO SparkContext: Running Spark version 1.6.1
17/03/01 20:22:00 ERROR SparkContext: Error initializing SparkContext.
org.apache.spark.SparkException: A master URL must be set in your configuration
at org.apache.spark.SparkContext.(SparkContext.scala:401)
at com.jd.data.center.machine.learn.train.WordCount .main(WordCount.scala:12)atcom.jd.data.center.machine.learn.train.WordCount.main(WordCount.scala)17/03/0120:22:00INFOSparkContext:SuccessfullystoppedSparkContextExceptioninthreadmainorg.apache.spark.SparkException:AmasterURLmustbesetinyourconfigurationatorg.apache.spark.SparkContext.(SparkContext.scala:401)atcom.jd.data.center.machine.learn.train.WordCount .main(WordCount.scala:12)
at com.jd.data.center.machine.learn.train.WordCount.main(WordCount.scala)

解决办法:
方法一:在configuration中vm参数中设置: -Dspark.master=local即可
方法二: val conf = new SparkConf().setMaster(“local”).setAppName(“WordCount”)即在SparkConf实例后设置其Master,local就是本机。上线后,不能设置该项为local。

2.Failed to locate the winutils binary in the hadoop binary path
由于本机没有安装hadoop导致的。因此,下载hadoop的windows版本,http://www.srccodes.com/p/article/39/error-util-shell-failed-locate-winutils-binary-hadoop-binary-path
ERROR util.Shell: Failed to locate the winutils binary in the hadoop binary path
If we directly take the binary distribution of Apache Hadoop 2.2.0 release and try to run it on Microsoft Windows, then we’ll encounter ERROR util.Shell: Failed to locate the winutils binary in the hadoop binary path.In the previous post - Build, Install, Configure and Run Apache Hadoop 2.2.0 in Microsoft Windows OS, I have already described how to build Windows distribution of Apache Hadoop 2.2.0. But if you are feeling little bit lazy to perform all the lengthy steps described there and want to get started with Hadoop quickly by-passing those steps, then this is the post worth looking into.
原因:The binary distribution of Apache Hadoop 2.2.0 release does not contain some windows native components (like winutils.exe, hadoop.dll etc). These are required (not optional) to run Hadoop on Windows.
Tools and Technologies used in this article :
Apache Hadoop 2.2.0
Windows 7 OS
JDK 1.6

我们可以使用Spark Mllib来构建一个基于用户历史订单和酒店信息的酒店推荐系统。下面是实现的步骤: 1.数据预处理 我们需要将用户历史订单和酒店信息转化为一个Spark RDD对象,然后将它们合并成一个包含用户、酒店和评分的数据。在这个数据,每一行包含一个用户的历史订单和对酒店的评分。 2.特征工程 我们需要从数据提取特征,以便训练推荐模型。我们可以使用Spark Mllib提供的特征提取工具来提取用户和酒店的特征。对于酒店,我们可以提取它的位置、价格、星级、评分等特征。对于用户,我们可以提取他们的性别、年龄、地理位置、搜索历史等特征。 3.训练模型 我们可以使用Spark Mllib提供的协同过滤算法来训练推荐模型。协同过滤算法基于用户历史行为和酒店信息来预测用户对未来酒店的评分。我们可以使用交叉验证来选择最佳的模型超参数,并使用训练和测试来评估模型性能。 4.推荐酒店 我们可以使用训练好的模型来为每个用户推荐酒店。对于每个用户,我们可以使用模型预测他们对未来酒店的评分,并推荐评分最高的酒店。 5.实时预测 我们可以将训练好的模型部署到一个实时预测系统,以便为新用户实时推荐酒店。我们可以使用Spark Streaming来实现实时数据处理,并使用Spark Mllib提供的模型接口来进行实时预测。 以上就是使用Spark Mllib构建酒店推荐系统的步骤。当然,在实际应用,我们还需要考虑数据的质量和安全性等问题
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值