<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Geospatial Analysis on Max Woolf&#39;s Blog</title>
    <link>https://minimaxir.com/category/geospatial-analysis/</link>
    <description>Recent content in Geospatial Analysis on Max Woolf&#39;s Blog</description>
    <image>
      <title>Max Woolf&#39;s Blog</title>
      <url>https://minimaxir.com/android-chrome-512x512.png</url>
      <link>https://minimaxir.com/android-chrome-512x512.png</link>
    </image>
    <generator>Hugo</generator>
    <language>en</language>
    <copyright>Copyright Max Woolf © 2026</copyright>
    <lastBuildDate>Tue, 13 Aug 2024 10:37:00 -0700</lastBuildDate>
    <atom:link href="https://minimaxir.com/category/geospatial-analysis/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>AI Seinfeld was the peak of AI-generated content. It will never happen again.</title>
      <link>https://minimaxir.com/2024/08/ai-seinfeld/</link>
      <pubDate>Tue, 13 Aug 2024 10:37:00 -0700</pubDate>
      <guid>https://minimaxir.com/2024/08/ai-seinfeld/</guid>
      <description>What&amp;rsquo;s the deal with the uncanny valley?</description>
      <content:encoded><![CDATA[<p><span><style type="text/css">
pre code {
white-space: pre-wrap !important;
word-break: normal !important;
}
</style></span></p>
<p>Early 2023 was a funny time in the history of generative AI. On November 30th 2022, <a href="https://openai.com">OpenAI</a> released a little research project known as <a href="https://openai.com/chatgpt/">ChatGPT</a>. The launch of ChatGPT began the period where large language models properly entered the mainstream outside of tech enthusiasts and ended soon after the <a href="https://minimaxir.com/2023/03/new-chatgpt-overlord/">launch</a> of ChatGPT API in March 2023 that spawned thousands of AI-powered apps. That was when the limitations and problems with LLMs also went mainstream, such as plagiarism, hallucinations, and low-quality slop replacing human-generated content at an objectively worse quality.</p>
<p>In December 2022, <a href="https://www.mismatchmedia.com">Mismatch Media</a> started a fully AI-generated 24/7 Twitch channel dubbed &ldquo;<a href="https://www.twitch.tv/watchmeforever">WatchMeForever</a>&rdquo;. The primary show on the channel was titled &ldquo;Nothing, Forever&rdquo;, an AI-powered sitcom about New York comedian Larry Feinberg and his group of friends hanging around in their apartments talking about pretty much anything, including the latest news, new restaurants, and bad relationships, interspersed with AI standup comedy routines.</p>
<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube-nocookie.com/embed/heKLe2NLccg?autoplay=0&amp;controls=1&amp;end=0&amp;loop=0&amp;mute=0&amp;start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"></iframe>
    </div>

<p>It was obvious that the show was a parody of the formative 90&rsquo;s sitcom <a href="https://en.wikipedia.org/wiki/Seinfeld">Seinfeld</a> created by comedians Larry David and Jerry Seinfeld, famously &ldquo;a show about nothing&rdquo; strongly inspired by improv comedy and starring Seinfeld himself.</p>
<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube-nocookie.com/embed/Lx1xPBLDh80?autoplay=0&amp;controls=1&amp;end=0&amp;loop=0&amp;mute=0&amp;start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"></iframe>
    </div>

<p>The show, dubbed &ldquo;AI Seinfeld&rdquo; by the community, used a script powered by the GPT-3 API, the voices were powered by Microsoft&rsquo;s <a href="https://learn.microsoft.com/en-us/azure/ai-services/speech-service/text-to-speech">Azure AI Speech</a> API with predefined voices from their <a href="https://speech.microsoft.com/portal/voicegallery">Voice Gallery</a>, and the scenes were rended using the <a href="https://unity.com">Unity</a> game engine along with purchased models/scenes/sounds/etc from the <a href="https://assetstore.unity.com">Unity Asset Store</a>.</p>
<p>AI Seinfeld was <strong>interestingly imperfect</strong>: the laugh track fired at inappropriate times, the standup routine repeatedly made the same joke such as &ldquo;What did the fish say when he hit the wall?&rdquo; (Damn!), and awkward silences at the end of scenes.</p>
<p>In February 2023, AI Seinfeld quickly went viral organically after its AI weirdness was a surprising complement for Seinfeld&rsquo;s style of weirdness, with many watchers being surprised at both its accuracy to the show and easily sharable metahumor. At its peak, AI Seinfeld had over 10,000 concurrent watchers on Twitch, putting it squarely in one of the top streams on the platform.</p>
<p>AI Seinfeld died as quickly as it rose: after a ban and subsequent revamp, the view count cratered, and as of August 2024, the Twitch stream hovers below 10 watchers, with no significant changes made since the previous year, and Mismatch Media has no social footprint since last year. Could there be another AI Seinfeld with the rapid advancements in generative AI? Unfortunately, there are too many factors — technical, societal, and comedic — working against a theoretical next-generation AI-generated sitcom.</p>
<h2 id="the-rise-of-ai-seinfeld">The Rise of AI Seinfeld</h2>
<p>AI Seinfeld launched before the release of the ChatGPT API; instead, they used the GPT-3 API, notably the <code>text-davinci-003</code> model which was OpenAI&rsquo;s first foray into <a href="https://openai.com/index/instruction-following/">instruction-tuned LLMs</a>. While previous versions of GPT-3 were <a href="https://github.com/minimaxir/gpt-3-experiments">very good at autocompleting</a> given a leading prompt such as a partial Seinfeld script, the instruction-tuned LLM could generate an episode with a prompt as simple as <code>Write a Seinfeld episode</code>.</p>
<p>First, let&rsquo;s go back to the beginning, as AI Seinfeld actually wasn&rsquo;t the first time a chatbot went megaviral on Twitch. In January 2017, long before the <a href="https://en.wikipedia.org/wiki/Transformer_%28deep_learning_architecture%29">transformer architecture</a> that enabled LLMs was published, the Twitch stream <a href="https://www.twitch.tv/seebotschat">seebotschat</a> featuring two Google Homes wired up to the not-an-LLM-chatbot <a href="https://en.wikipedia.org/wiki/Cleverbot">Cleverbot</a> <a href="https://mashable.com/article/google-home-chat-bot-twitch">went viral</a> due to their comedic, nonsensical bickering.</p>
<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube-nocookie.com/embed/QFyK1nRJ1LI?autoplay=0&amp;controls=1&amp;end=0&amp;loop=0&amp;mute=0&amp;start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"></iframe>
    </div>

<p>While everyone watching that stream knew it <em>really</em> wasn&rsquo;t AI, AI Seinfeld was a product that was at the peak of the famous <a href="https://en.wikipedia.org/wiki/Uncanny_valley">uncanny valley</a> curve, which is a hypothesis on how humans perceive imitations: there&rsquo;s a &ldquo;valley&rdquo; of negative acceptance where the imitation is more above-average in its likeness, but not quite close enough to the real thing. In this case, it&rsquo;s blatantly obvious and unambiguous that the Twitch stream was AI-generated especially with its mistakes, but not realistic enough that it falls into the valley itself:</p>
<figure>

    <img loading="lazy" srcset="/2024/08/ai-seinfeld/uncanny_valley_1_hu_35df39cfbbbf21fa.webp 320w,/2024/08/ai-seinfeld/uncanny_valley_1_hu_58319279acb34128.webp 768w,/2024/08/ai-seinfeld/uncanny_valley_1_hu_dbfbb3862c06dd8f.webp 1024w,/2024/08/ai-seinfeld/uncanny_valley_1.webp 1200w" src="uncanny_valley_1.webp"/> 
</figure>

<p>This AI weirdness made it very easy to build a community. Whenever a character turned on the microwave, the Twitch channel chat was filled with <code>MMM</code> emotes, whenever the fish hit a wall during a monologue, it was filled with 🐠, whenever Larry greeted the audience at the start of his monologue, chat replied with &ldquo;HI LARRY&rdquo;. Twitch chat <em>loves</em> memetic repetition. Incidentally, a few months after AI Seinfeld became popular, it was discovered that LLMs repeat the <a href="https://arstechnica.com/information-technology/2023/06/researchers-discover-that-chatgpt-prefers-repeating-25-jokes-over-and-over/">same joke over and over</a> again, with examples being similar to the jokes AI Seinfeld made.</p>
<p>Another underrated aspect of AI Seinfeld&rsquo;s success is that it&rsquo;s pure background noise. While personality-driven Twitch streams cause viewers to take a more active investment in what&rsquo;s being shown on screen due to <a href="https://en.wikipedia.org/wiki/Fear_of_missing_out">FOMO</a> of a hype moment on stream, AI Seinfeld is 100% passive: there can be exciting events, but the variance is low. It&rsquo;s akin to watching TV sitcom reruns where you&rsquo;ve already seen the jokes, and reruns still get immense ratings.</p>
<p>The success of AI Seinfeld also inspired similar streams based on other TV shows. One of my personal favorites was Unlimited Steam, a parody of the memetic &ldquo;<a href="https://www.youtube.com/watch?v=4jXEuIHY9ic">Steamed Hams</a>&rdquo; scene from The Simpsons, except made infinite with AI generation. That may sound like a pointless idea — Steamed Hams has a very fixed plot — but it went off the rails even harder than AI Seinfeld ever did.</p>
<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube-nocookie.com/embed/9i0L_IT82tA?autoplay=0&amp;controls=1&amp;end=0&amp;loop=0&amp;mute=0&amp;start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"></iframe>
    </div>

<h2 id="directing-ai-seinfeld">Directing AI Seinfeld</h2>
<p>AI Seinfeld was novel back in 2023, but now that LLMs are more mainstream you can probably figure out how the AI part of it worked, but let&rsquo;s do a refresher so we can figure out how a hypothetical future AI Seinfeld could innovate the algorithmic sitcom.</p>
<p>As noted earlier, the key of AI Seinfeld&rsquo;s success was the then-latest version of GPT-3: <code>text-davinci-003</code> and its then-novel instruction-based finetuning using RLHF. With that, you can give it a prompt such as:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-txt" data-lang="txt"><span class="line"><span class="cl">You are a professional comedian. Write an award-winning script for an episode of Seinfeld about a new restaurant. Include audience laugh tracks when appropriate.
</span></span></code></pre></div><p>Due to the low context length of these earlier LLMs, that&rsquo;s essentially all the <a href="https://platform.openai.com/docs/guides/prompt-engineering">prompt engineering</a> you can do without limiting the length of the output. The model would then output something similar to this script (using the more modern <a href="https://www.anthropic.com/news/claude-3-5-sonnet">Claude 3.5 Sonnet</a> at <code>temperature=0.0</code>): <sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup></p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-txt" data-lang="txt"><span class="line"><span class="cl">[Scene: Jerry&#39;s apartment]
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Jerry: So what&#39;s the deal with this new restaurant, &#34;The Blank Plate&#34;?
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Elaine: Oh, I&#39;ve heard about that place! Apparently, you don&#39;t order anything - the chef just brings you whatever he feels like making.
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Jerry: What? So you&#39;re telling me I have to eat whatever some stranger decides?
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">[Audience laughter]
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">George: (entering) Hey, guess where I&#39;m taking my date tonight? The Blank Plate!
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Jerry: George, you can&#39;t take a date there! What if they serve something weird?
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">George: What do you mean?
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Elaine: It&#39;s that new place where you don&#39;t get to choose your meal.
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">George: (panicking) Oh no, what have I done? She&#39;s going to think I&#39;m some kind of food weirdo!
</span></span></code></pre></div><p>One thing instruction-tuned LLMs are always good at is playing along: LLMs generate text sequentially without the explicit ability to plan ahead, so it must work with what it&rsquo;s given and what it has already generated. Coincidentally, this works <em>perfectly</em> with the improv comedy style of Seinfeld, where continuing the plot is more important than anything else, and the more ridiculous the situation becomes, that&rsquo;s even better. It&rsquo;s the rare case where <a href="https://www.iguazio.com/glossary/llm-hallucination/">LLM hallucination</a> is actually a feature, not a bug.</p>
<p>To get the LLM output into a format suitable for a Twitch stream, a programmatic script can then parse the output: extracting and mapping the characters and their lines, applause directions, and, of course, replacing all mentions of Jerry with Larry and Seinfeld with Feinberg. This workflow was surprisingly difficult at the time since GPT-3 did not have many techniques to control the format of the output, hence why I suspect there are awkward pauses and other glitches. Each line can then be passed to Azure&rsquo;s text-to-speech API to generate a distinct audio file, which can be played back in order in Unity.</p>
<p>In an <a href="https://www.polygon.com/23582937/ai-seinfeld-twitch-stream">interview with Polygon</a>, Skyler Hartle of Mismatch media noted the presence of a &ldquo;director&rdquo; which likely handles the camera, scene transitions, and the microwave:</p>
<blockquote>
<p>“In addition to the third party services we’ve used, we have a lot of proprietary generative algorithms that cause the show to be ‘formed’, so to be speak. We collectively call this logic the ‘director,’ as it is largely responsible for making sure all the individual pieces come together into a whole,” Hartle said via email. “It’s worth mentioning that we don’t generate the artwork or the laugh track — those are precanned assets, but we have ideas on how to do that in the future.”</p>
</blockquote>
<p>The AI aspect of AI Seinfeld was counterintuitively the easiest part of the pipeline, which explains how quickly variants popped up. However, with the inability to tweak the LLM output much with the technology at the time, the stream may have hit a creative limit.</p>
<h2 id="the-fall-of-ai-seinfeld">The Fall of AI Seinfeld</h2>
<p>Vice also <a href="https://www.vice.com/en/article/qjkyxp/whats-the-deal-with-nothing-forever-a-21st-century-seinfeld-that-is-ai-generated">interviewed</a> Hartle, who had an optimistic view of the future of AI Seinfeld:</p>
<blockquote>
<p>“Our grounding principle was, can we create a show that can generate entertaining content forever? Because that&rsquo;s truly where we see the future emerging towards. Our goal with the next iterations or next shows that we release is to actually trade a show that is like Netflix-level quality.”</p>
</blockquote>
<p>That&rsquo;s tempting fate a bit too much.</p>
<p>The reason AI Seinfeld fell out of favor is a case of unintentionally poor LLM testing. When the <code>text-davinci-003</code> model API endpoint had an outage, AI Seinfeld switched to a weaker GPT-3 model, <code>text-curie</code>, to keep the stream up. But unlike the davinci variant, curie was <em>not</em> RLHFed to follow instructions and safety.</p>
<p>During this brief period of low safety, one of Larry&rsquo;s AI-generated monologues <a href="https://www.vice.com/en/article/ai-generated-seinfeld-show-nothing-forever-banned-on-twitch-after-transphobic-standup-bit/">made a transphobic joke</a>: a type of joke that was unfortunately common during the 90&rsquo;s and has no place in modern society. Twitch banned the Watch Forever channel for 14 days as a result, completely killing the channel&rsquo;s growth momentum.</p>
<p>But when the ban concluded and AI Seinfeld came back, the show was changed significantly with a &ldquo;Season 2&rdquo;. Although AI Seinfeld was still about a group of friends hanging around talking about the latest gossip, all the characters were different and had new models, the sets were different, and instead of a comedy monologue, <del>Larry</del> Leo narrates writing a blog.</p>
<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube-nocookie.com/embed/7N2Wgqn45FI?autoplay=0&amp;controls=1&amp;end=0&amp;loop=0&amp;mute=0&amp;start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"></iframe>
    </div>

<p>Why Mismatch Media made such a format shift is unclear: <a href="https://en.wikipedia.org/wiki/Occam%27s_razor">Occam&rsquo;s razor</a> would suggest that a copyright holder for Seinfeld sent a cease and desist to Mismatch Media given the bad publicity behind the original ban, despite the clearly fair-use parody nature of the stream. It&rsquo;s fair that it may not have been worth the time and effort for Mismatch Media to fight a legal battle for a fun art project.</p>
<p>The rebooted WatchMeForever stream is <a href="https://www.twitch.tv/watchmeforever">still active</a> as of today, but with effectively no viewers.</p>
<p>The immediate failure of the AI Seinfeld retool does lend credibility to the theory that the stream only became popular <em>because</em> it was about Seinfeld and that it was a novelty doomed to a short shelf life. Still, there were detractors that said <a href="https://www.businessinsider.com/ai-generated-seinfeld-parody-twitch-nothing-forever-streaming-transphobia-banned-2023-2">AI Seinfeld was never funny and everyone is weird for liking it</a>. That&rsquo;s ok: the original Seinfeld received similar complaints back in the day. <sup id="fnref:2"><a href="#fn:2" class="footnote-ref" role="doc-noteref">2</a></sup> But it&rsquo;s hard to argue that there wasn&rsquo;t interest in a 24/7 livestream of surreal AI-generated content.</p>
<h2 id="what-would-ai-seinfeld-look-like-in-2024">What Would AI Seinfeld Look Like in 2024?</h2>
<p>Now that we know how AI Seinfeld worked and what didn&rsquo;t work, how would a year&rsquo;s worth of exponential progress in generative AI look for AI Seinfeld? Could AI Seinfeld be improved and come back? The answer is <em>maybe</em>.</p>
<p>Modern generative AI requires a lot of cherry picking the best results, and it&rsquo;s surprisingly hard to do: both images and text can take multiple generations and still require significant human-guided edits. But with a Twitch livestream, there can&rsquo;t be any cherry picking at all, which means that the entire generation pipeline has to be consistent, and its failures interesting in the worst case.</p>
<p>The only reason AI Seinfeld worked at all is because GPT-3 was trained on the entire internet, likely including Seinfeld scripts and forum discussions. The prompt would need to have contained <code>Write a Seinfeld script</code> since if you asked it <code>Write a sitcom script</code>, it would output something completely generic instead and there isn&rsquo;t much room to customize the prompt to make it more interesting. The GPT-3 variant that AI Seinfeld used had a 4k token context window limit (combined both the input prompt plus the output script text), but modern LLMs eclipse that: currently, Claude 3.5 Sonnet has a <a href="https://docs.anthropic.com/en/docs/about-claude/models">200k input/8k output</a> context, while GPT-4o has a <a href="https://platform.openai.com/docs/models/gpt-4o">128k input/16k output</a> context! With that much freedom, you can define many more constraints in the prompt and guide the LLM into exactly the type of sitcom you want.</p>
<p>One simple example that doesn&rsquo;t require any knowledge of machine learning is a parametric prompt, where one aspect of a prompt can be replaced with a user-defined choice or programmatically chosen at random. Unlimited Steam, for example, used a parametric prompt to change the cosmic phenomenon localized entirely within Principal Skinner&rsquo;s kitchen from the Aurora Borealis to something as silly as <a href="https://en.wikipedia.org/wiki/Rapture">The Rapture</a> or <a href="https://foofighters.com">Foo Fighters</a>, and forcing the characters to play along improv-style. <sup id="fnref:3"><a href="#fn:3" class="footnote-ref" role="doc-noteref">3</a></sup></p>
<p>Recall the example Seinfeld prompt to Claude 3.5 Sonnet I made earlier, except instead of prompting for a Seinfeld script about a <code>new restaurant</code>, we can instead have the LLM generate a script about <code>generative AI in 2024</code> by making only that substitution in the prompt — a topic on which there definitely has never been a Seinfeld episode about:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-txt" data-lang="txt"><span class="line"><span class="cl">George bursts in, looking frantic.
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">George: You guys! I think I&#39;m dating an AI!
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">[Audience laughter]
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Jerry: What makes you say that?
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">George: Well, she&#39;s perfect in every way. She laughs at all my jokes, she has an encyclopedic knowledge of obscure trivia, and she never gets mad when I say something stupid.
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">[Audience laughter]
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Jerry: George, that doesn&#39;t mean she&#39;s an AI. Maybe she just really likes you.
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">George: No, no. It&#39;s definitely an AI. No human woman would ever put up with me for this long.
</span></span></code></pre></div><p>Using modern LLMs, is there now a way to design a prompt which can make use of the long context windows? A prompt that can both leverage unique human writing and fix many of the issues that affected AI Seinfeld? Here&rsquo;s an approach at a much more sophisticated prompt, where all values in <code>{}</code> brackets are parameters that can be filled in:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-txt" data-lang="txt"><span class="line"><span class="cl">You are a professional comedian. Write an award-winning script for a a scene for Act I of a three act hit sitcom episode. Include audience laugh tracks when appropriate.
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Your script MUST incorporate ALL the following elements:
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Background:
</span></span><span class="line"><span class="cl">- {background}
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Setting:
</span></span><span class="line"><span class="cl">- {setting}
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Characters:
</span></span><span class="line"><span class="cl">- {character_1}
</span></span><span class="line"><span class="cl">- {character_2}
</span></span><span class="line"><span class="cl">- {character_3}
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Plots:
</span></span><span class="line"><span class="cl">- {a_plot}
</span></span><span class="line"><span class="cl">- {b_plot_1}
</span></span><span class="line"><span class="cl">- {b_plot_2}
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">The script MUST also follow the high-level comedic style of the following scripts:
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">- {script_1}
</span></span><span class="line"><span class="cl">- {script_2}
</span></span><span class="line"><span class="cl">- {script_3}
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">After the scene has concluded, output a summary of the scene.
</span></span></code></pre></div><p>Thanks to long context windows, the parametric changes don&rsquo;t have to be small, such as only a character name or two word setting. You, a human, can write <em>anything</em> to make each character distinct and robust, including name, gender, age, personality, likes, dislikes, etc. Plots can be derived from human-written scenarios beforehand: if you wrote 100 A-plots and 100 B-plots and randomly selected 1 A-plot and 2 B-plots, you&rsquo;d have about <em>1 million</em> possible plot permutations, ensuring you have something unique before the AI tries to reconcile them. You can feed in examples of human-written scripts to set the style and vibe of the generation in what is known as <a href="https://www.promptingguide.ai/techniques/fewshot">few-shot prompting</a>. You can maintain continuity over many scenes by having the LLM summarize its own output, and then feed those summaries back to the AI as background information to build upon them. The LLM can also be instructed to <a href="https://minimaxir.com/2023/12/chatgpt-structured-data/">output structured data</a> to avoid the need to loosely parse the script after it&rsquo;s completed, and as a bonus the model could be instructed to output additional metadata such as <a href="https://learn.microsoft.com/en-us/azure/ai-services/speech-service/speech-synthesis-markup-voice#use-speaking-styles-and-roles">SSML speech styles</a> based on a given line to add personality to the generated speech.</p>
<p>Unfortunately, creating this pipeline, writing original characters and plots for it for it, and sufficiently testing it to ensure the generated results are stable, would take weeks if not months to complete otherwise I would provide a more concrete demo. <sup id="fnref:4"><a href="#fn:4" class="footnote-ref" role="doc-noteref">4</a></sup> This pipeline approach to AI script writing would only be effective for unsupervised 24/7 generation and wouldn&rsquo;t replace skilled human writers who would do a more effective job much faster.</p>
<p>But would all of these prompt optimizations actually make the final generated script <em>funny</em>? After all, some of the failings like the awkward audience laughs and pauses and the end of scenes contributed to AI Seinfeld&rsquo;s humor. During a standup comedy event at AI Seinfeld&rsquo;s peak, Jerry Seinfeld himself <a href="https://www.reddit.com/r/seinfeld/comments/10tnn1k/jerry_talking_about_ai_seinfeld_last_night/">was asked</a> about the AI parody and he replied that he&rsquo;s not worried about AI:</p>
<blockquote>
<p>AI can be, definitely, they&rsquo;ll make it smarter and smarter, but to do [standup comedy] you have to make it dumber.</p>
</blockquote>
<p>Could AI Seinfeld benefit from advances in AI video? The answer this time is no. Generative video has been taking off in 2024 with projects such as OpenAI&rsquo;s <a href="https://openai.com/index/sora/">Sora</a> and Runway AI&rsquo;s <a href="https://runwayml.com/product">Gen-3 Alpha</a>, but those demos and the examples that go viral on social media are very heavily cherry picked, and even then there are consistency errors such as objects appearing in-and-out of existence. Generating video also requires exponentially more compute than just running Unity, and even with another few years of GPU hardware improvements it would be infeasible to cost-effectively create a 24/7 stream from those models.</p>
<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube-nocookie.com/embed/mnpGyVL1-0E?autoplay=0&amp;controls=1&amp;end=0&amp;loop=0&amp;mute=0&amp;start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"></iframe>
    </div>

<p>The greatest problem with generative AI video is that it is coherent overall but has emblematic errors that don&rsquo;t require a keen eye to notice, and as a result falls square into the uncanny valley, with its mistakes not being interesting, but disorienting. Mistakes in motion are easier to notice at a glance than images where a person&rsquo;s hands may have the wrong number of fingers. The only way for AI video to get out of the valley would be to improve the model to near-flawless quality, which won&rsquo;t happen any time soon. But Sora is more on the more realistic side of the curve than the less realistic side.</p>
<figure>

    <img loading="lazy" srcset="/2024/08/ai-seinfeld/uncanny_valley_2_hu_c3c8932aea493423.webp 320w,/2024/08/ai-seinfeld/uncanny_valley_2_hu_85ea0e247ba12df1.webp 768w,/2024/08/ai-seinfeld/uncanny_valley_2_hu_7690c09cf64f5daa.webp 1024w,/2024/08/ai-seinfeld/uncanny_valley_2.webp 1200w" src="uncanny_valley_2.webp"/> 
</figure>

<p>What about the AI-generated voices that would power these characters? At the time AI Seinfeld aired, many complained that Larry&rsquo;s voice &ldquo;didn&rsquo;t sound enough like Jerry Seinfeld.&rdquo; After AI Seinfeld concluded, a new technology called <a href="https://elevenlabs.io/blog/what-is-voice-cloning">voice cloning</a> popularized by <a href="https://elevenlabs.io">ElevenLabs</a> went mainstream&hellip;and it&rsquo;s unexpectedly the AI modality that&rsquo;s causing the most actual harm both with creative projects and outside of them. If you haven&rsquo;t heard as much about AI-generated voices, there&rsquo;s a good reason for that: voice synthesis projects such as Microsoft&rsquo;s <a href="https://www.microsoft.com/en-us/research/project/vall-e-x/vall-e-2/">VALL-E 2</a> and Meta&rsquo;s <a href="https://ai.meta.com/blog/voicebox-generative-ai-model-speech/">Voicebox</a> both have disclaimers saying they won&rsquo;t be released due to the dangers the technology possesses, although Microsoft&rsquo;s Azure does offer a &ldquo;<a href="https://learn.microsoft.com/en-us/azure/ai-services/speech-service/custom-neural-voice">custom neural voice</a>&rdquo; service. Voice cloning has been used to <a href="https://www.newyorker.com/science/annals-of-artificial-intelligence/the-terrifying-ai-scam-that-uses-your-loved-ones-voice">initiate scams</a> by impersonating spouses in an emergency. Professional voice actors have had their voices cloned and used without compensation due to contracts not specifically forbidding the practice, which is one of the reasons SAG-AFTRA <a href="https://www.theverge.com/2024/8/5/24213808/video-game-voice-actor-strike-sag-aftra">just went on strike</a> against the video game industry in order to get protections against voice cloning and synthetic performers.</p>
<p>Moreover, in the context of creating a next-gen AI Seinfeld, there&rsquo;s nothing inherently interesting about voice cloning since it&rsquo;s a copy by definition: the model <em>can&rsquo;t</em> generate unexpectedly amusing content other than the inherent gimmick of famous-voice-saying-something, such as the AI George Carlin standup special <a href="https://www.vice.com/en/article/the-george-carlin-ai-standup-is-worse-than-you-can-imagine/">which was not special</a>. There isn’t any way currently to prompt engineer a voice generation AI with the detail to create a voice <code>in the style of a masculine New York comedian, 2x speed, primetime television quality</code> which could open up more creative opportunities.</p>
<p>Although we can make drastic improvements with the textual script, that&rsquo;s the extent of how new AI approaches can be leveraged to make something interesting. But if you remember the early days of generative AI history, the best AI-generated projects were the simplest.</p>
<h2 id="ai-weirdness">AI Weirdness</h2>
<p>Generative &ldquo;AI&rdquo; has been around for a very long time (I had fun with <a href="https://en.wikipedia.org/wiki/Markov_chain">Markov chains</a> <a href="https://minimaxir.com/2013/11/innovation-rng/">a decade ago</a>!), but the study was mostly confined to tech-focused communities like <a href="https://news.ycombinator.com">Hacker News</a>. Modern generative AI didn&rsquo;t break into mainstream culture until 2018, ironically in a way that doesn&rsquo;t involve actual generative AI. In June of that year, comedian Keaton Patti posted a <a href="https://x.com/KeatonPatti/status/1006961202998726665">megaviral tweet</a> about how he &ldquo;forced a bot to watch over 1,000 hours of Olive Garden commercials and then asked it to write an Olive Garden commercial of its own.&rdquo;</p>
<figure>

    <img loading="lazy" srcset="/2024/08/ai-seinfeld/patti_hu_67c737b47f76017.webp 320w,/2024/08/ai-seinfeld/patti_hu_615be4497d8ad163.webp 768w,/2024/08/ai-seinfeld/patti_hu_421617479726cf8c.webp 1024w,/2024/08/ai-seinfeld/patti.webp 1554w" src="patti.webp"
         alt="An excerpt of the viral Olive Garden script."/> <figcaption>
            <p>An excerpt of the viral Olive Garden script.</p>
        </figcaption>
</figure>

<p>Yes, the script was human-written: for the technology at the time, no one could train an AI to behave like that from only video input data, and the script was <em>too surreal</em> even for the now-primitive generative AI. He did get popular enough to get <a href="https://www.amazon.com/Forced-Bot-Write-This-Book/dp/152485834X">a book deal</a> and a <a href="https://www.youtube.com/playlist?list=PLXSrjGY5Tz_gPdaU_L__S3hXua7zRQtUl">Netflix collaboration</a> leveraging this fake-AI gimmick.</p>
<p>Patti&rsquo;s comedic misrepresentation of AI did lead to genuine confusion about what a 2018-era generative AI can actually do. Janelle Shane, who maintains the <a href="https://www.aiweirdness.com">AI Weirdness blog</a> about weird things AI can generate, posted an <a href="https://x.com/JanelleCShane/status/1007061610005794817">epic takedown</a> of Patti&rsquo;s script which went equally viral and also led to the internet discovering her excellent <a href="https://www.aiweirdness.com/candy-heart-messages-written-by-a-18-02-09/">AI-generated Valentine&rsquo;s Day hearts</a> from the same year (and later <a href="https://www.amazon.com/You-Look-Like-Thing-Love/dp/0316525227">a book deal</a> too):</p>
<figure>

    <img loading="lazy" srcset="/2024/08/ai-seinfeld/heart_hu_292dce043896cad3.webp 320w,/2024/08/ai-seinfeld/heart.jpg 640w" src="heart.jpg"/> 
</figure>

<p>Image-based generative AI took a lot longer to go mainstream: websites like <a href="https://thispersondoesnotexist.com">This Person Does Not Exist</a> demonstrated the power of <a href="https://en.wikipedia.org/wiki/Generative_adversarial_network">generative adversarial networks</a> like <a href="https://github.com/NVlabs/stylegan">StyleGAN</a> to create images, but that wasn&rsquo;t weird outside of <a href="https://cedar.buffalo.edu/~srihari/CSE676/22.3-GAN%20Mode%20Collapse.pdf">mode collapses</a>. The first instance of weird images from AI was in January 2021 when OpenAI announced the <a href="https://openai.com/index/dall-e/">original DALL·E</a> and showed they could make unique armchairs in the shape of an avocado by asking the model to do so, although they never released the model itself.</p>
<figure>

    <img loading="lazy" srcset="/2024/08/ai-seinfeld/avocado_hu_5300a7e486e7afb5.webp 320w,/2024/08/ai-seinfeld/avocado_hu_84e7cd0392309830.webp 768w,/2024/08/ai-seinfeld/avocado.webp 830w" src="avocado.webp"/> 
</figure>

<p>DALL·E didn&rsquo;t get much attention outside of the AI hypesters since no one could play with it, but months later, things changed. <a href="https://x.com/borisdayma">Boris Dayma</a> led an initiative to reproduce and open-source a variant of the DALL·E model, labeled <a href="https://github.com/borisdayma/dalle-mini">DALL·E Mini</a> (later changed to <a href="https://www.craiyon.com">Craiyon</a> after a cease and desist from OpenAI), and <a href="https://huggingface.co/spaces/dalle-mini/dalle-mini">hosted it for free on Hugging Face</a> and went megaviral. And thus began the &ldquo;<a href="https://www.reddit.com/r/weirddalle/top/?t=all">weird DALL·E</a>&rdquo; phase of image generation AI, where anyone could create incoherent images and make people laugh.</p>
<figure class="align-center ">

    <img loading="lazy" srcset="/2024/08/ai-seinfeld/firehydrant_hu_4bd881a786b7493e.webp 320w,/2024/08/ai-seinfeld/firehydrant.webp 764w" src="firehydrant.webp#center"
         alt="Even back in 2021, image prompt engineering was a thing. via /u/royal_rigolo on Reddit / weirddalle subreddit" width="400"/> <figcaption>
            <p>Even back in 2021, image prompt engineering was a thing. <a href="https://www.reddit.com/r/weirddalle/comments/vjwcl5/fire_hydrant_takes_selfies_on_top_of_the_himalaya/">via /u/royal_rigolo on Reddit / weirddalle subreddit</a></p>
        </figcaption>
</figure>

<p>All of these examples of interesting failures are representative of a bygone AI era of experimentation. Once everyone had free access to more powerful text-generating AI with ChatGPT, and more powerful image-generating AI with <a href="https://www.midjourney.com/home">Midjourney</a>, AI stopped being fun and started being serious business, for better or for worse.</p>
<figure>

    <img loading="lazy" srcset="/2024/08/ai-seinfeld/uncanny_valley_3_hu_c912a98f812d692e.webp 320w,/2024/08/ai-seinfeld/uncanny_valley_3_hu_6cd7aa3fb6bb5ee5.webp 768w,/2024/08/ai-seinfeld/uncanny_valley_3_hu_e3c7199e7c82d8bd.webp 1024w,/2024/08/ai-seinfeld/uncanny_valley_3.webp 1200w" src="uncanny_valley_3.webp"/> 
</figure>

<h2 id="ai-generated-content-in-20xx">AI-Generated Content in 20XX</h2>
<p>Last year, I wrote a thought piece titled &ldquo;<a href="https://minimaxir.com/2023/10/ai-sturgeons-law/">The Greatest Threat to Generative AI is Humans Being Bad at Using it</a>&rdquo; in response to the increasing hostility against the use of AI in creative works, arguing that while AI is a tool like anything else, it is a tool that&rsquo;s very easy to use poorly and actually make projects worse. Additionally, the largest AI companies have both a business incentive and a duty to ensure that AI is used responsibly by its users downstream, as otherwise it will hurt the industry in the long term.</p>
<p>Now, it&rsquo;s apparent that I was correct. The large companies went full steam ahead on AI integrations even where it is highly questionable that they add value and productivity to the end-user, often signaled with a &ldquo;magical&rdquo; <a href="https://qz.com/how-became-the-unofficial-ai-emoji-1851059332">sparkle emoji</a>. Google has integrated Gemini to assist with document and email writing, Meta has integrated Meta AI to automatically generate images and comments, and Apple will <a href="https://www.bloomberg.com/news/articles/2024-07-28/apple-intelligence-to-miss-initial-release-of-upcoming-ios-18-ipados-overhauls?embedded-checkout=true">soon</a> allow Apple devices to generate text and images on your personal devices using Apple Intelligence. Marketing these features is typically met with backlash: Google had to <a href="https://www.cnbc.com/2024/08/02/google-pulls-ai-ad-for-olympics-following-backlash.html">pull an Olympics commercial</a> which encouraged a parent to use AI to write a letter for their child.</p>
<div style="position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;">
      <iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share; fullscreen" loading="eager" referrerpolicy="strict-origin-when-cross-origin" src="https://www.youtube-nocookie.com/embed/NgtHJKn0Mck?autoplay=0&amp;controls=1&amp;end=0&amp;loop=0&amp;mute=0&amp;start=0" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" title="YouTube video"></iframe>
    </div>

<blockquote>
<p>“I flatly reject the future that Google is advertising,” Shelly Palmer, professor of advanced media at Syracuse University’s S.I. Newhouse School of Public Communications, wrote in a widely circulated <a href="https://shellypalmer.com/2024/07/why-googles-dear-sydney-ad-makes-me-want-to-scream/">blog post</a>. The technology presents a “monocultural future where we see fewer and fewer examples of original human thoughts,” she wrote.</p>
</blockquote>
<p>In the process of pushing AI tech further mainstream in a rush to demonstrate to shareholders their generative AI capabilities without encouraging <em>responsible</em> usage of the technology, AI has entered a new era of &ldquo;<a href="https://simonwillison.net/2024/May/8/slop/">slop</a>&rdquo; where people post objectively bad AI content without any regard for how it will be perceived, especially for websites which rely on user-generated content.</p>
<figure>

    <img loading="lazy" srcset="/2024/08/ai-seinfeld/pinterest_hu_613e5e7f10764361.webp 320w,/2024/08/ai-seinfeld/pinterest_hu_fb37af21ee91c34f.webp 768w,/2024/08/ai-seinfeld/pinterest.webp 901w" src="pinterest.webp"
         alt="An annotated example of the Pinterest home page from July 2024. via @henningsanden on X"/> <figcaption>
            <p>An annotated example of the Pinterest home page from July 2024. <a href="https://x.com/henningsanden/status/1808126786389037107">via @henningsanden on X</a></p>
        </figcaption>
</figure>

<p>Facebook, whose algorithm <a href="https://transparency.meta.com/data/widely-viewed-content-report/">favors</a> emotionally-appealing engagement bait posts, has seen a deluge of high-engagement slop even when the content makes no logical sense.</p>
<figure class="align-center ">

    <img loading="lazy" srcset="/2024/08/ai-seinfeld/cabincrew_hu_bc23e6989111247c.webp 320w,/2024/08/ai-seinfeld/cabincrew_hu_c696ff0db8c80eff.webp 768w,/2024/08/ai-seinfeld/cabincrew_hu_b68182f34bfe5d01.webp 1024w,/2024/08/ai-seinfeld/cabincrew.webp 1080w" src="cabincrew.webp#center"
         alt="One of the few AI-generated images on Facebook with an actual cabin crew. via @FacebookAIslop on X." width="400"/> <figcaption>
            <p>One of the few AI-generated images on Facebook with an actual cabin crew. <a href="https://x.com/FacebookAIslop/status/1806416249259258189">via @FacebookAIslop on X</a>.</p>
        </figcaption>
</figure>

<p>This is, of course, quintessential uncanny valley: it&rsquo;s coherent at a glance but just even looking at it for a second it&rsquo;s obvious where the issues are, and these issues aren&rsquo;t a good kind of AI weirdness. What worse is that AI Slop a regression in realism, and falls onto the left side of the valley.</p>
<figure>

    <img loading="lazy" srcset="/2024/08/ai-seinfeld/uncanny_valley_4_hu_ce80aacfa47a581e.webp 320w,/2024/08/ai-seinfeld/uncanny_valley_4_hu_ffbc52f347062d8f.webp 768w,/2024/08/ai-seinfeld/uncanny_valley_4_hu_8f8817dd988ae0a9.webp 1024w,/2024/08/ai-seinfeld/uncanny_valley_4.webp 1200w" src="uncanny_valley_4.webp"/> 
</figure>

<p>Although we as humans can identify this slop, it is currently surprisingly hard for an AI to do so, although it hasn&rsquo;t stopped people from trying to build AIs that can detect AIs which in practice is filled with false positives that hurt real creatives. For slop-creators, this is a feature: if an AI company released a tool to reliably detect and punish slop, it would make their generative AI less valuable. It&rsquo;s <a href="https://www.wsj.com/tech/ai/openai-tool-chatgpt-cheating-writing-135b755a">reported</a> that one of the reasons that OpenAI won&rsquo;t release a reliable ChatGPT text detector is that it could harm their business.</p>
<p>The core reason for the big tech companies allowing generative AI to cause the <a href="https://en.wikipedia.org/wiki/Enshittification">enshittification</a> of the internet is misaligned incentives between the companies hosting AI slop and the users viewing it. Social media companies and their shareholders care about <a href="https://mixpanel.com/blog/north-star-metric/">North Star metrics</a> such as user retention and time-on-site, and normally those metrics can be correlated with user happiness and satisfaction with the service. But time-on-site, for example, can <em>also</em> be maximized by making the site harder and slower to use, and the deluge of AI slop accomplishes that. AI companies typically don&rsquo;t have analytics tracking negative user sentiment about their use of AI: if anything, the uncompromising backlash against AI convinces the companies that complainers are just a lost demographic to accommodate and double down on what they&rsquo;re already doing. Aggregate metrics treat human-made content and AI-generated content as equal, but <em>humans</em> do not.</p>
<p>Generative AI, even for researchers and practitioners such as myself, is a heavily nuanced topic that is very difficult to communicate succinctly, more difficult to do on social media which highly discourages nuance and context, and <em>even more difficult</em> as AI hypesters muddy the waters with misleading praises of generative AI such that they&rsquo;re easy to dunk on which just gets them more engagement and revenue. &ldquo;Made by AI&rdquo; is now a term that inspires dread, far from the Keaton Patti days where made-by-AI was an indicator of joyful weirdness. Bashing AI is now a meme, and there&rsquo;s isn&rsquo;t a single potential AI project that could challenge that perception because the well is poisoned beyond repair.</p>
<h2 id="would-a-247-ai-generated-twitch-stream-even-work-anymore">Would a 24/7 AI-Generated Twitch Stream Even Work Anymore?</h2>
<p>How does the modern AI backlash tie back into AI Seinfeld? Twitch&rsquo;s core demographic is the same demographic as those most against the use of generative AI. Part of the reason AI Seinfeld became so successful on Twitch is because of the community it cultivated: it wouldn&rsquo;t have gone viral if people weren&rsquo;t spamming microwave <code>MMM</code>s and and answering what did the fish say when it hit the wall. Even though Twitch viewers are mostly lurkers and not chatters, a channel with a good community builds word-of-mouth even outside of Twitch, which is how Twitch channels go viral.</p>
<p>I decided to determine what it would take to produce a &ldquo;fixed&rdquo; AI Seinfeld in 2024, given both the advances in AI and the ethics involved. Now, it&rsquo;s definitely not anything a scrappy group of hackers could do anymore. Sure, you could once again ask an LLM to generate a sitcom script and get a bunch of assets from the Unity Asset Store, but <em>that&rsquo;s already been done before</em>. In order to overcome the reflexive assumption that new AI generated content is slop, the stream would have to be something completely novel and unexpected: you can&rsquo;t, for example, just do an AI <a href="https://en.wikipedia.org/wiki/Curb_Your_Enthusiasm">Curb Your Enthusiasm</a>.</p>
<p>The script would be unique following from my demo of detailed parametric prompts, but it would require production-studio-class tracking and documentation for how the prompts and their parameters are used to codify said uniqueness. The stream video would still need to be rendered in Unity or another engine, but in order to be unique it would require commissioning human-made visuals and sound effects: given the animosity against those who work with AI, most artists would not accept those commissions even if they were paid at a significant premium. <sup id="fnref:5"><a href="#fn:5" class="footnote-ref" role="doc-noteref">5</a></sup> The voices would still have to be from an existing text-to-speech voice provider: voice cloning is right out, even with explicit consent and compensation for the voice actors.</p>
<p>And even if all the assets were fully sourced ethically with transparent documentation for the entire pipeline, the stream&rsquo;s Twitch chat would likely be derailed by <code>AI 👏 ART 👏 IS 👏 THEFT</code> spam, preventing the establishment of any community, and strict moderation to curb the spam risks causing a <a href="https://en.wikipedia.org/wiki/Streisand_effect">Streisand effect</a>.</p>
<p>The only entities that could feasibly create a 24/7 AI-generated livestream with fully ethically-sourced content would be, ironically, the big AI companies such as OpenAI which can afford to pay licenses for said data. Even <a href="https://www.disney.com">Disney</a>, which owns more than enough IP to train generative models of all modalities, would never do an AI Seinfeld-esque livestream for <a href="https://en.wikipedia.org/wiki/Brand_safety">brand safety</a> reasons alone: the nonzero possibility of a Disney character unexpectedly saying something problematic during the stream would make the entire project a complete nonstarter.</p>
<h2 id="whats-the-deal-with-the-uncanny-valley">What&rsquo;s the deal with the uncanny valley?</h2>
<p>One of the common criticisms about generative AI pointed out by creatives is &ldquo;if AI is trained on all human works, then how can it create anything new&rdquo;? AI Seinfeld is the perfect counterargument: even though it&rsquo;s powered by a LLM, the <em>humans</em> behind it are what made it go viral. Even before ChatGPT, generative AI has always excelled as a tool. The microwave gag and the 144p visual filter were not AI-generated or an attempt to emulate aspects of the Seinfeld sitcom: they were distinct creative decisions that made the entire project more interesting, and they aren&rsquo;t something that you could prompt an AI to suggest to add. AI Seinfeld in hindsight was an ethical form of AI-generated media: it did not replace Seinfeld the TV show, no one would stop watching streams of Seinfeld in favor of the AI-generated alternative, and copyright holders and Jerry Seinfeld did not lose revenue due to AI Seinfeld&rsquo;s existence: if anything, the nostalgic buzz increased streams of the original show.</p>
<p>With the current trajectory of AI slop and the perverse incentives by large tech companies to not address it, I am pessimistic that AI content will ever be at a state where it will cross that final hump of the uncanny valley curve into full acceptance, and even more pessimistic about the backlash against generative AI ever subsiding. With generative model training now at the point where it requires exponentially more compute and data for increasingly marginal returns, it will take years if at all for generative AI output to reach the far right of the uncanny valley chart, and unless the large tech companies actually create an <a href="https://en.wikipedia.org/wiki/Artificial_general_intelligence">AGI</a>, they are unlikely to obtain higher acceptability than AI Seinfeld ever did.</p>
<p>I wrote most of this blog post weeks ago but held off publishing it because new AI news kept happening. Most notably, the <a href="https://blackforestlabs.ai/our-team/">creators of Stable Diffusion</a> just released the <a href="https://blackforestlabs.ai">FLUX.1 series</a> of generative image AI models, which presents substantially improved coherence both to the provided prompt and within the image itself. Some of the variants are <a href="https://huggingface.co/black-forest-labs/FLUX.1-dev">open-source</a>, allowing the community to finetune them. The <a href="https://huggingface.co/XLabs-AI/flux-RealismLora">XLabs-AI/flux-RealismLora</a> in particular focuses on realism as it name implies, and <a href="https://www.reddit.com/r/StableDiffusion/comments/1emrprx/feel_the_difference_between_using_flux_with">one demo</a> from that finetune <a href="https://x.com/rpnickson/status/1821634114274873850">went megaviral</a>.</p>
<figure class="align-center ">

    <img loading="lazy" srcset="/2024/08/ai-seinfeld/flux_hu_f2586697cc180453.webp 320w,/2024/08/ai-seinfeld/flux.webp 664w" src="flux.webp#center"
         alt="One of the viral realism demo images: it does not have a dreamy look as other AI images but contextually expected stage lighting, the background and lanyard text is legible despite the depth-of-field blur, and body proportions are mostly correct except the long fingers. via /u/Glittering-Football9 on Reddit / StableDiffusion subreddit." width="400"/> <figcaption>
            <p>One of the viral realism demo images: it does not have a dreamy look as other AI images but contextually expected stage lighting, the background and lanyard text is legible despite the depth-of-field blur, and body proportions are mostly correct except the long fingers. <a href="https://www.reddit.com/r/StableDiffusion/comments/1emrprx/comment/lh30hvv/">via /u/Glittering-Football9 on Reddit / StableDiffusion subreddit</a>.</p>
        </figcaption>
</figure>

<p>That example in my opinion is more real than Sora but given the mixed reactions to the image, it&rsquo;s right at the acceptability = 0 threshold.</p>
<figure>

    <img loading="lazy" srcset="/2024/08/ai-seinfeld/uncanny_valley_5_hu_c33303ff9d736da6.webp 320w,/2024/08/ai-seinfeld/uncanny_valley_5_hu_d0b5c2c50072b2b0.webp 768w,/2024/08/ai-seinfeld/uncanny_valley_5_hu_7eb161e4aba72dd1.webp 1024w,/2024/08/ai-seinfeld/uncanny_valley_5.webp 1200w" src="uncanny_valley_5.webp"/> 
</figure>

<p>The generative AI bell cannot be unrung. As you can tell from this post, I personally try to thread the thin line between both cool applications of generative AI (at the risk of getting harrassed) and the problems generative AI can cause (also at the risk of getting harrassed) because it&rsquo;s important to shine a light on what&rsquo;s actually possible with AI when the misinformation around generative AI is only increasing. It&rsquo;s overall a big bummer how we went from weird Valentine&rsquo;s Day hearts, to a quirky livestream of a group of AI-generated friends, to what AI is now.</p>
<div class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1">
<p>All of the examples in this post use LLM APIs as they provide the customization necessary to get effective results: the results for asking the same prompts to free chat frontends such as chatgpt.com will be substantially different.&#160;<a href="#fnref:1" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn:2">
<p>When I was younger, I actually didn&rsquo;t like Seinfeld and instead preferred to watch <a href="https://en.wikipedia.org/wiki/Everybody_Loves_Raymond">Everybody Loves Raymond</a>.&#160;<a href="#fnref:2" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn:3">
<p>Incidentally, parametric prompts is why Unlimited Steam got <a href="https://www.reddit.com/r/unlimitedsteam/comments/12wto93/thank_you_for_enjoying_the_steam/">permanently banned</a> from Twitch: in what would now be known as a <a href="https://www.ibm.com/topics/prompt-injection">prompt injection</a>, one of the GitHub-hosted lists the channel sourced thousands of food choices for the prompt contained a few highly offensive selections.&#160;<a href="#fnref:3" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn:4">
<p>Prompt engineering instability grows exponentially as the prompt size increases since each part of the prompt has to relate to each other. Claude 3.5 Sonnet is the first LLM I&rsquo;ve tested that can handle super-long bespoke prompts and can actually account for all aspects of the prompt.&#160;<a href="#fnref:4" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
<li id="fn:5">
<p>To be fully ethical, an AI practitioner would have to proactively offer additional contractual guarantees to creatives they are commissioning, including highly-scoped usage of the assets they provide and a clause to not train generative AI on said assets to avoid future business.&#160;<a href="#fnref:5" class="footnote-backref" role="doc-backlink">&#x21a9;&#xfe0e;</a></p>
</li>
</ol>
</div>
]]></content:encoded>
    </item>
    <item>
      <title>Advantages of Using R Notebooks For Data Analysis Instead of Jupyter Notebooks</title>
      <link>https://minimaxir.com/2017/06/r-notebooks/</link>
      <pubDate>Tue, 06 Jun 2017 08:30:00 -0700</pubDate>
      <guid>https://minimaxir.com/2017/06/r-notebooks/</guid>
      <description>The relatively new R Notebooks improve the workflows of common data analysis in ways Jupyter Notebooks can&amp;rsquo;t.</description>
      <content:encoded><![CDATA[<p><a href="http://jupyter.org">Jupyter Notebooks</a>, formerly known as <a href="https://ipython.org/notebook.html">IPython Notebooks</a>, are ubiquitous in modern data analysis. The Notebook format allows statistical code and its output to be viewed on any computer in a logical and <em>reproducible</em> manner, avoiding both the confusion caused by unclear code and the inevitable &ldquo;it only works on my system&rdquo; curse.</p>
<figure>

    <img loading="lazy" srcset="/2017/06/r-notebooks/jupyterdemo_hu_287135b578ef9105.webp 320w,/2017/06/r-notebooks/jupyterdemo_hu_3059d8862e947c85.webp 768w,/2017/06/r-notebooks/jupyterdemo_hu_62821160794f3044.webp 1024w,/2017/06/r-notebooks/jupyterdemo.png 1536w" src="jupyterdemo.png"/> 
</figure>

<p>In Jupyter Notebooks, each block of Python input code executes in its own cell, and the output of the block appears inline; this allows the user to iterate on the results, both to make the data transformations explicit and to and make sure the results are as expected.</p>
<figure>

    <img loading="lazy" srcset="/2017/06/r-notebooks/jupyter_hu_919cd14dc214e4fc.webp 320w,/2017/06/r-notebooks/jupyter_hu_8647bc6d434c5157.webp 768w,/2017/06/r-notebooks/jupyter_hu_10ef5c83bc24f007.webp 1024w,/2017/06/r-notebooks/jupyter.png 1852w" src="jupyter.png"/> 
</figure>

<p>In addition to code blocks, Jupyter Notebooks support <a href="https://en.wikipedia.org/wiki/Markdown">Markdown</a> cells, allowing for more detailed write-ups with easy formatting. The final Notebook can be exported as a HTML file displayable in a browser, or the raw Notebook file can be shared and <a href="https://github.com/blog/1995-github-jupyter-notebooks-3">rendered</a> on sites like <a href="https://github.com">GitHub</a>. Although Jupyter is a Python application, it can run kernels of <a href="https://irkernel.github.io">non-Python languages</a>, such as <a href="https://www.r-project.org">R</a>.</p>
<p>Over the years, there have a been a few new competitors in the reproducible data analysis field, such as <a href="http://beakernotebook.com/features">Beaker Notebook</a> and, for heavy-duty business problems, <a href="https://zeppelin.apache.org">Apache Zeppelin</a>. However, today we&rsquo;ll look at the relatively new <a href="http://rmarkdown.rstudio.com/r_notebooks.html">R Notebooks</a>, and how they help improve the workflows of common data analysis in ways Jupyter Notebooks can&rsquo;t without third-party extensions.</p>
<h2 id="about-r-notebooks">About R Notebooks</h2>
<p>R Notebooks are a format maintained by <a href="https://www.rstudio.com">RStudio</a>, which develops and maintains a large number of open source R packages and tools, most notably the free-for-consumer RStudio R IDE. More specifically, R Notebooks are an extension of the earlier <a href="http://rmarkdown.rstudio.com">R Markdown</a> <code>.Rmd</code> format, useful for rendering analyses into HTML/PDFs, or other cool formats like <a href="http://rmarkdown.rstudio.com/tufte_handout_format.html">Tufte handouts</a> or even <a href="https://bookdown.org">books</a>. The default output of an R Notebook file is a <code>.nb.html</code> file, which can be viewed as a webpage on any system. (<a href="https://rpubs.com">RPubs</a> has many examples of R Notebooks, although I recommend using <a href="https://pages.github.com">GitHub Pages</a> to host notebooks publicly).</p>
<figure>

    <img loading="lazy" srcset="/2017/06/r-notebooks/RNotebookAnimation_hu_2bd7eafe2a4daec8.webp 320w,/2017/06/r-notebooks/RNotebookAnimation.gif 425w" src="RNotebookAnimation.gif"/> 
</figure>

<p>Instead of having separate cells for code and text, a R Markdown file is all plain text. The cells are indicated by three backticks and a gray background in RStudio, which makes it easy to enter a code block, easy to identify code blocks at a glance, and easy to execute a notebook block-by-block. Each cell also has a green indicator bar which shows which code is running and which code is queued, line-by-line.</p>
<p>For Notebook files, a HTML webpage is automatically generated whenever the file is saved, which can immediately be viewed in any browser (the generated webpage stores the cell output and any necessary dependencies).</p>
<figure>

    <img loading="lazy" srcset="/2017/06/r-notebooks/notebooktest_hu_7203602b197e5272.webp 320w,/2017/06/r-notebooks/notebooktest.png 642w" src="notebooktest.png"/> 
</figure>

<p>R Notebooks can only be created and edited in RStudio, but this is a case where tight vertical integration of open-source software is a good thing. Among many other features, RStudio includes a file manager, a function help, a variable explorer, and a project manager; all of which make analysis much easier and faster as opposed to the browser-only Jupyter.</p>
<figure>

    <img loading="lazy" srcset="/2017/06/r-notebooks/rstudio_hu_9ca09ff475c1ab6c.webp 320w,/2017/06/r-notebooks/rstudio_hu_8f31449381ea8c8c.webp 768w,/2017/06/r-notebooks/rstudio_hu_6790ce776fe0161c.webp 1024w,/2017/06/r-notebooks/rstudio.png 1280w" src="rstudio.png"/> 
</figure>

<p>I&rsquo;ve made many, many Jupyter Notebooks and R Notebooks <a href="http://minimaxir.com/data-portfolio">over the years</a>, which has given me insight into the strengths and weaknesses of both formats. Here are a few native features of R Notebooks which present an objective advantage over Jupyter Notebooks, particularly those not highlighted in the documentation:</p>
<h2 id="version-control">Version Control</h2>
<p>Version control of files with tools such as <a href="https://en.wikipedia.org/wiki/Git">git</a> is important as it both maintains an explorable database of changes to the code files and also improves collaboration by using a centralized server (e.g. GitHub) where anyone with access to the repository can pull and push changes to the code. In the data science world, large startups such as <a href="https://stripe.com/blog/reproducible-research">Stripe</a> and <a href="https://medium.com/airbnb-engineering/scaling-knowledge-at-airbnb-875d73eff091">Airbnb</a> have seen a lot of success with this approach.</p>
<p>RStudio incidentally has a native git client for tracking and committing changes to a <code>.Rmd</code> file, which is easy since <code>.Rmd</code> files are effectively plain text files where you can see differences between versions at a per-line level. (You may not want to store the changes to the generated <code>.nb.html</code> Notebook since they will be large and redundant to the changes made in the corresponding <code>.Rmd</code>; I recommend adding a <code>*.nb.html</code> rule to a <code>.gitignore</code> file during analysis).</p>
<figure>

    <img loading="lazy" srcset="/2017/06/r-notebooks/git_hu_81f9aa52fb4095c2.webp 320w,/2017/06/r-notebooks/git_hu_9986faacff44886a.webp 768w,/2017/06/r-notebooks/git_hu_b18c85f56c32a67c.webp 1024w,/2017/06/r-notebooks/git.png 1376w" src="git.png"/> 
</figure>

<p>The <code>.ipynb</code> Jupyter Notebook files are blobs of JSON that also store cell output, which will result in large diffs if you keep them in version control and make any changes which result in different output. This can cause the git database to balloon and makes reading per-line diffs hard if not impossible.</p>
<p>On Hacker News, the version control issues in Jupyter are <a href="https://news.ycombinator.com/item?id=14034341">a common complaint</a>, however a Jupyter developer noted of a possibility of <a href="https://news.ycombinator.com/item?id=14035158">working with RStudio</a> on solving this issue.</p>
<h2 id="inline-code-rendering">Inline Code Rendering</h2>
<p>A common practice in Jupyter Notebooks is to print common values as a part of a write-up or testing statistical code. In Jupyter Notebooks, if you want to verify the number of rows in a dataset for exploratory data analysis, you have to add an appropriate print statement to the cell to get the number <code>n</code> rows, and then add a Markdown cell to redundantly describe what you just print in the output.</p>
<p>In R Notebooks, you can skip a step by calling such print statements in-line in the Markdown text, which will then be rendered with the Notebook. This also avoids hard-coding such numbers in the Markdown text if you change the data beforehand (e.g. parameter tuning) or if the values are nontrivial to calculate by hand.</p>
<p>For example, these lines of R Markdown from my <a href="http://minimaxir.com/notebooks/first-comment/">Reddit First Comment Notebook</a>:</p>
<figure>

    <img loading="lazy" srcset="/2017/06/r-notebooks/inline_hu_c6d4dc66bf14ef60.webp 320w,/2017/06/r-notebooks/inline_hu_df8ce63e0e546f98.webp 768w,/2017/06/r-notebooks/inline.png 972w" src="inline.png"/> 
</figure>

<p>translate into:</p>
<figure>

    <img loading="lazy" srcset="/2017/06/r-notebooks/reddit_hu_8d3c46de15fb586d.webp 320w,/2017/06/r-notebooks/reddit_hu_9a37f5897d7a073f.webp 768w,/2017/06/r-notebooks/reddit_hu_f0ac03e8aa2e427.webp 1024w,/2017/06/r-notebooks/reddit.png 1024w" src="reddit.png"/> 
</figure>

<h2 id="metadata">Metadata</h2>
<p>R Notebooks are configured with a <a href="http://yaml.org">YAML</a> header, which can include common attributes such as title, author, date published, and other relevant options. These fields will then be configured correctly in the metadata for HTML/PDF/Handouts output. Here&rsquo;s an example from <a href="http://minimaxir.com/notebooks/amazon-spark/">one of my notebooks</a>:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nn">---</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">title</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;Playing with 80 Million Amazon Product Review Ratings Using Apache Spark&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">author</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;Max Woolf (@minimaxir)&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">date</span><span class="p">:</span><span class="w"> </span><span class="s2">&#34;January 2nd, 2017&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nt">output</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">html_notebook</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">highlight</span><span class="p">:</span><span class="w"> </span><span class="l">tango</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">mathjax</span><span class="p">:</span><span class="w"> </span><span class="kc">null</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">number_sections</span><span class="p">:</span><span class="w"> </span><span class="kc">yes</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">theme</span><span class="p">:</span><span class="w"> </span><span class="l">spacelab</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">toc</span><span class="p">:</span><span class="w"> </span><span class="kc">yes</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">toc_float</span><span class="p">:</span><span class="w"> </span><span class="kc">yes</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nn">---</span><span class="w">
</span></span></span></code></pre></div><p>Said metadata features are <a href="https://github.com/ipython/ipython/issues/6073">often requested but unimplemented</a> in Jupyter.</p>
<h2 id="notebook-theming">Notebook Theming</h2>
<p>As noted in the example metadata above, R Notebooks allow extensive theming. Jupyter Notebooks do <a href="https://github.com/dunovank/jupyter-themes">support themes</a>, but with a third-party Python package, or placing custom CSS in an <a href="https://stackoverflow.com/a/32158550">odd location</a>.</p>
<p>Like Jupyter Notebooks, the front-end of browser-based R Notebooks is based off of the <a href="http://getbootstrap.com">Bootstrap</a> HTML framework. R Notebooks, however, allow you to natively select the style of code syntax highlighting via <code>highlight</code> (similar options as <a href="https://help.farbox.com/pygments.html">pygments</a>) and also the entire Bootstrap theme via <code>theme</code> (with a selection from the excellent <a href="https://bootswatch.com">Bootswatch</a> themes by <a href="https://twitter.com/thomashpark">Thomas Park</a>), giving your Notebook a unique look without adding dependencies.</p>
<h2 id="data-tables">Data Tables</h2>
<p>When you print a data frame in a Jupyter Notebook, the output appears as a standard <em>boring</em> HTML table:</p>
<figure>

    <img loading="lazy" srcset="/2017/06/r-notebooks/htmltable_hu_320fef023a1fcc55.webp 320w,/2017/06/r-notebooks/htmltable_hu_20e1593d3a696894.webp 768w,/2017/06/r-notebooks/htmltable_hu_14e5ba80dcd5dd7f.webp 1024w,/2017/06/r-notebooks/htmltable.png 1836w" src="htmltable.png"/> 
</figure>

<p>No cell block output is ever truncated. Accidentally printing an entire 100,000+ row table to a Jupyter Notebook is a mistake you only make <em>once</em>.</p>
<p>R Notebook tables are pretty tables with pagination for both rows and columns, and can support large amounts of data if necessary.</p>
<figure>

    <img loading="lazy" srcset="/2017/06/r-notebooks/rtable_hu_57d067a3de215b70.webp 320w,/2017/06/r-notebooks/rtable_hu_e7f78f095bdb7f18.webp 768w,/2017/06/r-notebooks/rtable_hu_3a6c1cacd852bc16.webp 1024w,/2017/06/r-notebooks/rtable.png 1386w" src="rtable.png"/> 
</figure>

<p>The R Notebook output table also includes the data type of the column, which is helpful for debugging unexpected issues where a column has an unintended data type (e.g. a numeric <code>&lt;dbl&gt;</code> column or a datetime <code>&lt;S3: POSIXct&gt;</code> column is parsed as a text-based <code>&lt;chr&gt;</code> column).</p>
<h2 id="table-of-contents">Table of Contents</h2>
<p>A Table of Contents always helps navigating, particularly in a PDF export. Jupyter Notebooks <a href="https://github.com/minrk/ipython_extensions">requires an extension</a> for a ToC, while R Notebooks will natively create one from section headers (controllable via <code>toc</code> and <code>number_sections</code>). An optional <code>toc_float</code> parameter causes the Table of Contents to float on the left in the browser, making it always accessible.</p>
<figure>

    <img loading="lazy" srcset="/2017/06/r-notebooks/notebookheader_hu_adec52f6ee5a1336.webp 320w,/2017/06/r-notebooks/notebookheader_hu_5ecc23e67295d193.webp 768w,/2017/06/r-notebooks/notebookheader_hu_b18757e8f5470627.webp 1024w,/2017/06/r-notebooks/notebookheader.png 1976w" src="notebookheader.png"/> 
</figure>

<p>In conclusion, R Notebooks haven&rsquo;t received much publicity since the benefits aren&rsquo;t immediately obvious, but for the purpose of reproducible analyses, the breadth of native features allows for excellent utility while avoiding dependency hell. Running R in an R Notebook is a significantly better experience than running R in a Jupyter Notebook. The advantages present in R Notebooks can also provide guidance for feature development in other Notebook software, which improves the data analysis ecosystem as a whole.</p>
<p>However, there&rsquo;s an elephant in the room&hellip;</p>
<h2 id="what-about-python">What About Python?</h2>
<p>So you might be thinking &ldquo;an R Notebook forces you to use R, but <em>serious</em> data science work is done using Python!&rdquo; Plot twist: you can use Python in an R Notebook!</p>
<figure>

    <img loading="lazy" srcset="/2017/06/r-notebooks/python_hu_d75a8e044545d86b.webp 320w,/2017/06/r-notebooks/python.png 326w" src="python.png"/> 
</figure>

<p>Well, sort of. The Python session ends after the cell executes, making it unhelpful for tasks other than <em>ad hoc</em> scripts.</p>
<p>The topic on whether R or Python is better for data analysis is a <a href="https://news.ycombinator.com/item?id=14056098">common</a> <a href="https://news.ycombinator.com/item?id=13239530">religious</a> <a href="https://news.ycombinator.com/item?id=12301996">flamewar</a> topic which is best saved for a separate blog post (tl;dr: I disagree with the paraphrased quote above in that both languages have their advantages and you&rsquo;ll benefit significantly from knowing both ecosystems).</p>
<p>And I wouldn&rsquo;t count R out of &ldquo;serious data science&rdquo;. You can use R <a href="http://spark.rstudio.com">seamlessly</a> with big data tools like <a href="https://spark.apache.org">Apache Spark</a>, and R can <a href="https://rstudio.github.io/keras/">now</a> use <a href="https://keras.io">Keras</a>/<a href="https://www.tensorflow.org">TensorFlow</a> for deep learning with near-API-parity to the Python version. <em>Hmm</em>.</p>
]]></content:encoded>
    </item>
    <item>
      <title>Blockbuster Movies with Male Leads Earn More Than Those with Female Leads</title>
      <link>https://minimaxir.com/2016/04/movie-gender/</link>
      <pubDate>Wed, 13 Apr 2016 08:00:00 -0700</pubDate>
      <guid>https://minimaxir.com/2016/04/movie-gender/</guid>
      <description>On average, blockbuster movies with male leads generate 22% more domestic box office revenue, and this difference is statistically significant.</description>
      <content:encoded><![CDATA[<p>One of the more interesting revelations discovered during the <a href="https://en.wikipedia.org/wiki/Sony_Pictures_Entertainment_hack">2014 Sony Pictures Entertainment hack</a> was that actresses <a href="https://en.wikipedia.org/wiki/Jennifer_Lawrence">Jennifer Lawrence</a> and <a href="https://en.wikipedia.org/wiki/Amy_Adams">Amy Adams</a> made <a href="http://www.thedailybeast.com/articles/2014/12/12/exclusive-sony-hack-reveals-jennifer-lawrence-is-paid-less-than-her-male-co-stars.html">less money than their male costars</a> for the movie <a href="http://www.imdb.com/title/tt1800241/">American Hustle</a>. Specifically, Lawrence and Adams earned 7% of the profits while their male co-stars earned 9%: a 28% increase in pay.</p>
<p>That made me curious: is the discrepancy in pay between male-leads and female-leads justifiable? Do movies with male lead actors generate more box office revenue than movies with female leads? Are movies with male leads <em>better</em> than those with female leads?</p>
<p>Using movie data from <a href="http://www.omdbapi.com">OMDb API</a>, which is sourced from <a href="http://www.imdb.com">IMDb</a> and <a href="http://www.rottentomatoes.com">Rotten Tomatoes</a> data, I found that on average, blockbuster movies with male leads generate 22% more domestic box office revenue than those with female leads, and that this difference is statistically significant.</p>
<h2 id="setting-up-the-movie-data">Setting Up the Movie Data</h2>
<figure>

    <img loading="lazy" srcset="/2016/04/movie-gender/movie-gender-data_hu_4a04ca86d66702a8.webp 320w,/2016/04/movie-gender/movie-gender-data_hu_9180e5af9f46ff87.webp 768w,/2016/04/movie-gender/movie-gender-data_hu_e92fc98d559a5e13.webp 1024w,/2016/04/movie-gender/movie-gender-data.png 1158w" src="movie-gender-data.png"/> 
</figure>

<p>I&rsquo;ve talked about processing the OMDb dataset in <a href="http://minimaxir.com/2016/04/trust-but-verify/">my previous post</a>. For this analysis, I&rsquo;ll be filtering on a specific subset of movies:</p>
<ul>
<li>Movies with <strong>at least $10 million in inflation-adjusted domestic box office revenue</strong>. My <a href="http://minimaxir.com/2016/01/movie-revenue-ratings/">first analysis</a> showed that there is a distinct cluster of movies above the $10M threshold specifically. These blockbusters are also what the public knows and best reflects the perception of the industry.</li>
<li>Movies which were <strong>released in 2000 or later</strong>. There was <a href="http://minimaxir.com/2016/04/trust-but-verify/">missing box office revenue data</a> I had found with earlier years so I would prefer to use more robust data to be safe. Additionally, this avoids the complicated issue of <a href="https://www.reddit.com/r/dataisbeautiful/comments/4bcb6x/john_goodman_is_not_the_greatest_supporting_actor/d17y82k">20th-century gender politics in cinema</a>, which I cannot easily address statistically.</li>
</ul>
<p>After applying the filters and cleaning the data further to eliminate miscoded movies, I have created a dataset of 2,020 movies. No movies were removed as outliers in box office revenue (such as Star Wars VII and Avatar) since several tests failed to identify them as statistical outliers.</p>
<p>I identified the lead actor of each movie, using the first credited actor on the IMDb cast overview (NB: this may lead to counterintuitive behavior in casts with unknown leads; the first credited actor for <a href="http://www.imdb.com/title/tt2488496/">Star Wars: The Force Awakens</a> on IMDb is Harrison Ford, who is not the lead and I corrected it to Daisy Ridley in the data). Then I determined their gender by referencing a few gender/first-name mappings (with thanks to <a href="https://twitter.com/matthew_daniels">Matt Daniels</a> and his great work on <a href="http://polygraph.cool/films/index.html">gender and film dialogue</a>).</p>
<p>In all, the dataset has 467 (23%) of movies with a female lead actor, and 1,553 (77%) movies with a male lead actor. Both counts are more than enough for this analysis.</p>
<p>You can view and download the final dataset <a href="https://docs.google.com/spreadsheets/d/1UMV-6yCjHBveyOcZwiilEm2DWRMjdzAbgdHutcjCn-E/edit?usp=sharing">in this Google Sheet</a>.</p>
<h2 id="distribution-of-box-office-revenue">Distribution of Box Office Revenue</h2>
<p>Let&rsquo;s start with simple histograms of the box office data. What are the distributions of the data for each gender?</p>
<figure>

    <img loading="lazy" srcset="/2016/04/movie-gender/movie-gender-1_hu_ba4630023d169626.webp 320w,/2016/04/movie-gender/movie-gender-1_hu_1913056dfb19232d.webp 768w,/2016/04/movie-gender/movie-gender-1_hu_b7677ddca5ac0469.webp 1024w,/2016/04/movie-gender/movie-gender-1.png 1200w" src="movie-gender-1.png"/> 
</figure>

<p>On average, blockbuster movies with male lead actors generate <strong>$79.8M in revenue</strong>. The distribution, even when log-scaled, is skewed right, with the median being much lower at $49.8M.</p>
<figure>

    <img loading="lazy" srcset="/2016/04/movie-gender/movie-gender-2_hu_e139f1d47a17c8dc.webp 320w,/2016/04/movie-gender/movie-gender-2_hu_35fb447ef25e6c23.webp 768w,/2016/04/movie-gender/movie-gender-2_hu_ae70c6507dbe507d.webp 1024w,/2016/04/movie-gender/movie-gender-2.png 1200w" src="movie-gender-2.png"/> 
</figure>

<p>On average, blockbuster movies with female lead actors generate <strong>$65.6M in revenue</strong>. The general shape of the distribution is the same as with male lead actors.</p>
<p>Double-checking the math:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-txt" data-lang="txt"><span class="line"><span class="cl">79.8M / 65.6M = 22% increase in average box office revenue for male-lead movies
</span></span></code></pre></div><p>So it is.</p>
<p>Let&rsquo;s overlay the two distributions after normalizing and smoothing with a <a href="https://en.wikipedia.org/wiki/Kernel_density_estimation">2D kernel destiny estimator</a>.</p>
<figure>

    <img loading="lazy" srcset="/2016/04/movie-gender/movie-gender-3_hu_18845af10678e204.webp 320w,/2016/04/movie-gender/movie-gender-3_hu_26723a60944647e1.webp 768w,/2016/04/movie-gender/movie-gender-3_hu_27c9c779125cb70f.webp 1024w,/2016/04/movie-gender/movie-gender-3.png 1200w" src="movie-gender-3.png"/> 
</figure>

<p>Female movies have a clear mode near its average, but male movies have a flatter distribution, with significantly more movies making 9 figures.</p>
<p>But is the difference between the two averages statistically significant? We can run two statistical tests between the box-office revenues of male-led and female-lead movies:</p>
<ul>
<li>The <a href="https://en.wikipedia.org/wiki/Kolmogorov%E2%80%93Smirnov_test">Kolmogorov–Smirnov test</a> for determining if two populations have the same distribution. The null hypothesis is that the two are drawn from the same distribution; the alternative hypothesis is that the distributions are different. We reject the null hypothesis at the 95% level in favor of the alternative if the p-value of the test is less than 0.05. Running the test, <strong>p &lt; 0.01</strong>, so we can say the distributions are statistically different. (the p-values are the same whether the box office revenues are log-transformed or not)</li>
<li>The <a href="https://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U_test">Wilcoxon rank-sum test</a> for determining if the means (averages) of two populations are the same (null hypothesis) or different (alternative hypothesis). This test is used instead of a <em>t</em>-test if the populations are not Normally distributed, which is the case here. Running the test (one-sided, since only checking if a mean is greater), <strong>p &lt; 0.01</strong>, so we can say the two means are statistically different. (again, the p-values are the same whether the box office revenues are log-transformed or not)</li>
</ul>
<p>So we have statistical evidence that male-lead movies generate more money on average than female-led movies. But this claim is very serious, and as a result, we need even more proof.</p>
<h2 id="the-resampling">The Resampling</h2>
<p>Although 2,020 movies is a fair sample size by statistical standards, some may argue that the movies were chosen too arbitrarily and that there is not enough data to support the conclusions I make above. Enter <a href="https://en.wikipedia.org/wiki/Bootstrapping_%28statistics%29">bootstrap resampling</a>, in which we resample the data randomly (with replacement) to generate pseudo-datasets, and then calculate aggregate statistics (e.g. the average) on that simulated dataset. Repeat a large number of times, and we can form confidence intervals for the <em>true average</em> of a given data set.</p>
<p>In this case, we resample the box office revenues, calculate the average box office revenue for both male-led and female-led movies, store the result away and resample the data again, and keep repeating until satisfied.</p>
<p>Here&rsquo;s an animation of the resampling of both averages as the number of trials increases. As you can see, the shape of both distributions stabilize very quickly:</p>
<figure>

    <img loading="lazy" srcset="/2016/04/movie-gender/movie_frames_hu_b75f68c94f8f6b6c.webp 320w,/2016/04/movie-gender/movie_frames.gif 640w" src="movie_frames.gif"/> 
</figure>

<p>And the final plot, at 10,000 repetitions:</p>
<figure>

    <img loading="lazy" srcset="/2016/04/movie-gender/movie-gender-10_hu_9b2659adbcd46e82.webp 320w,/2016/04/movie-gender/movie-gender-10_hu_acd47c18821179f9.webp 768w,/2016/04/movie-gender/movie-gender-10_hu_c29d82b32f0a9e86.webp 1024w,/2016/04/movie-gender/movie-gender-10.png 1200w" src="movie-gender-10.png"/> 
</figure>

<p>The dot on the bottom of each distribution represents the <em>actual</em> sample average value calculated during the analysis earlier, while the line range represents a 95% confidence interval for the true average revenue value for each gender. The distribution of male-led movie averages is more narrow than female-led movies because there are 3 times as many male-led movies in the dataset.</p>
<p>As you can see, <em>the line ranges never intersect</em>. Even in the most favorable scenario at the 95% confidence level, the average domestic box office revenue for male-led movies will be greater. Specifically, of the 10,000 trials, only 2 trials had the case where female-led movies had equal or greater average revenue than the corresponding male-led movie revenue average from the same resampling; this implies <strong>p &lt; 0.01</strong> for the statistical test on whether the means are same or different.</p>
<p>Interestingly, there&rsquo;s a little overlap between in the distributions, which occurs when there are multiple instances of Star Wars VII in the resampled dataset and its high box office revenue pushes the <em>entire</em> female-lead average up very significantly.</p>
<h2 id="gender-and-quality">Gender and Quality</h2>
<p>It is also worth checking if male-led movies are <em>better in quality</em> than female-lead movies, as if that&rsquo;s the case, it might provide a more logical explanation why male-led movies make more money.</p>
<p>Let&rsquo;s check out the distribution of <a href="http://www.rottentomatoes.com">Rotten Tomatoes</a> Tomatometer scores of blockbuster movies.</p>
<figure>

    <img loading="lazy" srcset="/2016/04/movie-gender/movie-gender-4_hu_c3b4f611e5c0231b.webp 320w,/2016/04/movie-gender/movie-gender-4_hu_f5aee80afb8650f0.webp 768w,/2016/04/movie-gender/movie-gender-4_hu_98b2025a9dfc28cc.webp 1024w,/2016/04/movie-gender/movie-gender-4.png 1200w" src="movie-gender-4.png"/> 
</figure>

<figure>

    <img loading="lazy" srcset="/2016/04/movie-gender/movie-gender-5_hu_c66691d9603885b7.webp 320w,/2016/04/movie-gender/movie-gender-5_hu_4ad061f35df20055.webp 768w,/2016/04/movie-gender/movie-gender-5_hu_df788c802ac21824.webp 1024w,/2016/04/movie-gender/movie-gender-5.png 1200w" src="movie-gender-5.png"/> 
</figure>

<figure>

    <img loading="lazy" srcset="/2016/04/movie-gender/movie-gender-6_hu_e6fb427934edc63c.webp 320w,/2016/04/movie-gender/movie-gender-6_hu_93ae8dc244bf6e6c.webp 768w,/2016/04/movie-gender/movie-gender-6_hu_a4408dc61dff270.webp 1024w,/2016/04/movie-gender/movie-gender-6.png 1200w" src="movie-gender-6.png"/> 
</figure>

<p>There&rsquo;s no obvious difference. Female-led movies are about 2% points lower on average, but the general distribution is the same (<a href="https://en.wikipedia.org/wiki/Uniform_distribution_%28continuous%29">uniform</a>). Overlaying the two distributions shows as such.</p>
<p>The difference in averages is <em>not</em> statistically significant, as both the Kolmogorov–Smirnov test and the Wilcoxon rank-sum test fail to reject the null hypothesis at the 95% level (<strong>p = 0.37</strong> and <strong>p = 0.13</strong> respectively).</p>
<p>How about <a href="http://www.metacritic.com">Metacritic</a> scores?</p>
<figure>

    <img loading="lazy" srcset="/2016/04/movie-gender/movie-gender-7_hu_bed036eec5e23a96.webp 320w,/2016/04/movie-gender/movie-gender-7_hu_df2796912327ea43.webp 768w,/2016/04/movie-gender/movie-gender-7_hu_a7163ec6edb706d7.webp 1024w,/2016/04/movie-gender/movie-gender-7.png 1200w" src="movie-gender-7.png"/> 
</figure>

<figure>

    <img loading="lazy" srcset="/2016/04/movie-gender/movie-gender-8_hu_f1fa3d62ef9f075e.webp 320w,/2016/04/movie-gender/movie-gender-8_hu_fa5b50e026f60232.webp 768w,/2016/04/movie-gender/movie-gender-8_hu_5878e9f85f0d96fd.webp 1024w,/2016/04/movie-gender/movie-gender-8.png 1200w" src="movie-gender-8.png"/> 
</figure>

<figure>

    <img loading="lazy" srcset="/2016/04/movie-gender/movie-gender-9_hu_634303e4c532c292.webp 320w,/2016/04/movie-gender/movie-gender-9_hu_e0edcb3be8564355.webp 768w,/2016/04/movie-gender/movie-gender-9_hu_a560b65aabb24d98.webp 1024w,/2016/04/movie-gender/movie-gender-9.png 1200w" src="movie-gender-9.png"/> 
</figure>

<p>Again, distributions are the same (both take on the shape of a <a href="https://en.wikipedia.org/wiki/Normal_distribution">Normal distribution</a>, interestingly). And again, the Kolmogorov–Smirnov test and the Wilcoxon rank-sum test fail. (<strong>p = 0.45</strong> and <strong>p = 0.14</strong> respectively).</p>
<p>The quality of a movie is independent from the gender of the lead actor in determining the financial performance of a movie.</p>
<h2 id="conclusion">Conclusion</h2>
<p>In 2014, <a href="http://www.mpaa.org/wp-content/uploads/2015/03/MPAA-Theatrical-Market-Statistics-2014.pdf">according to the MPAA</a>, the gender breakdown of moviegoers who see blockbuster movies is about 50/50, eliminating another potential explanation for the average movie revenue discrepancy.</p>
<p>Granted, there still can be more work done, such as controlling on movie Genre in addition to gender. Is the gender of the lead actor a <em>causal</em> factor in a movie&rsquo;s success? Not necessarily, and this analysis does not assert such. But there definitely is a revenue disparity that&rsquo;s worth investigating, and it&rsquo;s not just that &ldquo;male-led movies are better.&rdquo;</p>
<p>There may be more movies like Star Wars Episode VII where a movie with a female lead can hit almost a billion dollars domestically (e.g. Star Wars VIII). Things are looking upward, and it would not surprise me if the 22% revenue difference decreases and disappears in the next decade.</p>
<hr>
<p><em>You can view the code used to process the data and generate the data visualizations <a href="https://github.com/minimaxir/movie-gender/blob/master/movie_gender.ipynb">in this Jupyter notebook</a>, <a href="https://github.com/minimaxir/movie-gender">open-sourced on GitHub</a>, or you can <a href="https://github.com/minimaxir/movie-gender/raw/master/movie_gender_pdf.pdf">view as a PDF</a> which is better if you are on a mobile device.</em></p>
<p><em>You are free to use the charts from this article however you wish, but it would be greatly appreciated if proper attribution is given to this article and/or myself!</em></p>
]]></content:encoded>
    </item>
    <item>
      <title>Locating All the Christmas Trees on Instagram</title>
      <link>https://minimaxir.com/2015/01/tree-time/</link>
      <pubDate>Thu, 01 Jan 2015 09:00:00 -0700</pubDate>
      <guid>https://minimaxir.com/2015/01/tree-time/</guid>
      <description>I downloaded &lt;em&gt;hundreds of thousands&lt;/em&gt; of #tree images and found 25,432 images which were taken on Christmas, have a #tree, and, most importantly, contain location data where the photo was taken.</description>
      <content:encoded><![CDATA[<p>Everyone enjoys taking photos of their Christmas trees, usually at their own home of their relatives. <a href="http://instagram.com/">Instagram</a> allows users to quickly upload any photo and share it socially to the world. On Christmas Eve, privacy author Tommy Collison <a href="http://www.tommycollison.com/blog/2014/12/24/christmas-geotagging">published a warning about this behavior</a>, noting that if a user tags a photo with #tree to tag their Christmas tree, for example, <em>anyone</em> will be able to see it, and if the user attached their location to the photo, anyone could theoretically find where they live.</p>
<p>How practical is this concern? Instagram <a href="http://instagram.com/developer/">offers an API</a> of all recent photos for a given #tag so developers can download pictures and their corresponding metadata, such as geolocation, in bulk. (Up to <em>165,000</em> Instagram images can be processed per hour!)</p>
<p>I downloaded <em>hundreds of thousands</em> of #tree images and found 25,432 images which were taken on Christmas, have a #tree, and, most importantly, contain location data where the photo was taken. From that, I created an <a href="https://www.google.com/fusiontables/DataSource?docid=1J3RQB6MuFbZvA_WcCVHlKAzDBUppxFBQ3LA054RL">interactive map</a> showing the location of all these images worldwide using <a href="https://support.google.com/fusiontables/answer/2571232?hl=en">Google Fusion Tables</a>. You can click-and-drag to move the map all over the world, and you can click on a marker on the map to see the Instagram image taken at that location! (note that if you&rsquo;re on a mobile device, the embedded map may work better on a desktop browser)</p>
<p>I found a few interesting things while playing with this map.</p>
<h2 id="christmas-trees-in-the-usa">Christmas Trees in the USA</h2>
<p>A downside of the interactive map is that quantifying the relative number of photos between dense areas (e.g. cities) can be misleading as the opaque markers overlap. Here is a static map of all of the Instagram photos in the United States, with each translucent point representing an image:</p>
<figure>

    <img loading="lazy" srcset="/2015/01/tree-time/instagram_treemap_state_hu_310e6466cb4d56c6.webp 320w,/2015/01/tree-time/instagram_treemap_state_hu_5bd9d945a0e5960c.webp 768w,/2015/01/tree-time/instagram_treemap_state_hu_f34ea37f8f670d55.webp 1024w,/2015/01/tree-time/instagram_treemap_state.png 1500w" src="instagram_treemap_state.png"/> 
</figure>

<p>The number of photos is densest near the large cities, which is what you would expect.</p>
<p>A way to calculate the relative proportion of the number of #tree photos between states is to use a type of chart known as a <a href="http://en.wikipedia.org/wiki/Treemapping">treemap</a> (pun <em>very</em> much intended).</p>
<figure>

    <img loading="lazy" srcset="/2015/01/tree-time/treemap-state_hu_8bc2d93f35500ca9.webp 320w,/2015/01/tree-time/treemap-state_hu_1bd1917eb4e74033.webp 768w,/2015/01/tree-time/treemap-state_hu_c02e557e8ccd19cf.webp 1024w,/2015/01/tree-time/treemap-state.png 1200w" src="treemap-state.png"/> 
</figure>

<p>In this treemap, the relative area of each block corresponds to the number of photos taken in the state; therefore, the combination of all the blocks represents 100% of the #tree photos taken in the USA. If two blocks are the same size (e.g. New York and Florida), then they have the same number of #tree photos.</p>
<p>As you may have noticed from these two charts, these data represented by these two charts is approximately the same as the <a href="http://en.wikipedia.org/wiki/List_of_U.S._states_and_territories_by_population">population density in the United States</a>. Although this touches on the <a href="http://xkcd.com/1138/">infamous statistical problem</a> of heat maps resembling population maps, in this case, it&rsquo;s what would be expected.</p>
<p>Looking at all the #tree photos in the world may tell a different story.</p>
<h2 id="christmas-trees-in-the-world">Christmas Trees in the World</h2>
<p>Christmas is a holiday for only one religion with a <a href="http://en.wikipedia.org/wiki/Christianity_by_country">low presence in Asia and northern Africa</a>, so it would be expected that the locations of Christmas trees worldwide do <em>not</em> correlate with population, which makes the analysis more interesting.</p>
<figure>

    <img loading="lazy" srcset="/2015/01/tree-time/instagram_world_map_hu_f4d21dccf9584d5f.webp 320w,/2015/01/tree-time/instagram_world_map_hu_4b8e0faede23b8c4.webp 768w,/2015/01/tree-time/instagram_world_map_hu_c92b64f4e8488b9f.webp 1024w,/2015/01/tree-time/instagram_world_map.png 1770w" src="instagram_world_map.png"/> 
</figure>

<p>The prevalence of Christmas trees is most prominent in the United States and Europe, with relatively few in Asia, where the majority of the world&rsquo;s population is located. Italy has Christmas trees <em>uniformly</em> throughout the entire country, which is an interesting behavior.</p>
<figure>

    <img loading="lazy" srcset="/2015/01/tree-time/treemap-world_hu_2356b81e1b32b230.webp 320w,/2015/01/tree-time/treemap-world_hu_b16be6e56813d829.webp 768w,/2015/01/tree-time/treemap-world_hu_42fd89f2e00723c.webp 1024w,/2015/01/tree-time/treemap-world.png 1200w" src="treemap-world.png"/> 
</figure>

<p>The treemap confirms that Asian and African countries like China, India, and Nigeria do not have as many Christmas trees than <a href="http://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_population">what their large populations would suggest</a>. Italy, however has a <a href="http://en.wikipedia.org/wiki/Demographics_of_Italy">population of 60 million</a> (the same as the United Kingdom) which is about 1/5th of the population of United States; the fact that Italy has more than half of the number of Christmas Trees than the United States is very unusual and should be questioned.</p>
<p>Italy <em>may</em> have a high number of Christmas trees since Vatican City is the seat of the papacy, but perhaps data <em>itself</em> should be questioned too.</p>
<h2 id="christmas-trees-in-the-world-1">&ldquo;Christmas Trees&rdquo; in the World</h2>
<p>If you check the photos in Italy, you many notice that many of them have a photo caption similar to this one:</p>
<figure>

    <img loading="lazy" srcset="/2015/01/tree-time/christmas_tagsforlikes_hu_1a3d8d47a4ba1921.webp 320w,/2015/01/tree-time/christmas_tagsforlikes.png 384w" src="christmas_tagsforlikes.png"/> 
</figure>

<p>There&rsquo;s obviously no Christmas tree in that photo. But there are a <em>lot</em> of tags.</p>
<p>Many Instagram photos use a service called <a href="http://www.tagsforlikes.com/">TagsForLikes</a>, which complies a list of popular hashtags that other users are able to see. Users can then then copy/paste them into the photo caption to spam hashtags increase the photo exposure, which, as I&rsquo;ve shown <a href="http://minimaxir.com/2014/03/hashtag-tag/">in a previous blog post</a>, does in fact increase the number of Likes the photo receives from other users.</p>
<figure>

    <img loading="lazy" srcset="/2015/01/tree-time/tags4likes_hu_10d67579073c03b7.webp 320w,/2015/01/tree-time/tags4likes.png 617w" src="tags4likes.png"/> 
</figure>

<p>Notice a resemblance between this list and the photo caption?</p>
<p>Fortunately, all the TagsForLikes hashtag lists contain #TagsForLikes as a branding trick, which makes such photos extremely easy to detect. Here&rsquo;s what the world map looks like if all the potentially spam photos were colored red:</p>
<figure>

    <img loading="lazy" srcset="/2015/01/tree-time/instagram_world_spamnonspam_hu_dc13dbebf48ccb41.webp 320w,/2015/01/tree-time/instagram_world_spamnonspam_hu_224cf95473e67e26.webp 768w,/2015/01/tree-time/instagram_world_spamnonspam_hu_447405a41aacbe52.webp 1024w,/2015/01/tree-time/instagram_world_spamnonspam.png 1770w" src="instagram_world_spamnonspam.png"/> 
</figure>

<p>Italy looks a <em>lot</em> different now! There is red in other counties, but it&rsquo;s not easily visible at a glance.</p>
<p>The treemap of photos, when seperated between spam and non-spam photos, tells the full story:</p>
<figure>

    <img loading="lazy" srcset="/2015/01/tree-time/treemap-spam-nonspam_hu_6c6548fc4a027e9a.webp 320w,/2015/01/tree-time/treemap-spam-nonspam_hu_3d902d5b2452b0ca.webp 768w,/2015/01/tree-time/treemap-spam-nonspam_hu_eaf60683eae8e729.webp 1024w,/2015/01/tree-time/treemap-spam-nonspam.png 1200w" src="treemap-spam-nonspam.png"/> 
</figure>

<p>About 20% of all the #tree photos are spam photos, and about half of those were taken by people in Italy. As a result, Italy has <em>more spam #tree photos than nonspam #tree photos!</em> This is an interesting cultural phenomenon that I have no guesses as to why it occurs. All other countries have significantly smaller numbers of spam photos relatively non-spam photos.</p>
<p>For non-spam photos, the number of #tree photos in Italy now matches the number of non-spam photos in the UK, which correlates with their populations, making the removal of spam photos a sane move.</p>
<p>Is it possible to track people in their homes via Instagram tags? Definitely. If you do care privacy and your Instagram account is not set to Private, I recommend not geotagging your photos. If you&rsquo;re interested in looking at such photos, ensure that the the tag is relevant for the given photo.</p>
<hr>
<p><em>All graphics were generated using R. The maps were created using <a href="http://ggplot2.org/">ggplot2</a> and the world map provided with the <a href="http://cran.r-project.org/web/packages/rworldxtra/index.html">rworldxtra</a> package. The treemaps were created using the <a href="http://cran.r-project.org/web/packages/treemap/index.html">treemap</a> package.</em></p>
<p><em>The source data is included with a seperate tab in Google Fusion Tables <a href="https://www.google.com/fusiontables/DataSource?docid=1J3RQB6MuFbZvA_WcCVHlKAzDBUppxFBQ3LA054RL">along with the interactive map</a>.</em></p>
]]></content:encoded>
    </item>
    <item>
      <title>Who Performs the Best in Online Classes?</title>
      <link>https://minimaxir.com/2014/07/online-class-charts/</link>
      <pubDate>Thu, 10 Jul 2014 08:30:00 -0700</pubDate>
      <guid>https://minimaxir.com/2014/07/online-class-charts/</guid>
      <description>Which types of student characteristics lead to the best performance in online classes? That depends on how you define &amp;ldquo;performance.&amp;rdquo;</description>
      <content:encoded><![CDATA[<p>At the end of May, <a href="http://www.harvard.edu/">Harvard</a> and <a href="http://web.mit.edu/">MIT</a> jointly <a href="http://newsoffice.mit.edu/2014/mit-and-harvard-release-de-identified-learning-data-open-online-courses">released a dataset</a> containing statistics about their online courses in the Academic Year of 2013. This <a href="http://dx.doi.org/10.7910/DVN/26147">Person-Course De-Identified dataset</a> contains 641,138 events, chronicling 476,532 students who have taken up to 13 unique courses from a variety of topics.</p>
<p>However, this assortment of courses is not a substitution for a typical college education, as the vast majority of students only take one class.</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/student-courses_hu_1f69b16ff227e785.webp 320w,/2014/07/online-class-charts/student-courses_hu_ba64318b3158934a.webp 768w,/2014/07/online-class-charts/student-courses_hu_aa97227dda830e1.webp 1024w,/2014/07/online-class-charts/student-courses.png 1200w" src="student-courses.png"/> 
</figure>

<p>Very, very few students take more than one class (22% of all students).</p>
<p>Other interesting variables included with the data set are the level-of-education of the student, the birth date of the student, the gender of the student, and the geographical location of student.</p>
<p>Which types of student characteristics lead to the best performance in these online classes? That depends on how you define &ldquo;performance.&rdquo;</p>
<p>Here&rsquo;s a look at the attendance of all the classes:</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/class-attendance_hu_309c150c193a7cf.webp 320w,/2014/07/online-class-charts/class-attendance_hu_b6e6a51f7fedf99e.webp 768w,/2014/07/online-class-charts/class-attendance_hu_1c38e8b439a9b471.webp 1024w,/2014/07/online-class-charts/class-attendance.png 1200w" src="class-attendance.png"/> 
</figure>

<p>Harvard&rsquo;s Introduction to Computer Science is by far the most popular class, and that&rsquo;s only accounting for one semester. (it still beat MIT&rsquo;s Intro to CS/Programming, which had 2 semesters).</p>
<p>Each color bar indicates the level of student participation in the class. <strong>Registered</strong> means the student simply registered for the class; <strong>Viewed</strong> means that the student viewed some of the course material, <strong>Explored</strong> means that students viewed atleast half of the course material, and <strong>Certified</strong> means that students completed the course and received a certificate of accomplishment. For the chart, it&rsquo;s interesting to note that most classes have a high percentage of people in each class who simply register just for fun and <em>don&rsquo;t actually do anything.</em></p>
<p>One metric of course success is the completion rate of each course, i.e. how many people actually complete the course after starting it. A frequent criticism of free online classes is that this number is very low, but what are the actual completion rates of these 13 classes?</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/class-perc-finished_hu_84a22119799a8548.webp 320w,/2014/07/online-class-charts/class-perc-finished_hu_14fd23dd414891c8.webp 768w,/2014/07/online-class-charts/class-perc-finished_hu_ce807a7001dd3f0a.webp 1024w,/2014/07/online-class-charts/class-perc-finished.png 1200w" src="class-perc-finished.png"/> 
</figure>

<p>Completion rates are low across the board, from 0.8% to 7.5%. A <a href="http://www.insidehighered.com/news/2013/05/10/new-study-low-mooc-completion-rates">2013 study</a> found that completion rate is less than 7%, which this data follows. Apparently, Challenges of Global Poverty is a very interesting course.</p>
<p>After the student completes a class, he or she receives a final grade, and if the grade is above the cutoff point (usually 50% - 80%), they will complete the class and receive the certificate. Here&rsquo;s the distribution of the average grades for students in each class, given that the student has successfully completed the class:</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/class-perc-grade_hu_3024a79b69a75b6a.webp 320w,/2014/07/online-class-charts/class-perc-grade_hu_d5a8ed7de8365738.webp 768w,/2014/07/online-class-charts/class-perc-grade_hu_58ae3c4aa5776ab.webp 1024w,/2014/07/online-class-charts/class-perc-grade.png 1200w" src="class-perc-grade.png"/> 
</figure>

<p>The grades vary significantly between classes. This doesn&rsquo;t necessarily imply that some classes are harder than others; it&rsquo;s possible some classes had lower cutoffs and therefore the effort put in by the students is lower. However, the perfect 100% average for Harvard&rsquo;s Intro to CS course implies that the class is pass/fail and that students can&rsquo;t get a final grade less than 100%. (as a result, we&rsquo;ll need to remove that class from future grade analyses in order to prevent bias due to the lack of score variance)</p>
<h2 id="age">Age</h2>
<p>Online classes are marketed toward college-age students.</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/student-age_hu_6807d79095a2ff9f.webp 320w,/2014/07/online-class-charts/student-age_hu_e18b3c21b40aee25.webp 768w,/2014/07/online-class-charts/student-age_hu_a6e0385b7db53e91.webp 1024w,/2014/07/online-class-charts/student-age.png 1200w" src="student-age.png"/> 
</figure>

<p>The mean age is about <strong>27.7</strong>, with a standard deviation of 8.89. The shape skews right and resembles a <a href="http://en.wikipedia.org/wiki/Gamma_distribution">gamma distribution</a>. There are even plenty of teenagers taking these classes too.</p>
<p>The proportion of students who take more than one class for each age group has a slightly flatter distribution, although more centralized at students in their 20&rsquo;s.</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/student-num-classes_hu_9c915570951ae0bc.webp 320w,/2014/07/online-class-charts/student-num-classes_hu_4cd1ab3cc2f0cccd.webp 768w,/2014/07/online-class-charts/student-num-classes_hu_64cbc61f2244451c.webp 1024w,/2014/07/online-class-charts/student-num-classes.png 1200w" src="student-num-classes.png"/> 
</figure>

<p>What about completion rate?</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/student-fulfillment_hu_815ed115d6a1ffa9.webp 320w,/2014/07/online-class-charts/student-fulfillment_hu_a2752617681d3a73.webp 768w,/2014/07/online-class-charts/student-fulfillment_hu_de7c359778e0ad44.webp 1024w,/2014/07/online-class-charts/student-fulfillment.png 1200w" src="student-fulfillment.png"/> 
</figure>

<p>Completion rate is a little more evenly distributed between the ages, indicating that the two metrics are likely uncorrelated. However, the older students have nearly double the completion rate of classes. (more on this later)</p>
<h2 id="education">Education</h2>
<p>One of the student-provided attributes is his or her highest level of education. These values are &ldquo;Less than Secondary,&rdquo; &ldquo;Secondary&rdquo;, &ldquo;Bachelor&rsquo;s&rdquo;, &ldquo;Master&rsquo;s&rdquo;, and &ldquo;Doctorate.&rdquo; Here&rsquo;s the distribution of the 409,601 students who provided their LoE:</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/education-count_hu_e516c9e258fac872.webp 320w,/2014/07/online-class-charts/education-count_hu_88815aeaf82ec8bc.webp 768w,/2014/07/online-class-charts/education-count_hu_4c7ca564ab53289b.webp 1024w,/2014/07/online-class-charts/education-count.png 1200w" src="education-count.png"/> 
</figure>

<p>This shows that the majority of students who are taking these online classes have already finished college and already obtained a degree, and therefore are likely taking the course as supplemental material.</p>
<p>We can correlate the levels of education with the average age for each LoE as a double-check.</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/education-age_hu_c6a3efb815a9cb41.webp 320w,/2014/07/online-class-charts/education-age_hu_f235f279c423cbcb.webp 768w,/2014/07/online-class-charts/education-age_hu_78613cdfee40ab3b.webp 1024w,/2014/07/online-class-charts/education-age.png 1200w" src="education-age.png"/> 
</figure>

<p>Indeed, each LoE average age is above the minimum expected threshold of time needed for each degree (~18 years for Secondary, ~22 years for Bachelor&rsquo;s, etc.)</p>
<p>How does the completion rate vary?</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/education-fulfillment_hu_9fd83dcbea2027f.webp 320w,/2014/07/online-class-charts/education-fulfillment_hu_896ebd06769a0a9e.webp 768w,/2014/07/online-class-charts/education-fulfillment_hu_40fb59a819fd2e28.webp 1024w,/2014/07/online-class-charts/education-fulfillment.png 1200w" src="education-fulfillment.png"/> 
</figure>

<p>Interestingly, those with Less than Secondary education have a much higher completion rate than those with Secondary educations and Bachelor&rsquo;s Degrees.</p>
<p>But are Doctorate smarter than those with lower education levels? Do they get higher grades on average?</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/education-grade_hu_c47a4403e95fee24.webp 320w,/2014/07/online-class-charts/education-grade_hu_609c06c2b1092a38.webp 768w,/2014/07/online-class-charts/education-grade_hu_8b5dacc02f4b7b4d.webp 1024w,/2014/07/online-class-charts/education-grade.png 1200w" src="education-grade.png"/> 
</figure>

<p>As it turns out, yes. The education level of a student is very relevant to a his or her academic performance in online classes.</p>
<h2 id="gender">Gender</h2>
<p>I previously <a href="http://minimaxir.com/2014/07/gender-course/">made a blog post</a> discussing the genders of students and the proportion of students by course. As it turns out, gender is a very important part of the student body composition.</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/gender-count_hu_b414e31dcd2d8ca.webp 320w,/2014/07/online-class-charts/gender-count_hu_12994bfa71cba66a.webp 768w,/2014/07/online-class-charts/gender-count_hu_7824ce476f654770.webp 1024w,/2014/07/online-class-charts/gender-count.png 1200w" src="gender-count.png"/> 
</figure>

<p>425,108 students have a gender on record, with 311,534 male students (73.3%) and 113,571 female students (26.7%). The fact that it&rsquo;s not even close to 50:50 is surprising.</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/gender-age_hu_539f995018b912df.webp 320w,/2014/07/online-class-charts/gender-age_hu_bc95ac13a6e629a2.webp 768w,/2014/07/online-class-charts/gender-age_hu_958ea821aba2a296.webp 1024w,/2014/07/online-class-charts/gender-age.png 1200w" src="gender-age.png"/> 
</figure>

<p>Age wise, there&rsquo;s not much difference between the genders. Female students are about a year older than male students on average.</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/gender-completion_hu_9c7d417f25dda2e1.webp 320w,/2014/07/online-class-charts/gender-completion_hu_df99c0272323ff57.webp 768w,/2014/07/online-class-charts/gender-completion_hu_7f901b735c694e27.webp 1024w,/2014/07/online-class-charts/gender-completion.png 1200w" src="gender-completion.png"/> 
</figure>

<p>Completion rate varies a bit more. Female students finish classes more frequently than male students.</p>
<p>Now to answer the age-old question: who get better grades: men or women?</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/gender-grade_hu_1c93bf06e894b04b.webp 320w,/2014/07/online-class-charts/gender-grade_hu_bcc0bf07a291db60.webp 768w,/2014/07/online-class-charts/gender-grade_hu_5cee9f59c053acd8.webp 1024w,/2014/07/online-class-charts/gender-grade.png 1200w" src="gender-grade.png"/> 
</figure>

<p>Ok, it&rsquo;s a tie.</p>
<h2 id="country">Country</h2>
<p>The home location of the students is, in my opinion, the most interesting student attribute in the data set. There are 24 different countries which were specified among 325,012 different students.</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/country-count_hu_249b43a42a00df0f.webp 320w,/2014/07/online-class-charts/country-count_hu_7a3b5a1a0883c878.webp 768w,/2014/07/online-class-charts/country-count_hu_953d18e6b6d1a170.webp 1024w,/2014/07/online-class-charts/country-count.png 1200w" src="country-count.png"/> 
</figure>

<p>The United States, as one of the more technologically-savvy countries, accounts for nearly 1/3rd of all online students. India has a very strong presence as well due to the combination of population and accessibility of materials. All the other countries have significantly fewer students.</p>
<p>Given such accessibility of online classes, students in some countries take more classes than others.</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/country-more-than-one_hu_bda45a1c1f50d29b.webp 320w,/2014/07/online-class-charts/country-more-than-one_hu_2e2cdce597206d16.webp 768w,/2014/07/online-class-charts/country-more-than-one_hu_f2ed6b9d4e00e5da.webp 1024w,/2014/07/online-class-charts/country-more-than-one.png 1200w" src="country-more-than-one.png"/> 
</figure>

<p>India&rsquo;s students also take the most classes on average.</p>
<p>The United States also has the oldest students on average among all the countries.</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/country-age_hu_1c71b549f970c024.webp 320w,/2014/07/online-class-charts/country-age_hu_32b19520dc1681a1.webp 768w,/2014/07/online-class-charts/country-age_hu_185d4bb0414d7b3f.webp 1024w,/2014/07/online-class-charts/country-age.png 1200w" src="country-age.png"/> 
</figure>

<p>Completion rate by country, however, is very, very significant.</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/country-completion_hu_526cedb1dfaaf5d8.webp 320w,/2014/07/online-class-charts/country-completion_hu_f6a6e7abe5fbc174.webp 768w,/2014/07/online-class-charts/country-completion_hu_db06854f718fda2e.webp 1024w,/2014/07/online-class-charts/country-completion.png 1200w" src="country-completion.png"/> 
</figure>

<p>The top seven countries with the highest rate of completion are <strong>all European countries</strong>, with Spain and Poland in particular having a higher rate of completion than all the other countries, and nearly <strong>four times</strong> the completion rate of the United States.</p>
<p>But which country has the students which get the best grades?</p>
<figure>

    <img loading="lazy" srcset="/2014/07/online-class-charts/country-grade_hu_3413485dc36590a8.webp 320w,/2014/07/online-class-charts/country-grade_hu_5ff553dbf0956728.webp 768w,/2014/07/online-class-charts/country-grade_hu_16b598e63ba06c34.webp 1024w,/2014/07/online-class-charts/country-grade.png 1200w" src="country-grade.png"/> 
</figure>

<p>China is at the top with 86%, but otherwise the distribution is fairly flat with no outliers, and no economic or demographical pattern to the top or bottom of the ranks. It&rsquo;s possible that the more structured format of the classes make it harder to skew.</p>
<p>This Person-Course dataset has helped reveal many interesting insights about online classes at Harvard and MIT. Whether you measure performance by % of classes completed or a % score received at the end of the class, it&rsquo;s clear that age, country, and level of education all have a statistically significant impact on performance. The impact of the student&rsquo;s gender on performance, however, is more ambiguous and could use further analysis.</p>
<hr>
<ul>
<li><em>Data was processed using R and all charts were made using ggplot2.</em></li>
<li><em>You can view code necessary to reproduce these results AND reproduce all the charts in <a href="https://github.com/minimaxir/online-class-charts">this GitHub repository</a>. Since MIT/Harvard prevent redistribution of the dataset, you&rsquo;ll have to <a href="http://dx.doi.org/10.7910/DVN/26147">download the dataset</a> yourself.</em></li>
</ul>
]]></content:encoded>
    </item>
    <item>
      <title>Mapping San Francisco Locations Using Facebook Data</title>
      <link>https://minimaxir.com/2014/04/san-francisco/</link>
      <pubDate>Tue, 08 Apr 2014 08:00:00 -0700</pubDate>
      <guid>https://minimaxir.com/2014/04/san-francisco/</guid>
      <description>With the data on approximately 8,000 Facebook Places in San Francisco, we can map where San Franciscans are checking-in, and determine what types of locations they like to visit.</description>
      <content:encoded><![CDATA[<p>Statisticians like to use data from the <a href="https://www.census.gov/">United States Census</a> to plot interesting trends such as unemployment and population of regions across the country. However, such data is typically historical and not very robust.</p>
<p>Facebook, on the other hand, has collected a large amount of data though its <a href="https://www.facebook.com/about/location">Places product</a>. Facebook Places allows users to &ldquo;check-in&rdquo; a place such as <a href="https://www.facebook.com/pages/Dolores-Park/105687759464007">Dolores Park</a> in a manner similar to <a href="https://foursquare.com/">Foursquare</a>.</p>
<figure>

    <img loading="lazy" srcset="/2014/04/san-francisco/dolores_hu_12ede87833359ff4.webp 320w,/2014/04/san-francisco/dolores_hu_52114517e94363ec.webp 768w,/2014/04/san-francisco/dolores.png 1011w" src="dolores.png"/> 
</figure>

<p>Through clever use of Facebook&rsquo;s Graph API and FQL, I was able to retrieve the data on all Facebook Places in and around San Francisco, along with the # of check-ins at each Place. With the data on approximately 8,000 Facebook Places in San Francisco, we can map where San Franciscans are checking-in, and determine what types of locations they like to visit.</p>
<!-- more -->
<p>First, let&rsquo;s look at the distribution of check-ins among Places in San Francisco:</p>
<figure>

    <img loading="lazy" srcset="/2014/04/san-francisco/sf-checkin-distribution_hu_3854c345ddda42aa.webp 320w,/2014/04/san-francisco/sf-checkin-distribution_hu_841db3f768d77d95.webp 768w,/2014/04/san-francisco/sf-checkin-distribution_hu_e7b23d21ac85d350.webp 1024w,/2014/04/san-francisco/sf-checkin-distribution.png 1200w" src="sf-checkin-distribution.png"/> 
</figure>

<p>On a logarithmic scale, the shape resembles a bell curve with a center at about 800 check-ins; however, the sample average of check-ins for the data set is <strong>3,241 check-ins</strong>, indicating that the data may be heavily skewed to the right. Some Places don&rsquo;t have many check-ins, while some Places have an incredibly large number of check-ins.</p>
<p>What are the Places with hundreds of thousands of check-ins? What does the city look like with all these Places plotted on a map of San Francisco?</p>
<figure>

    <img loading="lazy" srcset="/2014/04/san-francisco/sf-checkin_hu_f626a76ff02105d8.webp 320w,/2014/04/san-francisco/sf-checkin_hu_d002d3105f0deace.webp 768w,/2014/04/san-francisco/sf-checkin.png 900w" src="sf-checkin.png"/> 
</figure>

<p><em><a href="https://www.dropbox.com/s/cykofhlyus8atgw/sf-bubble.pdf">(PDF of Map)</a></em></p>
<p>The most checked-in Places are, unsurprisingly, the famous tourist attractions of San Francisco, such as <a href="https://www.facebook.com/pages/ATT-Park/116440731717551">AT&amp;T Park</a> and <a href="https://www.facebook.com/UnionSquareSF">Union Square</a>. These Top Places are spread all over the city.</p>
<p>It&rsquo;s also clear where the most dense areas are located in San Francisco. There are plainly-visible lines of Places along southern Mission Street and Outer Sunset. SOMA and Richmond have a large number of Places as well.</p>
<p>And yes, 155,000 people really did check-into <a href="https://www.facebook.com/pages/The-Cheesecake-Factory/107178672654937">The Cheesecake Factory</a>.</p>
<h2 id="what-types-of-locations-do-people-in-san-francisco-frequently-check-into">What types of locations do people in San Francisco frequently check-into?</h2>
<p>Facebook also records the category of its Places, such as &ldquo;Bar&rdquo; and &ldquo;Restaurant&rdquo;. What are the most numerous types of locations in San Francisco?</p>
<figure>

    <img loading="lazy" srcset="/2014/04/san-francisco/sf-checkin-distribution-count_hu_f79cbd2abc63c07c.webp 320w,/2014/04/san-francisco/sf-checkin-distribution-count_hu_5ed2300b1287f7bc.webp 768w,/2014/04/san-francisco/sf-checkin-distribution-count_hu_6b0563296ce10551.webp 1024w,/2014/04/san-francisco/sf-checkin-distribution-count.png 1200w" src="sf-checkin-distribution-count.png"/> 
</figure>

<p>Local businesses are by far the most frequent, as it&rsquo;s a more generic classifier for a Place and can be applied to anything that does not have an explicit classifier (such as startups). I find it interesting that non-profit organizations are more numerous than shopping centers.</p>
<p>However, the quantity of a specific type of business does not necessarily mean that San Franciscians will check-into that type of Place more often. Which type of Place, on average, receives the greatest number of check-ins?</p>
<figure>

    <img loading="lazy" srcset="/2014/04/san-francisco/sf-checkin-distribution-avg_hu_9d83d93564db88d4.webp 320w,/2014/04/san-francisco/sf-checkin-distribution-avg_hu_ebb677df847eeb2c.webp 768w,/2014/04/san-francisco/sf-checkin-distribution-avg_hu_12e33b3cf1fcb18d.webp 1024w,/2014/04/san-francisco/sf-checkin-distribution-avg.png 1200w" src="sf-checkin-distribution-avg.png"/> 
</figure>

<p>People are more likely to check-into memorable Places and events, instead of Places they frequently visit like Bars and Restaurants (Twice as many people check-into Attractions than Clubs). Again, tourist attractions are the most popular, which is due to both the relatively low number of Places and the extremely high number of check-ins into Places such as AT&amp;T Park.</p>
<p>The &ldquo;Lake&rdquo; corresponds to <a href="https://www.facebook.com/pages/Lake-Merced/113785468632283">Lake Merced</a>, if you&rsquo;re curious.</p>
<h2 id="which-san-francisco-neighborhoods-are-the-most-popular">Which San Francisco neighborhoods are the most popular?</h2>
<p>You saw earlier that the Facebook Places are concentrated in specific areas. Here&rsquo;s a map of San Francisco&rsquo;s neighborhoods, highlighted by the number of Places within:</p>
<figure>

    <img loading="lazy" srcset="/2014/04/san-francisco/sf-places-count_hu_a0cd8cba902f0960.webp 320w,/2014/04/san-francisco/sf-places-count_hu_1e7dbb5dad41ce5a.webp 768w,/2014/04/san-francisco/sf-places-count.png 900w" src="sf-places-count.png"/> 
</figure>

<p><em><a href="https://www.dropbox.com/s/63fgvcucvk9n9v3/sf-sum.pdf">(PDF of Map)</a></em></p>
<p>The neighborhoods with the most Places are unsurprisingly where the trendy areas are, such as the Mission and SOMA. Additionally, those types of neighborhoods are larger in square area than others, which may bias the results in their favor.</p>
<p>But are these large neighborhoods also the most active neighborhoods? Which neighborhoods have the most check-ins on average per Place within the neighborhood?</p>
<figure>

    <img loading="lazy" srcset="/2014/04/san-francisco/sf-places-avg_hu_b12109c74dbe9359.webp 320w,/2014/04/san-francisco/sf-places-avg_hu_a094e44cacbdee7d.webp 768w,/2014/04/san-francisco/sf-places-avg.png 900w" src="sf-places-avg.png"/> 
</figure>

<p><em><a href="https://www.dropbox.com/s/u613oh4fskjrkny/sf-avg.pdf">(PDF of Map)</a></em></p>
<p>The Embarcadero has by far the most check-ins on average, again, due to both its small size and AT&amp;T Park. Other neighborhoods, however, have more similar averages to each other. It&rsquo;s worth noting that the average number of check-ins is higher in neighborhoods adjacent to the San Francisco Bay, such as North Beach and Fisherman&rsquo;s Wharf: perhaps people check-in more frequently when they have a good view.</p>
<p>Can this data and conclusions about San Francisco Facebook Places be extrapolated to other cities? I&rsquo;d argue yes: it makes logical sense that people check-in more frequently to Places that are more significant, and it also makes sense that people frequently check-into Places with large amounts of tourist attractions. Facebook data shows us cool trends that the United States Census data cannot.</p>
<hr>
<p><em>All charts and maps were made using R, ggplot2, and ggmaps.</em></p>
<p><em>You can download a copy of the Facebook Places data set <a href="https://www.dropbox.com/s/6g6ap4poz1b2trs/sf-public.csv">here</a>. The place_id column corresponds to the San Francisco neighborhood where the Place is located.</em></p>
<p><em>Maps are from <a href="https://www.google.com/maps/">Google Maps</a>. San Francisco shape files for city neighborhoods are from <a href="https://data.sfgov.org/Service-Requests-311-/Neighborhoods/ejmn-jyk6">data.sf.gov</a>. Additionally, thanks to <a href="http://www.reddit.com/r/dataisbeautiful/comments/223ubt/map_of_places_in_san_francisco_by_of_facebook/">/r/dataisbeautiful</a> for offering ideas for improvements to the maps.</em></p>
<p><em>You may notice that the Check-In Counts on some of the official Facebook Place Pages strongly disagree with the Count reported in my charts. The Count reported on affected page is nearly double the value reported via the API in each instance. I believe this is a bug on Facebook&rsquo;s end: see <a href="http://i.imgur.com/I1syBhR.png">this image</a>, in which the Graph Search autocomplete reports a different value of check-ins than the Place Page itself. In this case, I trust the data from the API.</em></p>
]]></content:encoded>
    </item>
  </channel>
</rss>
