0

我正在尝试根据 predictionio 上的其他文本字段来预测文本字段。我使用指南作为参考。我使用创建了一个新应用程序

pio app new MyTextApp

并按照指南使用模板中提供的数据源进行评估。一切都还好,直到评估。在评估数据源时,我收到如下粘贴的错误。

[INFO] [CoreWorkflow$] runEvaluation started
[WARN] [Utils] Your hostname, my-ThinkCentre-Edge72 resolves to a  loopback address: 127.0.0.1; using 192.168.65.27 instead (on interface eth0)
[WARN] [Utils] Set SPARK_LOCAL_IP if you need to bind to another address
[INFO] [Remoting] Starting remoting
[INFO] [Remoting] Remoting started; listening on addresses  :[akka.tcp://sparkDriver@192.168.65.27:59649]
[INFO] [CoreWorkflow$] Starting evaluation instance ID: AU29p8j3Fkwdnkfum_ke
[INFO] [Engine$] DataSource: org.template.textclassification.DataSource@faea4da
[INFO] [Engine$] Preparator: org.template.textclassification.Preparator@69f2cb04
[INFO] [Engine$] AlgorithmList: List(org.template.textclassification.NBAlgorithm@45292ec1)
[INFO] [Engine$] Serving: org.template.textclassification.Serving@1ad9b8d3
Exception in thread "main" java.lang.UnsupportedOperationException: empty.maxBy
at scala.collection.TraversableOnce$class.maxBy(TraversableOnce.scala:223)
at scala.collection.AbstractTraversable.maxBy(Traversable.scala:105)
at org.template.textclassification.PreparedData.<init>(Preparator.scala:152)
at org.template.textclassification.Preparator.prepare(Preparator.scala:38)
at org.template.textclassification.Preparator.prepare(Preparator.scala:34)

我是否必须编辑任何配置文件才能使其工作?我已经成功地对movielens 数据进行了测试。

4

1 回答 1

3

DataSource因此,当您的数据未通过类正确读取时,会出现此特定错误消息。如果您使用不同的文本数据集,请确保您正确反映了readEventData方法中对 eventNames、entityType 和相应属性字段名称的任何更改。

maxBy方法用于拉取观察次数最多的类。如果要标记 Map 的类别为空,则意味着没有记录任何类,这实际上表明您没有输入任何数据。

例如,我刚刚使用这个引擎做了一个垃圾邮件检测器。我的电子邮件数据格式如下:

{"entityType": "content", "eventTime": "2015-06-04T00:22:39.064+0000", "entityId": 1, "event": "e-mail", "properties": {"label": "spam", "text": "content"}}

为了使用该数据的引擎,我在 DataSource 类中进行了以下更改:

entityType = Some("source"), // specify data entity type eventNames = Some(List("documents")) // specify data event name

更改为

entityType = Some("content"), // specify data entity type eventNames = Some(List("e-mail")) // specify data event name

)(sc).map(e => Observation(
  e.properties.get[Double]("label"),
  e.properties.get[String]("text"),
  e.properties.get[String]("category")
)).cache

更改为:

)(sc).map(e => {
  val label = e.properties.get[String]("label")


  Observation(
    if (label == "spam") 1.0 else 0.0,
    e.properties.get[String]("text"),
    label
  )
}).cache

在此之后,我可以进行构建、培训、部署以及评估。

于 2015-06-04T17:29:29.327 回答