NYC Data Science Academy| Blog
Bootcamps
Lifetime Job Support Available Financing Available
Bootcamps
Data Science with Machine Learning Flagship ๐Ÿ† Data Analytics Bootcamp Artificial Intelligence Bootcamp New Release ๐ŸŽ‰
Free Lesson
Intro to Data Science New Release ๐ŸŽ‰
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook Graduate Outcomes Must See ๐Ÿ”ฅ
Alumni
Success Stories Testimonials Alumni Directory Alumni Exclusive Study Program
Courses
View Bundled Courses
Financing Available
Bootcamp Prep Popular ๐Ÿ”ฅ Data Science Mastery Data Science Launchpad with Python View AI Courses Generative AI for Everyone New ๐ŸŽ‰ Generative AI for Finance New ๐ŸŽ‰ Generative AI for Marketing New ๐ŸŽ‰
Bundle Up
Learn More and Save More
Combination of data science courses.
View Data Science Courses
Beginner
Introductory Python
Intermediate
Data Science Python: Data Analysis and Visualization Popular ๐Ÿ”ฅ Data Science R: Data Analysis and Visualization
Advanced
Data Science Python: Machine Learning Popular ๐Ÿ”ฅ Data Science R: Machine Learning Designing and Implementing Production MLOps New ๐ŸŽ‰ Natural Language Processing for Production (NLP) New ๐ŸŽ‰
Find Inspiration
Get Course Recommendation Must Try ๐Ÿ’Ž An Ultimate Guide to Become a Data Scientist
For Companies
For Companies
Corporate Offerings Hiring Partners Candidate Portfolio Hire Our Graduates
Students Work
Students Work
All Posts Capstone Data Visualization Machine Learning Python Projects R Projects
Tutorials
About
About
About Us Accreditation Contact Us Join Us FAQ Webinars Subscription An Ultimate Guide to
Become a Data Scientist
    Login
NYC Data Science Acedemy
Bootcamps
Courses
Students Work
About
Bootcamps
Bootcamps
Data Science with Machine Learning Flagship
Data Analytics Bootcamp
Artificial Intelligence Bootcamp New Release ๐ŸŽ‰
Free Lessons
Intro to Data Science New Release ๐ŸŽ‰
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook
Graduate Outcomes Must See ๐Ÿ”ฅ
Alumni
Success Stories
Testimonials
Alumni Directory
Alumni Exclusive Study Program
Courses
Bundles
financing available
View All Bundles
Bootcamp Prep
Data Science Mastery
Data Science Launchpad with Python NEW!
View AI Courses
Generative AI for Everyone
Generative AI for Finance
Generative AI for Marketing
View Data Science Courses
View All Professional Development Courses
Beginner
Introductory Python
Intermediate
Python: Data Analysis and Visualization
R: Data Analysis and Visualization
Advanced
Python: Machine Learning
R: Machine Learning
Designing and Implementing Production MLOps
Natural Language Processing for Production (NLP)
For Companies
Corporate Offerings
Hiring Partners
Candidate Portfolio
Hire Our Graduates
Students Work
All Posts
Capstone
Data Visualization
Machine Learning
Python Projects
R Projects
About
Accreditation
About Us
Contact Us
Join Us
FAQ
Webinars
Subscription
An Ultimate Guide to Become a Data Scientist
Tutorials
Data Analytics
  • Learn Pandas
  • Learn NumPy
  • Learn SciPy
  • Learn Matplotlib
Machine Learning
  • Boosting
  • Random Forest
  • Linear Regression
  • Decision Tree
  • PCA
Interview by Companies
  • JPMC
  • Google
  • Facebook
Artificial Intelligence
  • Learn Generative AI
  • Learn ChatGPT-3.5
  • Learn ChatGPT-4
  • Learn Google Bard
Coding
  • Learn Python
  • Learn SQL
  • Learn MySQL
  • Learn NoSQL
  • Learn PySpark
  • Learn PyTorch
