【问题标题】:Apache Flink ALS with ids in Long instead of IntApache Flink ALS 的 ID 为 Long 而不是 Int
【发布时间】:2017-01-26 13:27:33
【问题描述】:

我正在尝试使用 Flink 1.1.3 版中的 ALS 代码:

mvn archetype:generate                             \
    -DarchetypeGroupId=org.apache.flink            \
    -DarchetypeArtifactId=flink-quickstart-scala   \
    -DarchetypeVersion=1.1.3                       \
    -DgroupId=org.apache.flink.quickstart          \
    -DartifactId=flink-scala-project               \
    -Dversion=0.1                                  \
    -Dpackage=org.apache.flink.quickstart          \
    -DinteractiveMode=false

我正在关注https://ci.apache.org/projects/flink/flink-docs-release-1.2/dev/libs/ml/als.html 中的示例代码,并更改了数据集中 Long 的 Int

val env = ExecutionEnvironment.getExecutionEnvironment
val csvInput: DataSet[(Long, Long, Double)] = env.readCsvFile[(Long, Long, Double)]("tmp-contactos.csv")

// Setup the ALS learner
val als = ALS()
  .setIterations(10)
  .setNumFactors(10)
  .setBlocks(100)


// Set the other parameters via a parameter map
val parameters = ParameterMap()
  .add(ALS.Lambda, 0.9)
  .add(ALS.Seed, 42L)

// Calculate the factorization
als.fit(csvInput, parameters)

但它会抛出runetime:

Exception in thread "main" java.lang.RuntimeException: There is no FitOperation defined for org.apache.flink.ml.recommendation.ALS which trains on a DataSet[(Long, Int, Double)]
at org.apache.flink.ml.pipeline.Estimator$$anon$4.fit(Estimator.scala:85)
at org.apache.flink.ml.pipeline.Estimator$class.fit(Estimator.scala:55)
at org.apache.flink.ml.recommendation.ALS.fit(ALS.scala:122)
at org.apache.flink.quickstart.BatchJob$.main(BatchJob.scala:119)
at org.apache.flink.quickstart.BatchJob.main(BatchJob.scala)

可以使用 Longs 代替 Ints 吗?

我搜索并找到了 0.9 版本,但没有找到 1.1.13:
https://issues.apache.org/jira/browse/FLINK-2211

【问题讨论】:

    标签: scala machine-learning apache-flink


    【解决方案1】:

    到目前为止,它还没有得到官方支持,但我已经创建了 a branch,我已经修复了这个限制。你可以试试这个分支。我会把它贡献给 Flink,以便它下次成为 master 的一部分。

    【讨论】:

      猜你喜欢
      • 2021-05-22
      • 1970-01-01
      • 2015-09-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-09
      • 1970-01-01
      • 2012-12-24
      相关资源
      最近更新 更多