| copyright |
|
||
|---|---|---|---|
| lastupdated | 2017-08-09 |
{:new_window: target="_blank"} {:shortdesc: .shortdesc} {:screen: .screen} {:codeblock: .codeblock} {:pre: .pre}
Use the following API call to post the input data to use by the deployed model to generate and return the predictive analytics in the score results.
POST http://{PA Bluemix load balancer
URL}/pm/v1/score/{contextId}?accesskey={access_key for this bound
application}
{: codeblock}
Request example:
Content-Type: application/json;charset=UTF-8
Parameters:
Path parameters:
contextId: the identifier of the deployed model to use to process this score request
Query Parameters:
accesskey: access_key from env.VCAP_SERVICES
Body: the input data, json string, eg.
{
"tablename":"DRUG1n.sav",
"header":["Age", "Sex", "BP", "Cholesterol", "Na", "K", "Drug"],
"data":[[43.0, "M", "LOW", "NORMAL", 0.526102, 0.027164, "drugY"]]
}
{: codeblock}
Example of a successful response to the previous request:
Content-Type: application/json;charset=UTF-8
Status code: 200
body: the score result, a json array, eg.
[
{
"header":["Age","Sex","BP","Cholesterol","Na""K","Drug","$N-Drug","$NC-Drug"],
"data":[[23.0,"M","NORMAL","NORMAL",0.78452,0.055959,"drugX","drugX",0.9892564426956728]]
}
]
{: codeblock}
Response when scoring request fails:
Content-Type: application/json
Status code: 200
body:
{
"flag":false,
"message":"reason"
}
{: codeblock}
Use this API call to retrieve metadata for the scoring branch of a deployed IBM SPSS Modeler stream. Do not supply a request body with this method.
GET http://{service
instance}/pm/v1/metadata/{contextId}?accesskey={access_key for
this bound application}&metadatatype=score
{: codeblock}
Request example:
Content-Type: application/json;charset=UTF-8
Parameters:
Path parameters:
contextId: the identifier of the deployed model to use to process this metadata retrieval request
Query Parameters:
accesskey: access_key from env.VCAP_SERVICES
{: codeblock}
Example of a successful response to the previous request:
Content-Type: application/json;charset=UTF-8
Status code: 200
body: the metadata (formatted for readability in this document) on the scoring branch eg.
[
{
flag: true
message:
"Model Score Input Metadata:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<metadata xmlns="http://spss.ibm.com/meta/internal">
<table xsi:type="nodeImpl" tag="id574QKQ8NL6E" name="baskrule_input.csv"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<field measurementLevel="CATEGORICAL" storageType="STRING" name="gender"/>
<field measurementLevel="CONTINUOUS" storageType="LONG" name="income"/>
</table>
</metadata>
Model Score Output Metadata:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<metadata xmlns="http://spss.ibm.com/meta/internal">
<table xsi:type="nodeImpl" tag="id32CPAJBGJFG" name="Flat File"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<field measurementLevel="CATEGORICAL" storageType="STRING" name="gender"/>
<field measurementLevel="CONTINUOUS" storageType="LONG" name="income"/>
<field measurementLevel="FLAG" storageType="STRING" name="$C-beer_beans_pizza"/>
<field measurementLevel="CONTINUOUS" storageType="DOUBLE" name="$CC-beer_beans_pizza"/>
</table>
</metadata>"
}
]
{: codeblock}
Response when a scoring request fails:
Content-Type: application/json
Status code: 200
body:
{
"flag":false,
"message":"reason"
}
{: codeblock}
Use the following API call to retrieve the WADL for this service.
OPTIONS http://{PA Bluemix load balancer URL}/pm/v1/wadl
{: codeblock}
Request example:
Content-Type: */*
{: codeblock}
Response when the WADL request succeeds:
Content-Type: application/vnd.sun.wadl+xml
Status code: 200
body: the WADL XML ,eg.
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<application>
<resources base="http://{PA Bluemix load balancer URL}/pm/v1/">
<resource path="score">
<doc title="Score using the model with given context ID" />
<resource path="{id}">
<param style="template" name="id" />
<method name="POST">
<request>
<param style="query" name="accesskey" />
<representation mediaType="application/json;charset=UTF-8" />
</request>
<response>
<representation mediaType="application/json;charset=UTF-8" />
</response>
</method>
</resource>
</resource>
...
</resources>
</application>
{: codeblock}
Response when the WADL request fails:
Content-Type: application/json
Status code: 200
body:
{
"flag":false,
"message":"reason"
}
{: codeblock}