Am building a model using K nearest neighbours. The model predicts if someone has cancer or not. 1 for true, 0 for false. I need the model other than predicting presence of cancer or not giving a 0 or 1,how can i make the model also show the probability of the prediction being 1?
Edit:Am doing a project and it specifies i use the K nearest Neighbour classifier
CodePudding user response:
You must use a regressor instead of a classifier, meaning that a regression model can give you a probability of someone having a concern or not and the probability between the two values of 0 and 1, 0~1 (0~100%).
CodePudding user response:
probability = model.predict_proba(X)
This gives you an array of probabilities of being 0 and 1.
If you need to check the probability of being 1 try
probability_class_1 = model.predict_proba(X)[:, 1]