A Machine Learning Model inside the Container

  1. pull the centOS image from DockerHub
  2. Install the Python on the container
  3. Create the ML model inside Docker
docker --version
This command gives information about our docker version
systemctl start docker
docker pull centos
docker run -it --name centos
yum install python3
pip3 install numpy
pip3 install pandas
pip3 install scikit-learn
  • I have used WinSCP to transfer my data from window to RedHat
docker cp Salary_Data.csv mlmod:/root/project
import pandas as pd 
import numpy as np
dataframe= pd.read_csv('Salary_Data.csv')
x = dataframe['YearsExperience'].values.reshape(30,1)
y = dataframe['Salary']
from sklearn.linear_model import LinearRegression
model = LinearRegression()
model.fit(x,y)
import joblib
joblib.dump(model,'Salary_model.pkl')
import joblib
model=joblib.load('Salary_model.pkl')
num=float(input("years of experience:"))
predict=model.predict([[num]])
print(predict)
Our model is predicting

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store