# Frown for a sex change, or, how do I unbork the “FacialGender” classifier in 11.2?

The limits of machine learning. I thought the new "FacialGender" option for Classifier would be an amusing thing to explore.

So far, so good. But that's me with bed-head. So let's try a picture after I'm a bit more cleaned up.

Oh.

It turns out you can confuse the classifier just by changing your facial expression. (Poking out your tongue is apparently male behaviour, by the way.)

I was interested in knowing if the classifier was picking out the more obvious facial differences between the sexes – the ones we can all subconsciously pick in a fraction of a second – or whether it was being bamboozled by mere gender presentation. So I checked it on photos of Riley J Dennis, a transgender woman with a rather obvious Adam's apple who writes for Everyday Feminism, and Lea DeLaria, a self-described butch lesbian, known for playing Big Boo on Orange Is the New Black. The classifier coded Riley as female and Lea as male. While some might argue the point on the former, the latter is clearly incorrect. (Lest you think I'm making a political statement here, I also tried a photo of Jon Bon Jovi in his 1987 big-hair days – the classifier says female!)

The classifier gets Ellen De Generes right, but is confused by Samira Wiley: the photo on her Wikipedia page gets classified as female, but this picture of her playing Poussey Washington from Orange Is the New Black codes as male. Here is that result along with the one for DeLaria.

At this point it became clear that the classifier has not been appropriately calibrated to detect sex. Since this is a Q&A site, I better phrase this as a question:

Is there a way to improve built-in classifiers, especially this one, with further training and feedback where it gets it wrong?

And when people mistakenly call me "Sir", do I just need to smile?

• lol -- that is all (p.s. nice to see you around) – Mr.Wizard Sep 30 '17 at 1:36
• Oh, this is going to be fun at immigration kiosks around the world.... – user21 Sep 30 '17 at 1:38
• The point of 'feedback' to math models is one discussed in Weapons of Math Destruction – user21 Sep 30 '17 at 1:41
• Women smile, men frown. What else do you need to know? – bill s Sep 30 '17 at 1:42
• We just tried it (on a female face—I have a beard so I can't get it to think I'm a girl), and it's not hard to make the classifier change its mind. It seems to be more sensitive to the hair than the smile. – Szabolcs Sep 30 '17 at 10:36

Practically, is there anything you can do? Probably not within reason.

Maybe here's a manageable suggestion: You've suggested in your example,that the classifier is picking up whether the face is smiling or not and this is informing its results (because for some reason one of the gender categories had more smiling in it). In that case you could explicitly try to debias for smiling. But this would really just be creating a classifier for smiling and then essentially penalizing predictions that went along with the bias by an amount proportional to the bias's strength. For example, we'd be interested in:

P(actualCategory = "female" | prediction = "female" && "face" = "smiling")

And we're worried about the fact that there's a bias because this:

P(prediction = "female" | "face" = "smiling")

isn't 50%.

If we can get an estimate for the bias and have a classifier for smiling, then we should just be able to update our result with Bayes' rule.

Is there a way to improve built-in classifiers, especially this one, with further training and feedback where it gets it wrong?

Am I missing something? I didn't expect the answer to be so obvious: https://www.wolfram.com/language/11/external-services/train-a-classifier-function-with-images-from-the-w.html?product=mathematica

Edit:

Doesn't really answer the question - I don't want to train a new custom classifier. I want to know if we can unbork the built-in ones

I don't think it would be hard (for Wolfram) to implement a hint suggestion system. We can already train ImageIdentify via the "Image Identification Project" web site:

https://www.imageidentify.com/

The ability to train and fine tune AI is a good idea. However when it comes to generic things like Facial Expressions (7 billion people times an average of 21 facial expressions) training is going to take a long, long time. You'd need a really smart system to train the AI system... eg something crafty like a Captcha Phone Unlock facial recognition app that feeds the Image Identification Project.

Training specific Buildings/Houses would be far easier, faster and accurate. Mere mortals could do that and its why I recommend putting in a feature request to do the same for Classifier and its various options as we can for ImageIdentify:

An interesting quote from Stephen Wolfram that talks to this topic:

"Like many projects we tackle for the Wolfram Language, developing ImageIdentify required bringing many diverse things together. Large-scale curation of training images. Development of a general ontology of picturable objects, with mapping to standard Wolfram Language constructs. Analysis of the dynamics of neural networks using physics-like methods. Detailed optimization of parallel code. Even some searching in the style of A New Kind of Science for programs in the computational universe. And lots of judgement calls about how to create functionality that would actually be useful in practice."

Ps Does this question remind anyone else of Silicon Valley S4 E3, where Erlich goes to Uni and gives students assignments to "classify" food types for their Seefood app? Very funny series if you haven't seen it.

• Doesn't really answer the question - I don't want to train a new custom classifier. I want to know if we can unbork the built-in ones. – Verbeia Oct 9 '17 at 4:44