"One may smile, and smile, and be a villain," William Shakespeare, Hamlet

Hamlet may have been able to see through a fake smile, but it's hard for most of us. People smile out of politeness, awkwardness or frustration, so how can we tell if a smile is real?

One project at MIT's celebrated Media Lab aims to do just that. It began by trying to "zoom into different kinds of smiles and deconstruct them into low level facial features, and then we wondered whether it's possible to train a computer to recognize some of the smiles automatically," said M. Ehsan Hoque, a research assistant at the lab.

To gather his data, Hoque and his colleague Rosalind Picard gave had test subjects complete a tedious questionnaire. But the questionnaire was rigged: when the subjects tried to submit their answers the page refreshed and destroyed their work. Sure enough, a common response to this frustrating task was a pained smile.

The researchers picked out facial features of these test subjects—such as "action unit 6," the muscles that raise the cheeks—and compared them to features of the same subjects making genuine smiles. Then they created an algorithm to try to guess whether a smile was faked.

Their algorithm held its own against humans when looking at a genuine smile, but it really shined in picking out the fakes, as Hoque explained:

Humans performed below chance whereas the algorithm performed more than 90%. One possible explanation is that we humans usually can zoom out and try to interpret an expression, whereas a computer algorithm can utilize the nitty-gritty details of a signal, which is much more enriching.

Hoque hopes the research can one day be applied to help people with autism spectrum disorders, which impairs the ability to recognize others' emotions. Read the paper here.

Also on HuffPost: