How to Convert your Machine learning Model into a Docker Image (Python ML Model)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so today I'll be teaching you how to convert your machine learning model into an image so the first thing we need is we need your test data train data and your machine learning model in the Python program or format within one folder so like I have named all of this in put this all in one folder named and underscore model so okay most of you probably know what a machine learning model is if you're watching the video so basically what a machine learning model is actually uh let me show you on my GitHub for that so okay you're free to use my repository as well as a margin shape right from the modern field you can see my repository here and use these codes as freely as you want okay because I like helping the community out so uh let me show you one of my uh predictive models which I made within a sample data set of housing prices okay predictive models here public okay so so basically uh you can see right this is a notebook so in order to download it you go to Rob you save it save as and it will be saved as a python notebook okay so in order to change that change it into a Python program you have to go to you can either do a command line which you can search in Google or you can directly download it from your jupyter notebook as well as where download as a python okay but I've already done it so I won't do it again okay so the first things first we have to get our Docker store ready okay your Docker has to be ready okay this is the one I've done previously Okay so to get started let's go and get open your command terminal run as administrator okay okay now start your docker see the Dockers already started first you I have to go to my folder because everything I have to do has to be on the folder so CD go to my foldered location downloads a model okay see see now I'm doing everything on the app model now in order to create a Docker file okay you have to create a Docker file put all the dependencies in it okay so Echo create Docker file it has to be Echo Dot Twitter than sign talk file okay so now my Docker file has been created now we'll see see it's been created now now within the docker file you have to put all the dependencies and you also have to create a text file separately okay now I've done this previously as well so let me open this notepad you can do it with Visual Studio as well Okay so from python you have to import slim Buster your work directory has to be your folder okay so this one is M model okay so and all your separate pipe installed require pip install requirements all your python libraries they have to be printed on a separate requirements text file and then you copy dot out and then you command it and install the output within using python within your model which will be installed on docker okay so I've also done that previously as well okay now first the docker file customs okay so let's copy this into the new Docker file open with text editor okay has to be M model okay save okay and I've created a separate text file as well okay so your text file has here to start attack so look these are all the libraries you have to install for your machine learning model to work or if you have any other libraries you can just put that and you have to equate it to the version of the library you wanted like my my skit learn has to be equated to 1.0 at least or if you have used a new version of skit learn then you have to equate it to that if it's 1.11 or whatever okay the same with the rest of your libraries including your machine learning libraries as well like light gradient booster is a separate Library not installed alone in schedulered alone so you have to separately install it so it has to be in the requirements file because your Docker file will be copying from the requirements file all the dependencies okay so I'll just copy that as well paste I'll delete this one in order to avoid any duplication errors okay okay now we have to run the dot file to prompt engineer the documentation from chat GPT took a bit of effort to get all of this done from chat GPT as well so to now copy your Docker to build your Docker image after putting all the files together in one place you have to copy Docker build Dash T your image whatever the image name you want so I'll name my image ml model okay your image name and then you have to put a full stop on space after that ml model okay now let's put that dot let's build it and you have to make sure that as usual your command directory is the folder where all the files are stored and underscore model okay foreign okay now you can see the image has been picked okay so in order to run the image you have to use Docker run your image okay and your image name is ml model okay first let's check on Docker if it's been built okay see the image has been built here
Info
Channel: Ammar Jamshed (Data Alchemist)
Views: 2,658
Rating: undefined out of 5
Keywords: Container, Docker, Image, Machine Learning
Id: JigSpm6KORI
Channel Id: undefined
Length: 8min 27sec (507 seconds)
Published: Mon Apr 17 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.