'Tensorflow classification predictions
I'm dealing with a simple classification problem and I'm new to it. I want it to give results like 0 and 1, but it gives a percentage ending as below. how can i solve this? There are 2 targets in the label column in the data set.
input_dict = {name: tf.convert_to_tensor([value]) for name, value in sample.items()}
predictions = model.predict(input_dict)
prob= tf.nn.sigmoid(predictions[0])
Thank you.
Solution 1:[1]
You can also set a threshold for model prediction like 50/60/70 % , if threshold > 50/60/70% , label it as long as it is short.
input_dict = {name: tf.convert_to_tensor([value]) for name, value in sample.items()}
predictions = model.predict(input_dict)//Normal returns a confidence score.
prob= tf.nn.sigmoid(predictions[0])
if prob > 0.6 : //(Threshold is 60% here you can change according to your requirement)
print("long")
else:
print("short")
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Tensorflow Support |