Setting up your local environment for using the Watson Machine Learning CLI

You can work with your IBM Watson Machine Learning service using a command line interface on your computer.

Command reference: Watson Machine Learning CLI external link

Tip If this is the first time you have set up the Watson Machine Learning CLI environment, review key terms.

 

Before you begin

  1. Sign up for an IBM Cloud account
    See: IBM Cloud registration external link
     
  2. Create an instance of Watson Machine Learning
    See: Watson Machine Learning in the IBM Cloud catalog external link

 

Procedure

Perform these steps on your computer:

  1. Install the IBM Cloud CLI
  2. Install the machine-learning plugin
  3. Set environment variables
  4. Login and test

 

1. Install the IBM Cloud CLI

Install the IBM Cloud command line interface (CLI) on your computer.

See: IBM Cloud CLI download page external link

 

2. Install the machine-learning plugin

From a command line on your computer, install the machine-learning plugin:

bx plugin install machine-learning

See: IBM Cloud CLI plugin install command reference external link

 

3. Set environment variables

3.1 Collect service credentials

Look up the url, username, password, and instance_id elements of your Watson Machine Learning service credentials.

See: Retrieving service credentials

3.2 Set variables

On your computer, set environment variables that the machine learning plugin requires:

Table 1. Environment variables
Environment variable Service credentials element
ML_ENV url
ML_USERNAME username
ML_PASSWORD password
ML_INSTANCE instance_id

Example: Setting variables for the current session on the Windows command line

set ML_ENV=https://us-south.ml.cloud.ibm.com
set ML_USERNAME=23d59ab1-72ea-38cd-7410-dd1790da35f9
set ML_PASSWORD=16382469-2481-d57a-e731-e582a78b2d78
set ML_INSTANCE=57a283db-452f-c359-00d4-8c3461a7b90e

Example: Setting variables for the current session on Linux or macOS

export ML_ENV=https://us-south.ml.cloud.ibm.com
export ML_USERNAME=23d59ab1-72ea-38cd-7410-dd1790da35f9
export ML_PASSWORD=16382469-2481-d57a-e731-e582a78b2d78
export ML_INSTANCE=57a283db-452f-c359-00d4-8c3461a7b90e

(Replace these example values with ones for your service instance.)

 

4. Log in and test

4.1 Log in

From a command line on your computer, log in to IBM Cloud:

bx login

See: IBM Cloud CLI login command reference external link

Tip The login command prompts you to specify your API endpoint. You can look up your Region on your IBM Cloud dashboard, and then select the API endpoint for that region from the prompt.

4.2 Test

Run a test Watson Machine Learning command:

bx ml list training-runs

Sample output

Fetching the list of training runs ...
SI No   Name   guid   status   framework   version   submitted-at

0 records found.
OK
List all training-runs successful

(Because no training runs have been started, you would not expect to see any runs listed. The most important part of this output is that the command completed successfully.)