Well, it's such an initial outfit, not vectored, on a pure python, no library. Just think of something like that. quadramatic deviation And we take the root from him to keep the size.
dataset = {
"Класс 1": [[16, 18, 11, 18], [14, 11, 14, 16], [13, 10, 11, 17]],
"Класс 2": [[38, 38, 34, 37], [30, 38, 39, 34], [30, 32, 38, 38]],
"Класс 3": [[57, 50, 51, 51], [58, 50, 50, 56], [50, 58, 56, 58]]
}
input_data = [[21, 11, 25, 16]]
for i in input_data:
print(i)
for k in dataset:
print(k, sum(sum((a-b)**2 for a,b in zip(row,i))/len(dataset[k]) for row in dataset[k])**0.5)
Conclusion:[21, 11, 25, 16]
Класс 1 15.340577998671801
Класс 2 36.71965867669978
Класс 3 72.1295131459146
The lowest deviation is here. Класс 1 It worked.Updated the formulathe result now does not depend on how many samples each class represents. In the previous version, the result could be distorted if the number of samples differed by grade.