Getting Started

In this tutorial, we will show you how to deploy an ML model in the Qwak platform in ~10 minutes

What do you need to know before starting?

At Qwak, we adhere to the convention over configuration paradigm. Qwak-based models need to be structured in a specific way. We won't discuss this here. See Model Anatomy for more details.

To make life easier, we have provided an out-of-the-box example called Titanic Survival Classification to use in this tutorial.

Throughout this quick start we refer to Qwak’s three-level hierarchy:

  • Projects. A project groups models with a shared scope, team, or business domain, such as churn or fraud detection. Each model may address a different problem posed by the project.
  • Models. Each machine learning model is associated with a particular project. Multiple models can be added to each project.
  • Builds. A machine learning equivalent of software build — a trained and serialized model instance. Builds are the deployable entities in the Qwak hierarchy.

Follow these steps to install the Qwak SDK, and then build, deploy, and query your model’s predictions:

Install (3 minutes)

  1. Contact Qwak support to receive your API key and username.
  2. Install Python versions 3.7-3.9. We recommend using a virtual environment.
  3. Install the Qwak Python SDK by running the following command from your console:
pip install --extra-index-url https://qwak:[email protected]/artifactory/api/pypi/qwak-pypi/simple qwak-sdk
poetry source add qwakpypi https://qwak:[email protected]/artifactory/api/pypi/qwak-pypi/simple/
poetry add --source qwakpypi "qwak-sdk<0.10"
  1. To perform operations against the Qwak platform, you first need to authenticate your user. To do so, run the following command:
qwak configure

5.Enter your API key. If authentication succeeds, the following appears:

User succesfully configured

6.Verify that qwak command working, if qwak commands are not recognized add it to the PATH.
If authentication fails, the API key may be invalid. Check that the username and API key were entered correctly. If the error persists, contact Qwak support.

Build a Model (5 minutes)

Now, we'll create the project/model/build structure. we start with the CLI commands, followed by the UI option.

  1. Create a project:
qwak projects create --project-name "Titanic Project" --project-description "Predict survival on the Titanic dataset"

  1. Create a model:
qwak models create --project-id {project_id} --model-name "Titanic Model"  --model-description "Predict survival on the Titanic dataset"

  1. To build the out-of-the-box model example, Titanic Survival Classification, create a folder with the Titanic Survival Classification example model:
qwak models init --example titanic .
  1. Change directory to the model folder (based on the output message):
cd titanic_survival_classification

  1. Run the build process:
qwak models build --model-id "titanic_model" .

The build process may take several minutes.

You can view the build logs by running qwak models builds logs -b <build-id> --follow. You will see the complete command results in the qwak models build output.

In the UI, the logs for the various build steps appear in the build page:

While your build is running, you can take a look at the example code in the main and tests directories. The code structure is described in Building a Qwak Model.

Deploy a Model (3 minutes)

After a successful build, deploy the model as an endpoint running in the Qwak platform.

  1. Deploy your build as a real-time endpoint:
qwak models deploy realtime --model-id titanic_model --build-id {build-id}

More deployment options are available via the Builds page in the Qwak UI.

  1. The Python SDK includes a real-time client module. You can use it to run predictions using the real-time API you just deployed:
from qwak.inference.clients import RealTimeClient

feature_vector = [
  {
    'PassengerId': 762,
    'Pclass': 3,
    'Name': 'Nirva, Mr. Iisakki Antino Aijo',
    'Sex': 'male',
    'Age': 34,
    'SibSp': 4,
    'Parch': 3,
    'Ticket': 'a',
    'Fare': 1.0,
    'Cabin': 'A',
    'Embarked': 'A'
  }
]

client = RealTimeClient(model_id='titanic_model')
client.predict(feature_vector)

Once you start running predictions against the model, you'll start seeing the relevant metrics in the Health dashboard on the Overview tab:

Query Your Model Predictions (1 minute)

  1. Go to the Qwak Management Application.
  2. From the sidebar menu, select Analytics.
  3. In the left side pane, find the model you want to query, and drag it into the top right pane.
  4. Click Run - and you'll be able to see a table containing a row for every prediction invoked against the model. More info can be found on the Analytics section.