Python SDK
After deploying a real time model, your Python client applications can use this module to get inferences from the model hosted as a real-time endpoint.
Installation
The Python inference clients is a more lightweight part of qwak-inference
package which contains only the modules that are required for inference. To install, run
pip install qwak-inference
Inference examples
The following example invokes the model test_model
. The model accepts one feature vector which contains three fields and produces one output field named "score".
from qwak_inference import RealTimeClient
model_id = "test_model"
feature_vector = [
{
"feature_a": "feature_value",
"feature_b": 1,
"feature_c": 0.5
}]
client = RealTimeClient(model_id=model_id)
response = client.predict(feature_vector)
Testing inference for a specific variation
You can optionally specify a variation name when working with the RealtimeClient
from qwak_inference import RealTimeClient
model_id = "test_model"
feature_vector = [
{
"feature_a": "feature_value",
"feature_b": 1,
"feature_c": 0.5
}]
client = RealTimeClient(model_id=model_id,
variation="variation_name")
response = client.predict(feature_vector)
Running inference for a different Qwak environment
When working in a multi environment account, you need to specify a environment name when sending an infernce to a non default account using the RealtimeClient
from qwak_inference import RealTimeClient
from qwak_inference.configuration import Session
Session().set_environment("staging")
model_id = "test_model"
feature_vector = [
{
"feature_a": "feature_value",
"feature_b": 1,
"feature_c": 0.5
}]
client = RealTimeClient(model_id=model_id,
, environment="staging")
response = client.predict(feature_vector)
Updated 3 months ago