Logistic Version of the Isolet Model Test in Wallaroo

An example of a Logistic version of an isolet model.

The following demonstrates how to use a converted sk-learn Logistics ML model converted to ONNX in Wallaroo. This is meant to be a follow up to the tutorial sk-learn Logistic Model to ONNX, which demonstrates how to convert the sk-learn logistics model to ONNX format and generates the file isolet_logistic_model_numclass.onnx that is used in this tutorial.

For more details on using Wallaroo workspaces, pipelines, and models, see the Wallaroo Documentation site.

This tutorial includes the following assets:

  • isolet_test_data.tsv: A test file that can be used to verify the output of the converted logistic model.
  • test-converted-sklearn-logistics-to-onnx.ipynb: This Jupyter Notebook that demonstrates the use of the converted sk-learn logistic ML model in ONNX with Wallaroo.

Test Steps

Load Libraries

The first step in the process is to load the necessary libraries.

# from their artifacts

import json
import wallaroo
import numpy
import pandas

Connect to Wallaroo Instance

Next we’ll connect to the Wallaroo Instance with the Client method.

wl = wallaroo.Client()

Connect to Workspace

Either create or use an existing workspace. In this example, we will connect to the existing workspace isolettest by using the set_current_workspace command. For more details on connecting to a workspace, see the Wallaroo SDK Essentials guide.

Wallaroo Workspace Example

wl.set_current_workspace(wl.list_workspaces()[1])

Upload Model

Upload the isolet_logistic_model_numclass.onnx model as isolet-test with the upload_model method:

wl.upload_model('isolet-test', './isolet_logistic_model_numclass.onnx').configure()

Deploy Pipeline

Pipelines can be deployed either with the Wallaroo Dashboard user interface or through the SDK. For this example, we have the pipeline isolet-pipeline deployed and assigned to the variable isoletpipeline. For more details, see the Wallaroo Pipeline Guide.

Wallaroo Workspace Example

We can check the status of the pipeline with the Wallaroo pipeline status method.

isoletpipeline = wl.list_pipelines()[0]
isoletpipeline.status()

Load the Data

Load the data from the file isolet_test_data.tsv into the variable testdata, and turn it into a data dictionary variable labeled input_dict.

# read in data
testdata = pandas.read_csv('isolet_test_data.tsv', sep='\t')

input_dict = {
    'tensor': testdata.values.tolist()
}

We’ll display the data shape to verify it has 9 rows and 617 columns per row.

# report the size of the data  -  9 rows, 617 columns each
testdata.shape

Run Inference

Use the Wallaroo pipeline infer method to run an inference and store the results into the variable result, then display the data from the result.

result = isoletpipeline.infer(input_dict)
result[0].raw['outputs']

Closing

Once the tests are done, the pipeline should be undeployed to allocate the resources back to the Wallaroo instance. For more details, see the Wallaroo Pipeline Management Guide.