{"id":157,"date":"2022-03-01T12:03:20","date_gmt":"2022-03-01T19:03:20","guid":{"rendered":"http:\/\/briancroxall.net\/w22dh\/?page_id=157"},"modified":"2022-03-01T13:11:12","modified_gmt":"2022-03-01T20:11:12","slug":"topic-modeling-peanuts","status":"publish","type":"page","link":"https:\/\/briancroxall.net\/w22dh\/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\/w22dh\/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\/w22dh\/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 collectively produce several topic models of the text of Schulz\u2019s strips and begin the process of analyzing them. The assignment has one outcome: a collaboratively written Google Doc. This Doc is due <strong>at the end of class on Tuesday, 8 March<\/strong>.<\/p>\n<h3>Step One: Get the Data<\/h3>\n<p>You can find the cleaned GoComics <em>Peanuts<\/em>\u00a0data in our repository in the\u00a0<code>gocomics\/peanuts-clean<\/code>\u00a0<a href=\"https:\/\/github.com\/briancroxall\/peanuts\/tree\/master\/gocomics\/peanuts-txt\">folder<\/a>. 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&#8217;re likely to see in your topic model. Jot down your thoughts in a shared Google Doc (see Step Six) so you don&#8217;t lose track of them. 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=\"https:\/\/briancroxall.net\/w22dh\/topic-modeling-step-by-step\/\">Step-by-Step Guide to Topic Modeling<\/a>, collectively make at least <strong>6\u00a0different topic models of the corpus<\/strong>. Experiment with changing some or all of the following:<\/p>\n<ul>\n<li>the number of topics<\/li>\n<li>using and\u00a0<strong><em>not\u00a0<\/em><\/strong>using 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, such as character names.<\/li>\n<li>the number of iterations you run<\/li>\n<li>whether or not you use the\u00a0<code>--optimize-interval<\/code>\u00a0setting<\/li>\n<\/ul>\n<p>Make sure that you keep careful records of the different commands you use to create each of the different models.<\/p>\n<h3>Step Four: Analyze the Data<\/h3>\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 rather than academic articles\u2014which is what topic modeling was designed around\u2014the appearance \u201cclear patterns\u201d is not guaranteed.)<\/p>\n<p>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 strips are published in? Is there one topic that seems to be high for a lot more strips than you would expect? (This often happens and represents what I sometimes call the \u201cEnglish language\u201d topic. This becomes easier to spot if you\u2019ve used the <code>--optimize-interval<\/code>\u00a0command.)<\/p>\n<p>Outside of Excel, 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.<\/p>\n<h3>Step Five: Visualize the Data<\/h3>\n<p>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<ul>\n<li>Using the six strips you collectively chose, 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>Using the six strips you collectively chose, 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>\n<li>Using an entire model, ask me to prep your data for network visualization in Gephi (or run <code><a href=\"https:\/\/github.com\/briancroxall\/peanuts\/blob\/master\/scripts\/mallet2gephi.py\">mallet2gephi.py<\/a><\/code>\u00a0yourself from the\u00a0<code>scripts<\/code>\u00a0folder in our repo).<\/li>\n<li>Using an entire model, ask me to visualize your models over time (or run <code><a href=\"https:\/\/github.com\/briancroxall\/peanuts\/blob\/master\/scripts\/topics-over-time.py\">topics-over-time.py<\/a><\/code> from the <code>scripts<\/code> folder in our repo).<\/li>\n<\/ul>\n<h3>Step Six: Write about the Data<\/h3>\n<p>Write about your hypothesis, modeling, and analysis <a href=\"https:\/\/docs.google.com\/document\/d\/1YEhjLT-Vx66bc3gb8y_Uu61aIYmysKexh5TR5pSXUcg\/edit\">using Google Docs<\/a>. When you are done, share it with <a href=\"#\" data-cx=\"8\/INk2AH85SSgbZwyiOux5oB60+7Yw8xgacAPVNVyMx7nZFVjPO7AqofpZHla8qMBJJZPFVGQpzfkpoPHoFwMLRR3XQBLwhuxIc=\" data-cxm=\"secure\" data-cxk=\"28b6ee28b36b12308fe70c0737cdf6030b63fead7abebb2801a728a62b12502d\" data-cxi=\"10000\" class=\"cryptx-link\">b [dot] croxall [at] gmail [dot] com<\/a>. The post is due by the end of class on\u00a0<strong>Tuesday, 8 March. <\/strong>Your write-up should contain the following information:<\/p>\n<ul>\n<li>Your hypotheses that you made in Step Two<\/li>\n<li>A list (bullet points are fine) of the different models you tried. This might look something like, \u201c20 topics, no stopwords, 1000 iterations, no optimization\u201d<\/li>\n<li>Identify which of the abovementioned models you think is best for Schulz\u2019s work and discuss why you made this decision.<\/li>\n<li>Write a minimum of 3 paragraphs to report on what you observed in Step Four.<\/li>\n<li>Include the visualizations that you produced in Step Five.<\/li>\n<li>Each of you should individually 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>\n<\/ul>\n<h2>Grading<\/h2>\n<p>This assignment is worth 50 points. You will be graded on whether your Doc 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<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>, and I&#8217;ve updated it each year since.<\/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\/w22dh\/wp-json\/wp\/v2\/pages\/157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/briancroxall.net\/w22dh\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/briancroxall.net\/w22dh\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/briancroxall.net\/w22dh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/briancroxall.net\/w22dh\/wp-json\/wp\/v2\/comments?post=157"}],"version-history":[{"count":14,"href":"https:\/\/briancroxall.net\/w22dh\/wp-json\/wp\/v2\/pages\/157\/revisions"}],"predecessor-version":[{"id":293,"href":"https:\/\/briancroxall.net\/w22dh\/wp-json\/wp\/v2\/pages\/157\/revisions\/293"}],"up":[{"embeddable":true,"href":"https:\/\/briancroxall.net\/w22dh\/wp-json\/wp\/v2\/pages\/13"}],"wp:attachment":[{"href":"https:\/\/briancroxall.net\/w22dh\/wp-json\/wp\/v2\/media?parent=157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}