لَآ إِلَـٰهَ إِلَّا هُوَ
LA ILAHA ILLA HU
Allah, Your Lord There Is No Deity Except Him.

Python Data Science Machine Learning Lesson 3: Percentile

A percentile (or a centile) is a measure used in statistics indicating the value below which a given percentage of observations in a group of observations fall under.

It is to be noted that while there is no universal definition of percentile, it is commonly expressed as the percentage of values in a set of data scores that fall below a given value.

xth Percentile value means that x% of the values fall under the caclulated specified value.
So, 75th Percentile value means that 75% of the values fall under the caclulated specified value.

Example: Consider the speed of 10 different trains as under.
speed = [92, 90, 95, 97, 85, 99, 88, 97, 84, 101]
In Python programming language you have a module called numpy to calculate the percentile.
You have to first import mumpy as under

import numpy as np
now the full code in python progamming will be as under:

code

import numpy as np
speed = [92, 90, 95, 97, 85, 99, 88, 97, 84, 101]
x = np.percentile(speed,25))
print(x)

the output will be.
25% of values fall under : 88.5

To calculate for multiple percentiles you can write the code as under.

code

print("25% of values fall under : ",np.percentile(speed,25))
print("40% of values fall under : ",np.percentile(speed,40))
print("50% of values fall under : ",np.percentile(speed,50))
print("75% of values fall under : ",np.percentile(speed,75))
print("90% of values fall under : ",np.percentile(speed,90))

output will be
25% of values fall under : 88.5
40% of values fall under : 91.2
50% of values fall under : 93.5
75% of values fall under : 97.0
90% of values fall under : 99.2

Note: if you have python installed on your pc you can install numpy as under.
Open Command Prompt from the start menu.
Inside the command prompt, type
pip install numpy
press enter
This command will install numpy on your computer after which you can run on python.