Deploying Simple Machine Learning Model inside Docker Container
Task Description ??
?? Pull the Docker container image of CentOS image from Docker Hub and Create a new container
?? Install the Python software on the top of the docker container
?? In Container you need to copy/create a machine learning model
1. Install docker in base OS:
- Already installed in my case.
2. Pulling the Centos image from docker hub
Pull the image using docker pull centos command.
3. Launching a Docker container using the centos image
By using docker run -it --name mlindocker centos command we have launched docker container with centos image and container name as mlindocker.
4. Copying the dataset into the container
5. Installing python3 software inside the docker container
6. Installing the necessary libraries (numpy, pandas, scikit-learn) using pip3
pip3 install numpy
pip3 install pandas
pip3 install scikit-learn
7. Writing the ML code
import pandas as pd dataset = pd.read_csv('salarydata.csv') X = dataset[['YearsExperience']] y = dataset['Salary'] from sklearn.linear_model import LinearRegression model = LinearRegression() model.fit(X,y) import joblib joblib.dump(model, 'finalsalary2.pk1')
8. Now we are set to run the model file
As we can see when we enter the number of years of experience the ML model is giving the expected salary.
Site Reliability Engineer at Crest data systems
3 年Great work Well explained