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

我正在使用 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

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

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