Same prediction for each input or configuration

for each type of input i am getting the same output positive 100% can anyone tell me the problem in code
working app url-https://st-heart-disease-prediction-jrqe6broeuunptpczwvf6h.streamlit.app/
github repo-GitHub - Mayankpathak07/st-heart-disease-prediction

Hi @Mayank_Pathak

This may be an issue with the model and prediction rather than the app implementation. To verify this, could you see if prediction is as intended in Jupyter notebook versus the app implementation.

I’d recommend to also print out the values of prediction and prediction_proba variables directly (e.g. st.write(prediction) and st.write(prediction_proba)) in the app so that we can see while diagnosing the app how the changes would influence the variables. Also it is worth looking into printing out the full variables prediction versus slicing a specific value from the list as in prediction[0] while diagnosing.

Looking at the performance it seems that random forest gave 100% accuracy which is abnormally high and would signal further investigation into the underlying prediction.

In the app, could you also print out a confusion matrix which would also help in diagnosing the prediction by allowing us to see the predicted class labels of all classes.

Hope this helps.

I can see at least two things that are off.

  1. The model is trained with scaler.
scalar = StandardScaler().fit(X_train)

X_train = scalar.transform(X_train)
X_test = scalar.transform(X_test)

This would mean if you use this model, you also need to scale your input in prediction.

  1. In your streamlit app
if prediction[0] == 1:
    bg_color = 'red'
    prediction_result = 'Positive'
else:
    bg_color = 'green'
    prediction_result = 'Negative'

Probably a better cutoff is:

if prediction[0] > 0.5: