查询互补购买项目时的运行时错误

我正在使用 https://templates.prediction.io/PredictionIO/template-scala-parallel-complementarypurchase 模板的 prediction.io,并通过 PHP-SDK 插入购买事件。

引擎已成功部署,但在查询时出现错误

curl -k -H "Content-Type: application/json" -d '{ "items": ["<item_id>"], "num": "3" }' https://localhost:8000/queries.json

错误信息如下

Stack Trace:java.lang.RuntimeException: Unable to invoke no-args constructor for scala.collection.immutable.Set<java.lang.String>. Register an InstanceCreator with Gson for this type may fix this problem.    at com.google.gson.internal.ConstructorConstructor$12.construct(ConstructorConstructor.java:210)    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:162)    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93)    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172)    at com.google.gson.Gson.fromJson(Gson.java:803)    at com.google.gson.Gson.fromJson(Gson.java:768)    at com.google.gson.Gson.fromJson(Gson.java:717)    at com.google.gson.Gson.fromJson(Gson.java:689)    at io.prediction.workflow.JsonExtractor$.extractWithGson(JsonExtractor.scala:152)    at io.prediction.workflow.JsonExtractor$.extract(JsonExtractor.scala:70)    at io.prediction.workflow.ServerActor$$anonfun$24.apply(CreateServer.scala:519)    at io.prediction.workflow.ServerActor$$anonfun$24.apply(CreateServer.scala:513)    at spray.routing.ApplyConverterInstances$$anon$22$$anonfun$apply$1.apply(ApplyConverterInstances.scala:25)    at spray.routing.ApplyConverterInstances$$anon$22$$anonfun$apply$1.apply(ApplyConverterInstances.scala:24)    at spray.routing.ConjunctionMagnet$$anon$1$$anon$2$$anonfun$happly$1$$anonfun$apply$1.apply(Directive.scala:38)    at spray.routing.ConjunctionMagnet$$anon$1$$anon$2$$anonfun$happly$1$$anonfun$apply$1.apply(Directive.scala:37)    at spray.routing.directives.BasicDirectives$$anon$1.happly(BasicDirectives.scala:26)    at spray.routing.ConjunctionMagnet$$anon$1$$anon$2$$anonfun$happly$1.apply(Directive.scala:37)    at spray.routing.ConjunctionMagnet$$anon$1$$anon$2$$anonfun$happly$1.apply(Directive.scala:36)    at spray.routing.directives.BasicDirectives$$anon$2.happly(BasicDirectives.scala:79)    at spray.routing.Directive$$anon$7$$anonfun$happly$4.apply(Directive.scala:86)    at spray.routing.Directive$$anon$7$$anonfun$happly$4.apply(Directive.scala:86)    at spray.routing.directives.BasicDirectives$$anon$3$$anonfun$happly$1.apply(BasicDirectives.scala:92)    at spray.routing.directives.BasicDirectives$$anon$3$$anonfun$happly$1.apply(BasicDirectives.scala:92)    at spray.routing.directives.ExecutionDirectives$$anonfun$detach$1$$anonfun$apply$7$$anonfun$apply$3.apply$mcV$sp(ExecutionDirectives.scala:89)    at spray.routing.directives.ExecutionDirectives$$anonfun$detach$1$$anonfun$apply$7$$anonfun$apply$3.apply(ExecutionDirectives.scala:89)    at spray.routing.directives.ExecutionDirectives$$anonfun$detach$1$$anonfun$apply$7$$anonfun$apply$3.apply(ExecutionDirectives.scala:89)    at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)    at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)    at scala.concurrent.impl.ExecutionContextImpl$$anon$3.exec(ExecutionContextImpl.scala:107)    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)Caused by: java.lang.reflect.InvocationTargetException    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)    at java.lang.reflect.Method.invoke(Method.java:498)    at com.google.gson.internal.UnsafeAllocator$1.newInstance(UnsafeAllocator.java:48)    at com.google.gson.internal.ConstructorConstructor$12.construct(ConstructorConstructor.java:207)    ... 33 moreCaused by: java.lang.InstantiationException: scala.collection.immutable.Set    at sun.misc.Unsafe.allocateInstance(Native Method)    ... 39 more

这是我的 engine.json

{  "id": "default",  "description": "Default settings",  "engineFactory": "com.my.ComplementaryPurchaseEngine",  "datasource": {    "params" : {      "appName": "store",      "eventNames": ["buy"]    }  },  "algorithms": [    {      "name": "algo",      "params": {        "basketWindow" : 120,        "maxRuleLength" : 2,        "minSupport": 0.001,        "minConfidence": 0.1,        "minLift" : 1.0,        "minBasketSize" : 2,        "maxNumRulesPerCond": 5,        "eventNames": ["buy"]      }    }  ]}

回答:

在您的 curl 请求中,num 字段不需要引号

curl -k -H "Content-Type: application/json" -d '{ "items": ["<item_id>"], "num": 3 }' https://localhost:8000/queries.json

Related Posts

L1-L2正则化的不同系数

我想对网络的权重同时应用L1和L2正则化。然而,我找不…

使用scikit-learn的无监督方法将列表分类成不同组别,有没有办法?

我有一系列实例,每个实例都有一份列表,代表它所遵循的不…

f1_score metric in lightgbm

我想使用自定义指标f1_score来训练一个lgb模型…

通过相关系数矩阵进行特征选择

我在测试不同的算法时,如逻辑回归、高斯朴素贝叶斯、随机…

可以将机器学习库用于流式输入和输出吗?

已关闭。此问题需要更加聚焦。目前不接受回答。 想要改进…

在TensorFlow中,queue.dequeue_up_to()方法的用途是什么?

我对这个方法感到非常困惑,特别是当我发现这个令人费解的…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注