Logi Predict API

The Logi Predict application can be used, somewhat like a web service, to generate predictions in response to REST API calls.


Introduction

The technology underlying Logi Predict provides powerful data analysis and prediction capabilities, which are surfaced through the Logi Predict application UI. Starting with v2.1, these capabilities can also be accessed through the Logi Predict API, allowing other applications to utilize this functionality remotely.

A typical REST protocol, using an HTTP GET request based on a URL, is used to generate predictions (GET is recommended, but PUT is also accepted). Query string parameters shape the request and include the values to be used for generating a prediction.

The prediction results are returned as a JSON data payload and include the values from the request, the predicted column value, and, when using a Classification model, the prediction probabilities. Typically, your request will include one set of parameter values and produce one prediction result; although you can send multiple sets of parameter values and have multiple result sets returned at once.

By default, the Logi Predict application is configured so that there are no security or encoding requirements for using the API. Logi Security can be added to the Logi Predict application, however, in which case requesting API sessions must first authenticate before sending a REST request. If security is configured for regular application users, it will also affect API calls; the two cannot be separated.

Back to top

API: Run a Prediction on Specific Data

You can use the API to run a prediction based on specific data, in order to get individual predictions. The prediction results and accuracy probabilities are returned in JSON data format.  

Auto Generate API Call Prototype

Logi Predict includes a feature that will build an API call prototype for you: 

Once a Prediction Model has been trained and selected as the "live" model, you'll see a "plug" icon in its Training Results table entry, as shown above. Click this icon.

The API wizard will appear, as shown above, with a API call URL prototype. You can add an optional JSON variable name for the results data and select between single- and multiple-row predictions using the controls, directly edit the URL, and even test the results. The URL can then be copied and used in other applications that need to call for a prediction.

Click Test to send the Sample URL request and see the returned JSON payload. Click X to close the panel. 

API Call Details

In case you need to customize the API call URL manually, here's an example (optional query string params shown within [ ]):

http://localhost/PredictGo/rdTemplate/rdData.aspx?rdData=PredictGo.Api.goPredict&rdDataID=PredictToJson
&ModelID=c8988ed0-15f2-4667-8c14-a8940a057099&Age=50&Glucose=148&Mass=33.6 [&JsonVar=myJsonResult][&TrainingID=24fca055-cb62-44fb-a27a-89c074dad8c3]

where: 

URL Segment Description Example

Protocol, Domain, and Path

(Required) The protocol and server name for the Predict application, and path to the API handler.

http://localhost/PredictGo/rdTemplate/rdData.aspx?

rdData

(Required) Argument and fixed value - do not edit.

rdData=PredictGo.Api.goPredict

rdDataID

(Required) Argument and fixed value - do not edit.

&rdDataID=PredictToJson

ModelID

(Required) Prediction Model ID1.

&ModelID=c8988ed0-15f2-4667-8c14-a8940a057099

Predicting Column name-value pairs

(Required) One or more predicting column name-value pairs. When multiple rows are to be predicted at once, append "_Row#" to each predicting column name, where "#" is the row number. The columns named must be chosen from those used to train the model.

Single row, three columns:

&Age=50&Glucose=148&Mass=33.6

Multiple rows, three columns:

&Age_Row1=50&Glucose_Row1=148&Mass_Row1=33.6

&Age_Row2=60&Glucose_Row2=122&Mass_Row2=32.5

JasonVar

If provided, the returned JSON data will include a variable declaration using this name.

&JsonVar=myJsonResult

TrainingID

If provided, specifies which training to use. Otherwise, the training currently selected as "live" is used2.

&TrainingID=24fca055-cb62-44fb-a27a-

89c074dad8c3


1- The ModelID GUID value can be found in the browser's URL bar when working with a Prediction Model.
2- The TrainingID GUID value can be found by right-clicking the training result's "Go Live" link, copying the link location, and examining it for its "ModelTrainingID" value. 

Result Examples

The following example shows the JSON data returned from a single-row API request using a Classification model, that includes a JsonVar parameter with a value of "myJsonResult":

var myJsonResult =
[
    {
        "Glucose" : "148",
        "Mass" : "33.6",
        "Age" : "50",
        "PredictedColumn" : "pos",
        "PredictedColumn_Probability" : "0.97",
        "PredictedColumn_Probability_neg" : "0.03",
        "PredictedColumn_Probability_pos" : "0.97"
    }
];

Note that the three "probability" values are only returned when a Classification model is called. These results are for a similar request with two rows: 

var myJsonResult =
[
    {
        "Glucose" : "148",
        "Mass" : "33.6",
        "Age" : "50",
        "PredictedColumn" : "pos",
        "PredictedColumn_Probability" : "0.97",
        "PredictedColumn_Probability_neg" : "0.03",
        "PredictedColumn_Probability_pos" : "0.97"
    },
    {
        "Glucose" : "122",
        "Mass" : "32.5",
        "Age" : "60",
        "PredictedColumn" : "pos",
        "PredictedColumn_Probability" : "0.8",
        "PredictedColumn_Probability_neg" : "0.2",
        "PredictedColumn_Probability_pos" : "0.8"
    }
];

Back to top