mleap icon indicating copy to clipboard operation
mleap copied to clipboard

How to use mleap-spring-boot's transform api?

Open potoo0 opened this issue 5 years ago • 0 comments

I run this container from combustml/mleap-spring-boot image. When I post json to http://localhost:8080/models/scikit-airbnb-lr/transform, got IllegalArgumentException: requirement failed: BLAS.dot(x: Vector, y:Vector) was given Vectors with non-matching sizes: x.size = 27, y.size = 32",.

Here is my steps:

  1. serialize sklearn model to bundle: followed this demo: mleap-demo/notebooks/airbnb-price-regression-scikit.ipynb
  2. post the bundle to the server:
MODEL_NAME='scikit-airbnb-lr'
BUNDLE_ZIP='file:/models/scikit-airbnb.lr.zip'

body='{"modelName":"'${MODEL_NAME}'","uri":"'${BUNDLE_ZIP}'","config":{"memoryTimeout":900000,"diskTimeout":900000},"force":false}'

curl --header "Content-Type: application/json" \
  --request POST \
  --data "$body" http://localhost:8080/models
  1. transform: url: http://localhost:8080/models/scikit-airbnb-lr/transform, json data:
{
  "schema": {
    "fields": [
      {
        "name": "imp_bathrooms",
        "type": "double"
      },
      {
        "name": "imp_bedrooms",
        "type": "double"
      },
      {
        "name": "imp_security_deposit",
        "type": "double"
      },
      {
        "name": "imp_cleaning_fee",
        "type": "double"
      },
      {
        "name": "imp_extra_people",
        "type": "double"
      },
      {
        "name": "imp_number_of_reviews",
        "type": "double"
      },
      {
        "name": "imp_square_feet",
        "type": "double"
      },
      {
        "name": "imp_review_scores_rating",
        "type": "double"
      },
      {
        "name": "room_type",
        "type": "string"
      },
      {
        "name": "host_is_superhost",
        "type": "string"
      },
      {
        "name": "cancellation_policy",
        "type": "string"
      },
      {
        "name": "state",
        "type": "string"
      },
      {
        "name": "instant_bookable",
        "type": "string"
      }
    ]
  },
  "rows": [
    [
      1.0,
      1.0,
      0.0,
      30.0,
      0.0,
      41.0,
      0.0,
      97.0,
      "Entire home/apt",
      "0.0",
      "strict",
      "Other",
      "0.0"]]
}

got error message:

2020-10-14 08:01:52.003 ERROR 1 --- [lt-dispatcher-3] m.c.m.s.LeapFrameScoringController       : Transform error due to

