Skip to content

nakshatrasinghh/ML-Docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mobile Classification- Docker

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.

Dataset

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.

Requirements & Training script

⚠️ All the necessary packages must be installed using pip in order to train the model. ⚠️ Decision Tree Classifier was used to train the model. Training and testing scores of dtc model were printed out. Detailed code of the training script with comments here.

Dockerfile

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).

⚠️This image does not contain the common packages contained in the default tag and only contains the minimal packages needed to run python. Unless you are working in an environment where only the python image will be deployed and you have space constraints, it's highly recommend using the default image of this repository. ⚠️

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 Commands

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.

Docker Hub

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.

An image  

Message Me

If you have any doubts feel free to click on the social icon you would like to connect with 🤗

           

Support Me

If you liked my work and gained insightful knowledge, you can buy me a coffee buying click the button below 😊

Buy Me A Coffee

Releases

No releases published

Packages

No packages published