In Machine Learning (and in mathematics) there are often three values that interests us:
Mean – The average value
Median – The mid point value
Mode – The most common value
Example: We have registered the speed of 13 cars:
#Calculating the Mean of the cars speed
import numpy # pip install numpy from cmd prompt to install numpy
speed = [99,86,87,88,111,86,103,87,94,78,77,85,86]
x = numpy.mean(speed)
print(x)
89.76923076923077
#Calculating the Median of the cars speed
import numpy
speed = [99,86,87,88,111,86,103,87,94,78,77,85,86]
x = numpy.median(speed)
print(x)
87.0
#Calculating the Mode of the cars speed
from scipy import stats #pip install scipy from cmd prompt
speed = [99,86,87,88,111,86,103,87,94,78,77,85,86]
x = stats.mode(speed)
print(x)
ModeResult(mode=array([86]), count=array([3]))
In [ ]: