0

I want to have the prediction probabilities of each class in a binary classification as sklearn's predict_proba, but with tensorflow.

in sklearn I managed to get a probability for each class with predict_proba and created a csv file like :

final_predictions = final_model.predict_proba(X_test)

sample_submission = pd.DataFrame(
    data = {
        'Id':test_df.Id,
        'class_0':final_predictions[:,0],
        'class_1':final_predictions[:,1]
    }
)

sample_submission.to_csv('submission.csv',index=False)

I want to recreate the same result but for tensorflow, but I'm stuck because tensorflow doesn't have a predict_proba method to get a probability for each class.

  • Could you provide (some of the) TensorFlow code that you have used? – nscholten Jul 22 '23 at 14:06
  • predict_pro = model.predict_proba(X_test) returns the following error AttributeError: 'Sequential' object has no attribute 'predict_proba' – Mamady Konaté Jul 22 '23 at 14:33
  • I think this one should answer your question: https://stackoverflow.com/questions/68971378/attributeerror-sequential-object-has-no-attribute-predict-proba – mhenning Jul 22 '23 at 22:22

0 Answers0