Interview Questions
  • Python Hard
  • R Easy
  • R Hard
  • SQL Easy
  • SQL Hard
  • Python Easy
Data Science Blog > R > What Makes it Funny?

What Makes it Funny?

Adam Cone
Posted on May 24, 2016

Adam Cone is currently in the NYC Data Science Academy 12 week full time Data Science Bootcamp program taking place between April 11th to July 1st, 2016. This post is based on his third class project - Web Scraping (due on the 6th week of the program). The video of his presentation is here:

At Slightly Warped I found 387 offensive jokes in text form with no pictures. I wrote a Python script to scrape these 387 offensive jokes off of the website using the bs4, requests, and string libraries.

After decomposing each joke into a Python list of words, I wrote further code to obtain, for each joke, the values of three integer variables: word count, curse word count, and number of exclamation points. For this project a curse word was an element of list of 41 character strings that I cobbled together from internet research and my own imagination. I considered these three variables independent.

I read each of the 387 jokes with the intent to gather, as the independent variable, whether I found each joke funny. However, I noticed internally that whether a joke was funny wasn't the determination that interested me. I noticed that the jokes, even when I liked them, would also be associated often with unpleasant feelings, like sadness or disgust. I imagine this is why they are clearly labeled "offensive jokes" and not simply "jokes". Generally, this alloyed feeling led me to wonder whether, on balance, I was pleased I had read the joke or not. So, although I set out with the intention to determine whether a joke was funny, I ended up recording whether a joke was worthwhile: was I pleased that I had heard it? This variable was a 2-level factor: 'yes' or 'no'. Of the 387 jokes, I found 87 worthwhile ('yes') and 300 not worthwhile ('no').

With three independent integer variables and one dependent factor variable, I imported the data into R as a data frame. I proceeded to investigate whether each independent variable, on its own, had a significant relationship to the dependent variable. I predicted that I would find so significant relationships between any of the individual independent variables and the dependent variable.

First, I looked at word count. The distribution of word count for the 387 jokes is given in the histogram below.

1. Word Count Histogram

The majority of the jokes are relatively short (30 words or fewer), with a few long outliers. To visually determine the distribution of word count at each level of the dependent variable, I used a box plot, below.

2. Word Count Box Plot

These distributions looked very similar to me. The median for 'no' is 16 and the median for 'yes' is 18. So far, I saw little evidence of a significant relationship between word count and subjective joke worthwhileness.

I performed Welch's t-test to determine whether the 'yes' and 'no' populations might have different mean word counts. Welch's t-test requires the assumptions of normality of the sample mean; and independent, random sampling. To verify normality, I confirmed that each population has N>30 (87 for 'yes', 300 for 'no'). On it's own, this would have been sufficient, but I also checked the qqplots for each sample, and they seemed acceptable. Verifying independence was more difficult: these jokes had been, as far as I could tell, curated by one Jason Donner. Presumably, he didn't pick random jokes. To pass the independence/randomness requirement, I consider my populations as follows. The 'no' population is the total set of jokes that Jason Donner would publish on his site if he read them, and that I wouldn't rate as worthwhile. The 'yes' population is the total set of jokes that Jason Donner would publish on his site if he read them, and that I would rate as worthwhile. Based on this definition, I'm comfortable asserting that the samples I have were the result of an independent and random process by which Jason Donner was exposed to the jokes.

H_0 for Welch's t-test is that the 'yes' and 'no' populations have the same mean word count. The p-value for the test was ~7.6% so I fail to reject H_0 based on the standard 5% significance level. So, overall, I found little evidence for a relationship between word count and my response to the jokes.

Next, I looked at the curse word variable. The sample curse word distribution is illustrated in the following histogram.

3. Curse Word Histogram

310 of the 387 jokes contained none of the 41 words I identified as curse words. To determine whether the distribution of curse words in the 'yes' and 'no' samples differed, I used a violin plot. I used a violin plot instead of a box plot over my default preference because the box plot had too much over-plotting to clearly communicate the distributions.

4. Curse Word Violin Plot

The median number of curse words in both the 'yes' and 'no' sample jokes was 0. The distribution for the 'yes' sample looks significantly taller, but it's possible that it just is accounting for a few outliers, which are visible in the histogram. Both distributions have heavy bases and don't look that dissimilar to me.

Again, after checking normality with qqplots and having already verified independence/randomness from the word count EDA, I performed Welch's t-test on the curse word samples. The p-value for the Welch's t-test was ~4.1%. While this is technically significant at the 5% significance level, it seemed unconvincing to me, given the violin plot. To further investigate, I considered each joke as either containing a curse word or not: the number of curse words became irrelevant. I thought this might mitigate the effect of the few heavy curse-word outliers. This left me with the following table.5. Curse Word Table

Now, since I had, in my own tortured way, already verified independent, random sampling, the only assumption necessary for the chi-squared test, I ran a chi-squared test to determine whether these variables, with curse words considered as a binary variable, were independent.

H_0 for the chi-squared test was that the variables are independent. The mosaic plot for the chi-square test was

6. Curse Word Mosaic

None of the four variable combinations yielded large residuals. Unsurprisingly, the p-value for the test was ~11.3%, which is not significant at the standard 5% significance level. Therefore, I failed to reject H_0.

So, my take-away is that I failed to find convincing evidence for a relationship between curse words and my response to the jokes. Although, when considered as an integer variable, the curse words showed a technically significant relationship to my response, the p-value was high and I sense that this was largely a result of a few outliers with high curse word count.

Finally, I investigated the relationship between exclamation points and my responses to the jokes. Here is the distribution of exclamation points in the entire sample of 387 jokes.

7. Exclamation Histogram

349 of 387 jokes had no exclamation points. Most of the rest had one exclamation point, with one outlier of 5 exclamation points. To visualize the distributions of exclamation points in the 'no' and 'yes' samples, I used a violin plot, for the same reasons outlined above.8. Exlamation Violin Plot

The median number of exclamation points in both samples was 0. The 'yes' distribution looked significantly taller and thinner to me. As before, I looked to verify a significant relationship with Welch's t-test after verifying normality. H_0 for the Welch's t-test was that the 'yes' and 'no' populations had the same mean exclamation point count. The p-value for Welch's t-test was ~2.3%, so I rejected H_0.

Now, although this p-value was stronger that the p-value for the curse word Welch's t-test, I wasn't completely sure this wasn't also largely due to the few outliers. Therefore, as with the curse words, I considered the exclamation point variable as binary: each joke either had at least one exclamation point or didn't. This way, the outliers with large numbers of exclamation points wouldn't have an effect. The resulting table was:

9. Exclamation Table

Now, since I had, in my own tortured way, already verified independent, random sampling, the only assumption necessary for the chi-squared test, I ran a chi-squared test to determine whether these variables, with exclamation points considered as a binary variable, were independent.

H_0 for the chi-squared test was that the variables are independent. The mosaic plot for the chi-square test was

10. Exclamation Mosaic

Here, there is a significant residual for the combination of worthwhile jokes and exclamation points: more than expected! The p-value for the chi-squared test was ~0.4%, which is significant at the standard 5% significance level.

Overall, I see significant evidence of a relationship between exclamation points and my response to the sample jokes. The Welch's t-test p-value was low and I can't dismiss this as some kind of outlier effect, since the chi-squared p-value was even lower.

Summary and Conclusion

In conclusion, I failed to find significant evidence of single-variable relationships between word count or curse words and joke response. I did find significant evidence of a relationship between exclamation points and joke response. This was a surprise.

If I worked on this project further, would like to pursue

  • responses from different people,
  • multi-variable relationships, and
  • honing response metric.

About Author

Adam Cone

Adam Cone received his BA with honors in Math from NYU, where he conducted original research in computational neural science and experimental fluid mechanics. He received his MA in Applied Math from UCLA, concentrating in differential equations and...
View all posts by Adam Cone >

