Creating a Machine Learning Model inside Docker Container using Python in RHEL8(Red Hat Enterprise Linux)
I would suggest you to first install RHEL-8 on your Virtual Machine/System and Python and then go through this article as we are going to create a Machine Learning Model inside Docker Container in RHEL8.
If you haven’t, you can refer to my blog on how to Install Python in Docker container:
Installing Python in Docker Container in RHEL8(Red Hat Enterprise Linux)
If you haven’t, you can refer to my blog on how to Install Docker in RHEL8:
1.First you need to transfer the data file from your OS to the container.
2. To do so, download
WinSCP Application in Windows.
ifconfig enp0s3 in the RHEL8 terminal to find your inet address.
4. Copy the IP Address on the RHEL8 terminal and paste it in the WinSCP application and enter your username
root along with password to begin a session.
5. Drag and Drop files which are to be transferred.
6. Check if file is transferred or no. In the RHEL8 terminal, type:
cd \root and then
ls to check if files have arrived to RHEL8 or no.
7. Now, we have to transfer files from RHEL8 to container. To transfer files, type :
docker cp /root/<filename> <container_name>:/root/ and then type
cd /root/ and type
ls. The file should be present inside the container.
8. Now we can start with our PYTHON program. So we need to first open editor by typing :
9. Press ‘i’ to insert code inside the file and type the code. My example program for explanation purpose is a Salary Prediction Program.
I have used pandas and sklearn packages inside my program.
10. We first import the libraries. Then, we import our dataset and store it in some object. Then, we store the independent data in ‘x’ and dependent data in ‘y’. We then use Simple Linear Regression(SLR) algorithm for prediction purpose in this program. We then use
.fit(x,y) to fit the dependent and the independent data inside the SLR object for training the model and then using
.predict(), the machine predicts the best possible output after internal calculations. We finally save or code using
11. We finally run the program using :
python3 <file_name.>.py and see if we have the desired output or if there is any error in the code.
Using the above steps, we just trained a model using the
.fit(x,y) function and predicted the output. The program also shows the coefficient value and the predicted value, which is very close to the actual output, which shows that our model is trained properly and is predicting an output which is more or less same as the original output.
Installing Python in Docker Container in RHEL8(RedHat Enterprise Linux)
I would first suggest you to install Docker in RHEL-8. If you haven’t, you can refer to my blog on how to Install…
Running GUI applications inside Docker Container in RHEL8(Red Hat Enterprises Linux)