Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache spark ALS建议的笛卡尔积误差_Apache Spark_Pyspark - Fatal编程技术网

Apache spark ALS建议的笛卡尔积误差

Apache spark ALS建议的笛卡尔积误差,apache-spark,pyspark,Apache Spark,Pyspark,我正在尝试向用户显示电影推荐列表。该模型已经过训练,但当试图显示预测时,我得到了一个错误 als = ALS(maxIter=5, regParam=0.01, userCol="userID", itemCol="movieID", ratingCol="rating") # ratings is a DataFrame of (movieID, rating, userID) model = als.fit(ratings) # allMovies is a DataFrame of (m

我正在尝试向用户显示电影推荐列表。该模型已经过训练,但当试图显示预测时,我得到了一个错误

als = ALS(maxIter=5, regParam=0.01, userCol="userID", 
itemCol="movieID", ratingCol="rating")
# ratings is a DataFrame of (movieID, rating, userID)
model = als.fit(ratings)
# allMovies is a DataFrame of (movieID, userID)
# it has userID=0 and all distinct movieID
recommendations = model.transform(allMovies)
recommendations.take(20)
使用pyspark.ml.recommendation.ALS中的
库和
当运行最后一行时,我得到了错误
检测到逻辑计划之间左外联接的笛卡尔积


为什么会这样?谢谢

在model.transform之前,您必须定义类似ALS的ALS(输入\列='类似输入功能',输出\列=预测\评级),或者您可以采用这种方式工作

 rank = 10
 numIterations = 100
 model = ALS.train(ratings, rank, numIterations) #where ratings is dataframe
 recommendation = model.predictAll(alMovies).map(lambda r: ((r[0], r[1]), r[2]))

希望这有帮助。

回答我自己的问题。您似乎不应该使用
transform
,而是使用
recommendForUserSubset
方法。

很抱歉,我无法使用此代码。无论如何,谢谢你的帮助!似乎您已经找到了解决方案,只是出于好奇,在使用上述代码时出现了什么错误?当然,我得到了一个
AttributeError:“ALS”对象没有属性“train”