Related Articles

AWS
Automated Data Extraction and Transformation Using Python, OpenAI, and AWS
Python
Can the data from EA's FIFA Potential Rating Help Bettors?
Data Visualization
Using Data to Get Cats Adopted on petfinder.com
Data Visualization
Wine 101: Gathering Data From Vivino
Python
Using Data to Analyze The Library of Audible

Leave a Comment

Cancel reply

You must be logged in to post a comment.

Torri July 9, 2016
This web site is actually a walk through for all the information you desired about this and didโ€™t know who to ask. Glimpse here, and youโ€™ll undoubtedly find it.

View Posts by Categories

All Posts 2399 posts
AI 7 posts
AI Agent 2 posts
AI-based hotel recommendation 1 posts
AIForGood 1 posts
Alumni 60 posts
Animated Maps 1 posts
APIs 41 posts
Artificial Intelligence 2 posts
Artificial Intelligence 2 posts
AWS 13 posts
Banking 1 posts
Big Data 50 posts
Branch Analysis 1 posts
Capstone 206 posts
Career Education 7 posts
CLIP 1 posts
Community 72 posts
Congestion Zone 1 posts
Content Recommendation 1 posts
Cosine SImilarity 1 posts
Data Analysis 5 posts
Data Engineering 1 posts
Data Engineering 3 posts
Data Science 7 posts
Data Science News and Sharing 73 posts
Data Visualization 324 posts
Events 5 posts
Featured 37 posts
Function calling 1 posts
FutureTech 1 posts
Generative AI 5 posts
Hadoop 13 posts
Image Classification 1 posts
Innovation 2 posts
Kmeans Cluster 1 posts
LLM 6 posts
Machine Learning 364 posts
Marketing 1 posts
Meetup 144 posts
MLOPs 1 posts
Model Deployment 1 posts
Nagamas69 1 posts
NLP 1 posts
OpenAI 5 posts
OpenNYC Data 1 posts
pySpark 1 posts
Python 16 posts
Python 458 posts
Python data analysis 4 posts
Python Shiny 2 posts
R 404 posts
R Data Analysis 1 posts
R Shiny 560 posts
R Visualization 445 posts
RAG 1 posts
RoBERTa 1 posts
semantic rearch 2 posts
Spark 17 posts
SQL 1 posts
Streamlit 2 posts
Student Works 1687 posts
Tableau 12 posts
TensorFlow 3 posts
Traffic 1 posts
User Preference Modeling 1 posts
Vector database 2 posts
Web Scraping 483 posts
wukong138 1 posts

Our Recent Popular Posts

AI 4 AI: ChatGPT Unifies My Blog Posts
by Vinod Chugani
Dec 18, 2022
Meet Your Machine Learning Mentors: Kyle Gallatin
by Vivian Zhang
Nov 4, 2020
NICU Admissions and CCHD: Predicting Based on Data Analysis
by Paul Lee, Aron Berke, Bee Kim, Bettina Meier and Ira Villar
Jan 7, 2020

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day ChatGPT citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay football gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income industry Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI

NYC Data Science Academy

NYC Data Science Academy teaches data science, trains companies and their employees to better profit from data, excels at big data project consulting, and connects trained Data Scientists to our industry.

NYC Data Science Academy is licensed by New York State Education Department.

Get detailed curriculum information about our
amazing bootcamp!

Please enter a valid email address
Sign up completed. Thank you!

Offerings

  • HOME
  • DATA SCIENCE BOOTCAMP
  • ONLINE DATA SCIENCE BOOTCAMP
  • Professional Development Courses
  • CORPORATE OFFERINGS
  • HIRING PARTNERS
  • About

  • About Us
  • Alumni
  • Blog
  • FAQ
  • Contact Us
  • Refund Policy
  • Join Us
  • SOCIAL MEDIA

    ยฉ 2025 NYC Data Science Academy
    All rights reserved. | Site Map
    Privacy Policy | Terms of Service
    Bootcamp Application