Skip to content
Advertisement

Input values return prediction with percentage [closed]

Hi I have write machine learning use decision tree model. I create webapp that user can input and web will call to model by flask api and then show result on webapp but my result have only Yes/No. It possible if the result can show percentage how much this input will yes/no, Example Yes 76%

Advertisement

Answer

You could use predict_proba() as it returns the class probabilities of the input samples X.

probs = clf.predict_proba(X)
# probs will output the probability of the prediction on each class. 

You can read more about it in the documentation and in this other post with a similar question.

https://scikit-learn.org/stable/modules/generated/sklearn.tree.DecisionTreeClassifier.html

Scikit-Learn Decision Tree: Probability of prediction being a or b?

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement