What are percentiles in Machine Learning?

A percentile is a term used to describe and interpret data distributions.

The nth percentile describes the percentage of data below that percentile.

For example, if in a class of 20 students, we find that the 25th percentile age is 20 years, it means that 25% of the students (in this case, 5 students) are below 20 years.

Example use cases

  1. Percentiles are useful in describing data distributions. For example, where we have a dataset containing houses in Boston and the 50th percentile on the Price Column is $ 8 million, then it means that 50% of the houses in Boston cost below $ 8 million.

  2. Percentiles are also useful in interpreting scores, indexes, health indicators, and other related measurements. For example, percentiles can be used in exam settings to rank performance and assign different teaching methodologies in a classroom while comparing the performance of individual students.

Calculate the nth percentile

The formula to manually obtain the nth percentile is:

n=(P/100)Nn = (P/100)*N

where PP is the percentile, NN is the number of data points in that dataset, and nn is the number of data points.

For example, we have 10 marks in an exam,[50,30,20,60,73,88,44,22,67,10], in order to obtain the 50th percentile:

  • Obtain nn using the formula, 50/100*10 = 5. This means that the 50th percentile is located in the 5th position in that dataset.

  • Order the dataset from the smallest to the largest. [10,20,22,30,44,50,60,67,73,88], the 5th number is 44. This means that 50% of the students scored below 44 marks.

Note: The median is also known as the 50th percentile.

Code example in Python

import numpy as np
data = [50,30,20,60.73,88,44,22,67,10]
perc = np.percentile(data,50)
print("50th percentile is:",perc)

  • Line 1: We import numpy as np.

  • Line 3: It contains data for use.

  • Line 5: We compute the 50th percentile.

  • line 6: We print 44 as the percentile.

This is the same answer as we had manually computed earlier.

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved