{"id":355,"date":"2020-03-24T11:57:58","date_gmt":"2020-03-24T17:57:58","guid":{"rendered":"https:\/\/briancroxall.net\/w20dh\/?page_id=355"},"modified":"2020-04-01T12:40:04","modified_gmt":"2020-04-01T18:40:04","slug":"topic-modeling-peanuts","status":"publish","type":"page","link":"https:\/\/briancroxall.net\/w20dh\/assignments\/topic-modeling-peanuts\/","title":{"rendered":"Topic Modeling Peanuts"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Rationale<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In the next week, we will have completed our reading of two of the <em>Complete Peanuts<\/em> volumes. As much time as we&#8217;ve spent on this, we&#8217;ll still have only seen 8% of Charles Schulz&#8217;s total output. We&#8217;ve read some of it closely thanks to your <a href=\"https:\/\/briancroxall.net\/w20dh\/assignments\/daily-comics-discussion\/\">daily comics discussions<\/a>, and we\u2019ve gotten an even closer look at a subset of those strips as we\u2019ve&nbsp;<a href=\"http:\/\/briancroxall.net\/w19dh\/assignments\/tei-markup\/\">marked them up with TEI and CBML<\/a>. With all of this behind us, I&#8217;m guessing that we could offer some pretty in-depth takes on what <em>Peanuts<\/em> is &#8220;about.&#8221; And yet, we&#8217;ll have only read two twenty-fifths of his 17,897 strips. So any pronouncements about what <em>Peanuts<\/em> is &#8220;about&#8221; at this point would necessarily require ignoring most of the available evidence. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Fortunately, digital humanities methods offer us multiple ways to understand what texts are &#8220;about&#8221; than the long and laborious process of reading them in the traditional way. One of these methods is topic modeling. From our reading, we know that topic modeling is, as <a href=\"http:\/\/journalofdigitalhumanities.org\/2-1\/topic-modeling-a-basic-introduction-by-megan-r-brett\/\">Megan Brett puts it<\/a>, &#8220;a way of identifying patterns in a corpus&#8221; by using an unsupervised machine-learning process to find &#8220;recurring pattern[s] of co-occurring words.&#8221; In other words, topic modeling should help us discover some of the underlying discourses within the whole <em>Peanuts<\/em> corpus, that thing we could never, ever read in a regular semester. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Of course, it needs to be said that topic modeling works with text and text only. And, as we all know at this point, <em>Peanuts<\/em> is about <em>so much more<\/em> than dialogue and diegetic text. This method cannot even pretend to account for the visual aspect of Schulz&#8217;s work. Nevertheless, in our quest to understand <em>Peanuts<\/em>\u2014and especially how it might change over time\u2014topic modeling provides us with a chance to consider patterns of linguistic affinity and difference that are invisible simply because of their scale. In short, while we know that topic modeling cannot be the final word about <em>Peanuts<\/em>, it&#8217;s still worth a shot!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Nitty Gritty<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For this assignment, you will produce several topic models of the text of Schulz&#8217;s strips and begin the process of analyzing them.&nbsp;The assignment has one outcome: a blog post. The blog post is due&nbsp;<strong>at the end of class on Monday, 30 March<\/strong>.&nbsp;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step One: Get the Data<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can find the GoComics <em>Peanuts<\/em> data in our repository in the <code>gocomics\/peanuts-txt<\/code> <a href=\"https:\/\/github.com\/briancroxall\/peanuts\/tree\/master\/gocomics\/peanuts-txt\">folder<\/a>. (If you sync your GitHub repo that you will have the files on your local hard drive.) Please remember that these data are copyrighted: while we are using them in a fair-use context (a research project and an educational experience), they should not be distributed outside of the class. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step&nbsp; Two: Model the Data<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Using MALLET and the&nbsp;<a href=\"https:\/\/briancroxall.net\/w20dh\/topic-modeling-step-by-step\/\">Step-by-Step Guide to Topic Modeling<\/a>, make at least <strong>5 different topic models of the corpus<\/strong>. Experiment with changing some or all of the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>the number of topics<\/li><li>using and&nbsp;<strong><em>not&nbsp;<\/em><\/strong>using&nbsp;stopwords; consider whether you need to supplement MALLET\u2019s default stopword list (viewable in the MALLET directory &gt; stoplists &gt; en.txt) with an additional stopwords file.<\/li><li>the number of iterations you run<\/li><li>whether or not you use the&nbsp;<code>--optimize-interval<\/code>&nbsp;setting<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Make sure that you keep careful records of the different commands you use to create each of the different models.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step Three: Analyze the Data<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">After making each model, look at the topic keys to see if there seem to be too few topics or too many. Too many topics tend to be easier to spot since you will have two or more topics that look relatively similar to one another. For example, if you have three \u201cbaseball\u201d topics, you should probably model the data with fewer topics. Too few topics can be spotted by there not being especially clear patterns to the topic keys. (That said, since we are working with relatively small documents rather than academic articles\u2014which is what topic modeling was designed around\u2014the clarity of such \u201cclear patterns\u201d is not guaranteed.)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">When you have a model with topic keys that seems workable, open the topic composition file in Excel. Insert a row at the top of the spreadsheet and name the columns to make them easy to work with. See which documents (AKA strips) rank high for the various topics. Do you see any patterns based on the year the poems are published in? Is there one topic that seems to be high for a lot more poems than you would expect? (This often happens and represents what I sometimes call&nbsp;the \u201cEnglish language\u201d topic. This becomes easier to spot if you\u2019ve used the&nbsp;<code>--optimize-interval<\/code>&nbsp;command.)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Outside of Excel, ask yourself which topics you are seeing that you had expected, which topics you hadn&#8217;t expected to appear, and which topics are &#8220;missing.&#8221; Consider which character names are prevalent in particular topics. Observe which words appear in multiple topics. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step Four: Visualize the Data<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Each of you should pick a favorite strip from the ones you selected for our daily discussions. Then, collectively, do one or more of the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Make a pie chart for each of the strips, showing which topics comprise the poem using Excel and the guidelines in Miriam Posner\u2019s \u201c<a href=\"http:\/\/miriamposner.com\/blog\/very-basic-strategies-for-interpreting-results-from-the-topic-modeling-tool\/\">Very basic strategies for interpreting results from the Topic Modeling Tool<\/a>\u201c<\/li><li>Identify the three most prominent topics for each strip, according to your model. Using the topic keys, color-code the terms in the strip that come from each of these three particular topics. <\/li><li>Ask me to prep your data for network visualization in Gephi (or run&nbsp;<code><a href=\"https:\/\/github.com\/briancroxall\/duffy2019\/blob\/master\/mallet2gephi.py\">mallet2gephi.py<\/a><\/code>&nbsp;yourself from the <code>scripts<\/code> folder in our repo).<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Step Five: Blog about the Data<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Write about your modeling and your data&nbsp;<a href=\"http:\/\/docs.google.com\/\">using Google Docs<\/a>. When you are done, make the Doc public and&nbsp;<a href=\"https:\/\/briancroxall.net\/w20dh\/wp-admin\/post-new.php\">post a link to it on our blog<\/a>. The post is due by the end of class on&nbsp;<strong>Monday, 30 March.&nbsp;<\/strong>Your write-up should contain the following information:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>A list (bullet points is fine) of the different models you tried. This might look something like, \u201c20 topics, no stopwords, 1000 iterations, no optimization\u201d<\/li><li>Identify which of the abovementioned models you think is best for Schulz&#8217;s work and discuss why you made this decision.<\/li><li>Write 2-3 paragraphs to report on what you observed in Step Three.<\/li><li>Include the visualizations that you produced in Step Four.<\/li><li>Write a paragraph that discusses what you learned from this approach that you didn\u2019t learn through reading the strips or marking the strips up.<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Grading<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This assignment is worth 75 points. You will be graded on whether your post has all the required items; the quality of the work that you did in trying and evaluating different models; and your analysis of the models that you create.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Credits<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This assignment was designed in 2018 and owes debts to Miriam Posner and Lisa Rhody for their ideas for visualizing the output of a topic model. In 2019, I simplified portions of the assignment based on what I learned the previous year. In 2020, I adapted the assignment for <em>Peanuts<\/em>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rationale In the next week, we will have completed our reading of two of the Complete Peanuts volumes. As much time as we&#8217;ve spent on this, we&#8217;ll still have only seen 8% of Charles Schulz&#8217;s total output. We&#8217;ve read some of it closely thanks to your daily comics discussions, and we\u2019ve gotten an even closer [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":34,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"footnotes":"","_links_to":"","_links_to_target":""},"class_list":["post-355","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/briancroxall.net\/w20dh\/wp-json\/wp\/v2\/pages\/355","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/briancroxall.net\/w20dh\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/briancroxall.net\/w20dh\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/briancroxall.net\/w20dh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/briancroxall.net\/w20dh\/wp-json\/wp\/v2\/comments?post=355"}],"version-history":[{"count":13,"href":"https:\/\/briancroxall.net\/w20dh\/wp-json\/wp\/v2\/pages\/355\/revisions"}],"predecessor-version":[{"id":392,"href":"https:\/\/briancroxall.net\/w20dh\/wp-json\/wp\/v2\/pages\/355\/revisions\/392"}],"up":[{"embeddable":true,"href":"https:\/\/briancroxall.net\/w20dh\/wp-json\/wp\/v2\/pages\/34"}],"wp:attachment":[{"href":"https:\/\/briancroxall.net\/w20dh\/wp-json\/wp\/v2\/media?parent=355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}