A recent study from Virginia Tech tackled this very question. Their study is called We Are Humor Beings: Understanding and Predicting Visual Humor.
According to this MIT Technology Review, "Arjun Chandrasekaran from Virginia Tech and pals say they’ve trained a machine-learning algorithm to recognize humorous scenes and even to create them. They say their machine can accurately predict when a scene is funny and when it is not, even though it knows nothing of the social context of what it is seeing."
They started by utilizing Amazon's Mechanical Turk service to create and amass 6,400 funny and unfunny scenes using a clip art program. For the funny scene submissions, they also asked for a one sentence description describing why the scene was funny. Then, they asked the AMT's to rate the level of funniness in each scene.
Above are some scenes from their study. The scene submissions led them to ask whether or not the funny object could be replaced by a similar, but unfunny counterpart in an attempt to home in on the semantics of humor. So they had AMT's create 15,000 alternatives to the funny scenes.
According to the study, the algorithm is relatively good at predicting the funniness of a scene. It finds that animate objects like people and animals tend to lead to a funnier scene than say inanimate objects.
These studies still make me wonder if we know enough about what makes something funny to tell if the machine really gets humor. The MIT Technology Review really captures this by saying, "Of course, an important question is what exactly the machine is learning to do. In this work, funniness may be a proxy for something else entirely. Indeed, if Chandrasekaran and co’s paper were rewritten with every instance of the word “funniness” replaced with the word “oddness” or “incongruity” or “unexpectedness,” the results would be no less valid."
Still, this is one of the most fascinating studies I've read in the field of computational humor. I look forward to contributing to the discussion by conducting my own comedy AI experiment soon.