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
Release history Release notifications | RSS feed
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
Close
Hashes for waylay_ml_adapter_sdk-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d308affe56d8a7660fb0f7bdb10b8b7e00297b227f47d321822712ba1d82424e |
|
MD5 | 7245ce94bd02388fdf92ad48d6710d11 |
|
BLAKE2b-256 | e0b2b8a1265d0dc24fb34c2b4b70682e4be1ebea1f6e3e5df376555ae3a6c348 |
Close
Hashes for waylay_ml_adapter_sdk-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7dce4ecd94ffabe008d3e6a54f2d0de32234b26c53952a066126a5d1d2d8615c |
|
MD5 | 92def99e13270f6a93af02e26fb9ff65 |
|
BLAKE2b-256 | 31ff0f449f8623f1db81eed308838296ba3c547d494a63907599ec1638493509 |