Machine Learning - Percentiles

What is a percentile?

In statistics, percentiles (Percentiles) provide a number that describes the value below which a given percentage value is less than.

For example: assume we have an array containing the ages of people living on a street.

ages = [5,31,43,48,50,41,7,11,15,39,80,82,32,2,8,6,25,36,27,61,31]

What is the 75th percentile? The answer is 43, which means that 75% of the people are 43 years old or younger.

The NumPy module has a method to find the specified percentile:

Example

Using NumPy percentile() Method to Find Percentile:

import numpy
ages = [5,31,43,48,50,41,7,11,15,39,80,82,32,2,8,6,25,36,27,61,31]
x = numpy.percentile(ages, 75)
print(x)

Run Instance

Example

What is the age of 90% of the population?

import numpy
ages = [5,31,43,48,50,41,7,11,15,39,80,82,32,2,8,6,25,36,27,61,31]
x = numpy.percentile(ages, 90)
print(x)

Run Instance