<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Michael Toth on Medium]]></title>
        <description><![CDATA[Stories by Michael Toth on Medium]]></description>
        <link>https://medium.com/@Michael_Toth?source=rss-52a034d7bbc9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*GlIxtojjAxe5yVyWeszUmg.jpeg</url>
            <title>Stories by Michael Toth on Medium</title>
            <link>https://medium.com/@Michael_Toth?source=rss-52a034d7bbc9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 22:06:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Michael_Toth/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Build your own AI Image Generation Playground in Slack with DALL-E and Zapier]]></title>
            <link>https://medium.com/@Michael_Toth/build-your-own-ai-image-generation-playground-in-slack-with-dall-e-and-zapier-47e243ea54a4?source=rss-52a034d7bbc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/47e243ea54a4</guid>
            <category><![CDATA[midjourney]]></category>
            <category><![CDATA[dalle-2]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[stable-diffusion]]></category>
            <category><![CDATA[image-generation]]></category>
            <dc:creator><![CDATA[Michael Toth]]></dc:creator>
            <pubDate>Thu, 16 Feb 2023 17:12:37 GMT</pubDate>
            <atom:updated>2023-02-16T17:12:37.804Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve been obsessively playing with different AI tools for the past few months. Sometimes they’re pretty user-friendly, and other times, they’re…not.</p><p>While <a href="https://chat.openai.com/">ChatGPT</a> has a clean textbox interface, and GPT-3 has a similar offering in the <a href="https://platform.openai.com/playground">OpenAI Playground</a>, image generation AI options are more limited.</p><p>DALL-E, for example, offers no option to generate images in the OpenAI Playground. It’s true, there are third-party tools to help with this, but I always like to work directly with the API where possible.</p><p>So, I set out to solve that, and I built myself a personal DALL-E Playground in Slack using Zapier and the OpenAI API.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b3w8te1XGhL5HGn0oFlbUw.png" /></figure><h3><strong>Video Tutorial</strong></h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FNRomi0_Duqw%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DNRomi0_Duqw&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FNRomi0_Duqw%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/d33f92d13d3f92c8aec03582dadb2ae4/href">https://medium.com/media/d33f92d13d3f92c8aec03582dadb2ae4/href</a></iframe><h3><strong>Zapier Template</strong></h3><p>I’ve created a Zapier template for this project, which you can use to build your own Slack bot:</p><p><a href="https://zapier.com/shared/caa962be5b06cebb81f6cdcc9385a4786761ffc1">Slack DALL-E Bot</a></p><h3><strong>Project Overview</strong></h3><p>This project is a relatively simple one, and only requires three steps:</p><ol><li><strong>Trigger: </strong>Retrieve messages posted to our dedicated Slack channel</li><li><strong>Action: </strong>Send the Slack prompt to OpenAI’s DALL-E API for image generation</li><li><strong>Action: </strong>Retrieve the generated image from DALL-E and send it back to Slack</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YoDMGC6UNwTPODM8A4V09Q.png" /></figure><h4><strong>Step 1: Set up your Zapier Trigger</strong></h4><p>First, you’ll want to sign up for a <a href="https://slack.com/">Slack</a> account if you don’t already have one. You can use the free plan for this.</p><p>For the Slack trigger, select the <em>New Message Posted to Channel </em>event. Next, choose the Slack account to use for this automation, connecting your Slack account to Zapier if you haven’t already. Finally, select the channel you want to retrieve messages from, and leave <em>Trigger for Bot Messages</em> set to No.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PBlm_qKUZpAGg7yD1qHwHw.png" /></figure><p>For this demonstration, we’re assuming all messages sent to this channel should be sent to DALL-E for image generation. If you want to use this channel for other tasks as well, you could do that relatively easily:</p><ol><li>Decide on a required text preface for all image generation requests. Something like <em>/dalle</em> would be a good choice</li><li>Create a <em>filter </em>action step in Zapier following this step that filters based on your text preface:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q2HyV3tTVuhyHrKejZnEUg.png" /></figure><p><strong>Step 2: Set up your OpenAI DALL-E Image Generation</strong></p><p>First, you’ll need to sign up for the <a href="https://openai.com/api/">OpenAI API</a> and generate an API Key if you haven’t already.</p><p>You’ll want to add an OpenAI action step as the next step in Zapier. Select the <em>Generate Image</em> Event.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PRdPc7AnK18xSBeCiT9lrQ.png" /></figure><p>Next, connect to your OpenAI account by providing your API key. Finally, set up your action by passing your text prompt from Slack to OpenAI and selecting the size of the output image you’d like. Larger images will be of higher quality but are more expensive to create.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a9uu09aKrZJUYLh7U_CToQ.png" /></figure><p><strong>Step 3: Return the Generated Image to Slack</strong></p><p>Add a 3rd action step in Zapier, selecting the Slack <em>Send Channel Message</em> Event.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ZKzmj0iDIioAd7DCNOavw.png" /></figure><p>This step is the most complex, but it looks more complicated than it really is, as most of the fields aren’t required. Here’s what to change:</p><ol><li>Select the <em>Channel</em> where you want the result to be sent. This will most likely be the channel you picked above in Step 1.</li><li>You’re required to provide some <em>Message Text</em>. I chose the simple “Here’s your image:”</li><li>Provide a <em>Bot Name</em>, or stick with the default <em>“Zapier”</em></li><li>Provide an emoji for your <em>Bot Icon</em> or simply leave blank</li><li>Set <em>Include a link to this Zap</em> to <em>No</em> unless you want this on for debugging</li><li>Map the image URL sent back from DALL-E in step 2 to the <em>Attach Image by URL </em>field</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*66wxd0R30cirrWry-C2pkg.png" /></figure><p>Now that you have everything mapped, publish your zap. Head over to Slack and send a message in your AI bot channel, and wait for the result. It should come in around 15 seconds.</p><p>Now you have a working DALL-E Playground that you can use to generate AI images whenever you like! I encourage you to experiment with this and expand on this example. Perhaps include more than 1 image result, or create a similar bot using Stable Diffusion. I’d love to see what you have to share!</p><p>If you’re interested in learning more about AI and Automation, subscribe to my Medium Account and follow me on Twitter at <a href="https://twitter.com/Michael_Toth">https://twitter.com/Michael_Toth</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47e243ea54a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I built a vintage image colorizer & restorer using Zapier & Replicate AI models]]></title>
            <link>https://medium.com/@Michael_Toth/i-built-a-vintage-image-colorizer-restorer-using-zapier-replicate-ai-models-a38c1a49c774?source=rss-52a034d7bbc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/a38c1a49c774</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[zapier]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[photography]]></category>
            <dc:creator><![CDATA[Michael Toth]]></dc:creator>
            <pubDate>Fri, 27 Jan 2023 20:17:46 GMT</pubDate>
            <atom:updated>2023-01-27T20:17:46.759Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’re anything like me, you’ve been playing with chatGPT pretty obsessively for the last few months. I wanted to expand on that, so recently, I’ve been diving more into other AI tools and finding out ways to combine them using Zapier to build interesting and useful projects.</p><p><a href="https://tally.so/r/mYj7YB">NostalgAI</a> is a tool to colorize, restore, and upscale any vintage photo. Give it a try! I built this using Tally Forms, Zapier, and the <a href="https://replicate.com/arielreplicate/deoldify_image">deoldify_image</a> and <a href="https://replicate.com/tencentarc/gfpgan/api">gfpgan</a> models on Replicate. The deoldify_image model colorizes old photos, and the gfpgan model performs facial correction &amp; upscaling. With this setup, you can restore old photos like this one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*XmwhjujbYb5Oh-ZgNL97hg.gif" /></figure><h3>Video Tutorial</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FyrZzA8qtqqc%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DyrZzA8qtqqc&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FyrZzA8qtqqc%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/16f6ffa458f1c9ece05e10d9ad1def9f/href">https://medium.com/media/16f6ffa458f1c9ece05e10d9ad1def9f/href</a></iframe><h3><strong>Zapier Templates</strong></h3><p>I’ve created Zapier templates for the entire process, which is broken out into 3 separate zaps:</p><ul><li><a href="https://zapier.com/shared/737a09eb4c88e394bff8d43b9b72645c6d51c8f0">Restore &amp; Colorize Photos with AI using Replicate - Step 1</a></li><li><a href="https://zapier.com/shared/92dd3b6e8f1926fa28f01572e250b9733f7e410e">Restore &amp; Colorize Photos with AI using Replicate - Step 2</a></li><li><a href="https://zapier.com/shared/99f182fbb53bfe552ddc8aa58a3d22009fdc57d0">Restore &amp; Colorize Photos with AI using Replicate - Step 3</a></li></ul><h3>Project Overview</h3><p>I’ve created a video walking through how to set up this system. Here’s a helpful flow chart that walks through the process and what happens in each Zapier step:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uncd9qrZFuv3U8_luwYXxw.png" /></figure><p>Why do we need 3 separate zaps? These AI tools generally take a while to actually generate the image. It could be looking at anywhere from 10 seconds up to a few minutes. We could use Zapier’s “delay” to wait for a period of time, but there’s no guarantee the image will be generated once the delay is over.</p><p>Instead, we will create separate zaps that receive webhook responses from Replicate once each image is generated. That way, we can proceed with the next step of our automation the second our prior step image is complete. I promise it’s not as complicated as it sounds!</p><h3><strong>Step 1: Set up Form Input</strong></h3><p>The first thing we need to do is set up our form. I used Tally Forms for this. You can use whatever you like, as Zapier has integrations with essentially every form builder. You’ll want to add 2 fields: one for the image upload and one for the user email address. Your form should look something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*idMCiGROwnuJBOx4GmdNqg.png" /></figure><h3>Step 2: Replicate Setup</h3><p>At this point, you’ll want to go to <a href="http://replicate.com/">replicate.com</a> to sign up for an account. You’ll need an account and an API key to send requests to Replicate. You can also read more about the <a href="https://replicate.com/arielreplicate/deoldify_image">deoldify_image</a> and <a href="https://replicate.com/tencentarc/gfpgan">gpfgan</a> models we’ll be using, if you’d like.</p><h3>Step 3: Zapier Setup</h3><p>For our Zapier setup, we’ll be working in reverse-chronolical order to set up our zaps. That means we’ll start with the 3rd zap in the workflow, followed by the 2nd, followed by the 1st. This will be easiest because in each step we’ll need the Webhooks link from the next step when we send our request to the Replicate API.</p><p><strong>Zap 3:</strong></p><p><a href="https://zapier.com/shared/99f182fbb53bfe552ddc8aa58a3d22009fdc57d0">Zap 3</a> is the one that will receive the results from the final Replicate gpfgan model and then send the email to the user. Our trigger event is the Webhook Catch Hook Event:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-nL4yAftTyU3IHi54cHx7A.png" /></figure><p>When you set this up, Zapier will generate a link that you’ll use in your Replicate API call in Zap 2 later. Copy this link down.</p><p>The Action step is Gmail’s Send Email action. Note that you won’t have the data you need yet to map everything properly (the query string email and output image link), so leave placeholders for now and come back once you’ve set up your other zaps. You can view my setup here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*esm7iGGZa7nldb2bKw9h8Q.png" /></figure><p><strong>Zap 2:</strong></p><p><a href="https://zapier.com/shared/92dd3b6e8f1926fa28f01572e250b9733f7e410e">Zap 2</a> will receive the results from the Replicate deoldify_image model and then pass this result to the Replicate gpfgan model. Like Zap 3, our trigger event is the Webhook Catch Hook Event:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*-nL4yAftTyU3IHi54cHx7A.png" /></figure><p>As before, Zapier will generate a link that you’ll use in your Replicate API call in Zap 1 later. Copy this link down and note this is your Zap 2 link.</p><p>The Action step is The Webhooks Custom Request action. Note that you won’t have the data you need yet to map everything properly (the query string email and output image link), so leave placeholders for now and come back once you’ve set up your other zaps. You can view my setup here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A1txHw5l6dFFEcVLTXggLw.png" /></figure><p>Below you can find the JSON code you’ll need for the “Data” section of the Webhook request. Replace the Webhook link with your link from Zap 3. You’ll come back later to add in the email and output image fields from Zap 1.</p><pre>{&quot;version&quot;: &quot;9283608cc6b7be6b65a8e44983db012355fde4132009bf99d976b2f0896856a3&quot;,<br>&quot;webhook_completed&quot;: &quot;&lt;YOUR ZAP 3 WEBHOOK LINK&gt;?email=&lt;YOUR ZAP 1 QUERYSTRING EMAIL&gt;&quot;,<br>&quot;input&quot;: {<br>&quot;img&quot;: &quot;&lt;ZAP 1 OUTPUT IMAGE&gt;&quot;<br>}}</pre><p>Note that you’ll also have to add your own Replicate API key in the Headers section. Match the formatting to mine above. There’s a space between Token and the API key.</p><p><strong>Zap 1</strong></p><p><a href="https://zapier.com/shared/737a09eb4c88e394bff8d43b9b72645c6d51c8f0">Zap 1</a> will receive the form response from Tally Forms submission and then pass this to the Replicate deoldify_image model. Our trigger event is the New Response in Tally Event:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WAY_D_w4xrowFjMxt6Z-qg.png" /></figure><p>As with Zap 2, the Action step is The Webhooks Custom Request action. You can view my setup here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PzkFawZhqxrXBJxCCg-Y0A.png" /></figure><p>Below you can find the JSON code you’ll need for the “Data” section of the Webhook request. Replace the Webhook link with your link from Zap 2.</p><pre>{&quot;version&quot;: &quot;376c74a2c9eb442a2ff9391b84dc5b949cd4e80b4dc0565115be0a19b7df0ae6&quot;,<br>&quot;webhook_completed&quot;: &quot;&lt;YOUR ZAP 2 WEBHOOK LINK&gt;?email=&lt;YOUR TALLY FORMS EMAIL&gt;&quot;,<br>&quot;input&quot;: {<br>&quot;input_image&quot;: &quot;&lt;YOUR TALLY FORMS IMAGE&gt;&quot;,<br>&quot;model_name&quot;: &quot;Artistic&quot;<br>}}</pre><p>Note that now you <em>will</em> have all of the information you need to fill in the placeholders here, as they’ll all come from the Tally Forms submission.</p><p>Now is a good time to discuss what’s going on with the <em>?email=&lt;YOUR TALLY FORMS EMAIL&gt;</em> at the end of the Webhook link. This is what’s called a Query String, and it allows us to encode some information at the end of a URL, in this case the Webhook URL. When we give Replicate this Webhook URL with the Email Query String, two things will happen. First, it will return the completed image to this URL, so we’ll be able to pick up the image in Zap 2. Second, it will also send this Email Query String back to us, so that in Zap 2 we can keep track of which user to email this result to. Without this, we wouldn’t know who to send this to once we reach Zap 3!</p><p><strong>Zap Cleanup</strong></p><p>Now that we have our entire zap structure set up, you’ll want to go through each of your zaps and clean up the placeholders we left before. Starting with Zap 1 (which should have everything already specified) you should test each step within your Zap by clicking the Test Action button.</p><p>Once you’ve tested Zap 1, head over to Replicate to monitor your result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o2F2--r3xfwF0AWJRrrruQ.png" /></figure><p>Once you see a status of Succeeded for your test, move on to Zap 2. Test your Webhooks trigger in Zap 2, which should now receive the result from your initial Replicate deoldify_image run.</p><p>In your Zap 2 Webhooks action step, you’ll now want to map the Query String email and image result that were returned from your Replicate Webhooks trigger. Once you’ve mapped these, test your Zap 2 action.</p><p>Again, head back to Replicate to monitor the result. Once you see a status of Succeeded for this second run, move on to Zap 3. Test your Webhooks trigger in Zap 3, which should now receive the result from your second Replicate gfpgan run.</p><p>In your Zap 2 Gmail action step, you’ll now want to map the Query String email and image result that were returned from your Replicate Webhooks trigger. Finally, test this result and head over to your email to receive the response.</p><p>If you receive the email, your process is working correctly! Now go to each of your zaps and Publish them to turn them on. You should now be able to go back to your form and Submit an image, and the entire process will run automatically. You will receive an email with your complete image in a few minutes!</p><p>In this tutorial, I’ve shown you how to can use Zapier and AI models on Replicate to build a simple image colorization &amp; restoration tool. Now, I encourage you to experiment with this! Feel free to edit and expand upon this example to see what you can build. I’d love to see what you have to share!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a38c1a49c774" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Detailed Investigation of State-Level Loan Pricing]]></title>
            <link>https://medium.com/@Michael_Toth/a-detailed-investigation-of-state-level-loan-pricing-7a003a2c25e9?source=rss-52a034d7bbc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a003a2c25e9</guid>
            <category><![CDATA[lending]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[rstats]]></category>
            <category><![CDATA[finance]]></category>
            <dc:creator><![CDATA[Michael Toth]]></dc:creator>
            <pubDate>Mon, 16 Sep 2019 12:10:13 GMT</pubDate>
            <atom:updated>2019-09-16T12:10:13.598Z</atom:updated>
            <content:encoded><![CDATA[<p><em>This article was originally published by Orchard Platform, a leading analytics provider for the online lending industry.</em></p><p>Loan pricing–the setting of interest rates for individual loans–varies significantly based on geography in the consumer lending space. In particular, there are large differences among states, both in current interest rates and in the changes of interest rates over time. As of Q2 2017, state-level average interest rates range from a low of 13.30% in Vermont to a high of 17.34% in Iowa. Historically, the variance among states was even larger–in Q1 2011 average rates in Alaska were 12.59% while average rates in Nebraska were 22.61%.</p><p>In this post we’re going to explore the impact that geography has on interest rates, analyzing the distribution of current interest rates across states, state-level deviations from national averages, and changes in state-level interest rates over time. This post will primarily act as an exploratory analysis, presenting different ways to think about and visualize interest rate levels and changes in interest rates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*yyZ5M7KIsDVtaWovx5Op8A.png" /></figure><p>Above, we’ve created a table showing average Q1 interest rates by state for the consumer lending universe in every year since 2010. Lower interest rates are colored red, while higher interest rates are colored blue. This presentation helps us to easily identify aggregate changes in rates over the last seven years: the bright red left column gives way to the pale blue right column, showing a steady rise in interest rates over this period. We can also use this table to easily see changes in interest rates at the state level over this same period. For example, we can quickly see that interest rates in California have steadily increased from 13.2% to 15.2% while rates in Indiana fell from 19.0% to 15.7%. If we’re interested in seeing how rates vary among different states within a given quarter, however, this table is not the best presentation. While it’s true that we can easily see outliers–for example Vermont, New York, and Connecticut all clearly show low rates in Q1 2017–it’s harder to see additional differences. Instead, we find it helpful to use a table like the one below, where we’ve shown the deviation in interest rates from the average U.S. rate in Q1 for each year from 2010:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*S4BM-u011dsHMsjgFNd7Zw.png" /></figure><p>In this table we first present average United States interest rates in each quarter, then we show each state’s deviation from this average. Negative values correspond to lower interest rates than the national average and are colored red, while positive values show higher interest rates than the national average, and are colored green. We can now more easily identify those states with below-average interest rates or above-average interest rates. In Q1 2017, some of the below-average states include New York, Vermont, Connecticut, and Maine, while some above-average states include Iowa, Florida, Alabama, Arkansas, and Tennessee. With some reflection, we can identify some of the below-average rate states as those in the Northeast and some of the above-average rate states as those in the South, but this table does not lend itself to this type of regional analysis. For this, let’s instead turn to an animated heat map, which displays these deviations over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*f1iUTNl6wLa1puCEiZlukA.gif" /></figure><p>This heat map is useful because it helps us to see the geographical trends mentioned above much more clearly. For example, as the animation progresses we can identify a band through the southeast and the rust belt where interest rates are slightly higher than the national average. We see the opposite effect in the northeast, with states stretching from Delaware through Maine all showing below-average interest rates. This map also helps us show that over time interest rates have become more consistent across states, which is represented by the fact that the colors become less vibrant (indicating smaller deviations from zero) over time.</p><p>While this graph makes it easy to identify geographical trends like the higher rates in the southeast or the lower rates in the northeast, it doesn’t show clearly how rates within states have changed over time. For this, we can use a geographically faceted graph of historical interest rates:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*Jq_JXlDoLW8GcETJ5qe5oA.png" /></figure><p>This helps us to see a few things. First, we can identify states like Idaho, Nebraska, and Mississippi who have experienced the highest amount of variance in interest rates historically. We can also use this graph to visualize interest rate trends within particular states. For example, while most states have seen slight increases in interest rates over the last seven years, we can identify exceptions like Indiana, which showed a large drop in 2013, and Maine, which has fallen in recent months.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*LkhDPAl3kDd0pv-iVWfsJw.png" /></figure><p>In the graph above we plot 2016 interest rates on the y-axis and the Q2 2016-Q2 2017 interest rate change on the y-axis. The slightly negative trend line shows that interest rates have experienced some reversion to the mean, with higher interest rate states tending to show larger reductions in interest rates while lower interest rate states have shown either small reductions or increases in interest rates over the prior year. This reversion to the mean effect corroborates our earlier finding above that interest rate differences across states have tended to reduce over time.</p><p>We know that there are differences in population characteristics across different regions–average incomes, credit scores, and education levels all vary geographically. Given these differences, we should expect that borrower state should play a role in aggregate loan-level pricing. There are many different ways to think about and visualize interest rate levels and changes, and they all help us to get a greater understanding of trends in pricing across the industry. While these discrepancies have fallen over the last several years, we believe that borrower state will continue to be a powerful predictor over the coming years, and we look forward to further explorations of the impact this factor has on loan pricing and borrower performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a003a2c25e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sentiment Analysis of Warren Buffett’s Letters to Shareholders]]></title>
            <link>https://medium.com/@Michael_Toth/sentiment-analysis-of-warren-buffetts-letters-to-shareholders-684d7ae8f6a4?source=rss-52a034d7bbc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/684d7ae8f6a4</guid>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[r]]></category>
            <category><![CDATA[warren-buffett]]></category>
            <category><![CDATA[sentiment-analysis]]></category>
            <category><![CDATA[finance]]></category>
            <dc:creator><![CDATA[Michael Toth]]></dc:creator>
            <pubDate>Mon, 20 Mar 2017 04:00:00 GMT</pubDate>
            <atom:updated>2018-08-07T22:05:15.112Z</atom:updated>
            <content:encoded><![CDATA[<p>Posted on Mon 20 March 2017 in <a href="http://michaeltoth.me/sentiment-analysis-of-warren-buffetts-letters-to-shareholders.html">Michael Toth’s Blog</a></p><p>Last week, I was reading through Warren Buffett’s most recent letter to Berkshire Hathaway shareholders. Every year, he writes a letter that he makes <a href="http://www.berkshirehathaway.com/letters/letters.html">publicly available</a> on the Berkshire Hathaway website. In the letters he talks about the performance of Berkshire Hathaway and their portfolio of businesses and investments. But he also talks about his views on business, the market, and investing more generally, and it’s after this wisdom that many investors, including me, read what he has to say.</p><p>In many ways Warren Buffett’s letters are atypical. When most companies report their financial performance, they fill their reports with dense, technical language designed to obscure and confuse. Mr. Buffett does not follow this approach. His letters are written in easily understandable language, beacuse he wants them to be accessible to everybody. Warren Buffett is not often swayed by what others are doing. He goes his own way, and that has been a source of incredible strength. In annually compounded returns, Berkshire stock has gained 20.8% since 1965, while the S&amp;P 500 as a whole has gained only 9.7% over the same period. To highlight how truly astounding this performance is, one dollar invested in the S&amp;P in 1965 would have grown to $112.34 by the end of 2016, while the same dollar invested in Berkshire stock would have grown to the massive sum of $15,325.46!</p><p>I’ve been reading the annual Berkshire letters when they come out for the last few years. One day I’ll sit down and read through all of them, but I haven’t gotten around to it yet. But while I was reading through his most recent letter last week, I got to thinking. I wondered whether there are any trends in his letters over time, or how strongly his writings are influenced by external market factors. I decided I could probably answer some of these questions through a high-level analysis of the text in his letters, which brings me to the subject of this blog post.</p><p>In this post I’m going to be performing a sentiment analysis of the text of Warren Buffett’s letters to shareholders from 1977–2016. A <a href="https://en.wikipedia.org/wiki/Sentiment_analysis">sentiment analysis</a> is a method of identifying and quantifying the overall sentiment of a particular set of text. Sentiment analysis has many use cases, bu a common one is to determine how positive or negative a particular text document is, which is what I’ll be doing here. For this, I’ll be using <a href="https://www.cs.uic.edu/~liub/FBS/sentiment-analysis.html">bing sentiment analysis</a>, developed by <a href="https://www.cs.uic.edu/~liub/">Bing Liu</a> of the University of Illinois at Chicago. For this type of sentiment analysis, you first split a text document into a set of distinct words, and then for each word determining whether it is positive, negative, or neutral.</p><p>In the graph below, I show something called the ‘Net Sentiment Ratio’ for each of Warren Buffett’s letters, beginning in 1977 and ending with 2016. The net sentiment ratio tells how positive or negative a particular text is. I’m definining the net sentiment ratio as:</p><p>(Number of Positive Words — Number of Negative Words) / (Number of Total Words)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ktP6TFmTRrcj5rPp.png" /></figure><p>The results here show that overall, Warren Buffett’s letters have been positive. Over the forty years of letters I’m analyzing here, only 5 show a negative net sentiment score. The five years that do show negative net sentiment scores are closely tied with major negative economic events:</p><ul><li><strong>1987</strong>: The market crash that happened on October 19th, 1987 (Black Monday) is widely known as the largest single-day percentage decline ever experienced for the Dow-Jones Industrial Average, 22.61% in one day.</li><li><strong>1990</strong>: The recession of 1990, triggered by an oil price shock following the United States’ invasion of Kuwait, resulted in a notable increase in unemployment.</li><li><strong>2001</strong>: Following the 1990s, which represented the longest period of growth in American history, 2001 saw the collapse of the dot-com bubble and associated declining market values, as well as the September 11th attacks.</li><li><strong>2002</strong>: The market, already falling in 2001, continued to see declines throughout much of 2002.</li><li><strong>2008</strong>: The Great Recession was a large worldwide economic recession, characterized by the International Monetary Fund as the worst global recession since before World War II. Other related events during this period included the financial crisis of 2007–2008 and the subprime mortgage crisis of 2007–2009.</li></ul><p>Another interesting topic to examine is which words were actually the strongest contributors to the positive and negative sentiment in the letters. For this exercise, I analyzed the letters as one single text, and present the most common positive and negative words in the graph below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*A70kxlYx0fWECvJH.png" /></figure><p>The results here are interesting. Many of the most common words — ‘gain’, ‘gains’, ‘loss’, ‘losses’, ‘worth’, ‘liability’, and ‘debt’ — are what we’d expect given the financial nature of these documents. I find the adjectives that make their way into this set particularly interesting, as they give insight into the way Warren Buffett thinks. On the positive side we have ‘significant’, ‘outstanding’, ‘excellent’, ‘extraordinary’, and ‘competitive’. On the negative side there are ‘negative’, ‘unusual’, ‘difficult’, and ‘bad’. One interesting inclusion that shows some of the limitations of sentiment analysis is ‘casualty’, where Mr. Buffett is not referring to death, but to the basket of property and casualty insurance companies that make up a significant portion of his business holdings.</p><p>While the above is interesting, and helps us to highlight the most frequent positive and negative words, it’s a bit limited in the number of words we can present before the graph becomes too crowded. To see a larger number of words, we can use a word cloud. The word cloud below shows 400 of the most commonly used words, split by positive and negative sentiment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*I3pn0R6qBmoKF5yb.png" /></figure><p>If you’re interested in reproducing this blog post or analysis, please check out the <a href="https://github.com/michaeltoth/michaeltoth/blob/master/content/_R/berkshire_hathaway_sentiment.Rmd">R code I used to produce this document</a></p><p><em>Originally published at </em><a href="http://michaeltoth.me/sentiment-analysis-of-warren-buffetts-letters-to-shareholders.html"><em>michaeltoth.me</em></a><em> on March 20, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=684d7ae8f6a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>