0
$\begingroup$

I am looking towards a solution where classification algorithms produce output with some confidence value. but I am confused whether classification algorithms are able to produce results with percentage of confidence? Thanks

$\endgroup$
0
$\begingroup$

Some classification algorithms can indeed return a probability distribution over the considered classes (see Wikipedia on probabilistic classification).

In the topic of your question you're asking about Decision Trees. Well, these have their limitations in terms of providing probability estimates (see this paper on probability estimates from decision trees).

In case you would like to play around with this, it's very easy to start with scikit-learn:

import numpy as np
from sklearn.tree import DecisionTreeClassifier

dtc = DecisionTreeClassifier()

# training samples
X = np.array([[1, 1, 0],
              [1, 1, 0],
              [0, 0, 1],
              [0, 0, 1]])

# target values for training samples
y = np.array([0, 0, 0, 1])

dtc.fit(X, y)

print 'Class probabilities for training samples:'
print dtc.predict_proba(X)
print 'Probabilities for previously unseen samples:'
for sample in ((1, 0, 1), (0, 0, 1), (1, 1, 1), (0, 0, 0)):
     print 'Sample {}. Result: {}'.format(sample, dtc.predict_proba(sample))

This code returns following results:

Class probabilities for training samples:
[[ 1.   0. ]
 [ 1.   0. ]
 [ 0.5  0.5]
 [ 0.5  0.5]]
Probabilities for previously unseen samples:
Sample (1, 0, 1). Result: [[ 0.5  0.5]]
Sample (0, 0, 1). Result: [[ 0.5  0.5]]
Sample (1, 1, 1). Result: [[ 0.5  0.5]]
Sample (0, 0, 0). Result: [[ 1.  0.]]

At this scale the results are easily interpretable:

  • a sample of features (1, 1, 0) is classified as 0 with 100% probability
  • a sample of features (0, 0, 1) is classified 50/50 as 0 or 1. etc.

This brings us to an important question of how accurate is your model?

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.