<?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[CompassRed Data Blog - Medium]]></title>
        <description><![CDATA[We live for data and analytics. - Medium]]></description>
        <link>https://medium.com/compassred-data-blog?source=rss----8742fb8d6446---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>CompassRed Data Blog - Medium</title>
            <link>https://medium.com/compassred-data-blog?source=rss----8742fb8d6446---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 07:06:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/compassred-data-blog" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Top 3 things I learned from attending a cannabis conference]]></title>
            <link>https://medium.com/compassred-data-blog/top-3-things-i-learned-from-attending-a-cannabis-conference-77811d7ed0ff?source=rss----8742fb8d6446---4</link>
            <guid isPermaLink="false">https://medium.com/p/77811d7ed0ff</guid>
            <category><![CDATA[mjbizcon]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[cannabis-industry]]></category>
            <category><![CDATA[cannabis-testing]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Eugene Olkhov]]></dc:creator>
            <pubDate>Wed, 08 Dec 2021 14:24:42 GMT</pubDate>
            <atom:updated>2021-12-08T14:24:42.869Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QHRNb8s7aO4Q60sH7qzmxA.jpeg" /></figure><p>You’re going to a what?? This was the reaction from family members and friends when I told them I was going to Las Vegas for a cannabis business conference.</p><p>It’s important though to go back several months to get some context around how we ended up at the <a href="https://mjbizconference.com/">2021 MJBizCon</a>, and the beginning of my journey into the world of the science of cannabis.</p><p>There’s never a boring day at <a href="https://www.compassred.com/">CompassRed</a> due to the plethora of interesting clients we get to work with on a daily basis, and <a href="https://www.labware.com/lims/ml-ai">LabWare</a> is no exception. <a href="https://www.labware.com/lims/ml-ai">LabWare</a> is one of the global leaders in providing LIMS (Lab Information Management System) software to analytical laboratories across many industries. One of their newest offerings, LabWare GROW, is aimed at tailoring and providing their software to cannabis testing labs. LabWare GROW automates sample management from receipt to reporting while capturing data with a fully compliant audit trail. Our solution, <a href="https://www.compassred.com/orbis-lab">Orbis Lab</a>, provides LabWare GROW users with advanced analytics capabilities. With the tools we’ve developed together, laboratory managers are able to yield better insights about their operations and quality assurance practices using interactive visualizations and predictive insights (anticipate demand and instrument repair). We’re excited about the work as we see a big opportunity in the LIMS space for advanced analytics.</p><p>So, we got to work on learning everything there is to know about how different cannabis products are tested. I didn’t know too much about the area before this work, so it really opened my eyes to just how much goes into this, from the countless combinations of products, to the potential contaminants and variations in potency of strains.</p><p>While there’s plenty of information available online — nothing compares to talking to actual people working in the industry. When we were told that the biggest cannabis business conference was happening in Las Vegas, we knew this would be an incredible opportunity to learn more about the industry.</p><p>First, the atmosphere: it was energizing and it felt like everyone was there with a purpose. During the first day of the conference (out of the two full days we were attending), our booth at LabWare was getting non-stop traffic! While most people were curious about the software — many were interested in the car that was parked in the booth!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AjfHeRqBa3YCUIhn6h2V8g.jpeg" /><figcaption>LabWare CEO Vance Kershner’s “Hellrunner” — a 1973 Plymouth Roadrunner with a 2016 Dodge Hellcat with a slogan of “High Performance” to attract attention</figcaption></figure><p>While talking to prospective testing laboratory clients was informative, it was really the second day where we started to explore other booths and hear what others are doing in the industry. The floor space was huge and stretched multiple conference halls, with hundreds of booths. This definitely made it difficult to talk to everyone, but we were still able to talk to some interesting people.</p><h3>Environmental Monitoring</h3><p>We spoke with several companies that provide equipment to cannabis growers to monitor their plants. While growers send their samples to testing labs to check for contaminants, potency, and other factors, it’s important to have a step which keeps track of the growing conditions. Having this step would allow an analysis where we can start to understand why certain contamination happens, and what types of growing conditions lead to differences in potency. Ultimately, this provides us with an incredible opportunity to begin to predict when these things will occur, which can then allow for prevention of unwanted outcomes.</p><h3>Therapeutics</h3><p>Most people likely associate cannabis use with changing one’s mental state for (usually) recreational use, and sometimes to reduce pain / stress from illness. However, doing research into cannabis and attending this conference revealed just how many other therapeutic applications there are.</p><p>For example, there’s companies that are producing CBD infused gels which can be applied to joints topically for a targeted way to reduce pain.</p><p>There’s also research going into what types of cannabis strains help with specific ailments. Similarly, the key is having targeted ways to alleviate health problems. This is a really exciting development that can help people without requiring having to try multiple products, and minimizing any unwanted side effects.</p><h3>Booming Industry</h3><p>The third takeaway is simply just how much growth and opportunity exists in the cannabis space. This industry is still in its infancy — and yet is already showing so much potential and innovation with the wide range of vendors.</p><p>We had conversations with folks from cannabis-focused digital marketing agencies, cannabis cultivator apparel companies, cannabis-focused payment processors, agriculture monitoring system providers, cannabis podcasters, supply chain focused vendors, and more. Every part of the cannabis production process was covered in one way or another.</p><p>It’s surprising to see how many people there were actively researching, making purchases, and forming formal partnerships. There is urgency in the industry to move quickly right now so the energy was exciting all around.</p><p>Overall, attending this conference was an incredibly informative experience. The CompassRed team got the opportunity to dive in head first into this exciting industry and learn quickly.</p><p>We saw that the business needs we help meet for our current clients are similar to the ones we talked about with cannabis vendors at MJBizCon: “I need to reduce costs”, “I need to optimize my production process”, “I need to better attract new customers”. These statements underline the need for good data solutions for people making decisions in every industry.</p><p>We took a lot away from the experience and it allowed us to better understand the clients we’re developing software for in the cannabis space! We see a bright future where LabWare Grow clients are able to utilize Orbis Lab, and gain valuable, actionable insights. Thanks again to our partner LabWare for including us.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=77811d7ed0ff" width="1" height="1" alt=""><hr><p><a href="https://medium.com/compassred-data-blog/top-3-things-i-learned-from-attending-a-cannabis-conference-77811d7ed0ff">Top 3 things I learned from attending a cannabis conference</a> was originally published in <a href="https://medium.com/compassred-data-blog">CompassRed Data Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Benefits of GPUs in Data Science and How I Taught Myself About Them]]></title>
            <link>https://medium.com/compassred-data-blog/benefits-of-gpus-in-data-science-and-how-i-taught-myself-about-them-2e766101645c?source=rss----8742fb8d6446---4</link>
            <guid isPermaLink="false">https://medium.com/p/2e766101645c</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[gpu]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Eugene Olkhov]]></dc:creator>
            <pubDate>Wed, 24 Mar 2021 17:53:43 GMT</pubDate>
            <atom:updated>2021-03-24T17:53:21.047Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XwFF8dkOzx2Y4Taa" /><figcaption>Photo by <a href="https://unsplash.com/@christianw?utm_source=medium&amp;utm_medium=referral">Christian Wiediger</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>As a Data Scientist who has done his own fair share of model training, I’m very familiar with spending long periods of time waiting for training to finish, especially as you increase your data size and / or model complexity.</p><p>When training on a local machine, these long wait times become inconvenient not just because of the wait itself, but also because you will often be forced to keep your computer running throughout the night, or even multiple nights in a row. Hopefully, your computer doesn’t randomly restart due to an update! Besides the issues of running overnight, you also face the problem of your machine slowing down during the day while you attempt to work on other things.</p><p>It was not until I started working on a computer vision problem, that I finally decided that I need another method for model training. Given the prevalence of face masks, I was working on training a model to detect when a face mask was worn improperly. Using my standard method of model training, the model would have taken over 24 hours to train. This is not a feasible training time especially when you consider needing to make tweaks to the model. Training times need to be relatively fast in order to properly iterate on the model.</p><p>So, what’s the solution? Clearly, as problems become more difficult, and models become more advanced, we can’t keep running things on our local machines, right? Sort of.</p><h3>Cloud Computing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iTAEr_NVnAvPkLvz50bBmg.png" /></figure><p>The easiest solution is to switch from your local machine, to a virtual one. You can create an account with Google Cloud Services (GCP), Microsoft Azure, Amazon Web Services (AWS), Digital Ocean, etc. Once you have an account, you can either setup a free virtual machine instance or a paid one. The free instance usually doesn’t have enough power to do any serious model training, but it’s good to use to get familiar with the service. Keep in mind, if this is your first time setting up an account, many services give you some free credit to use on the paid instances.</p><p>This solves the issue of needing to keep your local machine running, but also you can customize your virtual instance to be a lot more powerful than your local machine which will speed up your training time. You can also utilize a virtual GPU instance, which, as I will cover next, will speed up your training immensely. Of course with great power, comes a big price tag. The more powerful your virtual instances are (especially vGPUs), the more you’re going to pay. Of course, if this model is going to be part of your core business, then it’s just going to be part of your business expenses. However, what if this is your personal project, or maybe a proof-of-concept where you don’t want to spend that much money on resources (yet). In that case, setting up training on a local GPU might be worth your while.</p><h3><strong>Setting up a local GPU</strong></h3><p>The main caveat is you need to have your own NVIDIA GPU. You could also buy one, but depending on the GPU, it can get quite pricey. Of course, if you envision yourself using it a lot then it would be worth it. If you’re not sure you have an NVIDIA GPU on your local machine, you can check the device manager on Windows, or the “About This Mac” &gt; Display if you’re using a Mac.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/827/1*z0KvusePIlQ1jFVmUMVJbg.png" /></figure><p>The nice thing is that you don’t actually need to have a high-end GPU. The GPU in my laptop is on the lower end, and I was still able to see large improvements in training speed.</p><p>Ideally, you would also want to set this all up on a Linux machine. The process appears to be relatively straight-forward and involves installing the relevant drivers from NVIDIA. However, I am working on a Windows machine so my process was a bit different.</p><p>To make things even more complicated, my workflow also consists of working out of a Linux-based Docker container using Docker Desktop which adds some complexity in the setup process.</p><p>Luckily, I was able to find this helpful <a href="https://www.docker.com/blog/wsl-2-gpu-support-is-here/">post</a> which explained the steps I needed to take in order for Docker to be able to communicate with my GPU. The key steps are as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PfM0ep40dSepLHK56-xz9A.png" /></figure><p>While initially the steps seemed to be quite simple, there was one step in particular which at first I overlooked: Windows Insider. As I quickly learned, this actually involved installing a developer preview version of Windows on my machine. At first, I was a little reluctant to do so given that it could affect stability / compatibility of my machine, but since all the other methods I tried failed, I decided to go for it.</p><p>At first, the update actually failed! My machine then reverted back to the original version of Windows that I was on. However, since my settings were still set to the dev version of Windows, the next time I restarted my machine, it successfully installed the preview software.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JN5JTPcd2mq3mTey2xeTnQ.png" /><figcaption>The windows version should look something like this if successful</figcaption></figure><p>Once this happened, I spun up a Docker instance, and ran some simple benchmarks which revealed that Docker was communicating with my GPU!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*BJOe4yYDGpwY3Cpdv8CIJA.png" /><figcaption>Results of the benchmark listed in the Docker blog post linked above</figcaption></figure><p>One last step that I needed is to make sure it was working with the Jupyter Notebook instance inside the container. For this, I needed to make sure my Dockerfile contained all the proper NVIDIA drivers, so that when I built my image, everything could communicate with each other.</p><h3>Benefits</h3><p>Now that I was able to set this all up, does it actually improve my training speed?</p><p>Yes, definitely!</p><p>My training speed was about 3x faster, even with my low-end GPU. These are important findings, especially given that the CPU that I was using to train previously is a quite powerful i9 8th gen core. High-end GPUs are expected to have an even greater improvement of 10x+ the speed!</p><p>So, when should you use a GPU to train vs a CPU? At a very high level, GPUs are very good at doing a large number of small tasks quickly, where as CPUs are good at doing a small number of hard tasks. There’s obviously a lot more nuance there, but the key is that GPUs are ideal for deep learning tasks where in order to train the model, there’s a huge number of small calculations that need to happen.</p><p><strong>Disclaimer</strong></p><p>There is a lot of variation in the workflows that people use, and the process I outlined here has worked for me, as someone who has not had previous experience in utilizing GPUs in my work. It’s quite possible that there is a more simple solution that will work for you, but hopefully this has provided some general knowledge to allow you to either use this method, or find your own.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e766101645c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/compassred-data-blog/benefits-of-gpus-in-data-science-and-how-i-taught-myself-about-them-2e766101645c">Benefits of GPUs in Data Science and How I Taught Myself About Them</a> was originally published in <a href="https://medium.com/compassred-data-blog">CompassRed Data Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Three More Ways to Make your RMarkdown Better]]></title>
            <link>https://medium.com/compassred-data-blog/three-more-ways-to-make-your-rmarkdown-better-de4f391256de?source=rss----8742fb8d6446---4</link>
            <guid isPermaLink="false">https://medium.com/p/de4f391256de</guid>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[r]]></category>
            <category><![CDATA[markdown]]></category>
            <category><![CDATA[rstudio]]></category>
            <dc:creator><![CDATA[Eugene Olkhov]]></dc:creator>
            <pubDate>Thu, 28 Jan 2021 16:10:53 GMT</pubDate>
            <atom:updated>2021-01-28T16:10:09.534Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hyj8RIFrNjZ5RScV-MCSOA.png" /></figure><p>Several months ago, I published <a href="https://medium.com/compassred-data-blog/top-3-things-to-make-your-rmarkdown-better-part-1-a137f78315b9?source=friends_link&amp;sk=abe31e58dea345e4e16aff3f538830b0">an article</a> which covered 3 simple ways to improve your RMarkdown. In this sequel article, I want to cover 3 more ways to improve your RMarkdown which deal with slightly more advanced techniques.</p><h3>1. Adjusting CSS</h3><p>In the previous <a href="https://medium.com/compassred-data-blog/top-3-things-to-make-your-rmarkdown-better-part-1-a137f78315b9?source=friends_link&amp;sk=abe31e58dea345e4e16aff3f538830b0">article</a>, I covered using built-in themes. These are really easy to use, and require a single line of code in the YAML of the RMarkdown. However, what if you want to modify a specific part of the theme such as the colors or font for a specific section? Here’s how you can do that:</p><ol><li>First, visit <a href="https://bootswatch.com/3/">Bootswatch </a>and look for the theme you want. This will have the built-in themes that are available in RMarkdown.</li><li>Download the bootstrap.css file associated with your theme — use the arrow dropdown to choose the right file.</li><li>Make modifications to the .css file using your preferred method.</li><li>In the YAML, include the following:</li></ol><pre>output:<br>  html_document:<br>    css: your_css_file_name.css</pre><p>Once you have added it, it will behave exactly the same as the default theme, but will incorporate the changes you made.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x6wyjN285KpeeuvwMV1_EQ.png" /><figcaption>Original theme “United”</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6rawd6tstQofr-7hPs77Aw.png" /><figcaption>Modified background color</figcaption></figure><h3>2. Adding a logo</h3><p>Often, you want to customize your RMarkdown with some branding. Here at <a href="https://www.compassred.com/">CompassRed</a>, we like to include our company logo at the top of the document. This can be done using a variety of ways. Typically, we do this by adding a short jQuery snippet right after the YAML like so:</p><pre>---</pre><pre>&lt;script&gt;<br>  $(document).ready(function() {<br>    $(&#39;#section-TOC&#39;).parent().prepend(&#39;&lt;div id=\&quot;nav_logo\&quot;&gt;&lt;img src=&quot;logo_name.svg&quot;&gt;&lt;/div&gt;&#39;).css({&quot;padding-top&quot;: &quot;25px&quot;});<br>  });<br>&lt;/script&gt;</pre><pre>---</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*lLAB2R1U0dSGUTt5VoxBrQ.png" /></figure><p>The above can be customized in a variety of ways. We prefer our logo to sit on top of the table of contents in the top left corner.</p><p>The #section-TOC ID is the container for the table of contents. If you prefer the logo somewhere else, find the ID of the container you’re looking to target and input it into the jQuery (might take some modification of the parent function).</p><p>This code also assumes that the svg file of the logo exists in the same folder as the output html file. Alternatively, you can host the image somewhere and reference it in the src. This would be useful in instances where you need to host the output html file somewhere.</p><h3>3. Chunk options</h3><p>Finally, utilizing chunk options is another great way to customize your RMarkdown. There are many of these options that you can utilize. I will cover a few ways I personally use chunk options, but definitely check out the following <a href="https://bookdown.org/yihui/rmarkdown-cookbook/chunk-options.html">source</a> for ones I don’t mention.</p><p>Code folding is something that was briefly mentioned in the <a href="https://medium.com/compassred-data-blog/top-3-things-to-make-your-rmarkdown-better-part-1-a137f78315b9?source=friends_link&amp;sk=abe31e58dea345e4e16aff3f538830b0">previous article</a>. It’s useful if you are sharing your RMarkdown with different types of audiences, some of which may be interested in seeing your code. Code folding makes that easy by providing input buttons to either show or hide code. However, if you’re sharing with an audience that you know has no interest in seeing the code, you can omit the code output from individual chunks using the echo = F option.</p><pre>{r, echo = F}</pre><p>Alternatively, you can set the argument to TRUE if you want to force the code to be seen. You can also ignore warnings and messages if you would like. This is useful in the chunk which imports libraries since there’s often a lot of output that you wouldn’t want to clutter the document.</p><pre>{r, echo = F, message = F, warning = F}</pre><p>The final chunk option that I often use myself is setting figure sizes. Frequently, I find that the default aspect ratio of my ggplot2 visualizations isn’t quite how I want them to appear. For example, sometimes I want the viz to be wider in the output RMarkdown. For this I use the following:</p><pre>{r, fig.width = 10, fig.height = 5}</pre><p>The above gives me a 2:1 aspect ratio which usually works well. However, I encourage you to try out different sizes to see what works best for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UZIFLpIlH9xXaiCFrYkFFQ.png" /><figcaption>This is using an aspect ration of 5:7</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7bMowXlSMkkxPWCed7MUdw.png" /><figcaption>This is using a wider aspect ratio of 2:1</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de4f391256de" width="1" height="1" alt=""><hr><p><a href="https://medium.com/compassred-data-blog/three-more-ways-to-make-your-rmarkdown-better-de4f391256de">Three More Ways to Make your RMarkdown Better</a> was originally published in <a href="https://medium.com/compassred-data-blog">CompassRed Data Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[We Built a Data Innovation Lab. Here’s Who Makes it Happen.]]></title>
            <link>https://medium.com/compassred-data-blog/we-built-a-data-innovation-lab-heres-who-makes-it-happen-f6d40f52bce4?source=rss----8742fb8d6446---4</link>
            <guid isPermaLink="false">https://medium.com/p/f6d40f52bce4</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Ryan Harrington]]></dc:creator>
            <pubDate>Sat, 12 Dec 2020 16:25:34 GMT</pubDate>
            <atom:updated>2020-12-12T16:25:34.241Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*2lNQwlQPYN84yxA3Z6GfYA.gif" /><figcaption>👋👋👋</figcaption></figure><p>With the COVID-19 pandemic continuing to effect every facet of our daily lives, the CompassRed team wanted to find a way to help. To make that happen, we launched the <a href="http://ddil.ai/">Delaware Data Innovation Lab</a> (DDIL) with the help of CARES Act funding from New Castle County.</p><p>The goal of the DDIL is to tackle COVID adjacent issues from a position of strength in data — topics like housing insecurity, economic stability, and educational equity. <em>All</em> of these are <a href="https://ssir.org/books/excerpts/entry/wicked_problems_problems_worth_solving">wicked problems</a>. To make real headway on any of these, it requires having the right team.</p><p>What does that team look like? It looks diverse. Diverse data skillsets. Diverse lived experiences. Diverse ways of thinking. By bringing these different perspectives together, we can appropriately address the problems.</p><p>Our initial group of Fellows is 10 people strong and working on 6 proof-of-concepts. They’re supported by an additional team of data scientists and data engineers paving the way towards success. Meet our Fellows!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*r5kdxpDyXSrNdkkgeSmOgg.png" /></figure><h4>Rakhi Agrawal</h4><p>Rakhi brings her experience as a former secondary math teacher and nonprofit professional to the work that she does at the DDIL. She’s focused on bringing her skillset as a data scientist to educational equity issues, particularly as it relates to declining FAFSA completion in the wake of the pandemic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*0MRUC3_Y4iP9-B91yHPyUQ.png" /></figure><h4>Daniel Barlow</h4><p>In any other year, Dan would currently be teaching math in the Peace Corps. While his placement is delayed due to the pandemic, he’s spending his time focused on how to visualize and share data in augmented and virtual reality. He’s particularly focused on using mobility data as a proof of concept.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*e_losRMcDOCAIicr4ZAcLg.png" /></figure><h4>Meagan Brackeen</h4><p>Meagan’s expertise is focused on building narratives and telling stories. She brings a research and grant writing background at the University of Delaware to the DDIL. Now she uses that skillset to help tell the story of housing insecurity and evictions in New Castle County and beyond.</p><h4>Talla Cisse</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*Fd4HLkIIlpDDe7lrRzLq5A.png" /></figure><p>Talla’s story is grounded in a deep passion for education. He is a former Teach for America Corps Member who has built his knowledge of educational policy through work at the DE Department of Education, Southern Poverty Law Center, and Harvard Graduate School of Education. He brings his skills as a data analyst to telling the story of declining FAFSA rates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*ajLITymA7I8pUwqxNvZQVQ.png" /></figure><h4>Sara Gormley</h4><p>In previous work, Sara has used her skillset as a data analyst to focus on community well-being through projects with the City of Austin and Code for Philly. She continues this work at the DDIL, focused on identifying social determinants of health indicators to better understand Wilmington and the surrounding area.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*iqkY8i2NBhDBJBjN4y3ftw.png" /></figure><h4>Hector Maldonado-Reis</h4><p>A biomedical engineer turned data scientist, Hector brings his expertise in population health to his work at the DDIL. Hector is focused on understanding the relationships between COVID-19 and the eviction moratoria and then using this data to build a narrative about housing insecurity in New Castle County.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*sz2DkdGMA4OQmVGvIDLt8w.png" /></figure><h4>Shreshta Naskanti</h4><p>Having recently graduated with her Masters in Business Analytics from Arizona State University, Shreshta is interested in solving complex challenges with data. She has focused this skillset on identifying social determinants of health indicators across Wilmington.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*GZbaJamETmmcL-SqJUrGdg.png" /></figure><h4>Jasmine Pham</h4><p>A recent graduate of Drexel University, Jasmine brings her data analyst skillset to her work. She is particularly interested in how data can be used to help communities thrive. She is focused on visualizing COVID-19 viral load in wastewater as an early warning system to help New Castle County identify potential outbreaks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*AWEyyJkNYocHde9hyHCqRg.png" /></figure><h4>Steven Reiss</h4><p>Steven is a data scientist who leverages his experiences as a digital marketer and entrepreneur in his work. In particular, he is focused on understanding how COVID-19 safety measures — from masks to social distancing — have impacted reviews in the hospitality industry.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*Qcmvk9fGqboPGxC_1C8Jvw.png" /></figure><h4>Janie Truitt</h4><p>Janie joins the DDIL bringing a background in program delivery in the banking industry. Since transitioning from banking, she has spent her time focused on the intersection of data and health outcomes. She has used this expertise to help develop a tool to understand the effect of policy measures on COVID-19 viral load in wastewater in New Castle County.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6d40f52bce4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/compassred-data-blog/we-built-a-data-innovation-lab-heres-who-makes-it-happen-f6d40f52bce4">We Built a Data Innovation Lab. Here’s Who Makes it Happen.</a> was originally published in <a href="https://medium.com/compassred-data-blog">CompassRed Data Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The 8 Principles to Follow in a Post- Social Dilemma World]]></title>
            <link>https://medium.com/compassred-data-blog/the-8-principles-to-follow-in-a-post-social-dilemma-world-aaefbe2dd9d6?source=rss----8742fb8d6446---4</link>
            <guid isPermaLink="false">https://medium.com/p/aaefbe2dd9d6</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[big-data]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[social-media]]></category>
            <category><![CDATA[the-social-dilemma]]></category>
            <dc:creator><![CDATA[Ryan Harrington]]></dc:creator>
            <pubDate>Wed, 30 Sep 2020 14:31:39 GMT</pubDate>
            <atom:updated>2020-09-30T14:31:39.041Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*5_9r28OkZ-CxkGbFS5_DNQ.gif" /><figcaption>📹 <em>The Social Dilemma</em></figcaption></figure><p>Netflix’s <em>The Social Dilemma</em> waxed poetic about the insidious ways that social media has wrestled control from our lives, turning us into screen addicted, polarized versions of ourselves by using our data and our psychologies against us.</p><p>Concerns about social media have been around for several years now, but <em>The Social Dilemma</em> has captured our societal angst more than other attempts in recent memory. We can (ironically) see this with a small sample of tweets:</p><h3></h3><p>Still thinking about Social Dilemma on Netflix last night. I urge everyone to watch it. In a nutshell, we are now the product for business models that rely on clicks for revenue and Fake News, on both sides, produces the greatest revenue. We are being driven apart for profit.</p><h3></h3><p>Just watched The Social Dilemma on Netflix, and it paints a pretty scary picture of where we&#39;re heading. Must-see. 👀👀👀</p><h3></h3><p>Diving into The Social Dilemma. Maybe bye forever</p><p><em>The Social Dilemma</em> took its time explaining the dangers of social media and the existential threat that society faces if we do not begin addressing those dangers. However, <a href="https://www.businessinsider.com/how-to-put-your-phone-down-the-social-dilemma-2020-9">outside of the last few minutes</a>, it did little justice to <em>how</em> to address those dangers. Even within those few minutes that were spent addressing solutions, they were heavily focused on what an individual could do <em>right now</em> to address the issues and much less focused on systemic changes. Having immediately actionable steps for individuals is helpful, but it is broader systemic changes that will prevent the existential crisis described in the documentary.</p><p><em>The Social Dilemma</em> was created in partnership with the <a href="https://www.humanetech.com/">Center for Humane Technology</a> (CHT). To understand what those changes might look like, we explored CHT’s <a href="https://www.humanetech.com/policy-principles">Policy Principles</a>. They list 8 principles to be followed across “a broad array” of regulatory bodies.</p><p><em>The policy or proposal should…</em></p><ol><li><strong>Put people first<br></strong><em>… privilege the rights and interests of people over corporations</em></li><li><strong>Avoid “atomizing” solutions<br></strong><em>… where possible, prioritize social and collective approaches over “atomizing” solutions.</em></li><li><strong>Confront power<br></strong><em>… seek to identify and correct power asymmetries and imbalances.</em></li><li><strong>Address root causes<br></strong><em>… go beyond symptoms to address the root causes of the problem or challenge at hand.</em></li><li><strong>Presume harm<br></strong><em>… presume that all technologies, and their applications, are capable of inflicting a variety of harms and seek to identify those harms.</em></li><li><strong>Compel caution<br></strong><em>… require a precautionary approach to technology development and deployment.</em></li><li><strong>Embrace complexity<br></strong><em>… reflect the complexity of a problem or challenge by advancing comprehensive and contextualized solutions.</em></li><li><strong>Seek sustainability<br></strong><em>… privilege sustainable, regenerative solutions over self-terminating, quick-fixes.</em></li></ol><p>Let’s examine three of these principles further:</p><h4>Avoid “atomizing” solutions</h4><p>What is an “atomizing” solution? CHT points to an example familiar to all of us: consenting to Terms of Service. How is this “atomizing”? It forces us to negotiate our rights with an organization at an individual level as opposed to at a population level. With this approach, each of us is required to be an expert on our rights, putting the onus on the consumer. Further, while this model focuses on the rights of the individual, it ignores societal harm. Each decision cannot live in a vacuum.</p><p>According to CHT, a “non-atomizing alternative would impose minimum standards that benefit everyone equally such that the choices of one individual do not undermine the rights or protections of others.” In effect, the CHT approach is calling for a <a href="https://www.technologyreview.com/2018/12/14/138615/its-time-for-a-bill-of-data-rights/">Bill of Data Rights</a>.</p><h4>Compel caution</h4><p>How do you regulate technologies that do not exist yet? That is a fundamental question that regulators need to answer. The approach espoused by CHT focuses on the need for a precautionary approach to new technology. These approaches could “include undertaking an array of cost-benefit analyses and impact assessments … as well as harm reduction measures, among others.”</p><p>We are beginning to see such caution in action for specific technologies in some municipalities. In particular, CHT highlights facial recognition technology. Already, there have been bills passed to <a href="https://epic.org/state-policy/facialrecognition/">ban facial recognition</a> for policing, particularly in California. <a href="https://www.nbcnews.com/tech/security/2-democratic-senators-propose-ban-use-facial-recognition-federal-law-n1232128">A similar bill</a> has been proposed in the US Senate putting a moratorium in place on facial recognition for federal law enforcement.</p><h4>Seek sustainability</h4><p>Policy solutions cannot be focused on quick fixes, but must instead focus on the underlying issue. If policy solutions focus on quick fixes, then they will be outpaced by the speed of technical innovation. If we simply ban a technology, a new solution will arise to replace it. The example highlighted by CHT is focused on third-party cookies. If third-party cookies were banned, then other techniques could be used in order to track users across the web. Many of these solutions have the potential to be more harmful than third-party cookies. In this vein, policy should be focused on the root causes of the issues in an effort to get ahead of the technological innovation curve.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aaefbe2dd9d6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/compassred-data-blog/the-8-principles-to-follow-in-a-post-social-dilemma-world-aaefbe2dd9d6">The 8 Principles to Follow in a Post- Social Dilemma World</a> was originally published in <a href="https://medium.com/compassred-data-blog">CompassRed Data Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Music in A Virtual World: How musical events, communities, and learning have moved online this year]]></title>
            <link>https://medium.com/compassred-data-blog/music-in-a-virtual-world-how-musical-events-communities-and-learning-have-moved-online-this-year-9f3f68e49beb?source=rss----8742fb8d6446---4</link>
            <guid isPermaLink="false">https://medium.com/p/9f3f68e49beb</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[infographics]]></category>
            <category><![CDATA[music]]></category>
            <category><![CDATA[google-data-studio]]></category>
            <category><![CDATA[analytics]]></category>
            <dc:creator><![CDATA[Ben Kates]]></dc:creator>
            <pubDate>Wed, 23 Sep 2020 14:33:21 GMT</pubDate>
            <atom:updated>2022-07-07T15:35:31.052Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*J_BLcUAvcM2KgFHroK7_kQ.gif" /></figure><h3>Music in A Virtual World: How musical <strong>events</strong>, <strong>communities</strong>, and <strong>learning</strong> has moved online during the COVID-19 pandemic.</h3><p>Like many others, I was devastated when quarantine for COVID-19 postponed and cancelled many live performances. Many performing arts professionals are at a crossroads for performing live: will we embrace virtual events and permanently shift what it means to be a modern creative? Or will we “wait it out” until it’s safe to have large gatherings again? Additionally, what does this mean for people looking to learn a new musical instrument because they see themselves being on stage one day?</p><p>While the answers to these questions still seem uncertain, I wanted to dive into some numbers around how the online music community has grown during quarantine. Using publicly available data on Twitch, a streaming platform, and Google Trends data, here’s a closer look:</p><blockquote><a href="https://datastudio.google.com/reporting/10445ba2-1c96-4414-84a8-a1585d247060/page/tF4fB"><strong>Please click here to read the full infographic viz!</strong></a></blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fdatastudio.google.com%2Fembed%2Freporting%2F10445ba2-1c96-4414-84a8-a1585d247060%2Fpage%2FtF4fB%3Ffeature%3Doembed&amp;dntp=1&amp;display_name=Google+Data+Studio&amp;url=https%3A%2F%2Fdatastudio.google.com%2Freporting%2F10445ba2-1c96-4414-84a8-a1585d247060%2Fpage%2FtF4fB&amp;image=https%3A%2F%2Fdatastudio.google.com%2Freporting%2F10445ba2-1c96-4414-84a8-a1585d247060%2Fpage%2FtF4fB%2Fthumbnail%3Fsz%3Dw1200-h900-p-nu%26feature%3Doembed&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=google" width="1200" height="935" frameborder="0" scrolling="no"><a href="https://medium.com/media/e1c8107e6a99ebeb30a4f4c375a6d63c/href">https://medium.com/media/e1c8107e6a99ebeb30a4f4c375a6d63c/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f3f68e49beb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/compassred-data-blog/music-in-a-virtual-world-how-musical-events-communities-and-learning-have-moved-online-this-year-9f3f68e49beb">Music in A Virtual World: How musical events, communities, and learning have moved online this year</a> was originally published in <a href="https://medium.com/compassred-data-blog">CompassRed Data Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Top 3 Things To Make Your RMarkdown Better (Part 1)]]></title>
            <link>https://medium.com/compassred-data-blog/top-3-things-to-make-your-rmarkdown-better-part-1-a137f78315b9?source=rss----8742fb8d6446---4</link>
            <guid isPermaLink="false">https://medium.com/p/a137f78315b9</guid>
            <category><![CDATA[r-markdown]]></category>
            <category><![CDATA[reporting]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[analytics]]></category>
            <category><![CDATA[r]]></category>
            <dc:creator><![CDATA[Eugene Olkhov]]></dc:creator>
            <pubDate>Wed, 16 Sep 2020 15:25:59 GMT</pubDate>
            <atom:updated>2020-09-16T16:18:15.512Z</atom:updated>
            <content:encoded><![CDATA[<h3>Top 3 Ways To Make Your RMarkdown Better (Part 1)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*asykzmJZlg0b7otN.jpg" /><figcaption><a href="https://rstudio.com/about/pbc-report/">Source</a></figcaption></figure><p>Last month I talked about the <a href="https://medium.com/compassred-data-blog/how-to-host-and-share-rmarkdown-files-cc8474893818">multiple ways of sharing RMarkdown analyses with your target audience</a>. When you’re sharing your RMarkdown analysis, the most important aspect is the content itself, but formatting and aesthetic of the analysis is not far behind.</p><p>In this article, I am going to show you three simple things that can turn your analysis from a bland, flat file into a well organized, interactive document that people will want to read.</p><h3>1. YAML Settings</h3><p>The YAML section in an RMarkdown file is the very first section of code you see:</p><pre>---<br>title: &quot;Analysis&quot;<br>output: html_document<br>---</pre><p>The above YAML is at the most basic level, which just lists the title of the document (this shows up at the top when knitting/rendering), and then the output format. However, there are a huge amount of options that the YAML can take to help customize your document. Some of the ones I find most useful are using built-in themes, creating a table of contents and controlling code folding.</p><p><strong>Built-in Themes</strong></p><p>Using built-in themes is the easiest way to completely change the look of your entire document. This controls accent colors, font, and more.</p><pre>---<br>title<strong>:</strong> &quot;Analysis&quot;<br>output<strong>:</strong><br>  html_document<strong>:</strong><br>    theme<strong>:</strong> yeti<br>---</pre><p>The following themes are available: default, cerulean, journal, flatly, darkly, readable, spacelab, united, cosmo, lumen, paper, sandstone, simplex, and yeti.</p><p><strong>Table of Contents</strong></p><p>Another very useful option that can be added to the YAML is to include a table of contents. The code looks like this:</p><pre>---<br>title<strong>:</strong> &quot;Analysis&quot;<br>output<strong>:</strong><br>  html_document:<br>    theme: yeti<br>    toc: TRUE<br>    toc_float: TRUE<br>---</pre><p>This creates a table of contents on the right side of the document which lets you click on any section of the document to skip through. I particularly like using the float option as this makes the table of contents cleaner by only showing you the current section, but letting you scroll through the other sections. The sections are created by using different level headers ( # vs. ##, vs. ###…etc.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*_1SJi6-jUYkdODH_h1WNtA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/319/1*vw2Js5TRYYEFAsMODilVyA.png" /></figure><p><strong>Code Folding</strong></p><p>Code folding is another useful feature in case you want some of your target audience to be able to view the code which generated your analysis. The YAML option creates a clickable button at the beginning of the document to either show or hide all of the code:</p><pre>---<br>title<strong>:</strong> &quot;Analysis&quot;<br>output<strong>:</strong><br>  html_document:<br>    theme: yeti<br>    toc: TRUE<br>    toc_float: TRUE<br>    code_folding: hide<br>---</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/204/1*kIJ6X0kJa22haLqAoWpVNg.png" /></figure><h3>2. Tabset</h3><p>Often, in your analysis you will be creating multiple variants of plots, tables or other items used for comparison. These can quickly cause clutter, and make the document a lot longer than it needs to be.</p><p>Something that has completely changed my analyses is adding a tabset option for document sections which I want to collapse into a set of tabs. To make it work, create a header (let’s use a level 2 header for example). Under that header, create a few sub-headers (these are the items that will be collapsed into tabs).</p><pre>## Demographics {.tabset}</pre><pre>### Plot 1</pre><pre>&quot;Insert Plot 1 here&quot;</pre><pre>### Plot 2</pre><pre>&quot;Insert Plot 2 here&quot;</pre><pre>### Plot 3</pre><pre>&quot;Insert Plot here&quot;</pre><p>The results look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*Hbbf870KQrTNVqpwYw2cTQ.png" /></figure><h3>3. Plotly</h3><p><a href="https://plotly.com/r/">Plotly</a> is an interactive graphing library that allows for creating some really impressive interactive visuals. In order to get the best results, I would recommend using the syntax specific to Plotly. However, the Plotly package contains a ggplotly function which can take a ggplot object and make it interactive. While there are occasional bugs with this method, the ease of not needing to learn new syntax makes it worth it for many situations.</p><p>Here’s an example plot using just ggplot2 :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a8oThrjLR5tccA2kVJ0OeA.png" /></figure><p>Now here is an example of the exact same plot, but wrapping it in a ggplotly function. I can hover my mouse over each individual point, and get the data associated with it. It also has a capability for zooming in closer to a set of points by just drawing a shape around the points you want to investigate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*om870Xm6AoCZDSlDDSy2wA.png" /></figure><p>There are also some arguments that can be tweaked inside the ggplotly function. The documentation can be found <a href="https://plotly.com/ggplot2/">here.</a></p><p>These few examples will take your RMarkdown reports to the next level, but stay tuned for some more advanced techniques coming soon!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a137f78315b9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/compassred-data-blog/top-3-things-to-make-your-rmarkdown-better-part-1-a137f78315b9">Top 3 Things To Make Your RMarkdown Better (Part 1)</a> was originally published in <a href="https://medium.com/compassred-data-blog">CompassRed Data Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Word Embeddings and its Applications]]></title>
            <link>https://medium.com/compassred-data-blog/introduction-to-word-embeddings-and-its-applications-8749fd1eb232?source=rss----8742fb8d6446---4</link>
            <guid isPermaLink="false">https://medium.com/p/8749fd1eb232</guid>
            <category><![CDATA[word2vec]]></category>
            <category><![CDATA[word-embeddings]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[fasttext]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Aayush Dua]]></dc:creator>
            <pubDate>Wed, 05 Aug 2020 17:20:26 GMT</pubDate>
            <atom:updated>2020-08-05T17:20:25.983Z</atom:updated>
            <content:encoded><![CDATA[<h4>Intro to Word2Vec, Glove, ELMo and fastText</h4><figure><img alt="Software Galaxies Visualization of Glove Embeddings" src="https://cdn-images-1.medium.com/max/1024/1*1pZ8irTXf4zGEawOGh0JCw.png" /><figcaption>Source: <a href="https://anvaka.github.io/pm/#/galaxy/word2vec-wiki?cx=-17&amp;cy=-237&amp;cz=-613&amp;lx=-0.0575&amp;ly=-0.9661&amp;lz=-0.2401&amp;lw=-0.0756&amp;ml=300&amp;s=1.75&amp;l=1&amp;v=d50_clean">Software Galaxy Visualization of Word Embeddings by Andrei Kashcha</a></figcaption></figure><p>Before I give you an introduction on Word Embeddings, take a look at the following examples and ask yourself what is common between them:</p><ol><li>Using customer reviews or employee survey responses to understand sentiments towards a particular product or company.</li><li>Using lyrics of songs you liked to recommend songs that are similar in contextual meaning.</li><li>Using a web translation service, like Google Translate, to convert webpage articles seamlessly to a different language.</li></ol><p>You have probably guessed this right. All of these applications deal with large amounts of <strong>Text</strong>. Now obviously it’s a waste of resources to spend manual labor in these applications which have millions of sentences or documents containing text.</p><p>So what can we do now? We could feed this to Machine Learning and Deep Learning models and let them learn and figure out these applications. But most of these models can’t be fed textual data since they can’t interpret it in a human sense. Generally, they require numerical representations to perform any task. This is where <strong>Word Embeddings</strong> comes into use.</p><p>In this article we are going to address the following:</p><ol><li>What are Word Embeddings?</li><li>Why exactly do we prefer Word Embeddings?</li><li>What are the different types of Word Embeddings?</li><li>What are their Applications?</li></ol><h3><strong>What are Word Embeddings?</strong></h3><p>Word Embeddings are a numerical vector representation of the text in the corpus that maps each word in the corpus vocabulary to a set of real valued vectors in a pre-defined N-dimensional space.</p><p>These real valued vector-representation for each word in the corpus vocabulary are learned through supervised techniques such as neural network models trained on tasks such as <strong>sentiment analysis</strong> and <strong>document classification</strong> <em>or</em> through unsupervised techniques such as <strong>statistical analysis of documents</strong>.</p><p>The Word Embeddings try to capture the semantic, contextual and syntactic meaning of each word in the corpus vocabulary based on the usage of these words in sentences. Words that have similar semantic and contextual meaning also have similar vector representations while at the same time each word in the vocabulary will have a unique set of vector representation.</p><figure><img alt="Word2Vec Embeddings" src="https://cdn-images-1.medium.com/max/1024/1*omPLP2G1qlgZFJDVY63OMw.png" /><figcaption>Source: <a href="https://www.tensorflow.org/tutorials/representation/word2vec">https://www.tensorflow.org/tutorials/representation/word2vec</a></figcaption></figure><p>The above image displays examples of words in vocabulary having similar contextual, semantic and syntactic meaning to be mapped in a 3-Dimensional Vector Space. In the above picture example of Verb Tense, we can observe that vector differences between word pairs: (<em>walking &amp; walked) </em>and (<em>swimming &amp; swam) </em>is roughly equal.</p><h3>Why exactly do we prefer Word Embeddings?</h3><p>Certain questions might have popped into your mind by now.</p><ol><li>What is the simplest way to represent words numerically and why isn’t that sufficient?</li><li>If Word Embeddings are so complex, why do we prefer them to simpler methods?</li></ol><p>Lets address these questions one by one.</p><h4><strong>What is the simplest way to represent words numerically and why isn’t that sufficient?</strong></h4><p>The simplest ways to represent words numerically is to <strong>One-Hot-Encode </strong>unique word in a corpus of text. We can understand this better with an example. Suppose my corpus has only two documents:</p><p>* <em>The King takes his Queen for dinner.</em><br>* <em>The husband takes his wife for dinner.</em></p><p>You might notice that these two documents have the same contextual meaning. When we apply one hot encoding to the documents, here’s what happens:</p><pre>We first construct an exhaustive vocabulary — {“The”, “King”, “husband”, “takes”, “his”, “Queen”, “wife”, “for”, “dinner”}. </pre><p>There are nine unique words in the document text, so each word will be represented as a vector with a length of 9. The vector will consist a &quot;1&quot; that corresponds to the position of the word in the vocabulary with a &quot;0&quot; everywhere else. Here is what those vectors look like:</p><pre><em>The     -    </em>[1,0,0,0,0,0,0,0,0]<em><br>King    -    </em>[0,1,0,0,0,0,0,0,0] <em><br>husband -    </em>[0,0,1,0,0,0,0,0,0]<em><br>takes   -    </em>[0,0,0,1,0,0,0,0,0] <em><br>his     -    </em>[0,0,0,0,1,0,0,0,0] <em><br>Queen   -    </em>[0,0,0,0,0,1,0,0,0]<em><br>wife    -    </em>[0,0,0,0,0,0,1,0,0] <em><br>for     -    </em>[0,0,0,0,0,0,0,1,0] <em><br>dinner  -    </em>[0,0,0,0,0,0,0,0,1]</pre><p>Lets address some disadvantages of this method.</p><p>1. <strong>Scalability Issue- </strong>The above example contained only 2 sentences and only 9 words in vocabulary. But in a real-world scenario, we will have millions of sentences and millions of words in vocabulary. You can imagine how the dimensions of one-hot-encoded vectors for each word will explode in millions. This will lead to scalability issues when it is fed to our models, and in turn will lead to inefficiency in time and computational resources.</p><p>2.<strong> Sparsity Issue- </strong>Given that we will have 0’s everywhere except for single 1 at the correct location, the models have a very hard time learning this data, therefore your model may not generalize well over the test data.</p><p>3.<strong> No Context Captured- </strong>Since one-hot-encoding blindly creates vectors without taking into account the shared dependencies and context in which each word of vocabulary lies, we lose the contextual and semantic information. In our example, that means that we lose context between similar word pairs — <em>“king”</em> and <em>“queen”</em> are similar to <em>“husband”</em> and <em>“wife”</em>.</p><h4>If Word Embeddings are so complex, why do we prefer them to simpler methods?</h4><p>There are many other simpler methods than Word Embeddings, such as Term-Frequency Matrix, TF-IDF Matrix and Co-occurrence Matrix. But even these methods face one or more issues in terms of scalability, sparsity and contextual dependency.</p><p>Therefore, we prefer Word Embeddings since it resolves all the issues mentioned above. The embeddings maps each word to a N-Dimensional space where N ranges from 50–1000 in contrast to a Million-Dimensional Space. Thus we resolve scalability issues. Since each vector in the embeddings is densely populated in contrast to a vector containing 0’s everywhere, we have also resolved the sparsity issues. Thus the model can now learn better and generalize well. Finally, these vectors are learned in a way that captures the shared context and dependencies among the words.</p><h3><strong>Different Types of Word Embeddings</strong></h3><p>In this section, we will be reviewing the following <strong>State-Of-The-Art (SOTA)</strong> Word Embeddings:</p><ol><li>Word2Vec</li><li>Glove</li><li>ELMo</li></ol><p>This is not an exhaustive list, but a great place to start with. There are many other SOTA Word Embeddings such as <a href="https://arxiv.org/pdf/1810.04805.pdf"><strong>Bert</strong></a> (developed by Jacob Devlin at Google) and <a href="https://cdn.openai.com/better-language-models/language_models_are_unsupervised_multitask_learners.pdf"><strong>GPT</strong></a><strong> </strong>(developed at OpenAI) that have also made advanced breakthroughs in NLP applications.</p><h4><strong>Word2Vec</strong></h4><p>Word2Vec is an algorithm developed by <a href="https://arxiv.org/abs/1301.3781">Tomas Mikolov, et al.</a> at Google in 2013. The algorithm was built on the idea of the <strong>distributional hypothesis</strong>. The distributional hypothesis suggests that words occurring in similar linguistic contexts will also have similar semantic meaning. Word2Vec uses this concept to map words having similar semantic meaning geometrically close to each other in a N-Dimensional vector space.</p><p>Word2Vec uses the approach of training a group of shallow, 2-layer neural networks to reconstruct the linguistic context of words. It takes in a large corpus of text as an input and produces a vector space with dimensions in the order of hundreds. Each unique word in the corpus vocabulary is assigned a unique corresponding vector in the space.</p><p>It can be implemented using either of the two techniques: <strong>Common Bag of Words(CBOW)</strong> or <strong>Skip Gram</strong>.</p><p>a) <strong>Common Bag of Words<br></strong>This technique uses the shallow 2-layer neural network to predict the probability of a word given the context. A context can be a single word or a group of words. The following diagram illustrates the concept:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*8bp_c0bxWCpaCOFN2HAYoA.png" /><figcaption>Source: <a href="https://arxiv.org/pdf/1411.2738.pdf">word2vec Parameter Learning Explained by Xin Rong</a></figcaption></figure><p>The input will be the context of words each of them being one-hot-encoded and fed to the network and the output is the probability distributions of each word in the vocabulary.</p><p>b) <strong>Skip Gram<br></strong>The skip gram is the flipped version of CBOW. We feed the model a single word and the model tries to predict the words surrounding it. The input is the one-hot-encoded vector of the word and the output is a series of probability distributions of each word in the vocabulary. For example, <em>“I am going for a walk”.</em></p><pre>The vocabulary is — [“I”, “am”, “going”, “for”, “a”, “walk”]. </pre><pre>Length of Vocabulary V=6 </pre><p>For setting the number of surrounding words that model tries to predict, we define Context Window.</p><pre>Let Context Window C=4</pre><p>Let the input be one of the words in the vocabulary. We will input the one-hot-encoded representation of this word of dimension V and the model is expected produce an output of series of probability distributions of each word with the output dimension being C*V.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*u7M1-MVmXeN8dgcIF9hMsA.png" /><figcaption>Source: <a href="https://arxiv.org/pdf/1411.2738.pdf">word2vec Parameter Learning Explained by Xin Rong</a></figcaption></figure><p>Word2Vec was a major breakthrough in the field of Word Embeddings because it was able to capture relations in algebraic representations that were never captured before. For example, If we took words such as “King”, “Queen”, “man”, “wife” and mapped these words into the vector space, we found out out that the vector distance between “King” and “Queen” was the same as the vector distance between “man” and “woman”, which could allow us to produce outputs like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OrEaN8RDcTn8nVsjgeQo8w.jpeg" /></figure><h4><strong>Glove</strong></h4><p>While the Word2Vec technique relies on <strong>local statistics</strong> (local context surrounding the word) to derive local semantics of a word, the Glove technique goes one step further by combining local statistics with <strong>global statistics</strong> such as <strong>Latent Semantic Analysis </strong>(Word Co-occurrence Matrix) to capture the global semantic relationships of a word. Glove was developed by <a href="https://nlp.stanford.edu/projects/glove/">Pennington, et al.</a> at Stanford.</p><p>For example, consider the co-occurrence probabilities for target words <em>ice</em> and <em>steam</em> with various probe words from the vocabulary. Here are some actual probabilities from a 6 billion word corpus:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MQAdWuEIrZRvx567MKOHBA.png" /><figcaption><a href="https://nlp.stanford.edu/pubs/glove.pdf">GloVe: Global Vectors for Word Representation</a> — Jeffrey Pennington</figcaption></figure><p>From the above table, we can observe that <em>ice</em> co-occurs with <em>solid</em> more frequently than it does with <em>gas, </em>and <em>steam </em>co-occurs with <em>gas </em>more frequently than with <em>solid. </em>Both words co-occur with their shared property<em> water </em>frequently, and both co-occur with the unrelated word<em> fashion </em>infrequently<em>. </em>From the ratio of probabilities, we can observe that non-discriminative words(<em>water &amp; fashion) </em>have a ratio of probabilities approximately equal to 1, whereas discriminative words(<em>solid and gas) </em>have either high ratio of probabilities or very low ratio of probabilities. Using this method, the ratio of probabilities encodes some crude form of meaning associated with the abstract concept of thermodynamic phases. These ratios of probabilities are then encoded in the form of vector differences in N-Dimensional space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nolQEGkgnZkTTod5p-AiDQ.png" /><figcaption>Source: <a href="https://nlp.stanford.edu/projects/glove/">https://nlp.stanford.edu/projects/glove/</a></figcaption></figure><p>In the above image, we notice that the vector differences between word pairs such as <em>man &amp; woman </em>and <em>king &amp; queen </em>are roughly equal. The distinguishing factor between these word pairs is gender. As well as this pattern, we can also observe many other interesting patterns in the above visualization from Glove.</p><h4>ELMo</h4><p>Before we jump into ELMo, consider this example:</p><ol><li><em>Her favorite fruit to eat is a </em><strong><em>date</em></strong><em>.</em></li><li><em>Joe took Alexandria out on a </em><strong><em>date</em></strong><em>.</em></li></ol><p>We can observe that <strong><em>date </em></strong>has different meanings in different contexts. Word embeddings such as Glove and Word2Vec will produce the same vector for the word <strong><em>date </em></strong>in both the sentences. Hence, our models would fail to distinguish between the <strong>polysemous </strong>(having different meaning and senses) words. These word embeddings just cannot grasp the context in which the word was used.</p><p><strong>ELMo </strong>resolves this issue by taking in the whole sentence as an input rather than a particular word and generating unique ELMo vectors for the same word used in different contextual sentences.</p><p>It was developed by NLP researchers (<a href="https://arxiv.org/abs/1705.00108">Peters et. al., 2017</a>, <a href="https://arxiv.org/abs/1708.00107">McCann et. al., 2017</a>, and <a href="https://arxiv.org/pdf/1802.05365.pdf">Peters et. al., 2018 in the ELMo paper</a>) at Allen Institute of AI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*adXIEhql9B3_zd62kRQ7CA.png" /><figcaption>Source: <a href="http://jalammar.github.io/illustrated-bert/">The Illustrated BERT, ELMo, and co. (How NLP Cracked Transfer Learning) by Jay Allamar</a></figcaption></figure><p>ELMo uses Bi-directional LSTM, which is pre-trained on a large text corpus to produce word vectors. It works by training to predict the next word given a sequence of words. This task is also known as Language Modeling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*CjSTeme6K8SRuO08BIY5dw.png" /><figcaption>Source: <a href="http://jalammar.github.io/illustrated-bert/">The Illustrated BERT, ELMo, and co. (How NLP Cracked Transfer Learning) by Jay Allamar</a></figcaption></figure><p>ELMo representations are:</p><ul><li><em>Contextual</em>: The ELMo vectors produced for a word depends on the context of the sentence the word is being used in.</li><li><em>Character based</em>: ELMo representations are purely character based, allowing the network to use morphological clues to form robust representations for out-of-vocabulary tokens unseen in training.</li></ul><h3>Applications of Word Embeddings</h3><p>Word Embeddings have played a huge role across the complete spectrum of NLP applications. The following are some of the famous applications that use Word Embeddings:</p><ol><li>Word Embeddings have been integral in improving Document Search and Information Retrieval. An intuitive approach is to calculate <strong>Word Centroid Similarity</strong>. The representation for each document is the centroid of its respective word vectors. Since word vectors carry semantic information of the words, one could assume that the centroid of the word vectors within a document encodes its meaning to some extent. At query time, the centroid of the query’s word vectors is computed. The cosine similarity to the centroids of the (matching) documents is used as a measure of relevance. This speeds up the process and resolves the issue of search keywords needing to be exactly the same as those in the document.— <a href="https://github.com/lgalke/vec4ir">Vec4ir by Lukas Galke</a></li><li>Word Embeddings have also improved Language Translation System. Facebook had recently released Multi-Lingual Word Embeddings (<a href="https://github.com/facebookresearch/fastText"><strong>fastText</strong></a>) which has word vectors for 157 languages trained on Wikipedia and Crawl. Given a training data for example, Text Corpus having two language formats — Original Language: <em>Japanese</em>; Converted Language: <em>English, </em>we can feed the word vectors of the text corpus of these languages to a Deep Learning model say, <a href="https://google.github.io/seq2seq/"><strong>Seq2Seq</strong></a> model and let it learn accordingly. During the evaluation-phase you can feed the test Japanese text corpus to this learned Seq2Seq and evaluate the results. <strong>fastText </strong>is considered one of the most efficient SOTA baselines.</li><li>Lastly Word Embeddings have improved Text Classification accuracy in different domains such as Sentiment Analysis, Spam Detection and Document Classification.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8749fd1eb232" width="1" height="1" alt=""><hr><p><a href="https://medium.com/compassred-data-blog/introduction-to-word-embeddings-and-its-applications-8749fd1eb232">Introduction to Word Embeddings and its Applications</a> was originally published in <a href="https://medium.com/compassred-data-blog">CompassRed Data Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Our Favorite R Shiny UI Skins]]></title>
            <link>https://medium.com/compassred-data-blog/our-favorite-r-shiny-ui-skins-c505328b8268?source=rss----8742fb8d6446---4</link>
            <guid isPermaLink="false">https://medium.com/p/c505328b8268</guid>
            <category><![CDATA[dashboard-design]]></category>
            <category><![CDATA[r]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[ui-design]]></category>
            <dc:creator><![CDATA[Ben Kates]]></dc:creator>
            <pubDate>Wed, 29 Jul 2020 13:57:45 GMT</pubDate>
            <atom:updated>2020-07-29T13:57:45.535Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZUmp1T4h9q6d7tcl" /></figure><p>At CompassRed, we primarily work in R for client projects. Whether it’s creating models, custom data viz, or something in between, a static slide deck or HTML file only goes so far (more than once we’ve heard “I’d like to click into that” when presenting a static slide deck). Over the last year <a href="https://compassred.shinyapps.io/ncco_biobot/">our team has invested in the R Shiny application framework</a> to bring those static outputs to life in an interactive medium.</p><p>Most Shiny dashboards look the same. The “out of the box” page layout as well as the more &quot;dashboard-like” shinydashboard are easy to get up and running, but start to feel dull when using them project after project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1eyaBhbnv-G7LFNn.png" /><figcaption>An “out of the box” dashboard using the shinydashboard package, <a href="https://edgarruiz.shinyapps.io/db-dashboard/">live link here.</a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GxUeqjiao9XNwd7_fkVUOg.png" /><figcaption>Worldwide search term interest for “R Shiny” over the last 8 years July, 2012 to July, 2020 (Google Trends)</figcaption></figure><p>The Shiny community is growing rapidly; bringing R outputs to life in applications is becoming more important to users. With this comes more contribution to the project and ecosystem surrounding it. Here are some of our favorite Shiny skins that have been developed by the community.</p><h3><strong>tablerDash by </strong>RinteRface</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Xyowrqfr-D_vMGGS.png" /><figcaption>“A current demo of the tablerDash skin running on shiny server open source is available <a href="http://www.rinterface.com/shiny/tablerDash/">here</a>. (It uses echarts4r webGL components and might not render on several mobile devices.)” — David Granjon</figcaption></figure><p>Based on the <a href="https://tabler.io/">tabler.io</a> dashboard template, this skin feels clean and simple, yet different from the standard shinydashboard. Although not every component of the original template is in the Shiny implementation, the social cards can come in handy when displaying images and relevant data. In addition, the layout is fixed-width and does not fill the browser window (which can sometimes cause issues for those with large monitors).</p><ul><li><strong>Package Authors: </strong><a href="https://twitter.com/divadnojnarg">David Granjon</a>, <a href="http://Victor Perrier">Victor Perrier</a>, and <a href="https://github.com/irudolf16">Isabelle Rudolf</a></li><li><strong>Package Website:</strong> <a href="https://rinterface.github.io/tablerDash/">https://rinterface.github.io/tablerDash/</a></li><li><strong>GitHub Repo:</strong> <a href="https://github.com/RinteRface/tablerDash">https://github.com/RinteRface/tablerDash</a></li><li><strong>Functional Demo App: </strong><a href="https://dgranjon.shinyapps.io/shinyMons/">https://dgranjon.shinyapps.io/shinyMons/</a></li><li><strong>Package Demo App:</strong> <a href="https://dgranjon.shinyapps.io/tablerDashDemo/">https://dgranjon.shinyapps.io/tablerDashDemo/</a></li></ul><h3><strong>shiny.semantic by Appsilon Data Science</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Km0Bq5mgADZwCDHcLwdKA.png" /></figure><p>The elements in this package use the open-source <a href="https://semantic-ui.com/">Semantic UI</a>, another clean and simple library. The card and button combination, shown in in the right of the screenshot, gives the user clear instruction on how to act. Outside of this library, a Shiny developer would usually have to separate the text and button.</p><ul><li>Package Author: <a href="https://appsilon.com/">Appsilon Data Science</a></li><li>Package Website: <a href="https://appsilon.com/semantic-dashboard-new-open-source-r-shiny-package/">https://appsilon.com/semantic-dashboard-new-open-source-r-shiny-package/</a></li><li>GitHub Repo: <a href="https://github.com/Appsilon/shiny.semantic">https://github.com/Appsilon/shiny.semantic</a></li><li>Functional Demo App 1: <a href="https://demo.appsilon.ai/churn/">https://demo.appsilon.ai/churn/</a></li><li>Functional Demo App 2: <a href="https://demo.appsilon.ai/frauds/">https://demo.appsilon.ai/frauds/</a></li><li>Package Demo App: <a href="https://demo.appsilon.ai/semantic/">https://demo.appsilon.ai/semantic/</a></li></ul><h3><strong>shinyDashboardPlus by </strong>RinteRface</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5exP9F7mnphqkvnZ.png" /><figcaption>David Granjon <a href="https://divadnojnarg.github.io/post/awesomedashboards/">Intro to shinyDashboardPlus post</a></figcaption></figure><p>Although shinyDashboardPlus is based on the original shinydashboard, it’s a package that extends capabilities with new components. The right-hand navigation lends itself well to applications that require multiple points of input and the nested header experience gives the Shiny developer opportunity to address the user in subtle ways (see the notifications, alerts, and messages icons in the top right).</p><ul><li>Package Authors: <a href="https://twitter.com/divadnojnarg">David Granjon</a></li><li>Package Website: <a href="https://rinterface.github.io/shinydashboardPlus/">https://rinterface.github.io/shinydashboardPlus/</a></li><li>GitHub Repo: <a href="https://github.com/RinteRface/shinydashboardPlus">https://github.com/RinteRface/shinydashboardPlus</a></li><li>Package Demo App: <a href="https://rinterface.com/shiny/shinydashboardPlus/">https://rinterface.com/shiny/shinydashboardPlus/</a></li></ul><h3>shinyMobile</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*EhrvyGf409xJeTCu.png" /></figure><p>Mobile optimized dashboards have always been a challenge for Shiny developers. Although shinydashboard uses Bootstrap and a “fluid” layout for responsive design, this package allows a layout <strong>specific</strong> to mobile applications. The bottom toolbar in particular is something I think most of us are used to in applications like Twitter and Instagram.</p><p>A major feature of this library is the ability to <a href="https://rinterface.github.io/shinyMobile/index.html#progressive-web-app-pwa">render the Shiny app as a PWA</a> (Progressive Web App). Loading a PWA on a mobile phone bypasses the “ugly” browser UI and gives a fullscreen experience. In true app-like fashion, you can also add it to your home screen for easy access.</p><ul><li>Package Authors: <a href="https://twitter.com/divadnojnarg">David Granjon</a>, <a href="http://Victor Perrier">Victor Perrier</a>, and <a href="https://github.com/irudolf16">Isabelle Rudolf</a></li><li>Package Website: <a href="https://rinterface.github.io/shinyMobile/">https://rinterface.github.io/shinyMobile/</a></li><li>GitHub Repo: <a href="https://github.com/RinteRface/shinyMobile/">https://github.com/RinteRface/shinyMobile/</a></li><li>Example App: <a href="https://github.com/JohnCoene/coronavirus">https://github.com/JohnCoene/coronavirus</a></li><li>Package Demo App: <a href="https://dgranjon.shinyapps.io/miniUI2Demo/_w_4afb64c4/">https://dgranjon.shinyapps.io/miniUI2Demo/_w_4afb64c4/</a></li></ul><h3><strong>For Fun: LCARS by </strong>Matt Leonawicz</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aWhaWw5E0G9jXvs9.png" /></figure><p>We’re ending the list with a fun one, Star Trek fans will find this layout familiar! LCARS (Library Computer Access/Retrieval System) from the Star Trek universe has a unique design and works especially well on tablet devices. The package author maintains other R packages for the Star Trek Universe like <a href="https://github.com/leonawicz/rtrek">rtrek</a> and <a href="https://github.com/leonawicz/trekcolors">trekcolors</a>.</p><ul><li>Package Author: Matt Leonawicz</li><li>GitHub Repo: <a href="https://github.com/leonawicz/lcars">https://github.com/leonawicz/lcars</a></li><li>Example App: <a href="https://leonawicz.shinyapps.io/star-trek-console/">https://leonawicz.shinyapps.io/star-trek-console/</a></li></ul><p>What are some of your favorite Shiny skins? Are there any front-end libraries that don’t have a Shiny implementation that you’d like to see? Leave a comment below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c505328b8268" width="1" height="1" alt=""><hr><p><a href="https://medium.com/compassred-data-blog/our-favorite-r-shiny-ui-skins-c505328b8268">Our Favorite R Shiny UI Skins</a> was originally published in <a href="https://medium.com/compassred-data-blog">CompassRed Data Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[7 Levels of Data Manipulation with the tidyverse: Part 2]]></title>
            <link>https://medium.com/compassred-data-blog/7-levels-of-data-manipulation-with-the-tidyverse-part-2-f3809f10909a?source=rss----8742fb8d6446---4</link>
            <guid isPermaLink="false">https://medium.com/p/f3809f10909a</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[tidyverse]]></category>
            <category><![CDATA[rstats]]></category>
            <dc:creator><![CDATA[Ryan Harrington]]></dc:creator>
            <pubDate>Wed, 22 Jul 2020 15:39:49 GMT</pubDate>
            <atom:updated>2020-07-22T15:39:49.124Z</atom:updated>
            <content:encoded><![CDATA[<p>In the <a href="https://medium.com/compassred-data-blog/7-levels-of-data-manipulation-with-the-tidyverse-part-1-723fd4b70991">first part</a> of our exploration of data manipulation tools in the tidyverse, we concentrated on some of the basic dplyr and tidyr verbs. These tools allowed us to subset, transform, pivot, and join data in our quest to understand StackOverflow’s <a href="https://insights.stackoverflow.com/survey/">Annual Developer Survey</a> and the <a href="https://data.world/makeovermonday/2020w19-world-happiness-report-2020">2020 World Happiness Report</a>.</p><p>In this article, we will continue exploring data manipulation tools in the tidyverse, building on our learnings from <a href="https://medium.com/compassred-data-blog/7-levels-of-data-manipulation-with-the-tidyverse-part-1-723fd4b70991">Part 1</a>.</p><p>You can continue to find all of the code here:</p><p><a href="https://github.com/rharrington31/7_levels_of_data_manipulation_with_tidyverse">rharrington31/7_levels_of_data_manipulation_with_tidyverse</a></p><h4>Level 5: Colwise Transforming</h4><p>When preparing data for modeling, it is frequently necessary to transform several variables in the same way. For example, when working with continuous variables for modeling, we may want to scale or center them. Most of the World Happiness Index variables that we have augmented our data with are continuous variables that would benefit from this treatment. We can accomplish this with mutate, but it would be tedious. Here’s how we might do this:</p><pre>so_joined %&gt;% <br>  mutate(ladder_score   = scale(ladder_score),<br>         social_support = scale(social_support),<br>         generosity     = scale(generosity))</pre><p>We apply the same transformation to each variable within mutate: ladder_score, social_support, and generosity. For each, we are transforming the raw continuous values into z-scores using the scale() function. This is only 3 variables of the 18 variables that need transformation. Besides being tedious, this approach is error prone.</p><p>A solution is to utilize colwise transformations by using the <a href="https://dplyr.tidyverse.org/reference/across.html">across</a>() function. The across() function can be utilized inside mutate() or summarize() in order to apply the same transformation to multiple columns simultaneously. Here is how the same code as above can be applied to all 18 of the continuous variables from the World Happiness Index.</p><pre>so_scoped &lt;- <br>  so_joined %&gt;% <br>  mutate(across(.cols = ladder_score:dystopia_residual, <br>                .fns = scale))</pre><p>The across function is placed inside of mutate(). The across() function can accept the same type of tidy helpers as the select() function in the .cols parameter. In this case, we selected all of the columns from ladder_score to dystopia_residual by using ladder_score:dystopia_residual. The .fns parameter accepts a function which is then applied to all of the columns. This solution is simpler and significantly less error prone.</p><h4>Level 6: Nesting</h4><p>If we are aiming to predict whether or not a respondent is satisfied with their job, we might also be interested in understanding what drives that decision across different regions of the world. In a typical modeling process, we would accomplish this by creating an individual model for each world region. This might involve subsetting the data as an additional layer of data prep work. That might look something like this:</p><pre>so_western_europe &lt;- <br>  so_scoped %&gt;% <br>  filter(regional_indicator == &quot;Western Europe&quot;)</pre><pre>so_na_anz &lt;- <br>  so_scoped %&gt;% <br>  filter(regional_indicator == &quot;North America and ANZ&quot;)</pre><pre>so_s_asia &lt;- <br>  so_scoped %&gt;% <br>  filter(regional_indicator == &quot;South Asia&quot;)</pre><p>If we want to build a model for each region of the world in this way, then we would have to individually subset the data for each region. We would then need to go through the modeling process for each region after that. This presents a similar problem to transforming multiple columns — it is error prone and tedious.</p><p>In order to solve this problem, we must introduce the concept of “list columns”. Instead of storing types of data in columns — integers, doubles, strings, or logicals — we instead create a column of type <em>list</em>. This can be accomplished with the <a href="https://tidyr.tidyverse.org/reference/nest.html?q=nest">nest</a>() function (and then undone later with the unnest() function. This dramatically simplifies the process of subsetting the data for each region. Here is what this looks like in practice:</p><pre>so_nested &lt;- <br>  so_scoped %&gt;% <br>  group_by(regional_indicator) %&gt;% <br>  nest()</pre><p>The output of this ends up looking like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*-g2pr1zFqje8RiMJutcTgg.png" /></figure><p>The data frame has been reduced to one row per regional_indicator with an additional column called data, which is of type list. We can see that each observation of data is &lt;tibble&gt;. If we explored each &lt;tibble&gt;, we would find that each is extremely similar to our original data frame with two key differences:</p><ol><li>It is subset to only the observations from the respective regional_indicator.</li><li>It contains every original column with the exception of regional_indicator.</li></ol><p>We can prove this to ourselves using the pluck() function from the purrr package, which provides us with a convenient way of “plucking” data from a nested list structure.</p><pre>so_nested %&gt;% <br>  pluck(2, 1)</pre><p>Manipulating the data in this way gives us an excellent framework for building many models at once. We now just need a set of tools to build models (or anything else!) from this framework.</p><h4>Level 7: Mapping</h4><p>To take full advantage of the nest() paradigm, which takes advantage of lists, we need better tools for working with lists. Those tools are provided by the purrr package. The purrr package expands on R’s natural strength in functional programming. The star of the package is <a href="https://purrr.tidyverse.org/reference/map">map</a>(), which allows us to apply the same function to each element of a list. There are many variants to the map() function, such as map_lgl(), map_int(), map_dbl(), and map_chr(). These are particularly useful when it is important to induce whatever is being returned from a function as a particular type (logical, integer, double, and character respectively).</p><p>Here is a simple example of map() being paired with mutate(). Pretend that we want to get a count of how many records are in each of our subset tibbles after using nest(). The map_dbl() function makes this trivial.</p><pre>so_nested %&gt;% <br>  mutate(row_count = map_dbl(.x = data, .f = nrow))</pre><p>The output of this is a data frame with an additional column called row_count. It was created by iterating over the tibbles in the data list column and applying the function nrow() to each tibble. These are represented by the parameters .x and .f respectively. Because we used map_dbl() as opposed to map(), it forced the row_count column to be type double instead of type list (which is what would have happened if we used map() instead).</p><p>We can use the power of map() for much less trivial exercises. In preparation for modeling, we may want to set train-test splits for data. Here’s how we would do that:</p><pre>so_nested %&gt;% <br>  mutate(train = map(.x = data, <br>                     .f = slice_sample, <br>                     prop = .75))</pre><p>This is very similar to our last example. We paired map() with mutate() and applied the slice_sample() function to every tibble in the list column called data. The key difference is that there is now an additional parameter, prop = .75. The map() function (and its variants) can all accept additional parameters to be passed along to the function being applied across the list. In this case, prop = .75 is indicating that we want to randomly sample 75% of the observations to be included in the newly created train column.</p><p>Putting it all together, we can also create list columns for our test data and even for the model. We’ll use other variants of map() in order to facilitate this:</p><pre>so_mapped &lt;- <br>  so_nested %&gt;% <br>  mutate(train = map(.x = data, <br>                     .f = slice_sample, <br>                     prop = .75),<br>         test = map2(.x = data, <br>                     .y = train, <br>                     .f = anti_join, <br>                     by = &quot;Respondent&quot;),<br>         model = map(.x = data, <br>                     ~rpart::rpart(formula = JobSat ~ ., <br>                                   data = .x, <br>                                   minbucket = 50)))</pre><p>The way that test and model are created each represent slightly different ways to utilize the map() function.</p><p>test is created in a similar way to train, but utilizes <a href="https://purrr.tidyverse.org/reference/map2">map2</a>(). This function is one of several that allow us to iterate over multiple list columns at the same time. Notice that map2() includes parameters for .x <em>and</em> .y. This is necessary because the <a href="https://dplyr.tidyverse.org/reference/filter-joins.html">anti_join</a>() function <em>requires</em> two arguments, x and y, in order to work.</p><p>model is built slightly differently, using a formula instead. This is indicated by the ~. Notice how this looks more like a traditional function call, with parameters for rpart() listed in parentheses: formula, data, and minbucket. Also notice the .x inside the rpart() function: data = .x. This is directly referencing the field that we use in the first part of the map() function, .x = data. After applying these steps, our data frame now looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iFpBKtoaKALvEnFYi1NJwg.png" /></figure><p>In particular, it is interesting to notice the model column. While it is still a list column, instead of containing a &lt;tibble&gt;, it contains the output of our model as an &lt;S3: rpart&gt; object. In fact, we can contain any type of object in a list column — from a modeling object to a ggplot2 object. This unlocks many powerful ways for us to interact with our data moving forward.</p><h4>Wrapping Up</h4><p>In these two articles, we explored how we can use a variety of tools from the tidyverse in order to manipulate our data. We went through a sample analysis that allowed us to use simple techniques like select() and filter() and more complex techniques like map() and nest(). Every data analysis will require different tools, but understanding each of the 7 levels presented here will help you to learn and use those techniques more effectively.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3809f10909a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/compassred-data-blog/7-levels-of-data-manipulation-with-the-tidyverse-part-2-f3809f10909a">7 Levels of Data Manipulation with the tidyverse: Part 2</a> was originally published in <a href="https://medium.com/compassred-data-blog">CompassRed Data Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>