Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
158 views
in Technique[技术] by (71.8m points)

python - Interpretation of the function model.predict

I am working on medical image classification that has 23 different class.I have divided my dataset into 3 parts- train, val and test. With my model, I get an accuracy of about 75%. But I also want to predict how correctly my classes are getting classified. I have used this code that I found online for the predictions

# Model prediction
predictions = cnn.predict(test)

list_index = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
              17,18,19,20,21,22]
x = predictions
for i in range(23):
  for j in range(23):
    if x[0][list_index[i]] > x[0][list_index[j]]:
      temp = list_index[i]
      list_index[i] = list_index[j]
      list_index[j] = temp#Show the sorted labels in order from highest probability to lowest
print(list_index)

classification = ['Abdomen','Chest-Ap','Chest-Lat','CSpine-ap','CSpine-lat',
           'elbow','Foot-AP','Foot-lat','Hand-AP','Hand-lat','Hand-obli',
           'Hip-ap','Knee-AP', 'Knee-Lat', 'LSpine-ap-pa', 'LSpine-lat',
           'Pelvis-AP' , 'Shoulder-AP', 'Shoulder-Axial', 'Skull-ap-pa',
           'Skull-lat', 'TSpine-ap', 'TSpine-lat']
i=0
for i in range(10):
  print(classification[list_index[i]], ':', round(predictions[0][list_index[i]] * 100, 2), '%')

And this the output :

The testing accuracy is : 75.40650367736816 %
[15, 10, 3, 1, 0, 12, 13, 14, 16, 2, 17, 21, 22, 9, 11, 4, 20, 18, 6, 8, 19, 7, 5]
LSpine-lat : 46.92 %
Hand-obli : 14.4 %
CSpine-ap : 12.78 %
Chest-Ap : 8.69 %
Abdomen : 6.51 %
Knee-AP : 2.08 %
Knee-Lat : 1.87 %
LSpine-ap-pa : 1.06 %
Pelvis-AP : 0.9 %
Chest-Lat : 0.87 %

1)I am unable to interpret the output, if someone can explain it to me how exactly does the function work. Do this mean among the images in the test set there are 46.92 % images that look like LSpine-lat?

2)Also, would you use the predict function on your test images or it can also be used on your entire dataset.

question from:https://stackoverflow.com/questions/65842447/interpretation-of-the-function-model-predict

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...