2
$\begingroup$

Ive been working one a gender recognition problem from dataset containing pictures features. Normally the problem is a binary classification, meaning the training contains labels -1 if it's a female and 1 if it's a male.

X_train shape = 105600 rows ( people) for 128 columns (the features)

Im using SVM classifier with scikit learn

for the prediction, I want to add a third class, 0 , meaning the classifier simply don't know if it's a male or a female.

How can this be done, if the training target does not contain this class, meaning the SVC is not gonna learn it from the train.

Can you help me figure out how can this, be done ?

Thank you very much.

$\endgroup$
1
  • 1
    $\begingroup$ I don't think it's prudent to represent this unknown as a third class, unless your training set explicitly has an "unknown" class for certain images. Instead you have the option of setting two thresholds between -1 and 1 which define your notion of certainty for each class, and if you're between the thresholds, then you're "unknown." An SVM would naturally have two thresholds defined by the separation boundary between your classes. $\endgroup$
    – Alex R.
    Jan 28, 2017 at 17:25

1 Answer 1

2
$\begingroup$

Train as usual. Then you could use the output of decision_function and predict 1 if >1, -1 if < -1, and 0 otherwise.

Alternatively you could train to predict probabilities (using probability=True in the class constructor) and only predict male if prob male > th, female if < (1-th), and "don't know" otherwise.

$\endgroup$
2
  • $\begingroup$ How you would suggest the th choosing please? $\endgroup$
    – renaud
    Jan 28, 2017 at 17:32
  • $\begingroup$ With probability=True you get true probability estimates (between 0 and 1). It's your call how certain you want to be before saying that a subject is male (80%??). $\endgroup$
    – Luca Citi
    Jan 28, 2017 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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