Skip to main content

Model Usage

Uploading a Model

a navio model can be uploaded via the user interface in a few simple steps:

  1. If no workspace is available, create a new workspace
  2. If necessary, create a new use case:
    • At the top of the left-hand side panel, find the section "Use cases"
    • Click the "+" symbol opposite the section heading
  3. At the top right, click the button "New model"
  4. Click "Upload" on the right-hand side of the menu
  5. Select the file and name the model
  6. Click "Upload" to finish the dialog

The model should now appear in the list of models, where it should have an orange state indicator signifying that the model container is building. Once the state indicator turns green, the model container has finished building and is ready for use.

Deploying a Model

Once the model has been uploaded and is finished building, there's not much left to do to integrate the model into your application. This is accomlished by generating and exposing the model endpoint so that it is ready to accept HTTP prediction requests.

Deploy a model in two different ways:

  1. On deployment view, click "New Deployment" in the top right-hand corner and select your model.
  2. On the model details view, click the "Deploy" button under "Actions" in the panel on the right-hand side of a model.

Deployed models can be viewed on the deployment view. Each deployment represents one model deployment.

Integrating a Deployed Model

After deployment, find the newly created deployment and click "API Integration" to integrate your model.

Here you can do three things:

  1. Copy the model endpoint to your client
  2. Create a deployment key to secure the endpoint and secure the x-api-key HTTP header with the token.
  3. Copy the example request from the "Endpoint Desription" section

The API of an MLflow model hosted on navio is slightly different to that of a model served directly by MLflow.

Now you're ready to start using your model from any client that can consume a REST API.

Requesting Predictions from a Deployed Model

Tabular Data

For models working with tabular data, it is sufficient to provide a JSON object with a field rows containing data in record format. This is the same format you get by calling df.to_json(orient='records') on a pandas data frame.

Example:

{
"rows": [
{
"sepal_length": 4.6,
"sepal_width": 3.6,
"petal_length": 1.0,
"petal_width": 0.2
}
]
}

Models of this kind should always yield one prediction per row, and the (deployed model's endpoint's) API response format will always contain a list of objects under field "predictions". Please note that the model's predict method's output format is different to the deployed model's endpoint's API response. Please see the predict() section for more information.

Example:

{
"predictions": [
{
"prediction": "setosa"
},
{
"prediction": "versicolor"
}
]
}

Time Series Data 

The request format for time series models is discussed in the Time Series section.

Making API Requests

There are many ways to call the model endpoints and you can request prediction of a model using almost any programming langauge. One way in Python is to use the requests module:

import requests

response = requests.post(
url,
headers={'X-API-KEY': token},
json={
"rows": [
{
"sepal_length": 4.6,
"sepal_width": 3.6,
"petal_length": 1.0,
"petal_width": 0.2
}
]
})

response.raise_for_status()
predictions = response.json()['predictions']

url: The endpoint URL shown at the top of the main panel on the "API Integration" page

token: The access token which can be created by following the prompts after clicking "Create access token"