java.lang.IllegalArgumentException: requirement failed: BLAS.dot(x: Vector, y:Vector) was given Vectors with non-matching sizes: x.size = 27, y.size = 32
        at scala.Predef$.require(Predef.scala:224) ~[org.scala-lang.scala-library-2.11.12.jar:na]
        at org.apache.spark.ml.linalg.BLAS$.dot(BLAS.scala:104) ~[org.apache.spark.spark-mllib-local_2.11-2.4.5.jar:2.4.5]
        at org.apache.spark.ml.linalg.mleap.BLAS$.dot(BLAS.scala:17) ~[ml.combust.mleap.mleap-core-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at ml.combust.mleap.core.regression.LinearRegressionModel.predict(LinearRegressionModel.scala:28) ~[ml.combust.mleap.mleap-core-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at ml.combust.mleap.core.regression.LinearRegressionModel.apply(LinearRegressionModel.scala:20) ~[ml.combust.mleap.mleap-core-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at ml.combust.mleap.runtime.transformer.regression.LinearRegression$$anonfun$1.apply(LinearRegression.scala:13) ~[ml.combust.mleap.mleap-runtime-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at ml.combust.mleap.runtime.transformer.regression.LinearRegression$$anonfun$1.apply(LinearRegression.scala:13) ~[ml.combust.mleap.mleap-runtime-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at ml.combust.mleap.runtime.frame.Row$class.udfValue(Row.scala:241) ~[ml.combust.mleap.mleap-runtime-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at ml.combust.mleap.runtime.frame.ArrayRow.udfValue(ArrayRow.scala:17) ~[ml.combust.mleap.mleap-runtime-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at ml.combust.mleap.runtime.frame.Row$class.withValue(Row.scala:221) ~[ml.combust.mleap.mleap-runtime-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at ml.combust.mleap.runtime.frame.ArrayRow.withValue(ArrayRow.scala:17) ~[ml.combust.mleap.mleap-runtime-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at ml.combust.mleap.runtime.frame.DefaultLeapFrame$$anonfun$withColumn$1$$anonfun$apply$2$$anonfun$2.apply(DefaultLeapFrame.scala:54) ~[ml.combust.mleap.mleap-runtime-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at ml.combust.mleap.runtime.frame.DefaultLeapFrame$$anonfun$withColumn$1$$anonfun$apply$2$$anonfun$2.apply(DefaultLeapFrame.scala:54) ~[ml.combust.mleap.mleap-runtime-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234) ~[org.scala-lang.scala-library-2.11.12.jar:na]
        at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234) ~[org.scala-lang.scala-library-2.11.12.jar:na]
        at scala.collection.immutable.List.foreach(List.scala:392) ~[org.scala-lang.scala-library-2.11.12.jar:na]
        at scala.collection.TraversableLike$class.map(TraversableLike.scala:234) ~[org.scala-lang.scala-library-2.11.12.jar:na]
        at scala.collection.immutable.List.map(List.scala:296) ~[org.scala-lang.scala-library-2.11.12.jar:na]
        at ml.combust.mleap.runtime.frame.DefaultLeapFrame$$anonfun$withColumn$1$$anonfun$apply$2.apply(DefaultLeapFrame.scala:54) ~[ml.combust.mleap.mleap-runtime-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at ml.combust.mleap.runtime.frame.DefaultLeapFrame$$anonfun$withColumn$1$$anonfun$apply$2.apply(DefaultLeapFrame.scala:53) ~[ml.combust.mleap.mleap-runtime-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at scala.util.Success$$anonfun$map$1.apply(Try.scala:237) ~[org.scala-lang.scala-library-2.11.12.jar:na]
        at scala.util.Try$.apply(Try.scala:192) ~[org.scala-lang.scala-library-2.11.12.jar:na]
        at scala.util.Success.map(Try.scala:237) ~[org.scala-lang.scala-library-2.11.12.jar:na]
        at ml.combust.mleap.runtime.frame.DefaultLeapFrame$$anonfun$withColumn$1.apply(DefaultLeapFrame.scala:52) ~[ml.combust.mleap.mleap-runtime-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at ml.combust.mleap.runtime.frame.DefaultLeapFrame$$anonfun$withColumn$1.apply(DefaultLeapFrame.scala:49) ~[ml.combust.mleap.mleap-runtime-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at scala.util.Success.flatMap(Try.scala:231) ~[org.scala-lang.scala-library-2.11.12.jar:na]
        at ml.combust.mleap.runtime.frame.DefaultLeapFrame.withColumn(DefaultLeapFrame.scala:48) ~[ml.combust.mleap.mleap-runtime-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at ml.combust.mleap.runtime.frame.SimpleTransformer$class.transform(Transformer.scala:112) ~[ml.combust.mleap.mleap-runtime-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at ml.combust.mleap.runtime.transformer.regression.LinearRegression.transform(LinearRegression.scala:10) ~[ml.combust.mleap.mleap-runtime-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at ml.combust.mleap.runtime.frame.Transformer$class.transformAsync(Transformer.scala:83) ~[ml.combust.mleap.mleap-runtime-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at ml.combust.mleap.runtime.transformer.regression.LinearRegression.transformAsync(LinearRegression.scala:10) ~[ml.combust.mleap.mleap-runtime-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at ml.combust.mleap.runtime.transformer.Pipeline$$anonfun$transformAsync$2$$anonfun$apply$2.apply(Pipeline.scala:34) ~[ml.combust.mleap.mleap-runtime-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at ml.combust.mleap.runtime.transformer.Pipeline$$anonfun$transformAsync$2$$anonfun$apply$2.apply(Pipeline.scala:34) ~[ml.combust.mleap.mleap-runtime-0.17.0-SNAPSHOT.jar:0.17.0-SNAPSHOT]
        at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:253) ~[org.scala-lang.scala-library-2.11.12.jar:na]
        at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:251) ~[org.scala-lang.scala-library-2.11.12.jar:na]
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:36) [org.scala-lang.scala-library-2.11.12.jar:na]
        at akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55) [com.typesafe.akka.akka-actor_2.11-2.5.12.jar:2.5.12]
        at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply$mcV$sp(BatchingExecutor.scala:91) [com.typesafe.akka.akka-actor_2.11-2.5.12.jar:2.5.12]
        at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91) [com.typesafe.akka.akka-actor_2.11-2.5.12.jar:2.5.12]
        at akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91) [com.typesafe.akka.akka-actor_2.11-2.5.12.jar:2.5.12]
        at scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:72) [org.scala-lang.scala-library-2.11.12.jar:na]
        at akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:90) [com.typesafe.akka.akka-actor_2.11-2.5.12.jar:2.5.12]
        at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40) [com.typesafe.akka.akka-actor_2.11-2.5.12.jar:2.5.12]
        at akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:44) [com.typesafe.akka.akka-actor_2.11-2.5.12.jar:2.5.12]
        at akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) [com.typesafe.akka.akka-actor_2.11-2.5.12.jar:2.5.12]
        at akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) [com.typesafe.akka.akka-actor_2.11-2.5.12.jar:2.5.12]
        at akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) [com.typesafe.akka.akka-actor_2.11-2.5.12.jar:2.5.12]
        at akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107) [com.typesafe.akka.akka-actor_2.11-2.5.12.jar:2.5.12]

Did I miss something??

potoo0 avatar Oct 14 '20 08:10 potoo0