Wine Quality Classifier¶
Objective¶
In this exercise there are 4 steps from data to deployed model onto the OpenShift cluster. For each of these steps, a Jupyter Notebook is prepared.
Prerequisites¶
- Access to an OpenShift AI JupyterLab environment
- Basic familiarity with Python and Jupyter notebooks
MLOps Perspective
This end-to-end exercise demonstrates the complete MLOps lifecycle — from data exploration through deployment and monitoring — showing how each stage connects in a production ML workflow.
1. Data Explorations and Processing¶
Inside the first notebook we read the input data and perform some data exploration tasks. After processing and cleaning the data, it will be stored in a processed dataset.
Processed data will be then split into 3 datasets, train_dataset, test_dataset, and performance_dataset and stored in the corresponding directories.
2. Model Training and registration as well as Experment tracking¶
We take the preprocessed data and start training a model. The trained model as well as its performance and artifacts can be tracked using MLflow.
Usually, data scientists will not be satisfied with the first try. Hence, they will experiment with various sets of hyperparameters and different models. Next, these experiments will be compared on MLflow UI and the model with the best performance will be selected.
curl -X GET 'https://{us-south.ml.cloud.ibm.com}/ml/v1/foundation_model_specs?version=2024-07-25&filters=function_embedding'
3. Local model deployment with the help of MLflow¶
This model can be deployed locally using
But before starting the mlflow model server, the variable MLFLOW_TRACKING_URI should be defined:
4. Model packaging and deployment on the OpenShift cluster¶
Now that the model and its dependencies are pushed to the Github repository, we are ready to go to the OpenShift cluster and start building a container image for the model and deploying it on the cluster. finally we use the deployed model API to send prediction requests using a frontend application.
There are two important hints:
- Take care of the specific permissions for images deployed on OpenShift cluster.
This line
should be added to the Dockerfile After below line:- Configuring BuildConfig from Form is prone to error. So use the below template and adjust the corresponding variables.
As shown in the image, we should create an ImageStream resource and then a BuildConfig to configure the image building process.
When the container is running and the model API is ready, we can send a test requests as follows:
5. Deploy the simple webapp¶
In order to consume the deployed model we will integrate it with a simple webapp. The code and Dockerfile for the app is in the same repository but in directory app_wine_Clf.
We deploy the app in its own project. Let's call it app-wine-clf. Then create an imagestream and a buildconfig.
After the image is built, we can deploy the app. In the deployment definition we can set the model API by setting the variable Endpoint_URL.
When the app is deployed and reachable through its route, we can test the model again but this time from a nice interface.
6. Model and Data Monitoring¶
Summary¶
In this lab, you:
- Explored and processed the wine quality dataset
- Trained a model with MLflow experiment tracking
- Deployed the model locally using MLflow
- Containerized and deployed the model on OpenShift
- Integrated the model with a web application
- Set up model monitoring