tag:blogger.com,1999:blog-199744492024-03-05T21:11:15.670-05:00Digital History Hacks (2005-08)Methodology for the infinite archive.William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comBlogger165125tag:blogger.com,1999:blog-19974449.post-87003225300839641772011-02-10T09:04:00.002-05:002011-02-10T09:05:33.722-05:00GitHub Source Code RepositoryThere is now a <a href="https://github.com/williamjturkel/Digital-History-Hacks--2005-08-">GitHub source code</a> repository for all of the code from <span style="font-style:italic;">Digital History Hacks</span>.William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-91683262145625629042008-12-29T15:16:00.002-05:002008-12-29T15:30:55.633-05:00CodaWhen I began this blog, I had the idea that it would be an integral part of my critical and reflective technical practice. For the past three years, it has served admirably, providing an easy way to share ideas and code and putting me in touch with a wide range of colleagues and new friends. During that time I've tried to stay true to the promise of "hacks," even if I pushed the boundaries of both "digital" and "history". As my technical work has evolved, however, I've begun to feel like this blog is less and less suited to my day-to-day activities. Rather than try and force it to fit, I've decided to build something new.William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-54001567747722301872008-12-09T10:36:00.011-05:002008-12-09T12:50:21.772-05:00Some Winter Reading for Humanist Makers(Crossposted to Cliopatria & Digital History Hacks)<br /><br />In December 2004, I bought a copy of Joe Martin's <span style="font-style:italic;"><a href="http://www.amazon.com/Tabletop-Machining-Joe-Martin/dp/0966543300/">Tabletop Machining</a></span> to see what would be involved in learning how to make clockwork mechanisms and automata. It was pretty obvious that I had many years of study ahead of me, but I had just finished my PhD and knew that publishing that would take a few years more. So I didn't mind beginning something else that might take ten or fifteen years to master. Since then, I've been reading steadily about making things, but it wasn't until this past fall that I actually had the chance to set up a small <a href="http://digitalhistory.wikispot.org/Lab_for_Humanistic_Fabrication">Lab for Humanistic Fabrication</a> and begin making stuff in earnest. Since it's December again, I thought I'd put together a small list of books to help other would-be humanist makers.<br /><ul><li>Alexander, Christopher. <span style="font-style:italic;"><a href="http://www.amazon.com/Notes-Synthesis-Form-Harvard-Paperbacks/dp/0674627512/">Notes on the Synthesis of Form</a></span> (Harvard, 1964).</li><li>Ball, Philip. <span style="font-style:italic;"><a href="http://www.amazon.com/Made-Measure-Materials-21st-Century/dp/0691009759/">Made to Measure: New Materials for the 21st Century</a></span> (Princeton, 1999).</li><li>Barrett, William. <span style="font-style:italic;"><a href="http://www.amazon.com/Illusion-Technique-William-Barrett/dp/0385112025/">The Illusion of Technique</a></span> (Anchor, 1979).</li><li>Basalla, George. <span style="font-style:italic;"><a href="http://www.amazon.com/Evolution-Technology-Cambridge-Studies-History/dp/0521296811/">The Evolution of Technology</a></span> (Cambridge, 1989).</li><li>Bryant, John and Chris Sangwin. <span style="font-style:italic;"><a href="http://www.amazon.com/How-Round-Your-Circle-Engineering/dp/069113118X/">How Round is Your Circle? Where Engineering and Mathematics Meet</a></span> (Princeton, 2008).</li><li>Dourish, Paul. <span style="font-style:italic;"><a href="http://www.amazon.com/Where-Action-Foundations-Embodied-Interaction/dp/0262541785/">Where the Action Is: The Foundations of Embodied Interaction</a></span> (MIT, 2004).</li><li>Edgerton, David. <span style="font-style:italic;"><a href="http://www.amazon.com/Shock-Old-Technology-Global-History/dp/0195322835/">The Shock of the Old: Technology and Global History since 1900</a></span> (Oxford, 2006).</li><li>Frauenfelder, Mark and Gareth Branwyn. <span style="font-style:italic;"><a href="http://www.amazon.com/Best-MAKE-Mark-Frauenfelder/dp/059651428X/">The Best of MAKE</a></span> (O'Reilly, 2007).</li><li>Gershenfeld, Neil. <span style="font-style:italic;"><a href="http://www.amazon.com/Fab-Revolution-Desktop-Computers-Fabrication/dp/0465027466/">Fab: The Coming Revolution on Your Desktop--from Personal Computers to Personal Fabrication</a></span> (Basic, 2007).</li><li>Gordon, J. E. <span style="font-style:italic;"><a href="http://www.amazon.com/Structures-Things-Dont-Fall-Down/dp/0306812835/">Structures: Or Why Things Don't Fall Down</a></span> (Da Capo, 2003).</li><li>Gordon, J. E. <span style="font-style:italic;"><a href="http://www.amazon.com/Science-Materials-through-Princeton-Library/dp/0691125481/">The New Science of Strong Materials: Or Why You Don't Fall through the Floor</a></span> (Princeton, 2006).</li><li>Harper, Douglas. <span style="font-style:italic;"><a href="http://www.amazon.com/Working-Knowledge-Skill-Community-Small/dp/0226316882/">Working Knowledge: Skill and Community in a Small Shop</a></span> (Chicago, 1987).</li><li>Igoe, Tom. <span style="font-style:italic;"><a href="http://www.amazon.com/Making-Things-Talk-Practical-Connecting/dp/0596510519/">Making things Talk: Practical Methods for Connecting Physical Objects</a></span> (Make Books, 2007).</li><li>Ingold, Tim. <span style="font-style:italic;"><a href="http://www.amazon.com/Perception-Environment-Essays-Livelihood-Dwelling/dp/0415228328/">The Perception of the Environment: Essays on Livelihood, Dwelling and Skill</a></span> (Routledge, 2000).</li><li>Marlow, Frank M. <span style="font-style:italic;"><a href="http://www.amazon.com/Machine-Shop-Essentials-Questions-Answers/dp/0975996304/">Machine Shop Essentials</a></span> (Metal Arts, 2004).</li><li>Martin, Joe. <span style="font-style:italic;"><a href="http://www.amazon.com/Tabletop-Machining-Joe-Martin/dp/0966543300/">Tabletop Machining</a></span> (Sherline, 1998).</li><li>McDonough, William and Michael Braungart. <span style="font-style:italic;"><a href="http://www.amazon.com/Cradle-Remaking-Way-Make-Things/dp/0865475873/">Cradle to Cradle: Remaking the Way We Make Things</a></span> (North Point, 2002).</li><li>Molotch, Harvey. <span style="font-style:italic;"><a href="http://www.amazon.com/Where-Stuff-Comes-Toasters-Computers/dp/0415950422/">Where Stuff Comes From: How Toasters, Toilets, Cars, Computers and Many Other Things Come to Be As They Are</a></span> (Routledge, 2005).</li><li>Mims, Forrest M., III. <span style="font-style:italic;"><a href="http://www.amazon.com/Electronic-Sensor-Circuits-Projects-Forrest/dp/0945053312/">Electronic Sensor Circuits and Projects</a></span> (Master Publishing, 2004).</li><li>Mims, Forrest M., III. <span style="font-style:italic;"><a href="http://www.amazon.com/Science-Communication-Circuits-Projects-Forrest/dp/0945053320/">Science and Communication Circuits and Projects</a></span> (Master Publishing, 2004).</li><li>Napier, John. <span style="font-style:italic;"><a href="http://www.amazon.com/Hands-John-Napier/dp/0691025479/">Hands</a></span> (Princeton, 1993).</li><li>Oberg, Erik, et al. <span style="font-style:italic;"><a href="http://www.amazon.com/Machinerys-Handbook-Toolbox-Oberg/dp/0831128003/">Machinery's Handbook</a></span>, 28th ed. (Industrial Press, 2008).</li><li>O'Sullivan, Dan and Tom Igoe. <span style="font-style:italic;"><a href="http://www.amazon.com/Physical-Computing-Sensing-Controlling-Computers/dp/159200346X/">Physical Computing: Sensing and Controlling the Physical World with Computers</a></span> (Thomson, 2004).</li><li>Polanyi, Michael. <span style="font-style:italic;"><a href="http://www.amazon.com/Personal-Knowledge-Towards-Post-Critical-Philosophy/dp/0226672883/">Personal Knowledge</a></span> (Chicago, 1974).</li><li>Powell, John. <span style="font-style:italic;"><a href="http://www.amazon.com/Survival-Fitter-John-Powell/dp/1853393169/">The Survival of the Fitter</a></span> (Practical Action, 1995).</li><li>Pye, David. <span style="font-style:italic;"><a href="http://www.amazon.com/Nature-Art-Workmanship-David-Pye/dp/0713689315/">The Nature and Art of Workmanship</a></span> (A&C Black, 2008).</li><li>Rathje, William and Cullen Murphy. <span style="font-style:italic;"><a href="http://www.amazon.com/Rubbish-Archaeology-Garbage-William-Rathje/dp/0816521433/">Rubbish! The Archaeology of Garbage</a></span> (University of Arizona, 2001).</li><li>Schon, Donald A. <span style="font-style:italic;"><a href="http://www.amazon.com/Reflective-Practitioner-Professionals-Think-Action/dp/0465068782/">The Reflective Practitioner: How Professionals Think in Action</a></span> (Basic, 1984).</li><li>Sennett, Richard. <span style="font-style:italic;"><a href="http://www.amazon.com/Craftsman-Richard-Sennett/dp/0300119097/">The Craftsman</a></span> (Yale, 2008).</li><li>Slade, Giles. <span style="font-style:italic;"><a href="http://www.amazon.com/Made-Break-Technology-Obsolescence-America/dp/0674025725/">Made to Break: Technology and Obsolescence in America</a></span> (Harvard, 2007).</li><li>Sterling, Bruce. <span style="font-style:italic;"><a href="http://www.amazon.com/Shaping-Things-Mediaworks-Pamphlets-Sterling/dp/0262693267/">Shaping Things</a></span> (MIT, 2005).</li><li>Suchman, Lucy. <span style="font-style:italic;"><a href="http://www.amazon.com/Human-Machine-Reconfigurations-Cognitive-Computational-Perspectives/dp/052167588X/">Human-Machine Reconfigurations: Plans and Situated Action</a></span> (Cambridge, 2006).</li><li>Thackara, John. <span style="font-style:italic;"><a href="http://www.amazon.com/Bubble-Designing-Complex-World/dp/0262701154/">In the Bubble: Designing in a Complex World</a></span> (MIT, 2006).</li><li>Thompson, Rob. <span style="font-style:italic;"><a href="http://www.amazon.com/Manufacturing-Processes-Design-Professionals-Thompson/dp/0500513759">Manufacturing Processes for Design Professionals</a></span> (Thames & Hudson, 2007).</li><li>Woodbury, Robert S. <span style="font-style:italic;"><a href="http://www.amazon.com/Studies-History-Machine-Robert-Woodbury/dp/0262730332/">Studies in the History of Machine Tools</a></span> (MIT, 1973).</li></ul><br />Tags: <a href="http://technorati.com/tag/bricolage" rel="tag">bricolage</a> | <a href="http://technorati.com/tag/critical+technical+practice" rel="tag">critical technical practice</a> | <a href="http://technorati.com/tag/diy" rel="tag">DIY</a> | <a href="http://technorati.com/tag/fabrication" rel="tag">fabrication</a> | <a href="http://technorati.com/tag/humanism" rel="tag">humanism</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-50192914023327995562008-11-21T16:24:00.014-05:002008-11-21T18:22:51.803-05:00A Few Arguments for Humanistic FabricationBy hooking a computer up to a machine that can add, remove, cut or fuse material, it is possible to turn a digital representation into a physical object. Most historians (at least ones reading this blog) are probably familiar with the idea of digitization; think of this as 'materialization', a reversal of the process. The humble printer is a kind of materializer for two-dimensional text and images. These other machines (often referred to as rapid prototyping or computer-aided manufacturing machines, or even 'replicators') allow their users to make manifest three-dimensional objects of plastic, wood, metal, or fancier composites.<br /><br />Over the past few years, the price of rapid fabrication has been dropping, well, rapidly. A lab that once cost hundreds of thousands or millions of dollars can now be had for less than $20,000. Enthusiasts predict that the age of desktop fabrication is nigh; in the next few years we will all have devices on our desks that can print out 3D objects. (Neil Gershenfeld's <a href="http://www.amazon.com/Fab-Revolution-Desktop-Computers-Fabrication/dp/0465027466/"><span style="font-style:italic;">Fab</span></a> is a good introduction to some of the possibilities.) Small groups of DIY makers and hardware hackers are busy in their garages and attics trying to create <a href="http://reprap.org/bin/view/Main/WebHome">a printer that can print a copy of itself</a>, a machine that can <a href="http://fabathome.org/wiki/index.php?title=Main_Page">print out a flashlight</a>, one that can <a href="http://candyfab.org/">print a torroidal coil of candy</a>, or <a href="http://www.evilmadscientist.com/article.php/cnctoast">burn a message into your morning toast</a>. The popular appeal of all this activity is clear in the pages of <span style="font-style:italic;"><a href="http://makezine.com/">MAKE</a></span> magazine, or in the Discovery Channel's new show, "<a href="http://dsc.discovery.com/tv/prototype-this/prototype-this.html">Prototype This</a>".<br /><br />There are a number of reasons why historians and other humanists should be getting involved in desktop fabrication right now. Here are a few.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">We can't predict the future</span></span>. In the 1960s, for example, it wasn't clear to everyone that there would ever be much reason for individuals to have the undivided attention of a single computer (never mind the dozens that we each now monopolize without thinking about it.) In retrospect, the people who struggled to get individual access to computers, who bought them from mail-order catalogs and built them at home, who taught themselves how to program even when that meant reading thick manuals and punching cards... well, now we know how that turned out. Using a computer-controlled soldering iron to fuse grains of sugar into candy sculptures may seem a bit tangential to the serious business of academia, but it's really too soon to judge.<br /><br /><span style="font-weight:bold;"><span style="font-style:italic;">Mind and hand</span></span>. Just because the separation between thinking and making is longstanding and well-entrenched doesn't make it a good idea. At various times in the past, humanists have been deeply involved in making stuff: Archimedes, the Banu Musa brothers, da Vinci, Vaucanson, the Lunar Men, Bauhaus, W. Grey Walter, Gordon Mumma. The list could easily be multiplied into every time and place, but the main point is that getting your hands dirty might be worthwhile, even if you're not da Vinci.<br /><br /><span style="font-weight:bold;"><span style="font-style:italic;">Historic experimentation</span></span>. People who work with material culture, the history of technology or experimental archaeology know that you can learn a lot about the past by handling physical stuff. Until recently, that usually meant that you needed to have direct access to the stuff itself. Now it is possible to fabricate physical models or artifacts that share properties with possibly rare or priceless originals. Paleontologists and zooarchaeologists can learn from <a href="http://visualizingevolution.blogspot.com/2008/07/paleontology-in-3d.html">3D printouts of bones and fossils</a>. Historians of science can more readily <a href="http://stuff.mit.edu/afs/athena/course/other/sts.023/www/syllabus_01.pdf">replicate past experiments</a>. And so on.<br /><br /><span style="font-style:italic;"><span style="font-weight:bold;">Tangible / haptic history</span></span>. More generally, it will become possible to materialize shapes, surfaces, textures and artifacts that resemble those of the past, and that can be touched, felt, handled, and manipulated. It is easy to imagine a new tangible or haptic history that follows and extends the sensory histories that are being written right now. <br /><br /><span style="font-weight:bold;"><span style="font-style:italic;">Critical technical practice</span></span>. In the late 1990s, Philip Agre argued for a mode of research that involved both "the craft work of design and ... the reflexive work of critique." The benefits of this approach are already apparent in the digital humanities, where historians, anthropologists, archaeologists, artists, literary and media scholars, and their colleagues are busy both creating and critiquing digital sources. Why not extend this practice to rapid fabrication, microelectronics, new materials, robotics or nanotechnology?<br /><br />Some of the barriers are easily overcome. When someone asks me why a historian would need an 8-axis CNC milling machine or an oscilloscope, I say, "Why not?" The limitations of our physical spaces can be more difficult to circumvent. Most of the teaching and research environments available to humanists at my university are designed to support solitary or small-group office work. These spaces are almost comically unsuitable for the kinds of things I try to do with my students: soldering, moldmaking and casting, building and lighting physical exhibits, programming in groups, creating displays or signage. Although I could afford to purchase a laser cutter, I can't vent the poisonous fumes from my workspace. Cutting wood with power tools will set off the fire alarm. I certainly couldn't set up a little foundry to explore the bootstrapping process that led from metal casting to machine tools. There isn't even anywhere to lock up student project prototypes so they won't be stolen or vandalized. When I have a chance to talk to planners or people purchasing furniture or whatever, I ask them to imagine spaces that are appropriate for an art class or a shop class: high ceiling, natural light, plenty of ventilation, cement flooring, workbenches on casters, locking cabinets, big blank walls that you can hang things on. No carpeting, no beige cubicles, no coffee tables with plants. Humanists won't be able to think of themselves as makers until we create spaces for them to make things in.<br /><br />Tags: <a href="http://technorati.com/tag/bricolage" rel="tag">bricolage</a> | <a href="http://technorati.com/tag/diy" rel="tag">DIY</a> | <a href="http://technorati.com/tag/fabrication" rel="tag">fabrication</a> | <a href="http://technorati.com/tag/hacking" rel="tag">hacking</a> | <a href="http://technorati.com/tag/physical+computing" rel="tag">physical computing</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-21148800252664920792008-11-08T11:41:00.002-05:002008-11-08T11:47:24.682-05:00Hemlines and History Appliances[Crossposted to Cliopatria & Digital History Hacks]<br /><br />The <a href="http://www.vacuumwoman.com/MediaWorks/Stock/stock.html">Stock Market Skirt</a> is a robot of sorts. Created a number of years ago by Toronto-based media artist <a href="http://www.vacuumwoman.com/">Nancy Patterson</a>, it consists of a party dress on a dressmaker's mannequin and a number of monitors displaying stock tickers. As prices fluctuate, "these values are sent to a program which determines whether to raise or lower the hemline via a stepper motor and a system of cables, weights and pulleys attached to the underside of the skirt. When the stock price rises, the hemline is raised; when the stock price falls, the hemline is lowered." I can only assume that the edge of the dress is rumpled up on the floor these days, and that the motors are somewhat the worse for wear.<br /><br />The exhibit, of course, is a playful reinterpretation of George Taylor's hemline index. In the 1920s, Taylor, an economist at the Wharton school, observed that skirt lengths were correlated with the state of the economy. Since then, the observation has continued to be relatively robust, and these days has been extended into <a href="http://iht.nytimes.com/articles/2008/10/19/news/19lewin.php">many other domains</a>, like music and movie preferences, the water content in foods, and even the shapes of Playboy playmates.<br /><br />I think the stock market skirt is a great example of what I call a "history appliance." The idea is supposed to be whimsical: what if a device could dispense historical consciousness the way a tap dispenses water? I've found that academic historians have a much harder time entertaining this question than public historians do. After all, the latter have a long tradition of trying to build events, exhibits and situations that communicate interpretations of the past in ways that supplement the written word. A diorama, for example, represents the past faithfully along some dimensions, but not all. You can do scientific tests on an artifact--if it isn't a fake, its material substance can be informative about past events. (Ditto if it is a fake.) You can't necessarily do scientific tests on a diorama, and yet it is possible for it to communicate information about the past veridically.<br /><br />For a historian, the correlation between stock prices and hemlines raises questions of agency, and we feel comfortable exploring those on paper. Nothing foregrounds agency like a robot, however, and historians shouldn't shy away from building them into their historical interpretations.<br /><br />Tags: <a href="http://technorati.com/tag/history+appliances" rel="tag">history appliances</a> | <a href="http://technorati.com/tag/public+history" rel="tag">public history</a> | <a href="http://technorati.com/tag/thing+knowledge" rel="tag">thing knowledge</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-49811070668367071532008-11-02T11:35:00.016-05:002008-11-02T12:34:50.854-05:00The Bridge Goes Both WaysThis week I found myself in a somewhat unfamiliar situation. Along with <a href="http://www.history.vt.edu/faculty/shifflett.htm">Randy Shifflett</a> and <a href="http://www.scu.edu/cas/history/">Fabio Lopez-Lazaro</a>, I was asked to represent the discipline of history at a community building meeting of the <a href="http://www.likes.org.vt.edu/">LIKES</a> (Living in the KnowlEdge Society) project at Virginia Tech. There, surrounded by computer scientists, engineers and other 'hard' scientists, we had to explain some of the challenges that face people who wish to integrate computation into historical research and teaching. In many ways, it was a return to fundamentals. We explained that many facts about the past are readily quantified, but that doing so often misses the point. Historical examples raised by our non-historian colleagues often focused on names and dates, and we had to tell them that the really interesting action is usually elsewhere. We reviewed ideas of contingency, counterfactual reasoning, and ambiguity. We explained why it usually doesn't make sense to project anachronistic categories and ideas onto past situations. We discussed the holism and methodological individualism of most researchers in our field. <br /><br />When asked what kind of computational tools historians and other humanists need, the best metaphor that I could come up with drew on Jim Clifford's ideas of <a href="http://www.amazon.com/Routes-Travel-Translation-Twentieth-Century/dp/0674779614/">travel and translation</a>. It would be easy to make tools that quantified how many miles you traveled on your vacation, how many feet you were standing from the sculpture when you took the picture, how you rated your meal in Venice on a scale of 1 to 10 ... but it would completely miss the point. Instead you want ways to help you translate, to capture and document your experiences, to cue your memories, to support your storytelling, to deepen your interpretations and understanding.<br /><br />In this blog, I've assumed that most of my audience would be historians and other humanists who are interested in exploring digital and computational techniques at a number of levels. The LIKES meeting reminded me that the bridge goes both ways, that computer scientists, applied mathematicians, science educators and others are also interested in ways that their skills and tools might be applied in new domains. So, for those of you coming in the other direction: welcome! Here are a few things you might be interested to know:<br /><ul><li>Historians who are interested in quantification already know about and use spreadsheets, databases, mathematical models, computer programs and visualization. Historians who aren't interested in quantification won't be happy with a definition of 'qualitative' that consists of "leaving the numerical scale off of the axes of your graph."</li><li>The best way to promote computation amongst humanists is to emphasize social and textual applications of computing, especially ones that augment the power of individuals to do research that draws on collections of cultural / heritage materials that are distributed across many different repositories.</li><li>Verbs, not nouns. John Unsworth's paper on <a href="http://www3.isrl.uiuc.edu/%7Eunsworth/Kings.5-00/primitives.html">scholarly primitives</a> is a good place to start.</li><li>There are a number of good books that take a humanistic perspective while still being sensitive to the potential of instrumental thinking. I particularly like Philip Agre's <a href="http://www.amazon.com/Computation-Human-Experience-Learning-Doing/dp/0521386039/"><span style="font-style: italic;">Computation and Human Experience</span></a> and Lucy Suchman's <a href="http://www.amazon.com/Human-Machine-Reconfigurations-Cognitive-Computational-Perspectives/dp/052167588X/"><span style="font-style: italic;">Human-Machine Reconfigurations</span></a>.<br /></li></ul>Tags: <a href="http://technorati.com/tag/digital+history">digital history</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-72338971912771133642008-10-06T10:57:00.016-04:002008-10-06T12:17:06.249-04:00The One True LanguageIn <span style="font-style:italic;"><a href="http://www.amazon.com/Seven-Nights-Jorge-Luis-Borges/dp/0811209059/">Seven Nights</a></span>, Borges has an essay where he describes the process by which he first read the <span style="font-style:italic;">Divine Comedy</span>: <br /><blockquote><br />They were very handy books, published by Dent. They fit into my pocket. On the left was the Italian text, and on the right a literal translation. I devised this modus operandi: I first read a verse, a tercet, in the English prose; then I read the verse in Italian; and so on through to the end of the canto. Then I read the whole canto in English, and finally in Italian. With that first reading I realized that the translations were no substitute for the original text. The translation could be, at best, a means and a stimulus for the reader to approach the original. ... Poetry is, among so many other things, an intonation, an accentuation that is often untranslatable.<br /></blockquote><br />I was recently reminded of this because I decided that my digital history grad class should use the <a href="http://processing.org/">Processing</a> programming language for their group project. Since I haven't programmed in the language before, I bought a couple of textbooks and sat down to read them, slowing when I needed to mentally translate unfamiliar commands into more familiar idioms.<br /><br />Beginning programmers often worry about which language to learn first. Which one is the most powerful? The most useful? The easiest to learn? Which one will help me to get a high paying job? The investment of a semester or a year seems like a long time to study something when it might turn out to be the <span style="font-style:italic;">wrong choice</span>. At a theoretical level, programming languages are <a href="http://en.wikipedia.org/wiki/Turing_complete">deeply equivalent</a>, but that is more a matter of theory than practice... because every programming language makes some things easy and some things hard. Or in the slogan of one language, "makes easy things easy and hard things possible." These language differences become the stuff of <a href="http://www.americanscientist.org/issues/pub/the-semicolon-wars/">holy wars</a>, but they shouldn't. The best language for the job depends largely on the job.<br /><br />Processing, for instance, has built-in commands that make it easy to map numbers from one range of values to another. Now this isn't something that is too difficult to program from more primitive commands; it comes up frequently enough that you learn how to do it in whatever language you're using. But when I read the description of the Processing commands, I realized that I have implemented similar functions in almost every language that I've ever programmed in. By choosing to make this a language primitive, the designers of Processing made it easier for beginners to do a number of different tasks, including scaling the ranges of values returned by different analog sensors (which is something my students will need to do).<br /><br />There's no one true language for programming any more than there is one true language for humanism, or one true wood for carpenters. As Borges says, the intonations of poetry are often untranslatable, and it's true for code, too. In a sense, you don't really know how to program until you're familiar with more than one language, because the essence of programming consists in knowing how to translate the idioms of one language into a more or less familiar one. And this is something that humanists have long known: if there is a oneness and truth to language, it is to be found in the multiple practices of translation.<br /><br />Tags: <a href="http://technorati.com/tag/programming" rel="tag">programming</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-58904607195402603472008-10-03T18:45:00.006-04:002008-10-03T19:40:59.018-04:00Navigating Digital HistoryThis year, one of the first slides that I put up for the new Science, Technology and Global History class that Rob MacDougall and I are teaching was a quote from Patrick Manning's <span style="font-style:italic;"><a href="http://www.amazon.com/Navigating-World-History-Historians-Create/dp/1403961190/">Navigating World History</a></span>:<br /><blockquote><br />Navigating world history is an ambitious but limited goal, one quite distinct from the unattainable aim of "mastering" the topic. No one can learn all of world history. Anyone who pursues such a goal is sure to become lost. To strike an analogy, all those who have attempted to conquer the world have failed, but many of those who have traveled the globe have gained pleasure and expanded their understanding. (x)<br /></blockquote><br />I originally intended this forewarning as a way of managing expectations. I figured the students wouldn't be so disappointed in me when they found out that one consequence of taking on the history of everything from the Big Bang to human extinction is that the sum of the prof's knowledge asymptotically approaches zero. The students, however, seem to be taking my relative ignorance in stride, and the quote has mostly served to console me when I have to leave some stuff out of my lectures.<br /><br />I was reminded of navigation the other day when I met with a PhD student who is close to finishing her doctorate and thinking about her second project. She wants to do something with digital sources but is having a hard time getting her bearings. Our conversation made me realize that I didn't have a single-page "getting started" guide for people who have never seriously worked with online sources. So here it is.<br /><br />1. <span style="font-style:italic;">You won't be able to read everything</span>. In fact, new material on your topic will appear online faster than you can read it. The longer you work on a topic, the more behind you will get. It's OK, because everyone faces this problem whether they realize it or not.<br /><br />2. <span style="font-style:italic;">The first tool you should master is the search engine</span>. Most people think that typing a word or two into the Google or Yahoo! search box is all that you need to know. Not so! First of all, search engines have an advanced search page that lets you focus in on your topic, exclude search terms, weight some terms more than others, limit your results to particular kinds of document, to particular sites, to date ranges, and so on. Second, different search engines introduce different kinds of bias by ranking results differently. You get a better view when you routinely use more than one.<br /><br />3. <span style="font-style:italic;">You should have a strategy for information trapping</span>. An explicit search is something that you do once, but the web is constantly changing. By using RSS feeds it is possible to set up a number of searches that run automatically and provide you with a constantly updated view of your subject. You can learn more about the technique in Tara Calishain's <span style="font-style:italic;"><a href="http://www.amazon.com/Information-Trapping-Real-Time-Research-Web/dp/0321491718/">Information Trapping</a></span>.<br /><br />4. <span style="font-style:italic;">You can organize citations right in your browser</span>. Until you start doing advanced work in digital history, you will access almost all of your online sources through your web browser. If you use <a href="http://www.zotero.org/">Zotero</a>, you can keep track of those sources in your browser, too. It really speeds up the research process.<br /><br />5. <span style="font-style:italic;">It is possible to automate the process of downloading sources</span>. There are a number of tools that make it easy to grab large batches of online sources without having to download them one at a time. In the Firefox browser, for example, you can use something like <a href="http://www.downthemall.net/">DownThemAll</a>. Another option is GNU <a href="http://www.gnu.org/software/wget/">Wget</a>.<br /><br />6. <span style="font-style:italic;">The web is not structured like a ball of spaghetti</span>. A lot of the most interesting information to be gleaned from digital sources lies in the hyperlinks leading into and out of various nodes, whether personal pages, documents, archives, institutions, or what have you. Search engines provide some rudimentary tools for mapping these connections, but much more can be learned with more specialized tools.<br /><br />7. <span style="font-style:italic;">Assume that what you want to know is out there, and go looking for it</span>.<br /><br />Tags: <a href="http://technorati.com/tag/digital+history" rel="tag">digital history</a> | <a href="http://technorati.com/tag/history+education" rel="tag">history education</a> | <a href="http://technorati.com/tag/pedagogy" rel="tag">pedagogy</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-68906757068636692552008-09-21T10:33:00.008-04:002008-09-21T11:42:09.521-04:00Hello World!It's traditional when learning a new programming language to have your first program simply say "Hello world!" and terminate. It not only boosts your confidence, it signals that you've got all of the basics in place: an editor to create programs, an interpreter or compiler that can follow the instructions that you've programmed, and a way for the information to get out of the program and the computer into a form where you can make use of it. What you do at that point is up to you... hopefully more programming.<br /><br />Over the last few years, I've been wrapping up my <a href="http://www.amazon.com/Archive-Place-Unearthing-Chilcotin-Plateau/dp/0774813776/">first book project</a>: a study of how people reconstruct the past from various kinds of physical traces. My interest in the ways that material evidence and places can inform historical consciousness, and a growing interest in the potential of digital and public history, have led me to a related set of research questions. How can we use new technologies like ubiquitous / pervasive computing, ambient and tangible interfaces, and desktop fabrication to build historical interpretations into physical devices and environments? What happens when all of the bits that we've been creating through various kinds of digitization can become material atoms again? And how can this help us to better understand various pasts and make them usable in the present?<br /><br />For a couple of years I've been doing projects with my students and research assistants that use technology to augment everyday places and objects, to put historical interpretations back into <span style="font-style:italic;">stuff</span>. These projects have made use of <a href="http://digitalhistory.wikispot.org/Place-based_Computing">GPS-enabled handheld and tablet computers</a>; <a href="http://digitalhistory.wikispot.org/Interactive_Ambient_and_Tangible_Devices_for_Knowledge_Mobilization">microcontrollers, analog sensors and actuators</a>; and other electronic technologies. Up until now, however, we've had to buy physical components or fashion them by hand.<br /><br />Last week, <a href="http://adamcrymble.blogspot.com/">Adam</a>, <a href="http://devonelliott.blogspot.com/">Devon</a> and I had a chance to set up our new <a href="http://www.rolanddg.com/product/3d/3d/mdx-20_15/mdx-20_15.html">Roland Modela MDX-20</a> and try making something with it, a kind of physical "hello world."<br /><br /><a href="http://digitalhistory.wikispot.org/FabWiki_Using_MDX-20"><img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhv2ZB4d66kdmXTDpejOGQY-SZNzMQsBB1Nv1CCTHky4Zd5mamOzMzD0D87IhyphenhyphenCWB7g4bPAwhenRS07zG88DoBiRO4JjWLSEIjvCYWAtkCidA219BC4juRsolK442GEScqP3N-01Q/s400/mdx20-20080919-thumbs.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5248483861170730914" /></a><br /><br />The MDX-20 is a (relatively simple) computer-controlled milling machine. It is able to move a rapidly spinning, sharp tool in three dimensions, gradually removing material from a solid block, so that it comes to precisely resemble a three-dimensional model in the computer. What this means is that something that is almost purely virtual can be materialized in foam, plastic, wood, and other soft physical media. (Although our first efforts look pretty chunky, the machine is capable of much more precise contours--we have a lot to learn.) The MDX-20 also has a scanning probe, which we haven't had a chance to test yet. When used in scanning mode, the MDX-20 automates the creation of 3D models from physical objects. This allows you to start with one or more objects in the real world, scan them to create 3D models, edit or remix as desired, then replicate them in material form. At this point, the possibilities seem nearly endless.<br /><br />In <span style="font-style:italic;"><a href="http://www.amazon.com/Thing-Knowledge-Philosophy-Scientific-Instruments/dp/0520232496/">Thing Knowledge</a></span>, the philosopher Davis Baird argues that "Things and theory can both constitute our knowledge of the world." Things can serve as <span style="font-style:italic;">models</span>, physical representations that act in a similar way to theories. They can <span style="font-style:italic;">create phenomena</span>, separating action "from human agency and buil[ding it] into the reliable behavior of an artifact." Or they can serve as <span style="font-style:italic;">measuring instruments</span>, combining both representation and work (11-12). There's a long tradition of ignoring things to focus on ideas, cyberspace being one of many guises for idealism. It's time for digital humanists to say, "Hello, world!"<br /><br />Tags: <a href="http://technorati.com/tag/digitization" rel="tag">digitization</a> | <a href="http://technorati.com/tag/fabrication" rel="tag">fabrication</a> | <a href="http://technorati.com/tag/history+appliances" rel="tag">history appliances</a> | <a href="http://technorati.com/tag/stepwise+refinement" rel="tag">stepwise refinement</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-92191543076134981162008-09-06T18:20:00.008-04:002008-09-06T19:08:08.348-04:00Practices, Not ProductsThe first week of school is a good time to expect to see Murphy's law in action. This year my server suddenly decided to start falling over at diminishing intervals. A couple of weeks of sporadic debugging have left me where I started: with an unreliable server. All of the code and images for this blog are hosted there, so they are temporarily unavailable, and I had to scramble a bit to find a new online home for the group project that my students will be doing in their grad class in digital history. This summer, too, the keepers of my old standby the online <span style="font-style:italic;"><a href="http://www.biographi.ca/index-e.html">Dictionary of Canadian Biography</a></span> suddenly decided to overhaul their website. While I applaud the fact that they moved from Active Server Pages to PHP, I'm not so happy that so many of the code examples in <span style="font-style:italic;">Digital History Hacks</span> and the <span style="font-style:italic;"><a href="http://niche.uwo.ca/programming-historian/">Programming Historian</a></span> have to be revised.<br /><br />I've solved my server problem for the time being, or more accurately, sidestepped it, by moving a lot of my online stuff to a new home: <a href="http://digitalhistory.wikispot.org/">digitalhistory.wikispot.org</a>. In the process I was reminded again that wikis really are the fastest and most awesome way to get your stuff online in a form that is durable but plastic enough to be continually reshaped. I can thank <a href="http://raymondyee.net/wiki/">Raymond Yee</a> for the inspiration. Although I've used a number of online tools, it didn't occur to me that a wiki can replace most of them until I saw Raymond give a talk at <a href="http://thatcamp.org/">THATCamp</a>. Rather than bust out an Open Office presentation or something like that, Raymond pointed his browser to his own wiki, a "working space / public knowledge repository". He had already entered some of the material that he wanted to talk about, and as he gave his presentation he continued to edit. When his presentation was over, he clicked 'save' and everything was already available online.<br /><br />The beauty of a wiki, as many people have noted, is that it allows online material to grow quickly and organically. Rather than try to build my new online presence in one pass, I was able to sketch the outlines of what I wanted to add. Now, every time I look at the site, I see a whole bunch of work that still needs to be done. I can chip away at it, rethink, reorganize, and everything remains available to other people. On some of the pages I've roughed out sections for my students or research assistants to fill in; I expect them to chip away, rethink and reorganize, too. In effect, wiki software can provide scaffolding for practices. There's no real final product, just the most recent edit. (And, of course, access to the entire history of edits).<br /><br />This year, <a href="http://www.robmacdougall.org/">Rob MacDougall</a> and I are teaching a new course on science, technology and global history, and I find myself in the (exciting? unenviable?) position of writing my lectures the week before I give them. A lot of my projects feel like they may be on hold until November, when I can hand the lecturing off to Rob and start to deal with some of the changes that have broken things that used to work. I can't feel too bothered, however. <a href="http://digitalhistoryhacks.blogspot.com/2008/01/all-is-flux.html">All is flux</a>, especially on the internet. The trick is to find the techniques and tools that help you deal gracefully with change, to think in clay and not in stone.<br /><br />Tags: <a href="http://technorati.com/tag/dictionary+of+canadian+biography" rel="tag">Dictionary of Canadian Biography</a> | <a href="http://technorati.com/tag/digital+history" rel="tag">digital history</a> | <a href="http://technorati.com/tag/electronica" rel="tag">entropy</a> | <a href="http://technorati.com/tag/wikis" rel="tag">wikis</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-50652217625707992722008-08-20T05:34:00.004-04:002008-08-20T06:36:22.676-04:00Traces of UseWhen he figured that April was the cruelest month, I think TS Eliot was off by four. I find that the early summer stretches into an endless vista of exciting possibilities for new research and teaching. I make far too many commitments, all of which come back to haunt me in late August. Other than dropping in to do light maintenance, for example, I haven't had time recently to write much new material for the <span style="font-style:italic;"><a href="http://niche.uwo.ca/programming-historian/">Programming Historian</a></span>. The last time that I did, however, I noticed that visitor logs tell an interesting story.<br /><br />To date, the front page has received around 12 thousand hits, as people arrive at the site and decide what to do next. At that point, most of them leave. They may have ended up there by accident; they may bookmark the site to look at later. The next two sections are prefatory. The first (around 4 thousand visits) suggests why you may want to learn how to program. The second (almost 5 thousand visits) tells you how to install the software that you need to get started. My interpretation is that about a fifth of our visitors are already convinced they want to learn how to program, which I think is a good sign. The actual programming starts in the next section (2 thousand visits) and goes from there (while the number of visitors for subsequent sections slowly drops to about a thousand each). These numbers could be interpreted in various ways, but to me they suggest that (1) historians and other humanists want to learn how to program, (2) good intentions only get you so far, and (3) if you do stick with it, it gets harder gradually.<br /><br />These are pretty crude metrics, although more informative ones than I'm getting from, say, the sales figures for my award- winning- but- otherwise- neglected- monograph (<a href="http://www.amazon.com/Archive-Place-Unearthing-Chilcotin-Plateau/dp/0774813776/">buy a copy today!</a>) My friends who work in psycholinguistics have much more sophisticated ways of determining how people read and understand text, with devices that track the subject's gaze and estimate the moment-by-moment contents of their short term memory. I want people to get something out of the <span style="font-style:italic;">Programming Historian</span>, but I don't need that level of detail about what they're getting.<br /><br />In <span style="font-style:italic;">The Social Life of Information</span>, Brown and Duguid have an anecdote about a historian who goes through batches of eighteenth-century letters rapidly by sniffing bundles of them. When asked what he is doing, he explains that letters written during a cholera outbreak were disinfected with vinegar. "By sniffing for the faint traces of vinegar that survived 250 years and noting the date and source of the letters, he was able to chart the progress of cholera outbreaks." Brown and Duguid go on to note that "Digitization could have distilled out the text of those letters. It would, though, have left behind that other interesting distillate, vinegar."<br /><br />Probably, but not necessarily. Digitization simply refers to the explicit digital representation of something that can be measured. We are content at the moment with devices that take pictures of documents, and those devices have been steadily improving. We wouldn't be as content with the scanning quality of 2002, when <span style="font-style:italic;">The Social Life of Information</span> was published, and we'd, like, <span style="font-style:italic;">totally hate</span> the scanning quality of 1982 or 1962 ... just ask my students when they have to work with microfilm. That said, high resolution infrared spectroscopy makes it possible to build chemical sniffers that outperform human noses. They also make it possible to go through an archive and digitize the smells of every document.<br /><br />Saying that we can digitize any trace that we can discover and measure isn't the same thing as saying we can discover and measure any trace that we might need at the moment, episodes of <span style="font-style:italic;">CSI</span> notwithstanding. The material world is almost infinitely informative about the past, but the traces that are preserved have nothing to do with our interests and intents. And one shouldn't draw too fine a line between the analog and the digital, because digital representations are always stored on real-world analog devices, something Matt Kirschenbaum explores in his new book <span style="font-style:italic;"><a href="http://www.amazon.com/Mechanisms-New-Media-Forensic-Imagination/dp/0262113112/">Mechanisms</a></span>.<br /><br />Tags: <a href="http://technorati.com/tag/analog" rel="tag">analog</a> | <a href="http://technorati.com/tag/clues" rel="tag">clues</a> | <a href="http://technorati.com/tag/digitization" rel="tag">digitization</a> | <a href="http://technorati.com/tag/representation" rel="tag">representation</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-41125618869861977382008-08-07T10:15:00.012-04:002008-08-07T11:16:28.365-04:00Arms Races[Cross-posted to Cliopatria and Digital History Hacks]<br /><br />Like many people who blog at Blogger, I was recently notified by e-mail that my blog had been identified by their automated classifiers "as a potential spam blog." In order to prove that this was not the case, I had to log in to one of their servers and request that my blog be reviewed by a human being. The e-mail went on to say "Automatic spam detection is inherently fuzzy, and occasionally a blog like yours is flagged incorrectly. We sincerely apologize for this error." The author of the e-mail knew, of course, that if my blog were sending spam then his or her e-mail would fall on deaf ears (as it were)... you don't have to worry about bots' feelings. The politeness was intended for me, a hapless human caught in the crossfire in <a href="http://www.amazon.com/War-Intelligent-Machines-Manuel-Landa/dp/0942299752/">the war of intelligent machines</a>.<br /><br />That same week, a lot of my e-mails were also getting bounced. Since I have my blog address in my .sig file, I'm guessing that may have something to do with it. Alternately, my e-mail address may have been temporarily blocked as the result of a surge in spam being sent from GMail servers. This to-and-fro, attack against counter-attack, <a href="http://www.amazon.com/Spy-vs-Complete-Casebook/dp/0823050211/"><span style="font-style:italic;">Spy vs. Spy</span></a> kind of thing can be irritating for the collaterally damaged but it is good news for digital historians, as paradoxical as that may seem.<br /><br />One of the side effects of the war on spam has been a lot of sophisticated research on automated classifiers that use Bayesian or other techniques to categorize natural language documents. Historians can use these algorithms to make their own online archival research much more productive, as I argued in a <a href="http://digitalhistoryhacks.blogspot.com/search?q=bayesian">series of posts</a> this summer. <br /><br />In fact, a closely related arms race is being fought at another level, one that also has important implications for the digital humanities. The optical character recognition (OCR) software that is used to digitize paper books and documents is also being used by spammers to try and circumvent software intended to block them. This, in turn, is having a positive effect on the development of OCR algorithms, and leading to higher quality digital repositories as a collateral benefit. Here's how.<br /><ul><li>Computer scientists create the <a href="http://en.wikipedia.org/wiki/Captcha">CAPTCHA</a>, a "Completely Automated Public Turing test to tell Computers and Humans Apart." In essence, it shows a wonky image of a short text on the screen, and the (presumably human) user has to read it and type in the characters. If they match, the system assumes a real person is interacting with it.</li><li>Google releases the <a href="http://google-code-updates.blogspot.com/2006/08/announcing-tesseract-ocr.html">Tesseract OCR engine</a> that they use for Google Books as open source. On the plus side, a whole community of programmers can now improve Tesseract OCR. On the minus side, a whole community of spammers can put it to work cracking CAPTCHAs.</li><li>In the meantime, a group of computer scientists comes up with a brilliant idea, the <a href="http://recaptcha.net/">reCAPTCHA</a>. Every day, tens of millions of people are reading wonky images of short character strings and retyping them. Why not use all of these infinitesimal units of labor to do something useful? The reCAPTCHA system uses OCR errors for its CAPTCHAs. When you respond to a reCAPTCHA challenge, you're helping to improve the quality of digitized books.</li><li>The guys with <a href="http://en.wikipedia.org/wiki/White_hat">white hats</a> are also using OCR to crack CAPTCHAs, with the aim of creating stronger challenges. One side effect is that the OCR gets better at recognizing wonky text, and thus better for creating digital books.</li></ul><br />Tags: <a href="http://technorati.com/tag/machine+learning" rel="tag">machine learning</a> | <a href="http://technorati.com/tag/optical+character+recognition" rel="tag">optical character recognition (OCR)</a> | <a href="http://technorati.com/tag/turing+test" rel="tag">Turing test</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-58329643284793140202008-07-20T08:53:00.006-04:002008-07-20T10:30:45.224-04:00Towards a Computational History[Cross-posted to Cliopatria & Digital History Hacks]<br /><br />Given that relatively few of our colleagues are familiar with digital history yet--and that those of us who practice some form of it aren't sure what to call it: digital history? history and computing? digital humanities?--it may seem a bit perverse to start talking about computational history. Nevertheless, it's an idea that we need, and the sooner we start talking and thinking about it, the better.<br /><br />From my perspective, digital history simply refers to the idea that many of our potential sources are now online and available on the internet. It is possible, of course, to expand this definition and tease out many of its implications. (For more on that, see the forthcoming interchange on "The Promise of Digital History" in the September 2008 issue of <span style="font-style:italic;"><a href="http://www.journalofamericanhistory.org/">The Journal of American History</a></span>). To some extent we're all digital historians already, as it is quickly becoming impossible to imagine doing historical research without making use of e-mail, discussion lists, word processors, search engines, bibliographical databases and electronic publishing. Some day pretty soon, the "digital" in "digital history" is going to sound redundant, and we can drop it and get back to doing what we all love.<br /><br />Or maybe not. By that time, I think, it will have become apparent that having networked access to an effectively infinite archive of digital sources, and to one another, has completely changed the nature of the game. Here are a few examples of what's in store.<br /><br /><span style="font-style:italic;">Collective intelligence</span>. Social software allows large numbers of people to interact efficiently and focus on solving problems that may be too difficult for any individual or small group. Does this sound utopian? Present-day examples are easy to find in massive online games, open source software, and even the much-maligned <span style="font-style:italic;">Wikipedia</span>. These efforts all involve unthinkably complex assemblages of people, machines, computational processes and archives of representations. We have no idea what these collective intelligences will be capable of. Is it possible for an ad hoc, international, multi-lingual group of people to engage in a parallel and distributed process of historical research? Is it possible for a group to transcend the historical consciousness of the individuals that make it up? How does the historical reasoning of a collective intelligence differ from the historical reasoning of more familiar kinds of historian?<br /><br /><span style="font-style:italic;">Machines as colleagues</span>. Most of us are aware that law enforcement and security agencies routinely use biometric software to search through databases of images and video and identify people by facial characteristics, gait, and so on. Nothing precludes the use of similar software with historical archives. But here's the key point. Suppose you have a photograph of known provenance, depicting someone in whom you have an interest. Your biometric software skims through a database of historical images and matches your person to someone in a photo of a crowd at an important event. If the program is 95% sure that the match is valid, are you justified in arguing that your person was in the crowd that day?<br /><br /><span style="font-style:italic;">Archives with APIs</span>. Take it a step further. Most online archives today are designed to allow human users to find sources and read and cite them in traditional ways. It is straightforward, however, for the creators of these archives to add an application programming interface (API), a way for computer programs to request and make use of archival sources. You could train a machine learner to recognize pictures of people, artifacts or places and turn it loose on every historical photo archive with an API. Trained learners can be shared amongst groups of colleagues, or subject as populations to a process of artificial selection. At present, APIs are most familiar in the form of mashups, websites that integrate data from different sources on-the-fly. The race is on now to provide APIs for some of the world's most important online archival collections.<br /><br /><span style="font-style:italic;">Models</span>. Agent-based and other approaches from complex adaptive systems research are beginning to infiltrate the edges of the discipline, particularly amongst researchers more inclined toward the social sciences. Serious games appeal to a generation of researchers that grew up with not-so-serious ones. People who might once have found quantitative history appealing are now building geographic information systems. In every case, computational processes become tools to think with. I was recently at the <a href="http://metropolisontrial.wordpress.com/">Metropolis on Trial</a> conference, loosely organized around the 120 million word online archive of the <a href="http://www.oldbaileyonline.org/">Old Bailey proceedings</a>. At the conference, historians talked and argued about sources and interpretations, of course, but also about optical character recognition and statistical tables and graphs and search results generated with tools on the website. We're not yet at a point where these discussions involve much nuanced analysis of layers of computational mediation... but it is definitely beginning.<br /><br />Tags: <a href="http://technorati.com/tag/computational+history" rel="tag">computational history</a> | <a href="http://technorati.com/tag/digital+history" rel="tag">digital history</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-53017362241743672882008-07-03T17:03:00.006-04:002008-07-03T18:15:02.049-04:00A Naive Bayesian in the Old Bailey, Part 14I'm off to England next week to present some of this work at the <a href="http://metropolisontrial.wordpress.com/">Metropolis on Trial</a> conference, so it is time to bring this series of posts to a close. I'd like to wrap up by summarizing what we've accomplished and making a clearer case for machine learning as a tool for historical research.<br /><br />Papers in the machine learning literature often say something like "we tested learners <span style="font-style: italic;">x</span>, <span style="font-style: italic;">y</span>, and <span style="font-style: italic;">z</span> on this standard data set and found errors of 40%, 20% and 4% respectively. Learner <span style="font-style: italic;">z</span> should therefore be used in this situation." The value of such research isn't immediately apparent to the working historian. For one thing, many of the most powerful machine learning algorithms require the learner to be given all of the training data at once. Historians, on the other hand, tend to encounter sources piecemeal, sometimes only recognizing their significance in retrospect. Training a machine learner usually requires a labelled data set: each item already has to be categorized. It's not obvious what good a machine learner is, if the researcher has to do all the work in advance. Finally, there is the troublesome matter of errors. What good is a system that screws up one judgement in ten? Or one in four?<br /><br />In this work we considered a situation that is already becoming familiar to historians. You have access to a large archive of sources in digital form. These may consist of raw OCR text (full of errors), or they may be edited text, or, best of all, they may be marked up with XML, as in the case of the Old Bailey trials. Since most of us are not lucky enough to work with XML-tagged sources very often, I stripped out the tags to make my case more strongly.<br /><br />Now suppose you know exactly what you're looking for, but no one has gone through the sources yet to create an index that you can use. In a traditional archive, you might be limited to starting at the beginning and plowing through the documents one at a time, skimming for whatever you're interested in. If your archive has been digitized you have another option. You can use a traditional search engine to index the keywords in the documents. (You could, for example, download them all to your own computer and index them with <a href="http://desktop.google.com/features.html">Google Desktop</a>. Or you could get fancy with something like <a href="http://lucene.apache.org/">Lucene</a>.) Unless your topic has very characteristic keywords, however, you will be getting a mix of relevant and irrelevant results with every search. Under many conditions, a keyword search is going to return hundreds or thousands of hits, and you are back to the point of going through them one at a time.<br /><br />Suppose you're interested in larceny. (To make my point, I'm picking a category that the OB team has already marked up, but the argument is valid for anything that you or anyone else can reliably pick out. You might be studying indirect speech, or social deference, or the history of weights and measures. As long as you can look at each document and say "yes, I'm interested in this" or "no, I'm not interested in this" you can use this technique.) Anyway, you start with the first trial of 24 Nov 1834. It is a burglary, so you throw it in the "no" pile. The next record is a burglary, the third is a wounding, and so on. After you skim through 1,000 trials, you've found 444 examples of larceny and 556 examples of trials that weren't larceny. If you kept track of how long it took you to go through those thousand trials, you can estimate how long it will take for you to get through the remaining 11,959 trials in the 1830s, and approximately how many more cases of larceny you are likely to find. But you're less than a tenth of the way through the decade's trials, and <span style="font-style: italic;">no further ahead</span> on the remaining ones.<br /><br />Machine learning gives you a very powerful alternative, as we saw in this series. The naive bayesian learner isn't the most accurate or precise one available, but it has a couple of enormous advantages for our application. First of all, it is relatively easy to understand and to implement. Although we didn't make use of this characteristic, it is also possible to stop the learner at any point and find out which features it thinks are most significant. Second, the naive bayesian is capable of incremental learning. We can train it with a few labelled items, then test it on some unlabelled items, then train it some more. Let's go back to the larceny example. Suppose as you look at each of the thousand trials, you hand it off to your machine learner along with the label that you've assigned. So once you decide the first trial is a burglary, you give it to the learner along with the label "no". (This doesn't have to be laborious... the process could easily be built into your browser, so as you review a document, you can click a plus or minus button to label it for your learner.) Where are you after 1,000 trials? Well, you've still found your 444 examples of larceny and your 556 examples of other offence categories. But at this point, you've also trained a learner that can look through the next 11,959 trials in a matter of seconds and give you a pile containing about 2,500 examples of larceny and about 750 false positives. That means that the next pile of stuff that you look through has been "enriched" for your research. Only 44% of the first thousand trials you looked at were examples of larceny. Almost 77% of the next three thousand trials you look at will be examples of larceny, and the remaining 23% will be more closely related offences. Since the naive bayesian is capable of online learning, you can continue to train it as you look through this next pile of data.<br /><br />Machine learning can be a powerful tool for historical research because<br /><ol><li>It can learn as a side effect of your research process at very little cost to you</li><li>You can stop the system at any point to see what it has learned, getting an independent measure of a concept of interest<br /></li><li>You can use it at any time to "look ahead" and find items that it thinks that you will be interested in</li><li>Its false positive errors are often instructive, giving you a way of finding interesting things just beyond the boundaries of your categories</li><li>A change in the learner's performance over time might signal a historically significant change or discontinuity in your sources<br /></li></ol>Tags: <a href="http://technorati.com/tag/archive" rel="tag">archive</a> | <a href="http://technorati.com/tag/data+mining" rel="tag">data mining</a> | <a href="http://technorati.com/tag/digital+history" rel="tag">digital history</a> | <a href="http://technorati.com/tag/feature+space" rel="tag">feature space</a> | <a href="http://technorati.com/tag/machine+learning" rel="tag">machine learning</a> | <a href="http://technorati.com/tag/text+mining" rel="tag">text mining</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-36011540858696248212008-07-01T18:15:00.006-04:002008-12-29T20:02:46.786-05:00A Naive Bayesian in the Old Bailey, Part 13So far, we've only been working with the Old Bailey trials of the 1830s, almost thirteen thousand in total. It would be nice to know if our learner continues to perform well as we give it more testing data. In the following runs, I trained a TFIDF-50 learner for each offence category that was attested more than 10 times in the 1830s. The training data consisted of all of the trials from the decade, labelled and presented to the learner in chronological order. Training was then stopped, and each learner was tested on the 25,403 unlabelled trials of the 1840s, also presented in chronological order. In order to assess the learners' performance, I used the same measures that we developed earlier, comparing the ratio of misses to hits (accuracy) and the ratio of false positives to hits (precision). As before, I added one to the denominator, so as not to accidentally divide by zero. (Computers hate it when you do that.)<br /><br />The results for the accuracy measure are shown below, in the form of a bar graph rather than the scatterplot-style figure we used before. In this graph and the next one, we can see that the performance of the learner is about as good for data that it hasn't seen (i.e., the 1840s trials) as it is for the data that were used to train it. Most of the measures are around two or less, which is <a href="http://digitalhistoryhacks.blogspot.com/2008/06/naive-bayesian-in-old-bailey-part-11.html">comparable to what we saw before</a>. The performance has actually improved for many of the offence categories, like assault, fraud, perjury, conspiracy, kidnapping, receiving and robbery. We do notice, however, some performance degradation for a number of sexual offences, including sexual assault with sodomitical intent, bigamy, indecent assault, rape and sodomy. This might be a statistical anomaly. On the other hand, it might be a sign that the language that was used to describe sexual offences changed somewhat in the 1840s, causing a learner trained on 1830s data to miss later cases. This is one of the ways that tools like machine learning can be used to generate new research questions.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0f-_zc96DgwBb51AArkO173wJA_4YpT5XvLOs1NRSDPsyVCbTtegD1lWdPALllsmflbAjY4kNqc7t7Zw3BSJarPDoVfPhUAk2gl7PKPuuRkfWt7gyHYtliS2DqKWG37mJKRDppw/s1600-h/ob-tfidf50-1830s-40s-missratio.jpg"><img style="cursor:pointer; cursor:hand;width: 200px; height: 109px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0f-_zc96DgwBb51AArkO173wJA_4YpT5XvLOs1NRSDPsyVCbTtegD1lWdPALllsmflbAjY4kNqc7t7Zw3BSJarPDoVfPhUAk2gl7PKPuuRkfWt7gyHYtliS2DqKWG37mJKRDppw/s200/ob-tfidf50-1830s-40s-missratio.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5285382040417028146" /></a><br /><br />The next figure shows the results for the precision measure. In general the learner makes more false positive errors than misses, which is exactly what we want, given that <a href="http://digitalhistoryhacks.blogspot.com/2008/06/naive-bayesian-in-old-bailey-part-12.html">the false positives can be useful in themselves</a>. We don't see quite the same clear difference between sexual and non-sexual offence categories that we saw with the accuracy measure ... and for some reason it is quite hard for our learner to pick out cases of perverted justice in the 1840s.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCwYdRTNWymf6a80R1oojlPApSBAnZfX9EIfpHNMBFh6ac5CfLIiauyiVfBmS3_eRjVcxbxmEDZ91h3oZtqotx5dAqLGmD2WxxG-625gKv5AzFZYIwzk1YH8I_2Zy1zNw8L9mhpw/s1600-h/ob-tfidf50-1830s-40s-fpratio.jpg"><img style="cursor:pointer; cursor:hand;width: 200px; height: 117px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCwYdRTNWymf6a80R1oojlPApSBAnZfX9EIfpHNMBFh6ac5CfLIiauyiVfBmS3_eRjVcxbxmEDZ91h3oZtqotx5dAqLGmD2WxxG-625gKv5AzFZYIwzk1YH8I_2Zy1zNw8L9mhpw/s200/ob-tfidf50-1830s-40s-fpratio.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5285382232297536034" /></a><br /><br />Tags: <a href="http://technorati.com/tag/archive" rel="tag">archive</a> | <a href="http://technorati.com/tag/data+mining" rel="tag">data mining</a> | <a href="http://technorati.com/tag/digital+history" rel="tag">digital history</a> | <a href="http://technorati.com/tag/feature+space" rel="tag">feature space</a> | <a href="http://technorati.com/tag/machine+learning" rel="tag">machine learning</a> | <a href="http://technorati.com/tag/text+mining" rel="tag">text mining</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-22760031480373205392008-06-27T17:11:00.009-04:002008-12-29T19:57:52.850-05:00A Naive Bayesian in the Old Bailey, Part 12Up until now, we've measured the error rates of our various learners without worrying too much about what good an error-prone machine learner actually is. By dividing the learner's responses into the four categories of <span style="font-style:italic;">hit</span>, <span style="font-style:italic;">miss</span>, <span style="font-style:italic;">false positive</span> and <span style="font-style:italic;">correct negative</span>, we can get a more nuanced picture of what it is doing when it makes a mistake. Here we look at <span style="font-style:italic;">false positives</span>, trials that the learner mistakenly identifies as belonging to the category of interest. We start by writing a program that goes through each of the TFIDF-50 learner's responses for the various offence categories in the 1830s. It collects all of the false positives, making a note of what offence category each trial actually belongs to. The code to do this is <a href="http://digitalhistory.uwo.ca/dhh/hacks/ob-test-false-positives.py.html">here</a>. We can then plot the information in a convenient form. I've decided to use pie charts.<br /><br />The figure below shows the results for the offence category of assault, coded as a way of breaking the peace. What happens when our learner thinks that a trial is an example of this category but it really isn't? About 38.6% of the time, the trial in question was actually categorized as indecent assault (sexual), and about 38.6% of the time it was assault with intent (also sexual). Almost 11% of the time, the trial was a case of assault with sodomitical intent, and another 8% of the trials were actually categorized as an instance of wounding. In other words, about 96% of the learner's false positive "errors" in this case were other kinds of assault. What of the trials classified as "miscellaneous - other"? One was <a href="http://www.oldbaileyonline.org/browse.jsp?id=t18360919-2166&div=t18360919-2166">this trial</a>, where 44 year old William Blackburn was found guilty of "unlawfully and maliciously administering to Hannah Mary Turner 6 drachms of tincture of cantharides, with intent to excite, &c." I understand that this case probably doesn't fit the definition of assault used by either Blackburn's contemporaries or by the person who coded the file. Nevertheless, it is not completely unrelated to the idea of an assault, and is exactly the kind of source that a historian could use to shed light on gender relations, sexuality, or other topics.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCnciVmALKd0UGtL5dEu4v8HwjkdGc-xJllUyo1BW0AieXctApbowlv3cqcvPeLfSaZ9pmp_57ZMNEH25e_IXlExitagJpRu7SaDf1R-2blHShIdUlY6Y-1sNcnPrEyjN_DlXXoA/s1600-h/ob-tfidf50-1830s-fps-breakingpeace-assault.jpg"><img style="cursor:pointer; cursor:hand;width: 200px; height: 133px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiCnciVmALKd0UGtL5dEu4v8HwjkdGc-xJllUyo1BW0AieXctApbowlv3cqcvPeLfSaZ9pmp_57ZMNEH25e_IXlExitagJpRu7SaDf1R-2blHShIdUlY6Y-1sNcnPrEyjN_DlXXoA/s200/ob-tfidf50-1830s-fps-breakingpeace-assault.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5285380376305580482" /></a><br /><br />The next figure shows the false positives for fraud, categorized as a kind of deception. Seventy-two percent of the learner's false positives in this case were actually categorized as coining offences, and another 12% were actually cases of forgery. Once again, the vast majority of cases that were incorrectly identified as fraud belonged to relatively closely related offence categories. Note that these results cannot be explained by appealing to the distribution of offences in the sample as a whole. If the false positives were selected by the learner at random, we would expect most of them to be cases of larceny, which are by far the most commonly attested. Instead we see that a learner trained to recognize one kind of assault is confused by other kinds of assault, and one trained on fraud by other kinds of fraud.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDSUNKG_zO7pTcZzjb-DmN8cGaad1DJOOCRPbJnoH9a_RACb8nzO5cOlVankuE9eglGkUiLR9zdjLKYiF3ZQAwhaIt7Uh8eap1yKbF1Nw_Lcp3BkC_X0Iki7xF0fnqwQUUop1jDQ/s1600-h/ob-tfidf50-1830s-fps-deception-fraud.jpg"><img style="cursor:pointer; cursor:hand;width: 200px; height: 134px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDSUNKG_zO7pTcZzjb-DmN8cGaad1DJOOCRPbJnoH9a_RACb8nzO5cOlVankuE9eglGkUiLR9zdjLKYiF3ZQAwhaIt7Uh8eap1yKbF1Nw_Lcp3BkC_X0Iki7xF0fnqwQUUop1jDQ/s200/ob-tfidf50-1830s-fps-deception-fraud.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5285380592372886642" /></a><br /><br />A learner trained on manslaughter is mostly confused by cases of wounding and murder, as shown in the next figure.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCh4rDR-HkskjG5zxxRrjwUCz13amH_WGOp_xOnBZR14TN6V5WaQjN6MckrdDZ_8i4mrsVMCKKf2WGxVTg98EjUsl1z54flAFO3CXr0DWJiqTykLMtmMzMpwbM1KfTaoX10jcQTw/s1600-h/ob-tfidf50-1830s-fps-kill-manslaughter.jpg"><img style="cursor:pointer; cursor:hand;width: 200px; height: 142px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgCh4rDR-HkskjG5zxxRrjwUCz13amH_WGOp_xOnBZR14TN6V5WaQjN6MckrdDZ_8i4mrsVMCKKf2WGxVTg98EjUsl1z54flAFO3CXr0DWJiqTykLMtmMzMpwbM1KfTaoX10jcQTw/s200/ob-tfidf50-1830s-fps-kill-manslaughter.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5285380784178371810" /></a><br /><br />Finally we can consider a kind of theft, in this case housebreaking. If any learner were going to be confused by larceny cases, it should be one trained to recognize a type of theft. Instead, this learner is more confused by the less-frequently attested but more closely related categories of burglary and theft from place.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0ROubvOYh20U2uXaB49YhKQ2mst_rUt0aw-IwLLG_BDDwIkFWTi33V2m55TyizMccxINKxfYPDo2EuQQy2Qb8RRXNkZc4ortdRy4DS5Tl4uc7enwj-HTEVQzm9DWnoRU4FxkAgw/s1600-h/ob-tfidf50-1830s-fps-theft-housebreaking.jpg"><img style="cursor:pointer; cursor:hand;width: 200px; height: 136px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0ROubvOYh20U2uXaB49YhKQ2mst_rUt0aw-IwLLG_BDDwIkFWTi33V2m55TyizMccxINKxfYPDo2EuQQy2Qb8RRXNkZc4ortdRy4DS5Tl4uc7enwj-HTEVQzm9DWnoRU4FxkAgw/s200/ob-tfidf50-1830s-fps-theft-housebreaking.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5285380946666436194" /></a><br /><br />Now we are in a position to provide one kind of answer to the question, "what good is an error-prone learner?" Since the learner's errors are meaningfully related to its successful ability to categorize, we can use false positives as a way of generalizing beyond the bounds of hard and fast categorization. If we used a search engine to find cases of assault we might miss some of the most interesting such cases (like the cantharides example) ... cases that are interesting precisely because they lay just outside the category. One of the things that machine learning gives us, is a way of finding some of the more interesting exceptions to our rules.<br /><br />Tags: <a href="http://technorati.com/tag/archive" rel="tag">archive</a> | <a href="http://technorati.com/tag/data+mining" rel="tag">data mining</a> | <a href="http://technorati.com/tag/digital+history" rel="tag">digital history</a> | <a href="http://technorati.com/tag/feature+space" rel="tag">feature space</a> | <a href="http://technorati.com/tag/machine+learning" rel="tag">machine learning</a> | <a href="http://technorati.com/tag/text+mining" rel="tag">text mining</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-8817136884996583092008-06-25T14:42:00.009-04:002008-12-29T19:52:46.421-05:00A Naive Bayesian in the Old Bailey, Part 11We feel pretty confident that the performance of the TFIDF-50 version of the naive bayesian learner is going to be relatively stable regardless of the frequency with which a particular offence is attested. At this point we can write a routine which tests the learner on each of the offences which occurred 10 or more times in the 1830s. Our testing routine takes advantage of the fact that, unlike many other kinds of machine learner, the naive bayesian can be operated in <em>online</em> mode. What this means is that we can train the learner on some data, test its performance, then train it on some more data. Many learners can only be operated in <em>offline</em> or <em>batch</em> mode. This means they have to be trained on all of the data before they can be tested, and there is no way at that point to subject them to further training. The fact that the naive bayesian can be used for online learning will turn out to be crucial for us.<br /><br />The code for testing is <a href="http://digitalhistory.uwo.ca/dhh/hacks/ob-online-learning.py.html">here</a>. The learner is given the trials in chronological order, one at a time. The way that the program works is that it first uses the current state of the learner to classify a trial. The classification is scored as a hit, miss, false positive or correct negative, then the trial is used to train the learner (with the appropriate category being given as feedback). The learner is then given the next trial to judge. Once the learner has seen all of the data, the final count of hits, misses, etc. is output and the performance plotted as in previous posts. The results are shown below for the 1830s.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQrAjuSVayuY1YLza2Ux2n_jdj2Q1waxk0lYCkx5mIdJffk3j289X6tDh3_QWp0AmCoq83PLMSNubZM17dbjjTGVzVKKr_LqjK35IElFThxcpYndlQESHUxFUAY0x6pWS3J0W6OQ/s1600-h/ob-tfidf50-1830s.jpg"><img style="cursor:pointer; cursor:hand;width: 200px; height: 182px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQrAjuSVayuY1YLza2Ux2n_jdj2Q1waxk0lYCkx5mIdJffk3j289X6tDh3_QWp0AmCoq83PLMSNubZM17dbjjTGVzVKKr_LqjK35IElFThxcpYndlQESHUxFUAY0x6pWS3J0W6OQ/s200/ob-tfidf50-1830s.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5285379520717799538" /></a><br /><br />As can be seen, the performance is pretty stable, considering that different offences make up values ranging between 0.077% (for perverting justice 10/12959) and 42.48% of the total (for simple larceny 5505/12959). The system gets very few false positives for bigamy, and quite a few for shoplifting. We'll look at why this is the case in the next post. It is very accurate for the most frequently attested offence, simple larceny, and relatively inaccurate for the infrequently attested offences of kidnapping (11/12959) and perverting justice (10/12959). The central part of the plot is magnified and shown in the figure below. The performance of the learner varies for similar sorts of crime (e.g., it performs better for indecent assault than assault), something that we will take up next.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxm01CcN74exz4jBe5iqHuVY7_nRd1iIPiPs8tKrhyphenhyphenENU7x8kQVeSkqgl7RHyfLbrTdWoteWHRLz5KE-D-lRNsJnYEJrYmgLcRqCOu0kI8O528Gv7iMhXDVmB9jjXEA7xj7iqnBg/s1600-h/ob-tfidf50-1830s-detail.jpg"><img style="cursor:pointer; cursor:hand;width: 200px; height: 163px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjxm01CcN74exz4jBe5iqHuVY7_nRd1iIPiPs8tKrhyphenhyphenENU7x8kQVeSkqgl7RHyfLbrTdWoteWHRLz5KE-D-lRNsJnYEJrYmgLcRqCOu0kI8O528Gv7iMhXDVmB9jjXEA7xj7iqnBg/s200/ob-tfidf50-1830s-detail.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5285379678889310242" /></a><br /><br />Tags: <a href="http://technorati.com/tag/archive" rel="tag">archive</a> | <a href="http://technorati.com/tag/data+mining" rel="tag">data mining</a> | <a href="http://technorati.com/tag/digital+history" rel="tag">digital history</a> | <a href="http://technorati.com/tag/feature+space" rel="tag">feature space</a> | <a href="http://technorati.com/tag/machine+learning" rel="tag">machine learning</a> | <a href="http://technorati.com/tag/text+mining" rel="tag">text mining</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-59222495673856973332008-06-22T12:37:00.005-04:002008-12-29T19:50:36.456-05:00A Naive Bayesian in the Old Bailey, Part 10In our last post, we settled on a style of plotting that shows both how accurate our learner is (i.e., does it miss very often?) and how precise (i.e., how often does it return a false positive?) We also decided to do experiments with the version of the naive bayesian learner that uses the items with the highest tf-idf as features. Our experiments to date have used the category of simple larceny in the 1830s. This offence is very well-attested, making up about 42.5% of the trials (5505/12959). At this point, we can try the performance of the same learner on offence categories that are less frequent: stealing from master (1718/12959, approx. 13.3%) and burglary (279/12959, approx 2.2%). We've been using the 15 terms with the highest tf-idf, but we should try some other values for that parameter, too. A graph for the three different offence categories is shown below. The four learners use the top scoring 15, 30, 50 and 100 items, respectively.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3iXwQVfTt8mUpRCajLRtiiJdtCc9En0j4n340ISeJd5rmoV5HFAXNbv1SdnSK_SuuKC6yCqoB4f718kSaQwI-9OetniVxfie8ObbrpBctW-xcQnbHjC1Gv24l2IKiiRnj3HPMpQ/s1600-h/ob-tfidf-comparison.jpg"><img style="cursor:pointer; cursor:hand;width: 200px; height: 150px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi3iXwQVfTt8mUpRCajLRtiiJdtCc9En0j4n340ISeJd5rmoV5HFAXNbv1SdnSK_SuuKC6yCqoB4f718kSaQwI-9OetniVxfie8ObbrpBctW-xcQnbHjC1Gv24l2IKiiRnj3HPMpQ/s200/ob-tfidf-comparison.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5285379118372040930" /></a><br /><br />From the graph, it is pretty clear that it is easiest to learn to categorize larceny, which is the best-attested offence we looked at. We can also see that the TFIDF-15 learner does particularly poorly by missing many instances of the less frequent offences. Increasing the number of features the learner can make use of seems to improve performance up to a point. After that, increasing features increases the number of false positives the learner makes. We want the performance of our learner to be relatively robust when learning offence categories that are more or less frequently attested, which means we want the learner with the tightest grouping of results for these test categories (in other words, TFIDF-50).<br /><br />Note that in this test, we only ran each learner once on each data set, rather than doing ten-fold cross-validation. Our <a href="http://digitalhistoryhacks.blogspot.com/2008/06/naive-bayesian-in-old-bailey-part-7.html">experiments with cross-validation</a> suggested that the different versions of the learner were relatively insensitive to the order in which training and testing trials were presented. Since this is exploratory work, we will make the (possibly incorrect) assumption that a single trial is probably representative. This will let us do a lot more testing in the same amount of time.<br /><br />Tags: <a href="http://technorati.com/tag/archive" rel="tag">archive</a> | <a href="http://technorati.com/tag/data+mining" rel="tag">data mining</a> | <a href="http://technorati.com/tag/digital+history" rel="tag">digital history</a> | <a href="http://technorati.com/tag/feature+space" rel="tag">feature space</a> | <a href="http://technorati.com/tag/machine+learning" rel="tag">machine learning</a> | <a href="http://technorati.com/tag/text+mining" rel="tag">text mining</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-39128104535932718672008-06-21T16:56:00.006-04:002008-12-29T19:49:23.980-05:00A Naive Bayesian in the Old Bailey, Part 9There are many different ways to measure the performance of our various learning algorithms. The error rate that we've been using so far we defined as the sum of misses and false positives divided by the total number of trials. By this measure, <span style="font-style:italic;">COINFLIP</span> had an average error rate around 50%, and our naive bayesian learner had an error rate around 40% using one word features, and around 26% using either 2-grams or top-scoring tf-idf features. I thought I might be able to get better performance by using only those 2-grams that included terms with a high tf-idf, but that learner had an error rate around 26%, too. (Recall that we've been using cases of simple larceny in the 1830s for our experiments... the performance will be different for other offences and/or other decades. We'll test some of these soon.)<br /><br />By using a different measure, we can see that our various learners achieve their results in different ways. From our perspective as researchers, the least interesting category of answers are the correct negatives. Misses are a problem, because they may contain evidence that relates to the argument that we're trying to construct. False positives are a problem, because they are irrelevant but we have to look through them to determine that... in other words, they're a waste of time. A perfect learner would return all and only hits. If we consider the ratio of misses to hits we can get an idea of how accurate our learner is. As a learner gets better, the ratio of misses to hits approaches 0. As it gets worse, the ratio increases. A disastrous learner might not get any hits, so to avoid a division by zero error, we'll add one to the denominator. Our accuracy measure is thus <span style="font-style:italic;">misses / (hits + 1)</span>. If we consider the ratio of false positives to hits we can find out how precise our learner is. As it gets better, this ratio will go to zero, and as it gets worse, the ratio will increase. Our precision measure is <span style="font-style:italic;">false positives / (hits + 1)</span>. We can plot both measures on the same graph, with the origin in the lower left hand corner, as shown below. Since some of the values are large, I've used logarithmic axes. (Also, the results for <span style="font-style:italic;">YES</span> and <span style="font-style:italic;">NO</span> actually lie on the respective zero lines, but I've bumped them over so they can be seen in this plot.)<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPKJAA0acoF-11O2hk8_oiXYuylH8D3LkZBYbYSi2W08mRJxgmkQuWTuLk1d-kMIh6fcI1hj4I6eCbddQk9Z7SVXSM0cmz-tDjtHvsdP12dUPCN8mizdJ11eKC9m9DIyxm0bl81Q/s1600-h/ob-larceny-stats-2.jpg"><img style="cursor:pointer; cursor:hand;width: 200px; height: 184px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPKJAA0acoF-11O2hk8_oiXYuylH8D3LkZBYbYSi2W08mRJxgmkQuWTuLk1d-kMIh6fcI1hj4I6eCbddQk9Z7SVXSM0cmz-tDjtHvsdP12dUPCN8mizdJ11eKC9m9DIyxm0bl81Q/s200/ob-larceny-stats-2.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5285378790246746226" /></a><br /><br />Looking at the graph we notice some interesting results. The naive bayesian that uses words for features gets relatively few false positives, but at the cost of missing an order of magnitude more items than the other two learners. The 2-gram learner outperforms <span style="font-style:italic;">COINFLIP</span> and the tf-idf learner on false positives, but not on misses. The tf-idf learner is the only one that outperforms <span style="font-style:italic;">COINFLIP</span> in terms of both accuracy and precision. Thus we will do our next round of experiments with the tf-idf learner. <br /><br />Tags: <a href="http://technorati.com/tag/archive" rel="tag">archive</a> | <a href="http://technorati.com/tag/data+mining" rel="tag">data mining</a> | <a href="http://technorati.com/tag/digital+history" rel="tag">digital history</a> | <a href="http://technorati.com/tag/feature+space" rel="tag">feature space</a> | <a href="http://technorati.com/tag/machine+learning" rel="tag">machine learning</a> | <a href="http://technorati.com/tag/text+mining" rel="tag">text mining</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-31806352499310419192008-06-18T20:03:00.007-04:002008-06-18T20:45:31.667-04:00A Naive Bayesian in the Old Bailey, Part 8In the last post, we got a naive bayesian learner working and used it to categorize some Old Bailey trials from the 1830s as examples of larceny (or not). Our initial version of the learner was easy to implement, but it made the unrealistic assumption that the probabilities of particular words appearing in the text of a trial were independent. That greatly simplified computation at the cost of performance. Our initial learner had an error rate around 40%. We then revised it to use 2-grams as features rather than individual words. This captured some of the dependency between words, improving our average error rate so it was close to 25%.<br /><br />An alternative approach is to try and concentrate on the words in a trial which are most representative of a particular category. Without specifying these words in advance, we can make the assumption that they will be relatively frequent in the document in question, but relatively infrequent in the overall corpus of documents. One common measure for this is known as <a href="http://en.wikipedia.org/wiki/Tfidf">tf-idf</a>. Rather than handing all of the words in a given trial to our learner, or all except the stop words, we will only hand off the 15 or 20 with the highest tf-idf. There are many different ways to compute this measure. The version that I used is <span style="font-style: italic;">tfidf = log(tf+1.0) * log(numdocs/df)</span>, where <span style="font-style: italic;">tf</span> is the number of times the word occurs in a particular text, <span style="font-style: italic;">numdocs</span> is the total number of documents, and <span style="font-style: italic;">df</span> is number of documents that the word appears in. The word "cellar," for example, appears in <a href="http://www.oldbaileyonline.org/browse.jsp?div=t18341124-1">this trial</a> seventeen times, and in 221 other trials in the 1830s. The <span style="font-style: italic;">tfidf</span> for this word in this trial is <span style="font-style:italic;">log(17+1) * log(12959/221) = 11.76781</span>.<br /><br />To compute the tf-idf, we first need to create a list of every word that was used in all of the trials, and the number of different trials in which each word appears. We could put this information in a text file, but the file would be huge and very slow to access. Instead, we will store our document frequencies in a <a href="http://www.sqlite.org/">SQLite</a> database, using Python commands to store and retrieve the information. The code which creates this database is <a href="http://digitalhistory.uwo.ca/dhh/hacks/ob-compute-doc-freqs.py.html">here</a>. We can then compute the tf-idf scores for each word in a given trial, creating a new directory to store these files. The code to do that is <a href="http://digitalhistory.uwo.ca/dhh/hacks/ob-compute-tfidf.py.html">here</a>. Finally, we will want a version of our tenfold cross-validation routine to test the performance of a naive bayesian learner that operates across tf-idf vectors rather than raw words or 2-grams (<a href="http://digitalhistory.uwo.ca/dhh/hacks/ob-cross-validate-tfidf-learner.py.html">here</a>). This new learner has similar performance to the 2-gram version, with an average error rate of 25.73% when using the 15 highest scoring tf-idf terms to categorize cases of larceny in the 1830s. As a bonus, it is remarkably fast. At this point, you're probably wondering what good a machine learner is, if one quarter of its judgments are incorrect. We'll get there.<br /><br />Tags: <a href="http://technorati.com/tag/archive" rel="tag">archive</a> | <a href="http://technorati.com/tag/data+mining" rel="tag">data mining</a> | <a href="http://technorati.com/tag/digital+history" rel="tag">digital history</a> | <a href="http://technorati.com/tag/feature+space" rel="tag">feature space</a> | <a href="http://technorati.com/tag/machine+learning" rel="tag">machine learning</a> | <a href="http://technorati.com/tag/text+mining" rel="tag">text mining</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-42711321761427414112008-06-17T10:46:00.012-04:002008-12-29T19:46:26.816-05:00A Naive Bayesian in the Old Bailey, Part 7At last we're in a position to actually train and test some machine learners. The one that we'll start with is called a <span style="font-style: italic;">naive bayesian</span>. It is relatively simple to implement, although it usually doesn't perform nearly as well as fancier and more complicated learners. For our purposes, however, it has some real advantages, which we'll get to spelling out eventually. The version of the naive bayesian learner that I am going to use is the one that was implemented by Toby Segaran in his book <span style="font-style: italic;"><a href="http://www.amazon.com/Programming-Collective-Intelligence-Building-Applications/dp/0596529325/">Programming Collective Intelligence</a></span>. I won't post the code for the learner here, as it is already <a href="http://blog.kiwitobes.com/?p=44">available online</a>. If you are able to follow this series of posts and are interested in writing machine learning code in Python, Toby's book is a must-have. The only change that I have implemented is to remove stop words before submitting the trials for training or testing. You can get instructions and code for that from <span style="font-style: italic;"><a href="http://niche.uwo.ca/programming-historian/index.php/Main_Page">The Programming Historian</a></span>.<br /><br />Bayesian learners make use of a theorem proposed by Thomas Bayes and published in 1763, two years after his death (for more on Bayes, see Bellhouse's <a href="http://www.york.ac.uk/depts/maths/histstat/bayesbiog.pdf">biography</a>.) The theorem states that <span style="font-style:italic;">Pr[H|E] = (Pr[E|H] * Pr[H]) / Pr[E]</span>. <span style="font-style:italic;">Pr[H|E]</span> is the probability that the hypothesis <span style="font-style:italic;">H</span> is true, given some evidence <span style="font-style:italic;">E</span>. <span style="font-style:italic;">Pr[E|H]</span> is the probability that you would see evidence <span style="font-style:italic;">E</span> if the hypothesis <span style="font-style:italic;">H</span> were true. <span style="font-style:italic;">Pr[H]</span> is the probability of the hypothesis and <span style="font-style:italic;">Pr[E]</span> the probability of the evidence. Bayes theorem gives us a way of determining conditional probabilities: if we know one thing, how likely are we to know something else?<br /><br />Let's work through a simple example. Suppose bag A contains one black marble and three white ones, and bag B contains two white marbles and two black ones. Someone gives us a black marble but doesn't remember which bag they took it from. Given that you have a black marble, what are the chances that it came from bag A? In this case, <span style="font-style:italic;">Pr[H]</span> is the probability the marble came from bag A. Since each bag contains the same number of marbles, <span style="font-style:italic;">Pr[H] = 4/8 = 1/2</span>. <span style="font-style:italic;">Pr[E]</span> is the probability that a marble is black, so <span style="font-style:italic;">Pr[E] = (1+2)/8 = 3/8</span>. <span style="font-style:italic;">Pr[E|H]</span> is the probability that you are going to get a black marble if you choose from bag A, in other words <span style="font-style:italic;">Pr[E|H] = 1/4</span>. So Bayes theorem says that <span style="font-style:italic;">Pr[H|E] = (1/4*1/2) / 3/8 = 1/3</span>. Since we know that the marble had to come from one of the two bags, that means that it should have a 2/3 chance of coming from bag B, which we can double check. <span style="font-style:italic;">Pr[notH|E] = (Pr[E|notH] * Pr[notH]) / Pr[E] = (2/4*1/2) / 3/8 = 2/3</span>, as expected. You can learn more about Bayes theorem <a href="http://plato.stanford.edu/entries/bayes-theorem/">here</a>.<br /><br />When applied to the problem of learning, Bayes theorem looks like this: <span style="font-style:italic;">Pr[category|document] = Pr[document|category] * Pr[category]</span>. (We don't need to divide by <span style="font-style:italic;">Pr[document]</span> in this equation because it will scale all of our results by the same amount). We make the (incorrect) assumption that the probability of each word in the document is independent from the others, so we can set <span style="font-style:italic;">Pr[document|category]</span> equal to <span style="font-style:italic;">Pr[word1|category] * Pr[word2|category] * ...</span> Finally, <span style="font-style:italic;">Pr[category]</span> is simply the proportion of all documents that belong to our category of interest.<br /><br />So how well does the naive bayesian learner do? Not very well. In a tenfold cross-validation run testing for cases of simple larceny in the 1830s it has an average error rate of 39.17%, compared with <span style="font-style:italic;">COINFLIP</span>'s average error rate of 49.39%. The error rate is simply <span style="font-style:italic;">(Misses + False Positives) / Total Number of Trials</span>. Part of the problem is that we made the assumption that the probability of any word in a document is independent of the probability of any other word in the same document. We know this isn't strictly true. In the Old Bailey proceedings, for example, you find both "dwelling" and "dwelling house", as well as "victualling house", "sessions house", "station house", "house keeper" and many other forms. To the extent that these and other words tend to co-occur, the word probabilities can't be independent. We can improve the performance of our naive bayesian learner by using pairs of words (i.e., 2-grams) rather than individual words as features for the learner. This drops the error rate to 26.23% when categorizing trials for simple larceny in the 1830s. The code that tests the different learners is <a href="http://digitalhistory.uwo.ca/dhh/hacks/ob-cross-validate-learner.py.html">here</a>. A graph of performance is shown below.<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguBpwzlLLpzI5Nr4TOPCj9tI-GLpczHZdyj52vDoF2uyULw2m8NuneABC6d_SDrPi6nN8wkBmyxTpRG9apRxlh7RpZI_2tpOIGeybGayVj39EeqDKHL7rw_9m8tCkA0DWRjoPvuA/s1600-h/ob-cross-validation-larceny-stats.jpg"><img style="cursor:pointer; cursor:hand;width: 200px; height: 126px;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguBpwzlLLpzI5Nr4TOPCj9tI-GLpczHZdyj52vDoF2uyULw2m8NuneABC6d_SDrPi6nN8wkBmyxTpRG9apRxlh7RpZI_2tpOIGeybGayVj39EeqDKHL7rw_9m8tCkA0DWRjoPvuA/s200/ob-cross-validation-larceny-stats.jpg" border="0" alt=""id="BLOGGER_PHOTO_ID_5285378045780201762" /></a><br /><br />Tags: <a href="http://technorati.com/tag/archive" rel="tag">archive</a> | <a href="http://technorati.com/tag/data+mining" rel="tag">data mining</a> | <a href="http://technorati.com/tag/digital+history" rel="tag">digital history</a> | <a href="http://technorati.com/tag/feature+space" rel="tag">feature space</a> | <a href="http://technorati.com/tag/machine+learning" rel="tag">machine learning</a> | <a href="http://technorati.com/tag/text+mining" rel="tag">text mining</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-88430490223158581242008-06-13T06:32:00.004-04:002008-06-13T09:07:59.182-04:00A Naive Bayesian in the Old Bailey, Part 6Now that we have our training and testing samples, we will be able to estimate the error rates of our various machine learners. Some of them won't be very good, especially if they are trained on relatively small or unrepresentative samples. None of them will be perfect, or even approach human performance. So it is usually a good idea to ask if the performance of a given learner is significantly different from chance. Consider three other abstract machines which don't do any learning at all.<br /><br /><span style="font-style: italic;">YES</span> is a very simple machine. When given an item and asked whether or not it is an instance of a particular category, <span style="font-style: italic;">YES</span> says "yes". That's it. Suppose we have 100 test items and all of them are instances of our category, say 100 examples of burglary. We ask <span style="font-style: italic;">YES</span> about each of them and it 'decides' that each is a burglary. <span style="font-style: italic;">YES</span> makes no errors at all on this test sample! If half of the test items are not burglaries, however, <span style="font-style: italic;">YES</span>'s error rate climbs to 50%.<br /><br /><span style="font-style: italic;">NO</span> is also a very simple machine, responding "no" whenever tested. If we give it 100 examples of burglaries, it will fail to recognize every single one of them, with an error rate of 100%. The fewer burglaries our test sample contains, the better <span style="font-style: italic;">NO</span> does.<br /><br /><span style="font-style: italic;">COINFLIP</span> is more sophisticated than <span style="font-style: italic;">YES</span> or <span style="font-style: italic;">NO</span>. Every time we ask <span style="font-style: italic;">COINFLIP</span> to make a decision, it has a 50% chance of responding "yes" and a 50% chance of responding "no". Given a sample with 100 examples of burglaries, <span style="font-style: italic;">COINFLIP</span> gets it wrong about half the time. Given a sample with no burglaries in it, <span style="font-style: italic;">COINFLIP</span> will also have an error rate around 50%.<br /><br />With these three simple machines, we can be more clear about what it means to be right or wrong, distinguishing four categories:<br /><ul><li><span style="font-style: italic;">Hit</span>. If the machine says "yes" and the right answer is "yes", we say that it has scored a hit. This is one kind of correct answer. Both <span style="font-style: italic;">YES</span> and <span style="font-style: italic;">COINFLIP</span> are capable of scoring hits, but <span style="font-style: italic;">NO</span> never is, because it can never say "yes" to anything.</li><li><span style="font-style: italic;">False Positive</span>. If the machine says "yes" but the answer is really "no", we say that it has responded with a false positive, which is one kind of incorrect answer. <span style="font-style: italic;">YES</span> and <span style="font-style: italic;">COINFLIP</span> can reply with false positives, but <span style="font-style: italic;">NO</span> cannot.</li><li><span style="font-style: italic;">Miss</span>. If the machine says "no" but the correct answer was "yes", we say that it missed. <span style="font-style: italic;">NO</span> and <span style="font-style: italic;">COINFLIP</span> can miss, but <span style="font-style: italic;">YES</span> cannot, because it never says "no".</li><li><span style="font-style: italic;">Correct Negative</span>. This happens when the machine says "no" and the correct answer was "no". <span style="font-style: italic;">NO</span> and <span style="font-style: italic;">COINFLIP</span> can reply with correct negatives, but <span style="font-style: italic;">YES</span> cannot.<br /></li></ul>We expect our learners to produce answers in each of the four categories. A machine that always hits will also tend to identify a lot of false positives. This can be good if you are looking for a needle in a haystack, but will overwhelm you if your category is well-attested. A machine that always identifies correct negatives will often miss things. These kind of machines tend to be more useful when you would never have time to go through all of your items by hand. Most machine learners have parameters that allow you to tune their performance between these extremes.<br /><br />Tags: <a href="http://technorati.com/tag/archive" rel="tag">archive</a> | <a href="http://technorati.com/tag/data+mining" rel="tag">data mining</a> | <a href="http://technorati.com/tag/digital+history" rel="tag">digital history</a> | <a href="http://technorati.com/tag/feature+space" rel="tag">feature space</a> | <a href="http://technorati.com/tag/machine+learning" rel="tag">machine learning</a> | <a href="http://technorati.com/tag/text+mining" rel="tag">text mining</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-75507863878385787102008-06-12T10:12:00.007-04:002008-06-12T10:46:59.548-04:00A Naive Bayesian in the Old Bailey, Part 5With most of our support routines in place, we need to think about the problem of training a machine learner and then assessing its performance. A human being has already gone through each of the trials and assigned one or more offence categories to it:<br /><ul><li><a href="http://www.oldbaileyonline.org/browse.jsp?div=t18341124-1">this trial</a> is a burglary, which is a kind of theft</li><li><a href="http://www.oldbaileyonline.org/browse.jsp?div=t18341124-2">this trial</a> is also a burglary</li><li><a href="http://www.oldbaileyonline.org/browse.jsp?div=t18341124-3">this trial</a> is a wounding, which is a way of breaking the peace</li><li>...</li></ul>So we can give each raw trial to our learner and ask it to decide what offence category the trial belongs to, then we can check our learner's answer against the human-assigned category. If we do enough of these trials, we can get a precise sense of how good our learner is.<br /><br />Most machine learning researchers use a <em>holdout method</em> to test the performance of their learning algorithms. They use part of the data to train the system, then test its performance on the remaining part, the part that wasn't used for training. Items are randomly assigned to either the training or the testing pile, with the further stipulation that both piles should have the same distribution of examples. Since burglaries made up about 2.153% (279/12959) of the trials in the 1830s, we want burglaries to make up about two percent of the training data and about two percent of the test data. It would do us no good for all of the burglaries to end up in one pile or the other.<br /><br />But how do we know whether the results that we're seeing are some kind of fluke? We use <span style="font-style: italic;">cross-validation</span>. We randomly divide our data into a number of piles (usually 10), making sure that the category that we are interested in is uniformly distributed across those piles. Now, we set aside the first pile and use the other nine piles to train our learner. We then test it on the first pile and record its performance. We then set aside the second pile for testing, and use the other nine piles for training a new learner. And so on, until each item has been used both for testing and for training. We can then average the ten error estimates. There are many other methods in the literature, of course, but this one is fairly standard.<br /><br />Code to create a tenfold cross-validation sample from our data is <a href="http://digitalhistory.uwo.ca/dhh/hacks/ob-tenfold-crossvalidation-sample.py.html">here</a>. As a check, we'd also like to make sure that our offence category is reasonably distributed across our sample (code for that is <a href="http://digitalhistory.uwo.ca/dhh/hacks/ob-count-offence-instances.py.html">here</a>).<br /><br />Tags: <a href="http://technorati.com/tag/archive" rel="tag">archive</a> | <a href="http://technorati.com/tag/data+mining" rel="tag">data mining</a> | <a href="http://technorati.com/tag/digital+history" rel="tag">digital history</a> | <a href="http://technorati.com/tag/feature+space" rel="tag">feature space</a> | <a href="http://technorati.com/tag/machine+learning" rel="tag">machine learning</a> | <a href="http://technorati.com/tag/text+mining" rel="tag">text mining</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-84113793226440740552008-06-09T12:37:00.007-04:002008-06-09T13:10:10.976-04:00A Naive Bayesian in the Old Bailey, Part 4With raw text files for each of the trials, we're almost in a position to try doing some experiments with a machine learner. Before we get started we are going to need a few utility routines to make our lives easier. Programmers enjoy writing tools so much they have a special expression for the process: <a href="http://www.catb.org/jargon/html/Y/yak-shaving.html">yak shaving</a>. Sometimes it's necessary, sometimes it's just fun, sometimes it's a great way to procrastinate. We'll try to keep it in check.<br /><ul><li>First of all, we'll want lists of all of the files that need to be processed in a given decade. We could use the operating system for this, but Windows is pretty slow when you have tens of thousands of files in a directory. A program to grab the list of filenames to another text file is <a href="http://digitalhistory.uwo.ca/dhh/hacks/ob-trial-id-list.py.html">here</a>.</li><li>We're also going to want a list of all of the dates on which trials occurred (in other words, we will want a list of all of the days that the court was in session). The program to generate that list and sort it in ascending order is <a href="http://digitalhistory.uwo.ca/dhh/hacks/ob-get-date-range.py.html">here</a>.</li><li>Since our initial experiments will be focused on trying to automatically categorize trials by offence (e.g., "burglary"), we are going to need a few routines that make it easier to work with offences. One of these needs to return a mapping from trial IDs to one or more categories of offence (the code is <a href="http://digitalhistory.uwo.ca/dhh/hacks/ob-offence-category.py.html">here</a>):<br /></li><ul><li>t-18341124-1.txt -> theft-burglary</li><li>t-18341124-2.txt -> theft-burglary</li><li>t-18341124-3.txt -> breakingpeace-wounding</li><li>...</li><li>t-18341124-37.txt -> theft-stealingfrommaster, theft-simplelarceny</li><li>...</li></ul><li>Another routine needs to return a mapping from a particular offence to a list of matching trial IDs (the code is <a href="http://digitalhistory.uwo.ca/dhh/hacks/ob-offence-index.py.html">here</a>):</li><ul><li>theft-burglary -> t-18341124-1.txt, t-18341124-183.txt, t-18341124-185.txt, t-18341124-2.txt, t-18341124-4.txt, ...</li></ul><li>Finally, we are going to need to have some idea of how many offences there were of each kind in a particular decade (the code is <a href="http://digitalhistory.uwo.ca/dhh/hacks/ob-count-offences.py.html">here</a>). For the 1830s, the data look like the following:</li><ul><li>breakingpeace-assault.txt|51</li><li>breakingpeace-libel.txt|7</li><li>breakingpeace-riot.txt|5</li><li>breakingpeace-threateningbehaviour.txt|4</li><li>breakingpeace-wounding.txt|166</li><li>breakingpeace.txt|1</li><li>damage-arson.txt|7</li><li>damage-other.txt|1</li><li>...<br /></li></ul></ul>That about does it for the utility routines. Next we have to address the problem of sampling.<br /><br />Tags: <a href="http://technorati.com/tag/archive" rel="tag">archive</a> | <a href="http://technorati.com/tag/data+mining" rel="tag">data mining</a> | <a href="http://technorati.com/tag/digital+history" rel="tag">digital history</a> | <a href="http://technorati.com/tag/feature+space" rel="tag">feature space</a> | <a href="http://technorati.com/tag/machine+learning" rel="tag">machine learning</a> | <a href="http://technorati.com/tag/text+mining" rel="tag">text mining</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.comtag:blogger.com,1999:blog-19974449.post-13826921678227750892008-06-07T11:08:00.004-04:002008-06-07T11:36:11.788-04:00A Naive Bayesian in the Old Bailey, Part 3At this point, we have a directory that contains one file for each trial in a given decade. There are a lot of these files (almost 13,000 for the 1830s alone) and each trial is still marked up with XML. In the next step we're going to create parallel directories that contain trial files with all of the XML stripped out. In other words, our trial files currently look like this:<br /><blockquote><br /><span style="font-style: italic;"><trial id="t-18341124-1" n="1"><charge n="1" defid="def1-1-18341124" offenceno="1" verdictno="1"></charge><charge n="2" defid="def2-1-18341124" offenceno="1" verdictno="2"><p></span>1. <span style="font-style: italic;"><name role="defendant" id="def1-1-18341124" age="30" sex="m" given="JOHN" occupation="na" surname="HOLGATE"><lc></span>JOHN HOLGATE<span style="font-style: italic;"></lc></name></span> and<br /><span style="font-style: italic;"><name role="defendant" id="def2-1-18341124" age="27" sex="m" given="JAMES" occupation="na" surname="HOLGATE"><lc></span>JAMES HOLGATE<span style="font-style: italic;"></lc></name><offence n="1" ids="def1-1-18341124 def2-1-18341124"><theft category="burglary"></span> were indicted, for that they, on the <span style="font-style: italic;"><cd></span>1st of October<span style="font-style: italic;"></cd></span>, at <span style="font-style: italic;"><geo></span>St. Mary Magdalen, Bermondsey<span style="font-style: italic;"></geo></span>, about four o'clock in the night, the dwelling-house of <span style="font-style: italic;"><name age="na" given="JOHN" residency="st mary magdalen bermondsey" role="victim" sex="m" surname="THOMPSON"></span>John Thompson<span style="font-style: italic;"></name></span>, feloniously and burglariously did break and enter...</blockquote><br />and we're going to make copies that look like this:<br /><blockquote>1 john holgate and james holgate were indicted for that they on the 1st of october at st mary magdalen bermondsey about four o clock in the night the dwelling house of john thompson feloniously and burglariously did break and enter...</blockquote><br />It may seem a bit perverse to take out information that the OB team worked very hard to create, so it is probably a good idea to step back and get a broader overview of the data mining process. When writing programs to manipulate digital sources you can head down one of two paths. You can choose to explicitly encode more and more semantic (i.e., meaningful) information. This is what the OB team has done with XML markup. By using <span style="font-style:italic;"><geo>...</geo></span> tags to indicate that "St. Mary Magdalen, Bermondsey" is a geographical location, they are able to provide a powerful search engine that can <a href="http://www.hrionline.ac.uk/ccc/forms/formMaps.jsp">find places</a>. Similarly, by indicating the age and sex of criminals and victims they make it possible for researchers to do a variety of sophisticated <a href="http://www.hrionline.ac.uk/ccc/forms/formStats.jsp">statistics</a> on the archive as a whole. The downside, of course, is that this kind of explicit tagging is very labor-intensive. It is wonderful to be able to work with a digital archive that someone else has edited and marked up, but often you face a corpus of documents that is little better than raw text, or worse, that contains a high percentage of <a href="http://en.wikipedia.org/wiki/Optical_character_recognition">OCR</a> errors.<br /><br />An alternative approach is to work with domain-neutral representations and algorithms. You write programs that can't tell the difference between a person's name and a place name, between English and French, or between natural language and a genomic sequence. This is closer to what traditional search engines like Google do. The downside is that you can search for text that includes the string "Bermondsey" but you can't tell Google to limit your search to geographic uses of the term. Instead your results include the neighborhood, the tube station, a local history group, a diving club, a biography, a hymn, some photos, and so on.<br /><br />Having access to text that has been semantically marked up makes it possible to create and test a wide range of powerful tools that can then be used on raw text that hasn't been marked up. For example, we know that <a href="http://www.oldbaileyonline.org/browse.jsp?div=t18341124-1">this particular trial</a> was for a burglary that ended with the execution of two men. Suppose we want to create a computer program which can classify trials as either "burglary" or "not a burglary." We start by creating an archive of raw text examples by stripping out the markup. We give these texts to our program, one by one, and tell it whether each text was an instance of "burglary" or not. With any luck, the program learns, somehow, to distinguish burglaries from other kinds of trial. (The details will be filled in as we go along). Now, we can test the program on other examples from this archive and get a precise sense of how well it does. If it seems to work, we can then use it to try and ferret out burglaries from other collections of untagged trial records, or even from a mass of undifferentiated search results.<br /><br />So, to create a clean copy of each of the trial files we're going to use a very brute force method. We will simply copy the file, one character at a time, skipping any characters that fall between <span style="font-style:italic;"><</span> and <span style="font-style:italic;">></span> inclusive. The Python code which does this job is <a href="http://digitalhistory.uwo.ca/dhh/hacks/ob-clean-copy-trials.py.html">here</a>.<br /><br />Tags: <a href="http://technorati.com/tag/archive" rel="tag">archive</a> | <a href="http://technorati.com/tag/data+mining" rel="tag">data mining</a> | <a href="http://technorati.com/tag/digital+history" rel="tag">digital history</a> | <a href="http://technorati.com/tag/feature+space" rel="tag">feature space</a> | <a href="http://technorati.com/tag/machine+learning" rel="tag">machine learning</a> | <a href="http://technorati.com/tag/text+mining" rel="tag">text mining</a>William J. Turkelhttp://www.blogger.com/profile/05033419379580138964noreply@blogger.com