<?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 Kevin McDonough on Medium]]></title>
        <description><![CDATA[Stories by Kevin McDonough on Medium]]></description>
        <link>https://medium.com/@kpmcdonough?source=rss-bc4713d1a520------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*9QfayUscdzCUwCqx</url>
            <title>Stories by Kevin McDonough on Medium</title>
            <link>https://medium.com/@kpmcdonough?source=rss-bc4713d1a520------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 05:20:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kpmcdonough/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[The Meteoric Demise of the WFT Defense]]></title>
            <link>https://medium.com/down-in-the-ds/the-meteoric-demise-of-the-wft-defense-f7e73462da3?source=rss-bc4713d1a520------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7e73462da3</guid>
            <dc:creator><![CDATA[Kevin McDonough]]></dc:creator>
            <pubDate>Mon, 04 Oct 2021 17:52:58 GMT</pubDate>
            <atom:updated>2021-10-11T16:33:37.302Z</atom:updated>
            <content:encoded><![CDATA[<p>Coming into this year, the Washington Football Team defense was poised for a monster season. Ranked 3rd in Football Outsider’s DVOA (Defense-adjusted Value Over Average) last year, the Football Team’s defensive unit gave up the third-fewest points-per-drive and yards-per-drive in the league. As a WFT fan, despite the general pessimism towards the franchise that I have developed over the years, it was difficult for me to imagine a scenario in which this unit wouldn’t continue to dominate in 2021.</p><p>The defensive line, comprised of four first-round picks, including last year’s NFL Defensive Rookie of the year Chase Young, is arguably the most talented in football. Matt Ioannidis, a solid rotational player, missed all of last year with an injury and his return would bolster the group and provide valuable depth. The linebacking core was the weakest position group on the defense in 2020, but WFT drafted Jamin Davis from Kentucky in the first round to address this need. In the secondary, Washington lost a good corner in Ronald Darby but signed William Jackson III, who is potentially an upgrade. Lastly, with a full offseason under second-year defensive coordinator Jack Del Rio, the players would get more comfortable in his system.</p><p>I, like many pundits, bought into this narrative. I praised these shrewd offseason moves, and found myself brimming with excitement and confidence in this defense. Reports out of training camp suggested that the young guys were continuing to develop and that this group was hungry — during an interview, Montez Sweat <a href="https://profootballtalk.nbcsports.com/2021/08/10/montez-sweat-chase-young-and-i-want-combined-single-season-sack-record/">stated</a> that he and Chase Young were targeting the combined single-season sack record. Unfortunately, the defense as a whole appears to be closer to a more regrettable record: the largest single-year defensive decline in the modern NFL.</p><p>Through four games, the Washington defense has been brutal to watch. It is getting gouged by opposing offenses from the opening play (this week was the first week they didn’t allow a touchdown on the first possession: they only gave up a field goal) to the final whistle. The unit currently ranks 28th in DVOA, 31st in points-per-drive and 30th in yards-per-drive. Although its still early, it’s mind-boggling how much worse this defense is playing compared to last year, especially considering there were no big personnel changes or injuries.</p><p>In order to see just how unprecedented this decline has been, I gathered league-wide defensive data from Football Outsiders from 2000–2021 and compared each team’s defensive ranking to the prior year. I decided to use points-per-play, points-per-drive as the main statistics I would look at, as well as “DSR” (Drive Success Rate) which “measures the percentage of down series that result in a first down or touchdown.”</p><p>I created the chart below to show the NFL ranking for points-per-drive among defenses that improved from last year to this year. The circles represent the 2020 rank while the logos represent the current rank. From left to right the chart is ordered by largest increase in rankings. The Panther’s defense improved most dramatically, moving from 26th in the rankings to 3rd.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*MHEQeJJvld5u5h6XTjT4OQ.png" /></figure><p>Next, we’ll look at defenses that have declined. The chart below shows the change in rankings for defenses that are worse than they were last year, with logos representing 2021 and circles representing 2020. As you can see, WFT has the greatest differential (31 versus 3) followed by the Rams (23 versus 1).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*lvP0W94preGsMbhZ80ksyQ.png" /></figure><p>That’s pretty ugly, but just how bad is that in a historical context? I next looked at the year-over-year DSR rank change for each team from 2000 to 2021. The table below shows the largest single-year declines in DSR rank. The values are negative because it is taking the prior year rank and subtracting the current rank; in Washington’s case this would be 3 - 28 =-25. Washington is tied for 7th on this list with the 2001 Buffalo Bills. I want to quickly reiterate that this list is not the 10 worst defenses of all time, but rather the ten units that had the biggest change in DSR rankings from the prior year.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*WFfxyM2_Rg7X3LMGL4b8Cg.png" /></figure><p>It is interesting that this year’s Rams are on this list. In general, these three rankings seem to be highly correlated; however, the Rams’ drop in points-per-drive ranking is smaller than the other two categories. Perhaps this is due to a stout red zone defense or timely turnovers.</p><p>7th all time is pretty tough, but right now we are just looking at the rankings, not the stats themselves. Perhaps Washington’s defense is better than this group on a point-per-drive and yards-per-drive basis. With the 10 teams listed above, I created the below chart to look at yards-per-drive and points-per-drive from the year in which the defense declined (logos) as well as the previous year (circles).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vN44J3ykqG14Ou-Ns1qPWw.png" /></figure><p>As you can see, this year’s Washington defense gives up more yards per drive and more points per drive than any other team on this chart. Additionally the line connecting the current year with the previous year is much longer for WFT, indicating a more precipitous decline.</p><p>One area in which this defense is starkly underperforming is on third down. Thus far, WFT is allowing the opposition to convert on a whopping 60% of all third down opportunities. Since 2000, only one team has allowed opponents to convert more than 50% on third down; last year’s Titans (52%). In general, the correlation between points-per-drive and third down percentage is high(~.6) indicating that teams that have success on this down are able to limit opposing offense. The chart below compares points-per-drive and 3rd down percentage for teams in 2021. Although there are a few outliers (the Chiefs and Lions) there is a general positive linear trend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*DReHXnWdYsRnbnsWwknf4w.png" /></figure><p>Despite the somewhat grim picture this analysis has painted, it’s still early in the season and I don’t believe the current level of futility for a group this talented is sustainable (at least I hope not). That being said, Washington has to play New Orleans, GB, TB and KC in their next four contests so things might get worse before they get better. I think with a few tweaks (Ron, if you’re reading this please take Landon Collins out of the lineup) and maybe a third down stop or two this group could get back on track. On the bright side, despite the shambolic performance of the defense, WFT is 2–2 and 2–0 in the NFC.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7e73462da3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/down-in-the-ds/the-meteoric-demise-of-the-wft-defense-f7e73462da3">The Meteoric Demise of the WFT Defense</a> was originally published in <a href="https://medium.com/down-in-the-ds">Down in the (Crisp-)DMs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Soccer Formation Classification]]></title>
            <link>https://medium.com/down-in-the-ds/soccer-formation-classification-cb7f410873df?source=rss-bc4713d1a520------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb7f410873df</guid>
            <dc:creator><![CDATA[Kevin McDonough]]></dc:creator>
            <pubDate>Sat, 10 Jul 2021 23:53:45 GMT</pubDate>
            <atom:updated>2021-07-12T13:54:39.032Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xyq9LT0a_oIdyQ-FHU8-Nw.jpeg" /></figure><p>Hello readers! I’m currently writing this on the eve of a fantastic weekend of international soccer-watching. On Saturday we will be treated to Brazil versus Argentina for the Copa America title, and on Sunday England and Italy will face off against each other in the finals of a wild Euro 2020 tournament that has been incredible to watch. Additionally, the Gold cup is now underway with Mexico opening versus Trinidad on Saturday and the USMNT taking on Haiti on Sunday.</p><p>In the spirit of this, for this post I will explore a very cool 2019 research paper written by Laurie Shaw and Mark Glickman from the Department of Statistics at Harvard University entitled “Dynamic analysis of team strategy in professional football.” The link for this paper can be found <a href="https://static.capabiliaserver.com/frontend/clients/barca/wp_prod/wp-content/uploads/2020/01/56ce723e-barca-conference-paper-laurie-shaw.pdf">here</a>. In this paper, Laurie and Mark utilized player tracking data taken from 180 matches from a single season of an elite professional league to identify unique offensive and defensive formations and create a model to determine which of these formations a team was in at a given time.</p><h3>Methods</h3><p>For formation classification, the researchers began by aggregating together consecutive possessions of the ball for each team into two-minute non-contiguous time “observations” (excluding possessions &lt;5 seconds because they deemed that not enough time to get in a formation). With this approach, they found that, on average, each team has ~10 defensive and offensive observations per game. Using these observations, the researchers calculated the distance between each player and his teammates throughout the match, averaging the vectors between each pair of players over a time observation in order to get a sense of relative positioning. The final spatial distribution of the outfield players was determined by setting the centroid of the formation to be the position of the player in the densest part of the team (determined by the average distance to the third-nearest neighbor) and then mapping the position of each player using the relative distances. The image below shows the full set of formation observations for one team throughout a match (the arrow indicates the direction the team is attacking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*UNIf_59asuXiA-sprWHEOw.png" /></figure><h3>Results</h3><p>The researchers split their data set into a training test of 100 matches and a test set containing 80 matches and, utilizing agglomerative hierarchical clustering on the training set, the researches grouped together similar observations in order to determine unique formations. Wasserstein distance was used to measure similarity of formation observations. After running the algorithm, researchers identified 20 unique formation clusters. The image below shows these clusters (ellipses indicate a 68% confidence interval for the position of each player and teams are orientated to shoot from right to left).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wMxmoe1JeMRYfljkX6Xa0g.png" /></figure><p>With these formations identified, the researchers then used a Bayesian model selection algorithm to estimate the probability that a newly observed formation belongs to each of the 20 formation clusters shown above.</p><h3>Implications</h3><p>The analysis done by these researchers has many exciting applications. For one, using this approach, they were able to identify ways in which teams transition from defense to offense. The image below shows two common pairings that they found between defensive and offensive formations. In the red example, the researchers found that teams that use cluster 9 when defending (a 4–3–3), would generally transition into cluster 10 or 18 when attacking. These two clusters are tactically different in that, in cluster 10, the outside forwards have pushed wide and the fullbacks have advanced, whereas in cluster 18 the front three remain narrow with the full-backs advancing further up the field to provide width.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LRKSH4ZolDJM4-um0_2CbA.png" /></figure><p>Oftentimes, formations are thought of as static when, in reality, they are fluid and can change throughout the match as teams employ different tactics to break down their opponent. The approach used by these researchers recognizes this nuance and enables one to identify the ways in which formations change as the match progresses. The image below is a match summary created by the researchers between two teams labelled the <em>Red team </em>and the <em>Blue team </em>that depicts a shift in formation. The circles represent offensive possessions, diamonds indicate defensive possessions, the x-axis denotes minutes throughout the match and the y-axis labels correspond to the cluster numbers from the image above containing the 20 unique clusters. In the chart, you can see that at halftime the red team made a substitution that was accompanied by offensive and defensive formation changes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lHWyLtZjt5uxsoDXcOi1eA.png" /></figure><p>There are many other interesting applications from this study. The researchers noted that you could use this methodology to study how an opposing manager habitually responds to match specific situations so that one could, “anticipate, and therefore exploit, opposition tactical changes.” An application of this study that I find interesting would be to couple this with statistics such as expected goals or passing stats to evaluate how teams perform in different formations. At a more granular level, you could evaluate how a particular player performs when in different roles. For example, a certain striker might be more effective when paired with another striker or a fullback performs better when allowed to roam freely up the pitch.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb7f410873df" width="1" height="1" alt=""><hr><p><a href="https://medium.com/down-in-the-ds/soccer-formation-classification-cb7f410873df">Soccer Formation Classification</a> was originally published in <a href="https://medium.com/down-in-the-ds">Down in the (Crisp-)DMs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dash Interactive Dashboard Tutorial]]></title>
            <link>https://medium.com/down-in-the-ds/dash-interactive-dashboard-tutorial-3986e3356f11?source=rss-bc4713d1a520------2</link>
            <guid isPermaLink="false">https://medium.com/p/3986e3356f11</guid>
            <dc:creator><![CDATA[Kevin McDonough]]></dc:creator>
            <pubDate>Mon, 21 Jun 2021 06:11:57 GMT</pubDate>
            <atom:updated>2021-08-11T21:43:35.902Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello readers, today I will be walking through a quick tutorial on Dash — a python framework for building web analytic applications. Dash allows users to create customized dashboards that react to inputs such as drop-downs and hover data. Written on top of Flask, Plotly.js and React.js, Dash is made up of three component libraries: dash_html_components (lets you access HTML tags), dash_core_components (allows you to create interactive components like graphs, dropdowns, or date ranges), and dash (helps initialize the application). Though these component libraries, users who are unfamiliar with HTML, CSS and JavaScript are able to build dashboards using pure python. Dash apps are rendered in the web browser and users can deploy apps to servers and then share them through URLs. The syntax can be a bit tricky to get a handle on, and there aren’t too many resources out there for dash, so I will attempt to give an explanation and walkthrough catered to users such as myself who are fairly new to coding. Here are some resources that I found to help get me started:</p><p>Dash plotly user guide: <a href="https://dash.plotly.com/">https://dash.plotly.com/</a></p><p>Great Youtube channel with helpful tutorials : <a href="https://www.youtube.com/channel/UCqBFsuAz41sqWcFjZkqmJqQ">https://www.youtube.com/watch?v=hSPmj7mK6ng</a></p><h3>Installation and Imports</h3><p>I’d recommend first <a href="https://docs.conda.io/projects/conda/en/4.6.1/user-guide/tasks/manage-environments.html">creating a Conda environment for Dash</a> so that it doesn’t mess with the dependencies in your current environments. Once the environment is created, you can then install Dash as well as Pandas, which is required for plotly express. Once these two have been installed, you can import the necessary libraries with the following code:</p><p>In order to install Dash, simply run the following code in the terminal after you have activated your dash environment</p><pre>pip install dash</pre><p>Once these two have been installed, you can import the necessary libraries with the following code:</p><pre>import dash<br>import dash_core_components as dcc<br>import dash_html_components as html<br>from dash.dependencies import Input, Output</pre><pre>import json<br>import pandas as pd<br>import plotly.express as px </pre><p>For this tutorial I will be creating a dashboard using data from a Kaggle dataset containing UFO sightings. The dataset can be found here: <a href="https://www.kaggle.com/NUFORC/ufo-sightings">https://www.kaggle.com/NUFORC/ufo-sightings</a>. I did some initial data cleaning beforehand, such as bucketing by decade, limiting entries to the U.S., and dropping NAs.</p><p>Here is a quick sneak peak at what the finished dashboard will look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*QnZzr3oJBpXW3nujjg4rbg.gif" /></figure><h3>Getting Started</h3><p>In order to create a dashboard, you need to use the following code to initialize define and run the app:</p><pre>app = dash.Dash(__name__) # Initialize the app </pre><pre># ------------------------------------------------------------------</pre><pre>app.layout = html.Div() # Define the app </pre><pre># ------------------------------------------------------------------</pre><pre>if __name__ == &#39;__main__&#39;:<br>    app.run_server(debug=True) # Run the app </pre><p>Dash includes “hot-reloading”, this features is activated by default when you run your app with app.run_server(debug=True). This means that Dash will automatically refresh your browser when you make a change in your code.</p><h3>App Layout</h3><p>The layout of the app will occur within the html.Div() portion. The layout is composed of a tree of &quot;components&quot; like html.Div and dcc.Graph. Using these, you can add headers, charts maps and drop downs, and customize the style and formatting of these components. If you would like to set different colors for the background of your app or color of the text, you can create a dictionary containing the desired hexadecimal colors prior to initializing the app. For example, the first couple lines of code for the UFO app above look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PSdVUJ0gevwm9ghO6Wy7dA.png" /></figure><p>In the example above, the html.Div() piece creates the initial background upon which we will add charts and text. It then pulls in the background color we set above. The html.H1 line creates a header and is styled so that the text appears in the center and is colored using our color dictionary. Notice that the html.H1 is nested within the initial html.Div() — it is important to keep track brackets and parentheses when working in the layout to ensure that there are no errors and that headers and graphs appear in the correct place on the page.</p><p>While the html components allow us to style the app layout, the dcc components enable us to create interactive charts and maps that pull from our pandas DataFrame. Two examples of these dcc components which will explore are dcc.Dropdown and dcc.Graph. Going back to our UFO example, here is the initial code to create a dropdown:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*asSoIaq_tnLuh2Bu8tbDBQ.png" /></figure><p>Under our initial html.Div(), I created a new html.Div() that will house our dropdown and container. With every dcc component, an id needs to be specified which will be used later with our callback to create interactivity. The “options” piece of the code creates the list of different dropdown options we would like to create — “label” specifies what will show up in the dropdown while “value” is what we will use to slice our DataFrame. It is important to set the “value” to a column in the DataFrame so that you can use it to subset later on. The “value” attribute at the bottom specifies an initial value — in the example above I set the default at “2010–2014.” This will set an initial value before the user has selected an option using the dropdown. The container is a string a of text that will let the user know which option was chosen.</p><p>The code to create a chart is a little simpler.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*BLP5d7JkWBUk3pNVrVaSQw.png" /></figure><p>With graphs you simply need to create a a new html.Div() to house the chart and then specify the id. Ignore the hoverData piece for now — I will get into that in a bit.</p><h3>App Callbacks</h3><p>App callbacks allow the user to connect the plotly graphs with Dash components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AcSKBXvQW7uVtZf9KtXpTA.png" /></figure><p>In order to create the interactivity you use the @app.callback() syntax to take in inputs and return outputs. In the example above, the input is the dropdown that we selected earlier (notice how the ids match), and the outputs are the figure (in this case a plotly map) and a container letting the user know which decade was chosen. Underneath the callback, a function is used which takes in the input as a parameter. It then uses that input to subset the DataFrame. In this case, our slct_decade dropdown is used to create a new DataFrame with the selected value. The Plotly dyntax for creating a choropleth map is px.choropleth. One nice thing about Dash is that all of the charts are created using the same syntax as Plotly — the only difference is the inputs and outputs. Plotly choropleth has a built-in USA map that can be specified by setting “locationmode” to “USA-states.” Within our UFO DataFrame, there is a ‘states” column that contains state codes. By setting “locations” to this column, the choropleth map will put the appropriate UFO sighting counts in each state. Here is what our map and container look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*ODSUJgNVIoV_orswFl37wA.gif" /></figure><h3>Using HoverData</h3><p>Another great feature of Dash is Hoverdata. Hoverdata allows you to update charts based on where the mouse is on the app. In this case, we will use hoverData to create a barchart for each state that will update as a user moves across the choropleth map. Once again, here is the code used to create the map in app layout section:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*Au7uITNVmHsyY7vyOAYdrA.png" /></figure><p>The code above sets our initial data to TX so that a chart is set up even before the user hovers over the map. Hoverdata returns a dictionary that has “points” as a key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*fw3kQijrPXiSv3QMwCKhpg.gif" /></figure><p>The line at the bottom of the GIF above shows us the values for Hoverdata at different points in the map. The state name can be accessed through this dictionary, allowing us to create charts which subset our DataFrame using the specified state:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kKDapZRospmt-bNIkvBGyg.png" /></figure><p>Using the code above, we are able to create a bar that updates using HoverData. The “update_chart” function takes in Hoverdata as an input and subsets the Dataframe to only include values from that state. The y-values in the “create_chart” function are specified using another dropdown that corresponds to different columns in the DataFrame — in this case we can toggle between number of UFO sightings and the average duration (in seconds) of UFO sightings for each state. Lastly, the title is updated to show the State we are hovering over.</p><h3>Putting it all together</h3><p>Once again, here is the final output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*QnZzr3oJBpXW3nujjg4rbg.gif" /></figure><p>Using Dash, we were able to create an interactive app that enables users to subset a DataFrame and create visualizations. The full code for this tutorial can be found here: <a href="https://github.com/KPMcDonough49/Blog_3/blob/main/tutorial.py">https://github.com/KPMcDonough49/Blog_3/blob/main/tutorial.py</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3986e3356f11" width="1" height="1" alt=""><hr><p><a href="https://medium.com/down-in-the-ds/dash-interactive-dashboard-tutorial-3986e3356f11">Dash Interactive Dashboard Tutorial</a> was originally published in <a href="https://medium.com/down-in-the-ds">Down in the (Crisp-)DMs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[EMOT Library in Python]]></title>
            <link>https://medium.com/down-in-the-ds/post-2-emot-library-in-python-d7ce559b82a4?source=rss-bc4713d1a520------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7ce559b82a4</guid>
            <dc:creator><![CDATA[Kevin McDonough]]></dc:creator>
            <pubDate>Mon, 31 May 2021 16:05:15 GMT</pubDate>
            <atom:updated>2021-10-04T17:45:03.112Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post I will be exploring the Python EMOT library 👍. Created by Neel Shah and Shubham Rohilla (<a href="https://github.com/NeelShah18/emot/tree/v2.2">link to Github repo</a>), this library allows users to extract emojis and emoticons from a string of text 😎. Let’s dive in:</p><p>The EMOT library can be downloaded and imported using the following code:</p><pre>pip install emot --upgrade<br>import emot</pre><p>Once the library has been loaded, you can pass through a string and EMOT will return a dictionary that has 4 keys:</p><ul><li>“value” : Contains a list of all emojis in the string</li><li>“mean”: Contains a list of the meanings associated with the values. For example 🤣 would return “:rolling_on_the_floor_laughing:”</li><li>“ location” : specifies where in the string the emoji was</li><li>“flag”: A boolean that specifies if emojis or emoticons are present in the string. True means emoji or emoticons are present, False means absent</li></ul><p>Let’s check out an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*jPLKa9LzImMPOLQcPdDBlA.png" /></figure><pre>buy_you_a_drank = &quot;Ima 💰 you a 🍻 Ima take you 🏠 with 👦 I got 💰 in the 🏦 Find me in the gray 🚗 &quot;</pre><pre>emot.emoji(buy_you_a_drank)</pre><p>Passing the above tweet (the chorus of “Buy You A Drank” in Emoji form) returns the following output:</p><pre>{&#39;value&#39;: [&#39;💰&#39;, &#39;🍻&#39;, &#39;🏠&#39;, &#39;👦&#39;, &#39;💰&#39;, &#39;🏦&#39;, &#39;🚗&#39;],<br> &#39;mean&#39;: [&#39;:money_bag:&#39;,<br>  &#39;:clinking_beer_mugs:&#39;,<br>  &#39;:house:&#39;,<br>  &#39;:boy:&#39;,<br>  &#39;:money_bag:&#39;,<br>  &#39;:bank:&#39;,<br>  &#39;:automobile:&#39;],<br> &#39;location&#39;: [[4, 4],<br>  [12, 12],<br>  [27, 27],<br>  [34, 34],<br>  [42, 42],<br>  [51, 51],<br>  [73, 73]],<br> &#39;flag&#39;: True}</pre><p>Based on this output, if we were to sub the “mean” instead of the values for all of the emojis, the chorus would be:</p><p>“I’ma ‘money_bag’ you a you a ‘clinking_beer_mugs’, I’ma take you ‘house’ with ‘boy.’ I got ‘money_bag’ in the ‘bank,’ find me in the gray ‘automobile.’”</p><p>Not quite the same ring to it</p><h3>Using EMOT Library With Twitter API Data</h3><p>The EMOT Library allows users to analyze emoji usage on a large scale. For example, we could use the EMOT library to identify the emoji usage of different Twitter users. I was curious which celebrities use the most emojis on twitter, so I found <a href="https://digiday.com/marketing/7-celebrities-killer-emoji-game/">this article</a> on digiday.com entitled “7 Celebrities with Killer Emoji Game.” I thought I’d put this claim to the test and see how truly killer their emoji game was. Utilizing the twitter API, I downloaded the last 100 tweets for each of the celebrities listed and compiled it in a Pandas dataframe. I then wrote a function that added a new column to the dataframe called “emojis,” that contains the emojis from each string.</p><pre>def get_emojis(tweet):<br>    if len(emot.emoji(tweet)[&#39;value&#39;]) &gt; 0:<br>        return emot.emoji(tweet)[&#39;value&#39;]<br>    else:<br>        return &quot;No Emojis&quot; # If there are no emojis in tweet</pre><pre>emoji_df[&#39;emojis&#39;] = emoji_df[&#39;Tweets&#39;].apply(get_emojis)</pre><pre>cleaned_df = emoji_df[emoji_df[&#39;emojis&#39;] != &quot;No Emojis&quot;] # creates a new df that only contains rows for tweets that have emojis</pre><p>Now that we have this cleaned dataframe, we can create a dictionary that shows the emojis that each celebrity use:</p><pre>user_dict = {}<br>for user in user_list:<br>    user_dict[user] = []</pre><pre>for row in cleaned_df.index:<br>        user_dict[cleaned_df[&#39;user_handle&#39;][row]].extend(cleaned_df[&#39;emojis&#39;][row])</pre><p>The above code cycles through each row (tweet) in cleaned_df and adds the emojis used in each tweet to a dictionary that has each user as a key and a list of their emoji’s as values. One drawback to using EMOT that I noticed is that emojis that have a skin tone show up as two emojis rather than one. For example, let’s take at the following tweet by Neymar Jr.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*EUzMzTuNe-u4_Iy2tTP4_w.png" /></figure><p>Let’s plug this into EMOT and see what it returns.</p><pre>emot.emoji(neymar_tweet)</pre><p>Output:</p><pre>{&#39;value&#39;: [&#39;🙏&#39;, &#39;🏽&#39;, &#39;❤&#39;, &#39;⚽&#39;],<br> &#39;mean&#39;: [&#39;:folded_hands:&#39;,<br>  &#39;:medium_skin_tone:&#39;,<br>  &#39;:red_heart:&#39;,<br>  &#39;:soccer_ball:&#39;],<br> &#39;location&#39;: [[35, 35], [36, 36], [37, 37], [39, 39]],<br> &#39;flag&#39;: True}</pre><p>As you can see, although there are only three emojis in the tweet, EMOT returns four. The second emoji returned is ‘:medium_skin_tone:’. Because we don’t want to double count emoji usage, we need to figure out a way to remove these from the dictionary. To accomplish this, we can use a nested for loop to cycle through each emoji in our dictionary and keep it if the description doesn’t contain the word “tone.”</p><pre>cleaned_dict = {}<br>for user in user_dict:<br>    cleaned_dict[user] = []<br>    for emoji in user_dict[user]:<br>        if &quot;tone&quot; not in emot.emoji(emoji)[&#39;mean&#39;][0]:<br>            cleaned_dict[user].extend(emot.emoji(emoji)[&#39;value&#39;])</pre><p>Now that we have the emojis for each celebrity in a dictionary, we can see which celeb is the most prolific emoji-user. Here is a chart that shows how often each of the selected celebs used emojis in there last 100 tweets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/864/1*lv0eAKsNK9_8Xf_HE358Yg.png" /></figure><p>From the above chart, it looks like Neymar Jr. is the 👑 of emoji-usage! He has used over 200 emojis in his last 100 tweets, averaging over 2 emojis per tweet.</p><p>Additionally, we can compile all the emojis into one master list and see which emojis are used most frequently. Here are key-value pairs showing which emojis were used most frequently by our 7 celebs in their last 100 tweets:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*EeQK0WjNmoR13n-0AYbMPg.png" /></figure><p>Cool! 🤓🤯🤠🍻🔥👏🧑‍💻</p><p>Thanks for reading 🙏 . EMOT is a fun and simple package that is user-friendly and easy to install. One other quick thing I wanted to note is that there were a couple emojis that EMOT was not able to recognize. Flags in particular were a category that this package did not pick up on. Emojis are a recent innovation and new ones are constantly being added, so maybe EMOT has not been updated yet to include these changes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7ce559b82a4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/down-in-the-ds/post-2-emot-library-in-python-d7ce559b82a4">EMOT Library in Python</a> was originally published in <a href="https://medium.com/down-in-the-ds">Down in the (Crisp-)DMs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Post 1: My Path to Flatiron]]></title>
            <link>https://medium.com/@kpmcdonough/post-1-my-path-to-flatiron-64a3853f527b?source=rss-bc4713d1a520------2</link>
            <guid isPermaLink="false">https://medium.com/p/64a3853f527b</guid>
            <dc:creator><![CDATA[Kevin McDonough]]></dc:creator>
            <pubDate>Mon, 10 May 2021 02:28:11 GMT</pubDate>
            <atom:updated>2021-05-10T14:30:36.260Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone! My name is Kevin McDonough and I’m a 27-year-old data science student at the Flatiron school. A quick bit about me: I’ve always considered myself to be a person who wears many hats. I’m a brother, friend, dog-lover, avid reader, adventure-seeker, athlete, and student. I grew up in Connecticut but, at various points, have lived in North Carolina, Pennsylvania, New Jersey, New York City, Mexico, Lake Tahoe and San Francisco (where I currently live) . With this first post, I’m going to discuss the journey that culminated in my decision to enroll in the Flatiron School San Francisco Data Science program.</p><p>Two years ago, I was living in New York City and working at Guggenheim Partners, a boutique investment bank located in midtown. Although there were some things that I really enjoyed about my job, I grew frustrated with my role for a couple reasons. First off, the work life balance looked like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NGxIDbB97PbMMe9vRUvLvw.png" /></figure><p>In investment banking, there’s a an entrenched culture in which the analysts (the low men/women on the totem pole) are expected to work late most nights and be in the office on weekends. During my Guggenheim career, I missed some important life events and fell out of touch with friends due to the amount of time spent in the office.</p><p>I also quickly realized that I’m not passionate about finance. I enjoy working with numbers, and I found the excel analysis exciting and stimulating but that was only one piece of the work — there was a lot of busywork and powerpoint formatting as well. Additionally, it felt like there was a lot of dead-end work — long pitchbooks that we would put together for client meetings knowing that it wouldn’t lead anywhere. We advised clients on deals but didn’t really oversee the implementation of the acquisitions after the deals closed, so we didn’t have a lot of skin in the game, and, outside of fees, there wasn’t a tangible product that we were helping to create.</p><p>Lastly, although I think New York City is one of the greatest cities in the world, I prefer to be in a place where I can spend time outdoors hiking and biking. It was nice living in close proximity to lot of buddies from college and high school, but midtown Manhattan could be a bit overwhelming / stressful and I missed being in nature.</p><p>So, taking all this into account, last February I told my bosses that I wouldn’t be staying for a third year after my contract ended. Experiencing a bit of a quarter-life crisis, I began to formulate a plan to go abroad and work/volunteer at 6 or 7 in different countries. There is a very cool website called <a href="https://www.workaway.info/">Workaway</a> that connects travelers with hosts who cover living expenses in exchange for around 25 hours of work per week. I’ve always loved traveling and meeting new people, and, in addition to enabling me to travel cheaply, I thought workaway would allow me to get to develope relationships with locals and truly experience the culture. Excited about the plan, I set about creating a budget and list of must-see places. Unfortunately, I chose an absolutely horrible time to plan an around-the-world trip because, about a month after formulating my itinerary, the global pandemic rendered international travel impossible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GaLqFrJwrLC1wAASNXxUAQ.png" /></figure><p>I had to change up my plans a bit once it became clear that borders would remain closed for the foreseeable future. When twin sister was let go from her job due to COVID, we decided to embark on a cross-country road trip to visit our older sister in San Francisco. Although you did not ask for it, here is a montage of pics of me wearing a shirt with Owen Wilson’s face on it from that trip:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ia81yiW0h00TJ4cLowSPqg.png" /></figure><p>The trip was a blast and some great bonding time with my sister, but my desire to travel still wasn’t fully sated. I did a bit of recon and realized that U.S. citizens were not barred from traveling to Mexico. Through Workaway, I found a volunteer opportunity at a dog rescue in Puerto Vallarta called Las Animas Dog Rescue Association (or LADRA, the Spanish word for bark).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YnWoJVRdqcA0M8atHwfkXw.jpeg" /><figcaption>My room at the rescue</figcaption></figure><p>I ended up spending three awesome months down there, and met some incredible people and adorable dogs. The days were filled with dog walks, hikes, laughs, chores, vet visits, tacos, pacificos, and a little too much dog pee and poo. At night, the dog’s would sleep in the volunteers’ beds. To the left is a pic of the room I stayed in — this was a pretty common scene! At any given time, there were normally around 40 dogs at LADRA and 6 or 7 volunteers. LADRA partners with an organization called Mexpup to find prospective adopters for the pups in the Pacific Northwest and Canada. Although I wasn’t planning on adopting a dog, I bonded with a pup named Goliath (pictured below), and brought him back to the states with me when I returned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MIQ1qiQ732wU-AQ6hrJHCA.jpeg" /><figcaption>Goliath</figcaption></figure><p>When I got back from Mexico, I did a bit of soul-searching and research into career options. At my last job, I had found the excel work with clients’ financial and operational data to be interesting and compelling. I’ve always been pretty quantitative and I enjoy problem-solving. I also wanted to find a job in a growing field working at a company that created a product I believed in. I ultimately decided that a data science bootcamp would open up a door into the tech world and provide me with a valuable technical skillset that would hopefully make me an attractive candidate to potential future employers. I chose San Francisco because of the many outdoor activities I would be able to participate in out here, and because I have a sister and friends from high school and college that live in the Bay Area. I’ve outlined some of the personal and career goals that led me to choose the flatiron data science program in a chart below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l8hYXVWMT8P3vmY9126ELw.png" /></figure><p>It’s been an interesting journey to get here, and I’m very excited about where I am. I’m looking forward to exploring the world of data science in the coming days!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64a3853f527b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>