I'm facing with multi class classification task in Python.
I've predicted the classes using fit () and predict () functions and want to make a custom function which will calculate the share of right predicted classes in the top 3 highest classes from predict_proba (). For example, if the actual class is '2' and the model predicts class: '1' and the top high classes from predict_proba are the following: ['1','3','2'] the custom function will display 1.0 score because the right prediction (actual) is in this top probability interval.
How can this function be calculated?
Best Answer
I believe you are looking for the "inverted" zero-one-loss. Just calculate the 0-1 loss and then deduct it from the total number of predictions made, should give you your solution.