RUNNING ML CODE ON THE TOP OF CONTAINER !
2 min readMay 31, 2021
Task discription :-
👉 Pull the Docker container image of CentOS image from DockerHub and create a new container.
👉 Install the Python software on the top of docker container.
👉 Run the Machine learning code on top of the container.
Task
Start the Services Of Docker !
# systemctl start docker
Pull the Centos image From DockerHub!
# docker pull centos:latest
Launch container With name mlos
# docker run -it --name mlos centos
Now if you have data in windows then we can transfer that usin winscp to the linux vm system !
Copy the Dataset file in created container’s / folder
# docker cp SalaryData.csv mlos:/
Install python3 in container
# yum install python3
Install numpy, pandas and sklearn library using pip3
# pip3 install numpy# pip3 install pandas# pip3 install sklearn
You can check by command
# pip3 list
Now, let us start writing the code in vi editor
# vi code.py
code is
import pandas
import numpy
from sklearn.linear_model import LinearRegressiondb = pandas.read_csv("SalaryData.csv")x = db['YearsExperience']y = db['Salary']x = x.values.reshape(30,1)mind = LinearRegression()mind.fit(x, y)a = int(input(('Enter the years of experience gor which salary to be predicted: '))ans = mind.predict([[float(a)]])print(ans)
Task Competed !