Machine Learning on Docker
--
Summer Program — TASK 1
Task Description :
Run machine learning code written in python language on top of Docker container.
Let’s start with the task :
Step 1 : First get docker installed in Redhat or any Linux OS
command : yum install docker
Step 2 : Pull CentOS image with Latest version
command : docker pull centos:latest
Step 3 : Install and run a new container and Install python on Container
command : docker run -it — name=’machine2’ centos:latest
command : yum install python3
Step 4 : Get the data set having .csv extension and write machine learning code in a file having .py extension (Not Necessary) . This both files should be there in same directory .
import pandasdset = pandas.read_csv(‘marks.csv’)dset = dset.valuespredictors = dset[:,:-1]targets = dset[:,-1]from sklearn.linear_model import LinearRegressionmodel = LinearRegression()x=model.fit(predictors,targets)y=model.predict([[9,13,7]])print(y)import joblibjoblib.dump(model,’marks_predictor.pk1')
Step 4 : Run this file by python interpreter . If error come us showing some libraries missing then install them using pip3.
command : pip3 install pandas
command : pip3 install sklearn
Step 5 : Now run file with python interpreter .
command : python3 marks.py