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.
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 splitted into 3 datasets, train_dataset, test_dataset, and perfomance_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 depoloyment with the help of MLflow
This model can be deployed locally using
But before starting the mlflow model server, the varialbe MLFLOW_TRACKING_URI should be defined:
4. Model packaging and deplyoment on the Openshift cluster
Now that the model and its dependecies 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 Formular 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.