| copyright | lastupdated | ||
|---|---|---|---|
|
2018-10-04 |
{:shortdesc: .shortdesc} {:new_window: target="_blank"} {:codeblock: .codeblock} {:pre: .pre} {:screen: .screen} {:tip: .tip}
{: #machine-learning-cli}
You can use the {{site.data.keyword.pm_full}} CLI (plugin name: machine-learning) to train and deploy models, as well as manage objects in your repository from a command line on you computer.
{:shortdesc}
Notes
- Instructions for setting up the CLI on your local computer are here: Setting up the CLI
- Explanations for key terms are here: Terminology
In May 2018, the {{site.data.keyword.Bluemix_notm}} CLI commands changed from bluemix and bx to ibmcloud. So, for example, the command bx ml help became ibmcloud ml help. You can still use the bluemix and bx CLI commands until they are removed in the future. If you have scripts that use the bluemix and bx commands, update those scripts to use ibmcloud (or consider other strategies, such as using command aliases.) {: tip}
{: #commands_index}
You can specify one of the following commands:
| Commands | ||||
|---|---|---|---|---|
| [cancel](#cancel) | [delete](#delete) | [deploy](#deploy) | [experiments](#experiments) | |
| [generate-manifest](#generate-manifest) | [help ](#help) | [libraries](#libraries) | [list ](#list) | |
| [models ](#models) | [monitor ](#monitor) | [runtimes](#runtimes) | [score ](#score) | |
| [show ](#show) | [store ](#store) | [train ](#train) | [version](#version) | |
{: #cancel}
Cancel training a model.
ibmcloud ml cancel training-runs <model-id>
{: #delete}
Delete an object from the repository:
- Training definition
- Training run
- Experiment
- Experiment run
- Model
- Deployment
- Library
- Runtime
Syntax for different types of objects:
ibmcloud ml delete training-definitions <training-definition-id>
ibmcloud ml delete training-runs <training-run-id>
ibmcloud ml delete experiments <experiment-id>
ibmcloud ml delete experiment-runs <experiment-id> <experiment-run-id>
ibmcloud ml delete models <model-id>
ibmcloud ml delete deployments <model-id> <deployment-id>
ibmcloud ml delete libraries <library-id>
ibmcloud ml delete runtimes <runtime-id>
where the object identifier (such as <model-id>) specifies the object to delete from the repository.
{: #deploy}
Deploy a model that is stored in the repository.
Two types of deployment are supported:
- Web service
- Batch deployment
Syntax for deploying a web service:
ibmcloud ml deploy <model-id> <deployment-name>
Syntax for a batch deployment:
ibmcloud ml deploy -b <model-id> <deployment-name> <manifest-file-name>
where:
- <model-id> is the identifier of a model that is already stored in the repository.
- <deployment-name> is a name you choose for the deployment object.
- <manifest-file-name> is the absolute or relative path and name of a JSON- or YAML-formatted file that specifies details of the batch deployment.
{: #experiments}
Run or update an experiment that is stored in the repository.
Syntax for running an experiment:
ibmcloud ml experiments run <experiment-id>
Syntax for updating an experiment:
ibmcloud ml experiments update <experiment-id> <manifest-file-name>
where:
- <experiment-id> is the identifier of an experiment that is already stored in the repository.
- <manifest-file-name> is the absolute or relative path and name of a JSON- or YAML-formatted file that specifies details of the experiment.
{: #generate-manifest}
Generate a sample JSON manifest file.
With many machine learning commands, you specify execution or configuration details in a JSON- or YAML-formatted file , called a manifest file. The generate-manifest command generates a template JSON manifest file. You can use the generated manifest file template as a base for creating your own manifest files: update the template for use in JSON format, or convert the template to YAML.
Syntax for generating a manifest file for different scenarios:
ibmcloud ml generate-manifest <manifest-file-type>
where <manifest-file-type> is one of the values in table 2:
Table 2. Manifest file types| value | Scenario |
|---|---|
| `training-definitions` | Create a template manifest file for use with this command: `ibmcloud ml store training-definitions` |
| `training-runs` | Create a template manifest file for use with these commands: `ibmcloud ml train` `ibmcloud ml train training-definitions` |
| `store-training-runs` | Create a template manifest file for use with this command: `ibmcloud ml store training-runs` |
| `experiments` | Create a template manifest file for use with this command: `ibmcloud ml store experiments` |
| `update-experiments` | Create a template manifest file for use with this command: `ibmcloud ml experiments update` |
| `libraries` | Create a template manifest file for use with this command: `ibmcloud ml store libraries` |
| `update-libraries` | Create a template manifest file for use with this command: `ibmcloud ml libraries update` |
| `runtimes` | Create a template manifest file for use with this command: `ibmcloud ml store runtimes` |
| `update-runtimes` | Create a template manifest file for use with this command: `ibmcloud ml runtimes update` |
| `batch` | Create a template manifest file for use with this command: `ibmcloud ml deploy -b` |
{: #help}
Show command help.
ibmcloud ml help [ <command> ]
where <command> is one of the other commands listed in this topic.
{: #libraries}
Update a library that is stored in the repository, or download a library from the repository.
Syntax for updating the metadata for a library that is already stored in the repository:
ibmcloud ml libraries update <library-id> <manifest-file-name>
Syntax for updating the custom Python distribution package of a library that is already stored in the repository:
ibmcloud ml libraries update-content <library-id> <custom-package-file-name>
Syntax for downloading a library from the repository to the current directory:
ibmcloud ml libraries download <library-id>
where:
- <library-id> is the identifier of a library that was stored in the repository with the command:
ibmcloud ml store libraries. - <manifest-file-name> is the absolute or relative path and name of a JSON- or YAML-formatted file that specifies details of the update.
- <path-to-content> is the absolute or relative path and name of a custom Python distribution package .zip file.
{: #list}
List objects that are stored in the repository.
Syntax for listing different types of objects:
ibmcloud ml list training-definitions
ibmcloud ml list training-runs
ibmcloud ml list training-runs <experiment-id> <experiment-run-id>
ibmcloud ml list experiments
ibmcloud ml list models
ibmcloud ml list deployments
ibmcloud ml list deployments <model-id>
ibmcloud ml list libraries
ibmcloud ml list runtimes
ibmcloud ml list experiment-runs <experiment-id>
where the object identifier (such as <model-id>) specifies an object associated with the objects to list.
{: #models}
Download a model from the repository to the current directory.
ibmcloud ml models download <model-id>
where <model-id> specifies the model to download.
{: #monitor}
Show metrics or log messages of a training run or experiment.
Syntax for training runs:
ibmcloud ml monitor training-runs <training-run-id> [ metrics | logs [ last <number-of-lines> ] ]
Syntax for experiments:
ibmcloud ml monitor experiments <experiment-id> <experiment-run-id> [ metrics | logs ]
where:
- The object identifier (such as <training-run-id>) specifies the object for which to retrieve metrics or logs.
- <number-of-lines> is a number you choose. If you specify this optional argument, only up to the specified number of lines of the most recent messages will be shown.
{: #runtimes}
Update the metadata of a runtime in the repository, upload new content for a runtime in the repository, or download a runtime that is stored in the repository.
Syntax for updating the metadata of a runtime that is already stored in the repository:
ibmcloud ml runtimes update <runtime-id> <manifest-file-name>
Syntax for uploading a Conda YAML file (for Python) or a Scala build definition file for a runtime:
ibmcloud ml runtimes upload <runtime-id> <sbt-yaml-file-name>
Syntax for downloading a runtime to the current directory:
ibmcloud ml runtimes download <runtime-id>
where:
- <runtime-id> is the identifier of a runtime that was stored in the repository with the command:
ibmcloud ml store runtimes. - <manifest-file-name> is the absolute or relative path and name of a JSON- or YAML-formatted file that specifies details of the update.
- <sbt-yaml-file-name> is the absolute or relative path and name of a Conda YAML file (for Python) or a Scala build definition file.
{: #score}
Analyze data (for example, classify the data, or make a prediction from the data) using a model deployment in the repository.
ibmcloud ml score <data-file-name>
where <data-file-name> specifies the absolute or relative path and name of a JSON-formatted file that specifies the model identifier, the deployment identifier, and the data to be analyzed (the payload.)
Example
Sample data file JSON content for a hypothetical model that has been trained to predict the chance of rain based on three weather characteristics:
{
"modelId" : "a8379aaa-ea31-4c22-824d-89a01315dd6d",
"deploymentId" : "9d6a656c-e9d4-4d89-b335-f9da40e52179",
"payload" : {
"fields" : [ "temperature", "windspeed", "iscloudy" ],
"values" : [ 15, 50, "F" ]
}
}
{: #show}
Get detailed information about objects that are stored in the repository.
Syntax for getting detailed information about different types of objects:
ibmcloud ml show training-definitions <training-definition-id>
ibmcloud ml show training-runs <training-run-id>
ibmcloud ml show experiments <experiment-id> <experiment-run-id>
ibmcloud ml show experiment-runs <experiment-id> <experiment-run-id>
ibmcloud ml show models <model-id>
ibmcloud ml show deployments <model-id> <deployment-id>
ibmcloud ml show libraries <library-id>
ibmcloud ml show runtimes <runtime-id>
where the object identifier (such as <model-id>) specifies an object that is stored in the repository.
{: #store}
Store an object in the repository.
Syntax for storing different types of objects:
ibmcloud ml store training-definitions <training-definition-file-name> <manifest-file-name>
ibmcloud ml store training-runs <training-run-id> [ <manifest-file-name> ]
ibmcloud ml store experiments <manifest-file-name>
ibmcloud ml store <model-file-name> <manifest-file-name>
ibmcloud ml store libraries <library-file-name> <manifest-file-name>
ibmcloud ml store runtimes <manifest-file-name>
where:
- <model-file-name> is the absolute or relative path and name of a file in tar.gz format that contains model-building code.
- <manifest-file-name> is the absolute or relative path and name of a JSON- or YAML-formatted file that specifies metadata for storing the object.
- <library-file-name> is the absolute or relative path and name of a file in .zip format that contains a custom library.
- <training-definition-file-name> is the absolute or relative path and name of a training definition file in .zip format.
{: #train}
Start a training run to train a model.
Syntax for training a model by passing model-building code:
ibmcloud ml train <model-building-file-name> <manifest-file-name>
Syntax for training a model by using a training definition:
ibmcloud ml train training-definitions <training-definition-id> <training-definition-version-id> <manifest-file-name>
where:
- <model-building-file-name> is the absolute or relative path and name of a file in .zip format that contains model-building code.
- <manifest-file-name> is the absolute or relative path and name of a JSON- or YAML-formatted file that specifies model and training details.
- <training-definition-id> is the identifier generated when you stored the training definition.
- <training-definition-version-id> is version identifier generated when you stored the training definition.
{: #version}
View the Git commit hash and build time of the currently installed machine learning CLI.
ibmcloud ml version