ZeroDivisionError: float division by zero

i am stuck here . kindly anyone help me how to solve this problem.

thanks in advance.

Your output complains about a “float division by zero” in line 214. You are only having one division there so you might find pretty fast that class_total[i] is 0 for some i.
My intuition is that labels.size(0) is smaller than 3 and that you initialized class_total to zero for every class before the loop in line 205.

Hope this solves your problem.

you are talking about this ?
but its not work.see

There the class label is a float, which can’t be indexed because it is just a number. class_total as you had before should be a list with zeros on line 23, then populated on the for loop in line 24.
Your problem before was that for one of your classes line 27 never happens, i.e. you probably are missing one class in your labels because by the time you arrive to the next for loop one of your class_total elements is 0.
Check your class_total before the last for loop to see what I am saying. Then go backwards inspecting labels and so on and you will quickly find the solution.