Here is a bit of code that will give you the top 3 predictions and their % probabilities.

#function to get the arg_first_max, arg_second_max etc.,

def argNmax(a, N):

return np.argpartition(a.ravel(), -N)[-N]

#predict

prd_cat, num_cat, prob, data_text_c,first_cat, second_cat, third_cat = [],[],[],[],[],[],[]

for data_text in df_val[‘text’]:

cat_i, num_cat_i,prob_i = learn.predict(data_text)

pro = prob_i.numpy()*100

arg1max,arg2max,arg3max = argNmax(pro,1),argNmax(pro,2),argNmax(pro,3)

first_cat_percent = data_clas.classes[arg1max] + " " + str(round(pro[arg1max],2)) + “%”

second_cat_percent = data_clas.classes[arg2max] + " " + str(round(pro[arg2max],2)) + “%”

third_cat_percent = data_clas.classes[arg3max] + " " + str(round(pro[arg3max],2)) + “%”

prd_cat.append(data_clas.classes[arg1max])

first_cat.append(first_cat_percent)

second_cat.append(second_cat_percent)

third_cat.append(third_cat_percent)