{"id":157,"date":"2023-03-07T12:03:20","date_gmt":"2023-03-07T19:03:20","guid":{"rendered":"http:\/\/briancroxall.net\/w23dh\/?page_id=157"},"modified":"2023-03-09T12:42:19","modified_gmt":"2023-03-09T19:42:19","slug":"topic-modeling-peanuts","status":"publish","type":"page","link":"https:\/\/briancroxall.net\/w23dh\/assignments\/topic-modeling-peanuts\/","title":{"rendered":"Topic Modeling Peanuts"},"content":{"rendered":"<h2>Rationale<\/h2>\n<p>We recently finished our reading of the first volume of <em>The <\/em><em>Complete Peanuts<\/em>. We\u2019ve read some of it closely thanks to your <a href=\"http:\/\/briancroxall.net\/w23dh\/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\u00a0<a href=\"http:\/\/briancroxall.net\/w23dh\/assignments\/encoding-peanuts\/\">marked them up with TEI and CBML<\/a>. With all of this behind us, I\u2019m guessing that we could offer some pretty in-depth takes on what\u00a0<em>Peanuts<\/em> is \u201cabout.\u201d And yet, we have only read 4% of his 17,897 strips. So any pronouncements about what <em>Peanuts<\/em>\u00a0is \u201cabout\u201d at this point would necessarily require ignoring most of the available evidence.<\/p>\n<p>Fortunately, digital humanities methods offer us, as <a href=\"https:\/\/dsl.richmond.edu\/dispatch\/introduction\">Robert K. Nelson writes<\/a>, &#8220;an additional method that allows us to examine and detect patterns within not a sampling but in the entirety of an archive.&#8221; 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>, \u201ca way of identifying patterns in a corpus\u201d by using an unsupervised machine-learning process to find \u201crecurring pattern[s] of co-occurring words.\u201d In other words, topic modeling should help us discover some of the underlying discourses within the whole\u00a0<em>Peanuts<\/em>\u00a0corpus, that thing we could never, ever read in a regular semester.<\/p>\n<p>Of course, it needs to be said that topic modeling works with text and text only. And, as we all know at this point,\u00a0<em>Peanuts<\/em>\u00a0is about\u00a0<em>so much more<\/em> than dialogue and diegetic text. This method cannot even pretend to account for the visual aspect of Schulz\u2019s 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\u00a0<em>Peanuts<\/em>, it\u2019s still worth a shot!<\/p>\n<h2>Nitty Gritty<\/h2>\n<p>For this assignment, you will create at least two topic models of the text of Schulz\u2019s strips and begin analyzing them. The assignment has one outcome: a 5-minute presentation on <strong>Tuesday, 21 March,<\/strong> about what you&#8217;ve learned.<\/p>\n<p>You will each meet with me during our regular class time on Tuesday, 14 March to talk about this assignment. The appointments are<\/p>\n<ul>\n<li>12:30-12:45, Washington<\/li>\n<li>12:45-1:00, Will<\/li>\n<li>1:00-1:15, Winthrop<\/li>\n<li>1:15-1:30, Rachel<\/li>\n<li>1:30-1:45, Lillian<\/li>\n<\/ul>\n<p>You should all feel free to consult with me frequently during this project. This is something that&#8217;s probably new for most of you, and I don&#8217;t expect it to work perfectly. If something with Mallet isn&#8217;t working, let&#8217;s solve it. If you&#8217;ve got a model but don&#8217;t know what to do next, let&#8217;s talk about it. If you&#8217;re annoyed with the class, <a href=\"https:\/\/media.giphy.com\/media\/3owyoRzZuJj0jdGgBG\/giphy.gif\">let&#8217;s fight<\/a>! The point of all this is <em>not<\/em> to prove that you are a hacker; the point is to give us all a different pathway for thinking about <em>Peanuts<\/em>.<\/p>\n<h3>Step One: Get the Data<\/h3>\n<p>You will work with two data sets in our repository:<\/p>\n<ul>\n<li>the GoComics data is in the <code>gocomics\/peanuts-clean<\/code>\u00a0<a href=\"https:\/\/github.com\/briancroxall\/peanuts\/tree\/master\/gocomics\/peanuts-txt\">folder<\/a>, these data have descriptive text that describes what happens in each strip<\/li>\n<li>the &#8220;Jesse&#8221; data is in the <code>jesse_data\/extracted-speech-strips<\/code> <a href=\"https:\/\/github.com\/briancroxall\/peanuts\/tree\/master\/jesse_data\/extracted-strips-speech\">folder<\/a>, these data only have the contents of speech and thought balloons<\/li>\n<\/ul>\n<p>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<h3>Step Two: Predict the Data<\/h3>\n<p>Spend a little time thinking about what you expect to see in a topic model. Think about a particular character and\/or types of activities that happen in Peanuts. Jot down your thoughts so you don&#8217;t lose track of them (you&#8217;ll need them later). In many ways, this is sort of like the &#8220;hypothesis&#8221; step in that science project you did in middle school.<\/p>\n<h3>Step\u00a0 Three: Model the Data<\/h3>\n<p>Using MALLET and the <a href=\"http:\/\/briancroxall.net\/w23dh\/topic-modeling-step-by-step\/\">Step-by-Step Guide to Topic Modeling<\/a>, make models of each data set. Make sure you use the same options for both data sets, which will allow for better comparisons. You need to make the following choices:<\/p>\n<ul>\n<li>the number of topics<\/li>\n<li>whether to remove\u00a0stopwords; 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, such as character names.<\/li>\n<li>whether to use the <code>--optimize-interval<\/code>\u00a0setting<\/li>\n<\/ul>\n<p>Make sure that you keep records of the settings you use to create your models (you&#8217;ll need them later).<\/p>\n<p>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 the appearance \u201cclear patterns\u201d is not guaranteed.)<\/p>\n<h3>Step Four: Analyze the Data<\/h3>\n<p>Ask yourself which topics you are seeing that you had expected, which topics you hadn\u2019t expected to appear, and which topics are \u201cmissing.\u201d Consider which character names are prevalent in particular topics. Observe which words appear in multiple topics. Does one data set seem to better match your predictions?<\/p>\n<p>Looking at the model of one data set, find a topic that is interesting to you. Open the topic composition file in Excel; insert a row at the top of the spreadsheet and name the columns to make them easier to navigate. See which documents (AKA strips) rank high for this topic. Do you see any patterns for the years the strips were published? Do any of these top strips seem like they don&#8217;t really belong in the topic?<\/p>\n<p>See whether you can find a similar topic in the other data set. Do the same strips appear near the top of this &#8220;mirror topic&#8221;?<\/p>\n<h3>Step Five: Visualize the Data<\/h3>\n<p>Choose at least one of the following to visualize your data:<\/p>\n<ul>\n<li>Pick one of the strips that you selected for our daily discussions. Identify the three most prominent topics for this strip,\u00a0<em>according to your model of the Jesse data<\/em>. Using the topic keys, color-code the words in the strip that come from each of these three particular topics.<\/li>\n<li>Pick one of the strips that you selected for our daily discussions. Make a pie chart for each of the strips, showing which topics comprise the strip 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>\n<li>Ask me to visualize one or more of your topics over time (or run\u00a0<code><a href=\"https:\/\/github.com\/briancroxall\/peanuts\/blob\/master\/scripts\/topics-over-time.py\">topics-over-time.py<\/a><\/code>\u00a0from the\u00a0<code>scripts<\/code>\u00a0folder in our repo).<\/li>\n<\/ul>\n<h3>Step Six: Present the Data<\/h3>\n<p>Give a five-minute presentation about your topic models and what you learned during class on\u00a0<strong>21 March<\/strong>. Your presentation should cover the following:<\/p>\n<ul>\n<li>Your hypotheses from Step Two<\/li>\n<li>A summary of the settings for the topic model you used for your analysis (how many topics, whether you removed stopwords, etc.)<\/li>\n<li>What you learned during your analysis in Step Four<\/li>\n<li>Your visualization(s)<\/li>\n<li>What you learned from this approach that you didn&#8217;t learn through reading the strips or marking the strips up<\/li>\n<\/ul>\n<p>This can be a relatively informal presentation.<\/p>\n<h2>Grading<\/h2>\n<p>This assignment is worth 50 points. You will be graded on whether you complete all of its requirements.<\/p>\n<h2>Credits<\/h2>\n<p>This assignment was designed in 2018 and owes debts to <a href=\"http:\/\/miriamposner.com\/\">Miriam Posner<\/a> and <a href=\"https:\/\/www.lisarhody.com\/\">Lisa Rhody<\/a> 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\u00a0<em>Peanuts<\/em>. In 2023, I changed this from a group to an individual assignment. We&#8217;ll see whether that was a good idea.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Rationale We recently finished our reading of the first volume of The Complete Peanuts. We\u2019ve read some of it closely thanks to your daily comics discussions, and we\u2019ve gotten an even closer look at a subset of those strips as we\u2019ve\u00a0marked them up with TEI and CBML. With all of this behind us, I\u2019m guessing [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":13,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"footnotes":""},"class_list":["post-157","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/briancroxall.net\/w23dh\/wp-json\/wp\/v2\/pages\/157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/briancroxall.net\/w23dh\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/briancroxall.net\/w23dh\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/briancroxall.net\/w23dh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/briancroxall.net\/w23dh\/wp-json\/wp\/v2\/comments?post=157"}],"version-history":[{"count":21,"href":"https:\/\/briancroxall.net\/w23dh\/wp-json\/wp\/v2\/pages\/157\/revisions"}],"predecessor-version":[{"id":380,"href":"https:\/\/briancroxall.net\/w23dh\/wp-json\/wp\/v2\/pages\/157\/revisions\/380"}],"up":[{"embeddable":true,"href":"https:\/\/briancroxall.net\/w23dh\/wp-json\/wp\/v2\/pages\/13"}],"wp:attachment":[{"href":"https:\/\/briancroxall.net\/w23dh\/wp-json\/wp\/v2\/media?parent=157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}