Creating a Web service deployment

Create an online , or Web service deployment to load a model or Python code when the deployment is created to generate predictions online, in real time.

For example, if you create a classification model to test whether a new customer is likely to participate in a sales promotion, you can create an online deployment for the model, and enter the new customer data to get an immediate prediction.

Create the deployment

  1. From the Assets page of the deployment space, click the deploy icon for the model you want to deploy.
  2. Choose Web service as the deployment type.
  3. Provide a name and optional description for the deployment, then click Create to create the deployment.
  4. When the deployment status shows Deployed, click the name of the deployment to view the deployment details.

Working with an online deployment

There are two tabs for an online deployment:

  • API Reference displays the API endpoint you will need to access the deployment programmatically. You will need the endpoint to use the deployment in an application. There are also code snippets in a variety of programming languages that illustrate how to access the deployment.
  • Test provides a place where you can enter data and get a prediction back from the deployed model. If your model has a defined schema, you will see a form where you can submit data that matches the schema and get a score, or prediction, back. Otherwise, you can submit input data in JSON format and get a score back.

Sample deployment code

When you submit JSON code as the payload, or input data, for a deployment, your input data must match the schema of the model. The ‘fields’ must match the column headers for the data, and the ‘values’ must contain the data, in the same order. Use this format:

        "fields": [<field1>, <field2>, ...],
        "values": [[<value1>, <value2>, ...]]

For example:

        "fields": ["PassengerId","Pclass","Name","Sex","Age","SibSp","Parch","Ticket","Fare","Cabin","Embarked"],
        "values": [[1,3,"Braund, Mr. Owen Harris",0,22,1,0,"A/5 21171",7.25,null,"S"]]


  • Note that all strings are enclosed in double-quotes. The Python notation for dictionaries looks very similar, but Python strings in single-quotes are not accepted in the JSON data.
  • Missing values can be indicated with null.

Creating online deployments programmatically

See Machine Learning samples and examples for links to sample notebooks that demonstrate creating online deployments using the Watson Machine Learning REST API and Watson Machine Learning Python client library.