Seldon JavaScript API for Prediction

The Seldon JavaScript API provides the simplest method of integrating Seldon onto web based services. It provides the following methods:

Events

An endpoint to allow the injestion of arbitrary JSON event data.

GET     /js/event/new

Input

If a json parameter is not provied then all parameters will be marshalled into a JSON event other than the reserved parameters: consumer_key, consumer_secret, oauth_token, client and jsonpcallback

If a timestamp field is not provided one will be added.

Example

http://<HOST>/js/event/new?consumer_key=XYZ&user=1&num_rooms=4&postcode=sw1&price=400000&jsonpCallback=j

Assuming the consumer key matches client “client1” this would create an event object similar to below:

{
	"num_rooms":4,
	"postcode":"sw1",
	"price":400000,
	"client":"client1",
	"timestamp":1421336333669
}

Predict

GET     /js/predict

Input

The JSON input should contain two fields

The meta data can at present just contain a provided optional prediction id “puid”.

Example

A housing price predictor based on features:

{
"meta" :
       {
		"puid" : 1
       },
"data":
	{
		"num_bedrooms"    :        2,
		"detached" 	  : true,
		"postcode"    :        "SW1"
	}
}

Example

http://<HOST>/js/predict?consumer_key=XYZ&json=%7B%22meta%22%3A%7B%22puid%22%3A%221%22%7D%2C%22data%22%3A%7B%22num_rooms%22%3A2%2C%22detached%22%3Atrue%2C%22postcode%22%3A%22sw1%22%7D%7D&jsonpCallback=j

A response maybe like the following where the “price” field is predicted:

{
  "meta": {
    "puid": "1",
    "modelName": "model_prices",
    "variation": "default"
  },
"predictions":
	[
	{"prediction":400000,"predictedClass":"1","confidence":1.0}
	]
}