A docker image for scoring a simple DTC model on training and testing sets using Mobile price classification dataset. This is a very simple image which prints out model scores on training and testing sets, scores can vary as random seed
parameter is not a constant. Green command to be executed to run the image directly in any local machine and red is the output after running the image.
For this project, I have used the Mobile price classification dataset from kaggle. This is a simple and clean practice dataset for classification modelling. It consists of 2000 rows and 21 columns. The model will be based on “features” like battery power, bluetooth and n_cores etc. You can also use feature engineering to create new features. But we won't be dealing with feature engineering in this project. On the side note, I used the Rainbow CSV extension for VS-code to make .csv files look more attractive 😅. The dataset can be viewed here.
To create docker images and run them in containers, you need to have a dockerfile which includes all the commands to be executed sequential for the application to run in the base OS kernel (in this case, Ubuntu). Firstly, we'll use a basic linux OS kernel with python 3.7.5-slim edition (keeps the image size small and very portable across different computers).
Secondly, we copy the requirements.txt file in the root director, move to the root directory and pip install all the requirements. Finally, we execute python3 command along with the file we need to execute for the application to run.
docker build -t mobile-classification-v3:latest .
Docker build command will build the docker image for us, docker build -t <image-name>:<tag> .
, here -t stands for tag. Tag is used to version the docker images in deployement phase. The default tag is latest. Make sure you are in the working directory of the project.
docker run --name mobile-classification-test --rm mobile-classification-v3:latest
Docker run command will run the docker image in a docker container for us, docker build --name <container-name>:<tag> .
, here --name stands to container name, --rm automatically removes the container when it exits
docker commit <container-id> <dockerhub-username>/<repo-name>
Docker commit command will commit the the unstaged changed and prepare the changes to be pushed in docker hub repositories.
docker login
Docker login command will setup the credentials to log in to a Docker registry.
docker push <newly-created-image-name>
Docker push command will push the staged changes to docker cloud.
Click the icon below to checkout the docker registry, just execute docker run nakshatrasinghh/mobile-classification-v3:latest
on cmd and have the results right at your terminal without any training requirements. Make sure you have docker installed.
If you have any doubts feel free to click on the social icon you would like to connect with 🤗
If you liked my work and gained insightful knowledge, you can buy me a coffee buying click the button below 😊