通过以下代码使用Apache Flink als时:
val env=ExecutionEnvironment.getExecutionEnvironment
val inputDS: DataSet[String]=env.readTextFile("/home/master/dataset/ml-10m/trainset")
val inputDS1: DataSet[Tuple3[Int,Int,Double]] = inputDS.map{
t =>
val split = t.split("::")
Tuple3(split(0).toInt, split(1).toInt, split(2).toDouble)
}
val als = ALS()
.setIterations(5)
.setNumFactors(10)
.setBlocks(300)
// Set the other parameters via a parameter map
val parameters = ParameterMap()
.add(ALS.Lambda, 0.2)
.add(ALS.Seed, 42L)
// Calculate the factorization
als.fit(inputDS1, parameters)
val inputttestDS: DataSet[String] = env.readTextFile("/home/master/dataset/ml-10m/testset")
val testingDS: DataSet[Tuple2[Int,Int]] = inputttestDS.map{
t =>
val split = t.split("::")
Tuple2(split(0).toInt, split(1).toInt)
}
val predictedRatings=als.predict(testingDS)
predictedRatings.print()
predictedRatings.writeAsText("path to result")
env.execute()但结果只预测结果文件中的最后13个数据。数据是否太大,apache flink无法在idea中使用(对于训练数据集,它有8000000个观察值。此外,测试数据集有20000000个观察值)?数据帧是"userid::itemid::rating::timestamp“。另外,我的电脑内存是8G的。或者我的代码中有一些错误?请告诉我,谢谢。
发布于 2018-04-18 12:34:29
我发现了问题,这是我的数据集的问题。在我的测试数据集中,它只有13个用户It出现在训练数据集中的观察值。因此,它只对这些数据进行预测。
https://stackoverflow.com/questions/49859928
复制相似问题