tree: 91954c112a2c2834385343ee6f68663e0954f4b2 [path history] [tgz]
  1. project/
  2. build.sbt
  3. engine.json
  4. MyAlgorithm.java
  5. MyDataSource.java
  6. MyEngineFactory.java
  7. MyModel.java
  8. MyPrediction.java
  9. MyQuery.java
  10. MyTrainingData.java
  11. README.md
examples/java-local-helloworld/README.md

My First “Hello World” Engine

$ cd $PIO_HOME/examples/java-local-helloworld

Prepare training data:

$ cp ../data/helloworld/data1.csv ../data/helloworld/data.csv

Register engine:

$ ../../bin/pio register

Train:

$ ../../bin/pio train

Example output:

2014-08-11 14:29:35,877 INFO  APIDebugWorkflow$ - Metrics is null. Stop here
2014-08-11 14:29:36,099 INFO  APIDebugWorkflow$ - Saved engine instance with ID: 201408110004
$ ../../bin/pio deploy

Retrieve prediction:

$ curl -H "Content-Type: application/json" -d '{ "day": "Mon" }' http://localhost:8000/queries.json

Output:

{"temperature":75.5}

Retrieve prediction:

$ curl -H "Content-Type: application/json" -d '{ "day": "Tue" }' http://localhost:8000/queries.json

Output:

{"temperature":80.5}

Re-train with new data:

$ cd $PIO_HOME/examples/java-local-helloworld
$ cp ../data/helloworld/data2.csv ../data/helloworld/data.csv
$ ../../bin/pio train
$ ../../bin/pio deploy
$ curl -H "Content-Type: application/json" -d '{ "day": "Mon" }' http://localhost:8000/queries.json

{"temperature":76.66666666666667}