Commit 73f97268 authored by MithilaGunasinghe's avatar MithilaGunasinghe

giving class label from probabilities

parent c9e43f40
#!/usr/bin/env python
'''
Author : Gunasinghe M.D.
IT NUM : IT17043342
'''
# Giving class label from probabilities
from keras.utils import np_utils
import numpy as np
def probas_to_classes(y_pred):
if len(y_pred.shape) > 1 and y_pred.shape[1] > 1:
return categorical_probas_to_classes(y_pred)
return np.array([1 if p > 0.5 else 0 for p in y_pred])
def categorical_probas_to_classes(p):
return np.argmax(p, axis=1)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment