I am a university student studying machine learning.
I am writing a two-class classification program using python, tensorflow, and keras.
The classification probability can be model.predict
, but
I don't know how to output the probability value for which data.
Below is a partial program for probability values.
result=model.predict(X_test)
import csv
with open('aaa.csv', 'w', newline=')ascsv_file:
title=['0', '1']
writer=csv.writer(csv_file)
writer.writerow (title)
writer.writerows (result)
I want to improve this, but I don't know how to do it.
Ideally
Probability value
that is probability value 1 with filename 0
1.png 0.99990.0001
2.png 0.99990.0001
.
.
.
output as shown in .
Thank you for your cooperation.
python machine-learning tensorflow keras
I don't have the first half of the code you suggested.
Assume that it is a binary classification problem and that the number of labels was also learned in 2.
The result is [[probability that it is label1 of data 1, probability that it is label2 of data], [data2...]...]
It will be returned in the form of , so I think you should do the following.
with open('aaa.csv', 'w', newline=')ascsv_file:
title=['0', '1']
writer=csv.writer(csv_file)
for n, lin zip (X_test [index of filename], result):
writer.writerows ([n, title[0], r[0], title[1], r[1])
If the number of labels is one, not two,
(If it is a model that outputs a probability of 0)
The result only returns the probability of zero, so the probability of one should be a complement
© 2024 OneMinuteCode. All rights reserved.