Using Python ML for Predictive Analytics

1 hour
  • 5 Learning Objectives

About this Hands-on Lab

This lab guides the student through Python examples that utilize metrics gathered from Prometheus. The Python Sci-Learn library is used for a Linear Regression example.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Install pip3.

The command to install pip3 is:

sudo apt install python3-pip
Install Sci-Kit and Pandas Python modules.

Use the pip3 command to install Sci-Kit Learn:

pip3 install scikit-learn


pip3 install pandas
Review and run the program.

To review the code, you can navigate to the GitHub repository and view the file. The link is:

The command to run the program is:

Review and run the and programs.

To review the programs, you may use the following links:

For predictcpu:

For predictmem:

To run the programs, the command is:



Change the number of replicas to project.

To change the number of replicas to project, edit the following file:

[vi or nano] promql2.csv

And then change the data column for replicas to the values you want to project.

Additional Resources

All of the necessary commands may be found in the instructions below.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?