ML_adapter plugin for waylay-sdk-py.
Project description
waylay-ml-adapter-sdk
ML Model Adapter plugin for waylay-sdk.
Installation
# installs the ml tool, and the required sdk modules:
pip install waylay-ml-adapter-sdk
# install the adapter module you need:
pip install waylay-ml-adapter-sklearn[dill]
Exported classes
This module exports the following classes:
ml_adapter.sdk.MLTool
MLAdapter utility service for the waylay client.
Helps creating waylay webscripts and plugs that wrap a machine learning model.
Loaded as tool with name ml_tool
in the python sdk.
Example
# create and test a simple model
import numpy as np
test_data = [1,2,3]
expected_result = [2,4,6]
doubler = lambda x: x*2
assert np.array_equal(
np.array(expected_result),
doubler(np.array(test_data))
)
# wrap in an adapter, test remoting
from ml_adapter.numpy import V1NumpyModelAdapter
adapter=V1NumpyModelAdapter(model=doubler)
test_resp == await adapter.call({"instances": test_data.tolist()})
assert test_resp['predictions'] = expected_result.tolist()
# use the ml_tool to deploy and test a webscript
# configure logging to see what is happening
import logging
logging.basicConfig(level='INFO')
from waylay.sdk import WaylayClient
client = WaylayClient.from_profile('demo')
ref = await client.ml_tool.create_webscript(
adapter, name='MyMLWebscript', draft=True
)
ref = await client.ml_tool.wait_until_ready(ref)
result = await client.ml_tool.test_webscript(ref, test_data)
if expected_result.to_list() == result:
await client.ml_tool.publish(ref)
else:
await client.ml_tool.remove(ref)
See also
- waylay-sdk the Waylay python SDK.
- waylay-ml-adapter-sklearn ML adapter for scikit-learn models.
- waylay-ml-adapter-torch ML adapter for pytorch models.
- waylay-ml-adapter-base provides the basic ML adapter infrastructure.
- waylay-ml-adapter-api defines the remote data interfaces.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file waylay_ml_adapter_sdk-0.0.7.tar.gz
.
File metadata
- Download URL: waylay_ml_adapter_sdk-0.0.7.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7731e87e2b8876aa211a7eb57cec66435bf6ae21ca4f734a1a8ce5f6d5a6ffff |
|
MD5 | 686bf98638baa8d49a7a6d7d1434128a |
|
BLAKE2b-256 | c41ccbf51766d4b1799422a214d36d273a9cc756625e68c376bba98926f12b68 |
File details
Details for the file waylay_ml_adapter_sdk-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: waylay_ml_adapter_sdk-0.0.7-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39e60e5f0ffcb6ebd10377031faebdc15ac540fcb86779c9bf2620b9ac623809 |
|
MD5 | 25b618788a6a9c71abe7aaa656a10185 |
|
BLAKE2b-256 | 434ea03044d2c644c2211230eaf880f57b67f3d9f3ab60b4904d276c553c1b69 |