我使用以下代码在Spark环境中训练我的惊喜库推荐器模型
def fit(data):
trainset = data["train"]
testset = data["test"]
sim_options = { "name": "cosine", "user_based": False }
model = KNNBasic(sim_options=sim_options)
model.fit(trainset)
predictions = model.test(testset)
return accuracy.rmse(predictions)
# KNN Basic with cosine
print("Item-based with cosine")
data = [dm.loadData(spark)]
predictions = spark.sparkContext \
.parallelize(data, 1) \
.map(fit) \
.collect()
print(predictions)
我返回RMSE,该值为0.0。当我在本地计算机上运行此火车代码时,它是4.5。有人可以帮我解决这个问题吗?