mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-09-28 21:45:27 +08:00
Fix cnn prediction (#14904)
* Fix CNN prediction threshold for binary classification * Use ternary operator for binary prediction --------- Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
co-authored by
Christian Clauss
parent
2f4a9fe998
commit
242bd232a9
@@ -94,7 +94,6 @@ if __name__ == "__main__":
|
||||
test_image = np.expand_dims(test_image, axis=0)
|
||||
result = classifier.predict(test_image)
|
||||
# training_set.class_indices
|
||||
if result[0][0] == 0:
|
||||
prediction = "Normal"
|
||||
if result[0][0] == 1:
|
||||
prediction = "Abnormality detected"
|
||||
# The sigmoid output is a probability in the range [0, 1].
|
||||
# Use a threshold of 0.5 to convert the probability into a binary prediction.
|
||||
prediction = "Normal" if result[0][0] < 0.5 else "Abnormality detected"
|
||||
|
||||
Reference in New Issue
Block a user