我正在尝试根据predictionio上的其他文本字段来预测文本字段。我参考了this指南。我创建了一个新的应用程序使用
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)我必须编辑任何配置文件才能使其工作吗?我已经成功地对电影镜头数据进行了测试。
发布于 2015-06-05 01:29:29
因此,当您的数据没有通过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在此之后,我可以进行构建、培训和部署,以及评估。
https://stackoverflow.com/questions/30639115
复制相似问题