You can deploy Python functions in Watson Machine Learning the same way that you can deploy models. Your tools and apps can use the Watson Machine Learning Python client or REST API to send data to your deployed functions the same way that they send data to deployed models. Deploying functions gives you the ability to hide details (such as credentials), preprocess data before you pass it to models, handle errors, and include calls to multiple models, all within the deployed function instead of in your application.
Sample notebooks for creating and deploying Python functions
For examples of how to create and deploy Python functions by using the Watson Machine Learning Python client library, refer to these sample notebooks:
Sample name | Framework | Techniques demonstrated |
---|---|---|
Use Python function to recognize hand-written digits | Python | Use a function to store a sample model then deploy it |
Predict business for cars | Hybrid(Tensorflow) | Set up an AI definition Prepare the data Create a Keras model using Tensorflow Deploy and score the model Define, store and deploy a Python function |
Deploy Python function for software specification | Core | Create a Python function Create a web service Score the model |
The notebooks demonstrate the six steps for creating and deploying a function:
- Define the function.
- Authenticate and define a space.
- Store the function in the repository.
- Get the software specification.
- Deploy the stored function.
- Send data to the function for processing.
For links to other sample notebooks that use the Watson Machine Learning Python client library, refer to Using Watson Machine Learning in a notebook.
Increasing scalability for a function
When you deploy a function from a deployment space or programmatically, a single copy of the function is deployed by default. To increase scalability, you can increase the number of replicas by editing the configuration of the deployment. Additional replicas allow for a larger volume of scoring requests.
The following example uses the Python client API to set the number of replicas to 3.
change_meta = {
client.deployments.ConfigurationMetaNames.HARDWARE_SPEC: {
"name":"S",
"num_nodes":3}
}
client.deployments.update(<deployment_id>, change_meta)
Learn more
- For information on defining a deployable Python function, refer to General requirements for deployable functions section in Writing and storing deployable Python functions.
- You can deploy a function from a deployment space through the user interface. For details on creating and deploying from a deployment space, refer to Deployment spaces.
Parent topic: Managing predictive deployments