<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Joseph Nelson on Medium]]></title>
        <description><![CDATA[Stories by Joseph Nelson on Medium]]></description>
        <link>https://medium.com/@josephofiowa?source=rss-690e8d667b35------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*VrN6twMjXhVMdaXh5MKB5Q.png</url>
            <title>Stories by Joseph Nelson on Medium</title>
            <link>https://medium.com/@josephofiowa?source=rss-690e8d667b35------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 01:22:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@josephofiowa/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Training a TensorFlow Faster R-CNN Object Detection Model on Your Own Dataset]]></title>
            <link>https://medium.com/data-science/training-a-tensorflow-faster-r-cnn-object-detection-model-on-your-own-dataset-b3b175708d6d?source=rss-690e8d667b35------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3b175708d6d</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Joseph Nelson]]></dc:creator>
            <pubDate>Mon, 16 Mar 2020 04:26:54 GMT</pubDate>
            <atom:updated>2020-03-16T04:36:55.702Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Following this tutorial, you only need to change two lines of code to train an object detection model to your own dataset.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y75PN1lj2X5djEf2PdmLiw.png" /><figcaption>Finding red blood cells, white blood cells, and platelets!</figcaption></figure><p>Computer vision is revolutionizing medical imaging. Algorithms are<a href="https://blog.google/technology/health/improving-breast-cancer-screening/"> helping doctors identify</a> one in ten cancer patients they may have missed. There are even <a href="https://twitter.com/jeremyphoward/status/1237378225497452550">early indications</a> chest scans can aid in COVID-19 identification, which may help determine which patients require lab-based testing.</p><p>To that end, in this example, we’ll walk through training an object detection model using the TensorFlow object detection API. While this tutorial describes training a model on medical imaging data, it can be easily adapted to <em>any</em> dataset with very few adaptations.</p><blockquote>Impatient? Skip directly to the Colab Notebook <a href="https://colab.research.google.com/drive/1U3fkRu6-hwjk7wWIpg-iylL2u5T9t7rr#scrollTo=uQCnYPVDrsgx">here</a>.</blockquote><p>The sections of our example are as follows:</p><ul><li>Introducing our dataset</li><li>Preparing our images and annotations</li><li>Creating TFRecords and Label Maps</li><li>Training Our Model</li><li>Model Inference</li></ul><p>Throughout this tutorial, we’ll make use of <a href="https://roboflow.ai/">Roboflow</a>, a tool that dramatically simplifies our data preparation and training process. Roboflow is free for small datasets, so we’ll be all set for this example!</p><h4><strong>Our Example Dataset: Blood Cell Count and Detection (BCCD)</strong></h4><p>Our <a href="https://public.roboflow.ai/object-detection/bccd">example dataset</a> is 364 images of cell populations and 4888 labels identifying red blood cells, white blood cells, and platelets. Originally open sourced two years ago by <a href="https://github.com/cosmicad/dataset">comicad</a> and <a href="https://github.com/akshaylamba/all_CELL_data">akshaymaba</a>, and available at <a href="https://public.roboflow.ai/">https://public.roboflow.ai</a>. (Note the version hosted on Roboflow includes minor <a href="https://blog.roboflow.ai/releasing-an-improved-blood-count-and-cell-detection-dataset/">label improvements</a> versus the original release.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6i74JQU7ndkck9JSqNXvMA.png" /><figcaption>Screenshot via <a href="https://public.roboflow.ai/object-detection/bccd">Roboflow Public</a>.</figcaption></figure><p>Fortunately, this dataset comes pre-labeled, so we can jump right into preparing our images and annotations for our model.</p><p>Knowing the presence and ratio of red blood cells, white blood cells, and platelets for patients is key to identifying potential maladies. Enabling doctors to increase their accuracy and throughput of identifying said blood counts can massively improve healthcare for millions!</p><p><em>For your custom data, </em>consider collecting images from <a href="https://www.pyimagesearch.com/2017/12/04/how-to-create-a-deep-learning-dataset-using-google-images/">Google Image search in an automated fashion</a> and labelling them using a free tool like <a href="https://github.com/tzutalin/labelImg">LabelImg</a>.</p><h4><strong>Preparing Our Images and Annotations</strong></h4><p>Going straight from data collection to model training leads to suboptimal results. There may be problems with the data. Even if there aren’t, applying image augmentation expands your dataset and reduces overfitting.</p><p>Preparing images for object detection includes, but is not limited to:</p><ul><li>Verifying your annotations are correct (e.g. none of the annotations are out of frame in the images)</li><li>Ensuring the EXIF orientation of your images is correct (i.e. your images are stored on disk differently than how you view them in applications, see more)</li><li>Resizing images and updating image annotations to match the newly sized images</li><li>Checking the health of our dataset, like its class balance, images sizes, and aspect ratios — and determining how these might impact preprocessing and augmentations we want to perform</li><li>Various color corrections that may improve model performance like grayscale and contrast adjustments</li></ul><p>Similar to tabular data, cleaning and augmenting image data can improve your ultimate model’s performance more than architectural changes in your model.</p><p>Let’s take a look at the “<a href="https://public.roboflow.ai/object-detection/bccd/health">Health Check</a>” of our dataset:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HxF2tghQcQdWjU_4nAnUlw.png" /><figcaption>Available <a href="https://public.roboflow.ai/object-detection/bccd/health">here</a>.</figcaption></figure><p>We can clearly see we have a large class imbalance present in our dataset. We have significantly more red blood cells than white blood cells or platelets represented in our dataset, which may cause issues with our model training. Depending on our problem context, we may want to prioritize the identification of one class over another as well.</p><p>Moreover, our images are all the same size, which makes our <a href="https://blog.roboflow.ai/you-might-be-resizing-your-images-incorrectly/">resize</a> decision easier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*q2shQSdHJhmiYSapyp6Mzw.gif" /><figcaption>Available <a href="https://public.roboflow.ai/object-detection/bccd/health">here</a>.</figcaption></figure><p>When examining how our objects (cells and platelets) are distributed across our images, we see our red blood cells appear all over, our platelets are somewhat scattered towards the edges, and our white blood cells are clustered in the middle of our images. Given this, we may want to be weary of cropping the edges of our images when detecting RBC and platelets, but should we just be detecting white blood cells, edges appear less essential. We also want to check that our training dataset is representative of how our out-of-sample images. For example, can we expect white blood cells to commonly be centered in newly collected data?</p><p><em>For your custom dataset,</em> upload your images and their annotations to Roboflow following this simple <a href="https://blog.roboflow.ai/getting-started-with-roboflow/">step-by-step guide</a>.</p><h4><strong>Creating TFRecords and Label Maps</strong></h4><p>We’ll be using a TensorFlow implementation of Faster R-CNN (more on that in a moment), which means we need to generate TFRecords for TensorFlow to be able to read our images and their labels. <a href="https://www.tensorflow.org/tutorials/load_data/tfrecord">TFRecord</a> is a file format that contains both our images and their annotations. It’s serialized at the dataset-level, meaning we create one set of records for our training set, validation set, and testing set. We’ll also need to create a label_map, which maps our label names (RBC, WBC, and platelets) to numbers in a dictionary format.</p><p>Frankly, TFRecords are a little cumbersome. As a developer, your time should be focused on fine tuning your model or the business logic of using your model rather than writing redundant code to generate file formats. So, we’ll use Roboflow to generate our TFRecords and label_map files for us with a few clicks.</p><p>First, visit the dataset we’ll be using here: <a href="https://public.roboflow.ai/object-detection/bccd/1">https://public.roboflow.ai/object-detection/bccd/1</a> (Note we’re using a specific version of the dataset. Images have been resized to 416x416.)</p><p>Next, click “Download.” You may be prompted to create a free account with email or GitHub.</p><p>When downloading, you can download in a variety of formats and download either locally to your machine, or generate a code snippet. For our purposes, we want to generate TFRecord files and create a download code snippet (not download files locally).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*VRsyPsCB528oObx9Bs9K5w.gif" /><figcaption>Export our dataset.</figcaption></figure><p>You’ll be given a code snippet to copy. That code snippet contains a link to your source images, their labels, and a label map split into train, validation, and test sets. Hang on to it!</p><p><em>For your custom dataset,</em> if you followed the <a href="https://blog.roboflow.ai/getting-started-with-roboflow/">step-by-step guide</a> from uploading images, you’ll have been prompted to create train, valid, test splits. You’ll also be able to export your dataset to any format you need.</p><h4><strong>Training Our Model</strong></h4><p>We’ll be training a Faster R-CNN neural network. Faster R-CNN is a two-stage object detector: first it identifies regions of interest, and then passes these regions to a convolutional neural network. The outputted features maps are passed to a support vector machine (VSM) for classification. Regression between predicted bounding boxes and ground truth bounding boxes are computed. Faster R-CNN, despite its name, is known as being a slower model than some other choices (like YOLOv3 or MobileNet) for inference but slightly more accurate. For a deeper dive, consider this <a href="https://towardsdatascience.com/faster-r-cnn-object-detection-implemented-by-keras-for-custom-data-from-googles-open-images-125f62b9141a">post</a> for more!</p><p>Faster R-CNN is one of the many model architectures that the TensorFlow Object Detection API provides by default, including with pre-trained weights. That means we’ll be able to initiate a model trained on COCO (common objects in context) and adapt it to our use case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QT7ZPCVpGsSNRjge8LQoMQ.png" /><figcaption>Take advantage of the TensorFlow model zoo. (<a href="https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md#coco-trained-models">Source</a>)</figcaption></figure><p>TensorFlow even <a href="https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/detection_model_zoo.md#coco-trained-models">provides</a> dozens of pre-trained model architectures on the COCO dataset.</p><p>We’ll also be taking advantage of Google Colab for our compute, a resource that provides free GPUs. We’ll take advantage of Google Colab for free GPU compute (up to 12 hours).</p><p><strong>Our Colab Notebook is </strong><a href="https://colab.research.google.com/drive/1U3fkRu6-hwjk7wWIpg-iylL2u5T9t7rr#scrollTo=uQCnYPVDrsgx"><strong>here</strong></a><strong>. The GitHub repository from which this is based is </strong><a href="https://github.com/roboflow-ai/tensorflow-object-detection-faster-rcnn"><strong>here</strong></a><strong>.</strong></p><p>You need to be sure to update your code snippet where the cell calls for it with your own Roboflow exported data. Other than that, the notebook trains as-is!</p><p>There are a few things to note about this notebook:</p><ul><li>For the sake of running an initial model, the number of training steps is constrained to 10,000. Increase this to improve your results, but be mindful of overfitting!</li><li>The model configuration file with Faster R-CNN includes two types of data augmentation at training time: random crops, and random horizontal and vertical flips.</li><li>The model configuration file default batch size is 12 and the learning rate is 0.0004. Adjust these based on your training results.</li><li>The notebook includes an optional implementation of TensorBoard, which enables us to monitor the training performance of our model in real-time.</li></ul><p>In our example of using BCCD, after training for 10,000 steps, we see outputs like the following in TensorBoard:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*xgtN-tkflRVCuWU-Labzow.png" /><figcaption>Our loss, in general, continues to fall after 10,000 epochs.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BjyQX4DIXSvccsj5HIK8dA.png" /><figcaption>We’re finding the right boxes, but we risk overfitting.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Nlt1zSymWJzhkIhsiZ7pw.png" /><figcaption>Recall may indicate a similar overfitting story.</figcaption></figure><p>In this example, we should consider collecting or generating more training data and making use of greater data augmentation.</p><p><em>For your custom dataset</em>, these steps will be largely identical as long as you update your Roboflow export link to be specific to your dataset. Keep an eye on your TensorBoard outputs for overfitting!</p><h4><strong>Model Inference</strong></h4><p>As we train our model, its fit is stored in a directory called ./fine_tuned_model. There are steps in our notebook to save this model fit — either locally downloaded to our machine, or via connecting to our Google Drive and saving the model fit there. Saving the fit of our model not only allows us to use it later in production, but we could even resume training from where we left off by loading the most recent model weights!</p><p>In this specific notebook, we need to add raw images to the /data/test directory. It contains TFRecord files, but we want raw (unlabeled) images for our model to make predictions.</p><p>We should upload test images that our model hasn’t seen. To do so, we can download the raw test images from Roboflow to our local machines, and add those images to our Colab Notebook.</p><p>Revisit our dataset download page: <a href="https://public.roboflow.ai/object-detection/bccd/1">https://public.roboflow.ai/object-detection/bccd/1</a></p><p>Click download. For format, select COCO JSON and download locally to your own computer. (You can actually download any format that isn’t TFRecord to get raw images separate from annotation formats!)</p><p>Once unzipping this file locally, you’ll see the test directory raw images:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*chV_TzdzPlP1FAVqMCgGXg.png" /></figure><p>Now, in the Colab notebook, expand the left hand panel to show the test folder:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*Ph7kTQjlqWofH5yH5PbHDQ.png" /></figure><p>Right click on the “test” folder and select “Upload.” Now, you can select all the images from your local machine that you just downloaded!</p><p>Inside the notebook, the remainder of the cells go through how to load the saved, trained model we created and run them on the images you just uploaded.</p><p>For BCCD, our output looks like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*iIOJNd3u6nPpGax6ZWopxA.gif" /><figcaption>Our model does pretty well after 10,000 epochs!</figcaption></figure><p><em>For your custom dataset</em>, this process looks very similar. Instead of downloading images from BCCD, you’ll download images from your own dataset, and re-upload them accordingly.</p><h4><strong>What’s Next</strong></h4><p>You’ve done it! You’ve trained an object detection model to a custom dataset.</p><p>Now, making use of this model in production begs the question of identifying what your production environment will be. For example, will you be running the model in a mobile app, via a remote server, or even on a Raspberry Pi? How you’ll use your model determines the best way to save and convert its format.</p><p>Consider these resources as the next steps based on your problem: converting to <a href="https://github.com/peace195/tensorflow-lite-YOLOv3">TFLite</a> (for Android and iPhone), converting to <a href="https://github.com/Ma-Dan/YOLOv3-CoreML">CoreML</a> (for iPhone apps), converting for use on a remote server, or deploying to a <a href="http://funofdiy.blogspot.com/2018/08/deep-learning-with-raspberry-pi-real.html">Raspberry Pi</a>.</p><p>Also, <a href="http://eepurl.com/gIRP6f">subscribe to Roboflow updates</a> to be the first to know when we publish more content like this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3b175708d6d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/training-a-tensorflow-faster-r-cnn-object-detection-model-on-your-own-dataset-b3b175708d6d">Training a TensorFlow Faster R-CNN Object Detection Model on Your Own Dataset</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Training a YOLOv3 Object Detection Model with a Custom Dataset]]></title>
            <link>https://medium.com/data-science/training-a-yolov3-object-detection-model-with-a-custom-dataset-4981fa480af0?source=rss-690e8d667b35------2</link>
            <guid isPermaLink="false">https://medium.com/p/4981fa480af0</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Joseph Nelson]]></dc:creator>
            <pubDate>Thu, 09 Jan 2020 17:43:27 GMT</pubDate>
            <atom:updated>2020-02-11T03:34:37.240Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Following this guide, you only need to change a single line of code to train an object detection model to your own dataset. </em><a href="https://blog.roboflow.ai/training-a-yolov3-object-detection-model-with-a-custom-dataset/"><em>Story published here too</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*y13Ie2-DI2LVvtflWzEoOA.gif" /><figcaption>In our guided example, we’ll train a model to recognize chess pieces. (Full <a href="https://www.youtube.com/watch?v=XLispu-Yb_0">video</a>)</figcaption></figure><p><em>Impatient? </em><a href="https://colab.research.google.com/drive/1ByRi9d6_Yzu0nrEKArmLMLuMaZjYfygO#scrollTo=WgHANbxqWJPa"><em>Skip to the Colab Notebook.</em></a></p><p>Object detection models are extremely powerful — from finding dogs in photos to <a href="https://arxiv.org/pdf/1702.05747.pdf">improving healthcare</a>, training computers to recognize which pixels constitute items unlocks near limitless potential. However, one of the biggest blockers keeping new applications from being built is adapting state-of-the-art, open source, and free resources to custom problems.</p><p>In this post, we’ll walk through how to prepare a custom dataset for object detection using tools that simplify image management, architecture, and training. In each section, we’ll first follow what I’ve done for a specific example and then detail what modifications you’ll need to make for your custom dataset. My recommendation is that you follow along step-by-step to duplicate my process before adapting these steps to your problem.</p><p>Let’s start with a clear description of our process.</p><p>Any given machine learning problem begins with a well-formed problem statement, data collection and preparation, model training and improvement, and inference. Often, our process is not strictly linear. For instance, we may find our model performs very poorly on one type of image label, and we need to revisit collecting more data on that example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UFEaEvlewluL-5yFRK9FMA.png" /><figcaption><em>The general machine learning workflow.</em></figcaption></figure><h3>Problem Statement</h3><p>Chess is a fun game of wit and strategy. Improving your playing ability requires understanding where you’ve previously made notable mistakes and what move(s) a superior player to you may have made in the same situation.</p><p>Thus, having a system that recognizes the state of the game and records each move would be valuable. This requires not just determining what a given chess piece is, but where that piece is on the board — a leap from image recognition to object detection. For the purposes of this post, we will constrain the problem to focus on the object detection portion: can we train a model to identify which chess piece is which and to which player (black or white) the pieces belong, and a model that finds at least half of the pieces in inference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S_fpaziibYAsh6lcQT_imw.png" /><figcaption><em>Image Processing Problems, adapted from Stanford’s </em><a href="http://cs231n.stanford.edu/slides/2016/winter1516_lecture8.pdf"><em>CS231N course</em></a></figcaption></figure><p><em>For your non-chess problem statement</em>, consider constraining the problem space to a specific piece. Moreover, consider the minimal acceptable criteria for the model’s performance. (In this example, we are constraining to just the identification of correct bounding boxes, and seting a relatively low bar for acceptable criteria. To be more rigorous, we may want to identify our model’s <a href="https://giou.stanford.edu/">IOU</a> or <a href="https://medium.com/@jonathan_hui/map-mean-average-precision-for-object-detection-45c121a31173">mAP</a> — but that is for a different post.)</p><h3>Data Collection</h3><p>To identify chess pieces, we need to collect and annotate chess images.</p><p>I made a few assumptions in my data collection. First, all my images were captured from the same angle. I set up a tripod on the table near my chess board. For inference, this would require that my camera is at the same angle as the training data was captured — and not all chess players may be setting up tripods before their games. Second, I created 12 different classes: one for each of the six pieces times the two colors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gZvaKeOK91Vvu5wWZwu2qg.jpeg" /><figcaption>An (unlabeled) image example from our dataset.</figcaption></figure><p>Ultimately, I collected 292 images. I labeled all the pieces in each of these images, totaling 2894 annotations. This dataset is publicly available <a href="https://public.roboflow.ai/">here</a>. For labelling, there are many high quality, free, and open source tools available like <a href="https://github.com/tzutalin/labelImg">LabelImg</a>. I happened to use <a href="https://rectlabel.com/">RectLabel</a>, which is $3/month.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g7A8lIfWNFqN1D_FEih-XA.png" /><figcaption><em>An example image I labeled in RectLabel.</em></figcaption></figure><p><em>For your non-chess problem</em>, consider collecting images that are in-context of where your model will perform in production. This means ensuring you have a similar angles, lighting, quality, and objects in frame. The more situations your training set takes into account that your model may encounter in production, the better its performance will be. When labelling, it is best to draw bounding boxes that include the entirety of your objects, even if there’s a small amount of space between the object and the bounding box. Simply put, do not cut out any of the underlying object with your bounding boxes. If one piece blocks view (occludes) that of another, label as though you could see the full object (see the white-bishop and white-rook example above).</p><p>If you’re seeking already annotated images, consider object detection datasets on sites like <a href="https://public.roboflow.ai/">Roboflow</a> or <a href="https://www.kaggle.com/tags/object-detection">Kaggle</a>.</p><h3>Data Preparation</h3><p>Going straight from data collection to model training leads to suboptimal results. There may be problems with the data. Even if there aren’t, applying image augmentation expands your dataset and reduces overfitting.</p><p>Preparing images for object detection includes, but is not limited to:</p><ul><li>Verifying your annotations are correct (e.g. none of the annotations are out of frame in the images)</li><li>Ensuring the EXIF orientation of your images is correct (i.e. your images are stored on disk differently than how you view them in applications, <a href="https://news.ycombinator.com/item?id=21207411">see more</a>)</li><li>Resizing images and updating image annotations to match the newly sized images</li><li>Various color corrections that may improve model performance like grayscale and contrast adjustments</li><li>Formatting annotations to match the requirements of your model’s inputs (e.g. generating <a href="https://www.tensorflow.org/tutorials/load_data/tfrecord">TFRecords for TensorFlow</a> or a flat text file for some <a href="https://github.com/qqwweee/keras-yolo3">implementations of YOLO</a>).</li></ul><p>Similar to tabular data, cleaning and augmenting image data can improve your ultimate model’s performance more than architectural changes in your model.</p><p>Roboflow Organize is purpose-built to seamlessly solve these challenges. In fact, Roboflow Organize cuts the code you need to write roughly in half while giving you access to more preprocessing and augmentations options.</p><h3>Vicki Boykis on Twitter</h3><p>Learning PyTorch by doing a project. Which part am I stuck on so far?</p><p>For our specific chess problem, our already preprocessed chess data is available <a href="https://public.roboflow.ai/object-detection/chess-full">here</a>.</p><p>We’ll be working with the Download version titled, “416x416-auto-orient.”</p><p>In the case of our tutorial, we’re using 416x416 images because (1) we want smaller images than the originally captured 2284 × 1529 dimensions for faster training and (2) for YOLOv3, multiples of 32 are most performant for its architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dSIv4pmGpJWt-ljIXL2j4g.png" /><figcaption>Note in this export, our preprocessing includes “Auto-Orient” and “Resize.”</figcaption></figure><p>Our images also have had “auto-orient” applied to them, a Roboflow preprocessing step that strips the EXIF data of unintuitive orientations. Auto-orient is important because images are sometimes stored on disk in different orientations than the applications we use to view them. If left uncorrected, this can cause silent failures in our models (see a discussion on HackerNews <a href="https://news.ycombinator.com/item?id=21207411">here</a>). I recommend leaving this option on by default.</p><p>To download this dataset, select “416x416-auto-orient.” In the upper righthand corner, select “Download.” You’ll be prompted to create a free account, and redirected back to the chess public dataset page.</p><p>Now, Roboflow allows you to download your images and annotations in a variety of formats. You can also download them locally to your computer, or generate a code snippet you can use to download them directly to a Jupyter Notebook (including Colab) or Python script.</p><p>For our problem, we’ll be using a Keras YOLOv3 implementation that calls for a flat text file of annotations. We’ll also be making use of Google Colab for training, so select the “show download code” in the export options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*li6o8KDkS2ZyaVILHel-Lg.png" /><figcaption>These are the options you’ll select for your Download format.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*tasZfSGvDfbPxLsK_tjs9Q.png" /><figcaption>Roboflow generates a code snippet you can drop directly into a Jupyter Notebook, including Colab. Be sure you never share your keys publicly!</figcaption></figure><p><em>For your non-chess problem</em>, you can create a free Roboflow account, upload images, preprocess, augment, and export them to any annotation format your model may require. To do so, follow the <a href="https://www.notion.so/roboflow/Quick-Start-7e9923ae026445f89a714e94d7f33fe0">Quick Start</a>.</p><h3>Model Training</h3><p>The model architecture we’ll use is called YOLOv3, or You Only Look Once, <a href="https://arxiv.org/abs/1804.02767">by Joseph Redmon</a>. This specific model is a one-shot learner, meaning each image only passes through the network once to make a prediction, which allows the architecture to be very performant, viewing up to 60 frames per second in predicting against video feeds. Fundamentally, YOLO divides an image into subcomponents, and conducts convolutions on each of those subcomponents before pooling back to create a prediction. A recommended deeper dive on YOLO is available <a href="http://datahacker.rs/yolov3-tensorflow/">here</a>.</p><p>Now, even though we’re training our model on a custom dataset, it is still advantageous to use another already trained model’s weights as a starting point. Think of this like we want to climb a mountain as quickly as possible, and instead of starting completely from scratch in creating our own trail, we’ll start with assuming that someone else’s trail is a better faster than us randomly trying to guess twists and turns to follow.</p><p>To power our model’s computation, we’ll be using Google Colab, which provides free GPU compute resources (up to 24 hours with your browser open).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ndbyH3_kNMklMPzwUM_Vng.png" /><figcaption>As validation loss drops, our model is improving.</figcaption></figure><p>In our notebook, we are predominantly doing six things:</p><ol><li>Selecting up our environment, model architecture, and pre-fit weights (someone else’s “trail”)</li><li>Loading in our data via the Roboflow code snippet shared above</li><li>Determining our model configuration, like how many epochs to train, training batch sizes, the size of our training vs test set, and our learning rate</li><li>Initiating training (…and waiting!)</li><li>Using our trained model for inference (predictions!)</li><li>(Optional bonus) Save our newly trained weights to our Google Drive so we can make predictions in the future without waiting for training to finish</li></ol><p>Now, make a copy of <a href="https://colab.research.google.com/drive/1ByRi9d6_Yzu0nrEKArmLMLuMaZjYfygO#scrollTo=WgHANbxqWJPa">this Colab Notebook</a>, and continue our tutorial over there.</p><p><em>For your non-chess problem</em>, to train this same architecture, <strong>you only need to change a single URL to train a YOLOv3 model on your custom dataset.</strong> That URL is the Roboflow download URL where we load the dataset into the notebook. Moreover, you can toy with the training parameters as well, like setting a lower learning rate or training for more/fewer epochs.</p><h3>Inference</h3><p>Once our model has finished training, we’ll use it to make predictions. Making predictions requires (1) setting up the YOLOv3 model architecture (2) using the custom weights we trained with that architecture.</p><p>In our notebook, this step takes place when we call the yolo_video.py script. This script accepts a path to either video files or images, custom weights, custom anchors (we did not train any in this example), custom classes, the number of GPUs to use, a flag describing if we’re predicting an image instead of a video, and an output path for the predicted video/image.</p><p>In our case, we’ll call the script with custom weights and custom class names. The script compiles a model, waits for an input to an image file, and provides the bounding box coordinates and class name for any objects it finds. The bounding box coordinates are provided in the format of bottom left-hand corner pixels (mix_x, min_y) and upper right-hand corner pixels (max_x, max_y).</p><p>As an important callout, the custom weights we’re loading in this example are actually not the YOLOv3 architecture’s best. We’ll be loading the “initial_weights” rather than the final trained weights. Due to Colab compute limitations, our model fails to train the final weights. This means our model is not as performant as it could be (as only the backbone architecture of YOLO have been adapted to our problem). On the bright side, it’s free compute!</p><p>Note that you can see the files available to your in your Colab notebook on the left (expand the panel if you have note already by locating the small right arrow below “+Code” and “+Text”). Inside the keras-yolo-3 folder, you can see all the image available to us.</p><p>I recommend trying out these images upon running your predict script to get a sense of our model’s performance:</p><ul><li>00a7a49c47d51fd16a4cbb17e2d2cf86.jpg white-king works! + knight</li><li>015d0d7ff365f0b7492ff079c8c7d56c.jpg black-queen mixes up</li><li>176b28b5c417f39a9e5d37545fca5b4c.jpg finds only five</li><li>4673f994f60a2ea7afdddc1b752947c0.jpg white-rook (thinks king)</li><li>5ca7f0cb1c500554e65ad031190f8e9f.jpg white-pawn (missed white-king)</li><li>fbf15139f38a46e02b5f4061c0c9b08f.jpg black-king success!</li></ul><p>Turn back to the notebook you copied above, and let’s give this script a try.</p><p><em>For your non-chess problem</em>, this step will be largely the same. Be sure to follow the arguments detailed in the notebook if you want to apply this model to a video feed or try different weights. If you’re training in a non-Colab environment that can handle producing the model’s final weights as well, be sure to provide the path to those weights rather than our “initial_weights.” You may consider creating a directory called “predictions” in the notebook or your Google Drive, and writing the results of the model’s predictions there.</p><h3>What’s Next</h3><p>You’ve done it! You’ve trained an object detection model to a chess and/or a custom dataset.</p><p>Now, making use of this model in production begs the question of identifying what your production environment will be. For example, will you be running the model in a mobile app, via a remote server, or even on a Raspberry Pi? How you’ll use your model determines the best way to save and convert its format.</p><p>Consider these resources as next steps based on your problem: converting to <a href="https://github.com/peace195/tensorflow-lite-YOLOv3">TFLite</a> (for Android and iPhone), converting to <a href="https://github.com/Ma-Dan/YOLOv3-CoreML">CoreML</a> (for iPhone apps), converting for use on a remote server, or deploying to a <a href="http://funofdiy.blogspot.com/2018/08/deep-learning-with-raspberry-pi-real.html">Raspberry Pi</a>.</p><p><em>Want more?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q-cgKPoKyN79LqRSQimSYg.gif" /><figcaption>Join the Roboflow community for object detection discussion!</figcaption></figure><p><a href="http://eepurl.com/gIRP6f">Subscribe to Roboflow updates</a> to be the first to know when we publish more content like this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4981fa480af0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/training-a-yolov3-object-detection-model-with-a-custom-dataset-4981fa480af0">Training a YOLOv3 Object Detection Model with a Custom Dataset</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BetaVector]]></title>
            <link>https://medium.com/@josephofiowa/betavector-c02237891442?source=rss-690e8d667b35------2</link>
            <guid isPermaLink="false">https://medium.com/p/c02237891442</guid>
            <category><![CDATA[business]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[consulting]]></category>
            <dc:creator><![CDATA[Joseph Nelson]]></dc:creator>
            <pubDate>Wed, 02 Oct 2019 16:05:33 GMT</pubDate>
            <atom:updated>2019-10-02T16:27:19.108Z</atom:updated>
            <content:encoded><![CDATA[<p>I hired my friend to do my job better (again)</p><p><em>Want a tl;dr? Scroll to the bottom.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kBNUsmvWxCZgotdJDzCPnA.png" /><figcaption>BetaVector is the new ROC AUC, LLC.</figcaption></figure><p>After selling my last company, <a href="https://represently.com/">Represently</a>, it became clear that one of the biggest value adds we provided to the acquirer wasn’t just our technology or dedication to solving similar problems. It was our excitement to bring a fresh, data-driven product perspective to an existing product suite. What mountain of training data are we sitting on but not leveraging? How can we use recommendations to make our products easier to use? What data could be visualized more meaningfully to ensure our customers reached their goals? There were many places to make advances — simply through bringing a fresh perspective.</p><p>It was this realization that led me to subsequently start <a href="https://rocauc.com/">ROC AUC, LLC</a> last year, a consultancy whose mission was to deliver value predominantly through building prototypes of machine learning products. And fast. Nearly every company is sitting on hundreds of opportunities to dramatically decrease costs, to improve efficiency, and to better serve their users with existing data. It is often competing priorities, a need for data talent, and a lack of data experience creating a gap between expected results and what actually happens. ROC AUC, LLC filled that gap.</p><p>For me, personally, ROC AUC, LLC represented two things: (1) the opportunity to swiftly advance machine learning within a wide array of use cases and (2) the chance to build data products in new industries. After all, Represently was born out of a problem I faced first-hand: the US Congress needed to scale its ability to respond to ten million inbound messages per year, and you could only hire so many mail-sorting interns. <em>(Aside: </em><a href="https://www.fireside21.com/hubfs/How%20Fireside%20is%20Leveraging%20Machine%20Learning%20to%20Improve%20the%20US%20Congress%20(1).pdf"><em>here’s</em></a><em> more about how Represently and Fireside tackled that problem.)</em> Starting a consulting practice represented the opportunity to experience many new problems first-hand, ultimately to create products in new verticals.</p><p>Excitingly, ROC AUC, LLC’s mission to quickly build data products driving ROI resonated. Not just with companies, but with other data scientists eager to make an impact. So we evolved.</p><h3>Today, I’m announcing BetaVector, the next step in ROC AUC, LLC’s evolution.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kGmS5nqLJTIXtqP7O6WBgQ.png" /><figcaption>Our logo combines a beta ( β ) and a vector ( ⬈ ).</figcaption></figure><p><a href="https://betavector.com/">BetaVector</a> launches with the mission of advising on, educating about, and building out data solutions. We’re equally connecting practicing data scientists to problems of their choice.</p><p>I’ve wanted a better marketplace where companies could easily, flexibly, and transparently contract top data scientists on high impact problems. Like an AWS for machine learning expertise. Companies get a scarce resource that unlocks significant value on data they already have. Data scientists gain exposure to new problems and markets. So I built one.</p><p>To that end, I’m excited to share <a href="http://argmatt.com/">Matthew Brems</a>, a close friend and previous coworker, will be leading BetaVector as a Managing Partner. Matt brings a wealth of data science experience. He has consulted on data strategy for Presidential and Senate campaigns. He’s built machine learning models forecasting consumer behavior for Fortune 500 companies. He’s trained nearly a thousand individuals to become productive data scientists and was recently recognized as the top instructor (of over a global network of 20,000) at General Assembly. And he’s already been instrumental in serving our clients.</p><p>I’ll continue to guide BetaVector as its founder and as a Managing Partner. Matt’s addition solidifies our transition to being one step closer to a ‘marketplace’ for data talent. And I, personally, can focus on productizing learnings I’ve had in the last year into something new. (Stay tuned for that…)</p><blockquote>For data scientists, BetaVector is like the best of UpWork — compelling work at preferred rates on challenging problems of their choice with transparent partners. This applies to Matt and myself, too; we simply happen to have the additional responsibility of managing the marketplace. (<a href="https://betavector.com/#contact">Reach out</a> if you’d like to be included.)</blockquote><p>For companies, BetaVector refines the ROC AUC, LLC model:</p><p>• <strong>We advise</strong> companies in standing up, improving, and scaling their team’s data practice.<br>• <strong>We educate</strong> on our work and our clients’ opportunities by emphasizing clarity, fluency, and self-sufficiency in our deliverables and methods.<br>• <strong>We build</strong> data products from scratch, create proof-of-concepts, and iterate on existing products. We emphasize reproducibility and interpretability.</p><p>And, for the fans, ROC AUC, LLC itself isn’t disappearing: it built and owns IP that is separate from BetaVector’s consulting practice. e.g. Products like <a href="https://80acres.co/">predicting farm valuations</a> continue under the ROC AUC, LLC banner.</p><p>Years ago, Matt joined my team at General Assembly to train people to develop the skills needed in data science careers. We advised students on their data careers and colleagues on standing up data cohorts in new markets. We have taught over 10,000 hours of data science while pushing customer satisfaction to new highs at GA. We built out aspects of the business, including new curriculum, employer-student partnerships, and enterprise offerings.</p><p>In a sense, the last time I hired Matt, he took my role and did it better than I ever could. I can’t wait to make the same thing happen for our clients that we advise, educate, and build with at BetaVector.</p><p><em>Too long, didn’t read —</em></p><p><em>My consulting business, ROC AUC, LLC, is now BetaVector, and Matt is joining to help lead. ROC AUC, LLC continues to own the IP of non-consulting products made over the last year. I’m, personally, creating flexibility to build new products beyond consulting. Stay tuned…</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c02237891442" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What I’ve Learned from Teaching 1,960 Hours of Data Science]]></title>
            <link>https://medium.com/@josephofiowa/what-ive-learned-from-teaching-1-960-hours-of-data-science-342031916e8?source=rss-690e8d667b35------2</link>
            <guid isPermaLink="false">https://medium.com/p/342031916e8</guid>
            <category><![CDATA[teaching]]></category>
            <category><![CDATA[management]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[leadership]]></category>
            <category><![CDATA[education]]></category>
            <dc:creator><![CDATA[Joseph Nelson]]></dc:creator>
            <pubDate>Fri, 26 May 2017 20:14:46 GMT</pubDate>
            <atom:updated>2018-03-21T03:11:15.623Z</atom:updated>
            <content:encoded><![CDATA[<h4>Everyone is learning. Some are further ahead in the process.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xi9gaxJrKDvtMiHU0UEV8g.jpeg" /></figure><p>Nearly 2,000 hours later, and I still don’t consider myself a teacher. Rather, to me, “teaching” is a lively and constant show-and-tell of the unending potential data science unlocks.</p><p>That’s why I struggle to say goodbye to being a full-time educator.</p><p>I’ve been fortunate to be a part of the instructional staff for <a href="https://generalassemb.ly/education/data-science-immersive?utm_medium=social&amp;utm_source=blog&amp;utm_campaign=josephdsi">General Assembly’s Data Science Immersive</a> for a little over a year, which is better measured by four 12-week, intense cohorts. While I started as a lowly night-time TA, an opportunity came for GA to trust me to lead the program. I’m incredibly proud of our team: we transformed our operation to become one of the company’s best (and still hold an internal record for student satisfaction!).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*wwv0Nx8hwkurOqh6pEtOfg.png" /></figure><p>But I’m even more proud of the students and co-instructors with whom I worked. Understanding GA’s model is requisite to empathize with and celebrate them. In exchange for a new career as a data scientist, GA asks that individuals devote themselves entirely to learning data science. Students hail from all backgrounds — college new grads, PhDs in Chemical Engineering, Ivy League degrees, and even those without bachelor’s degrees — and quit their full-time job to change their career in the span of a three-month window, thereby often foregoing both stable income and tremendous amounts of leisure time.</p><p>Instructors are, thus, placed at the nexus of one’s future aspirations. Anticipating a career transformation, students place their full trust in those at the front of the classroom. It is these stakes that drove me to give my students my absolute best self. (In fact, I never took a vacation day in my time here, even when I had time between cohorts, as I found there to always be something I could do to better serve learners. I should emphasize that was an entirely voluntary choice, and perhaps to GA’s dismay. <a href="https://media.giphy.com/media/2L4YDs59H7ssM/giphy.gif">I regret nothing</a>.)</p><p>Given the uniqueness of the position, I learned a number of valuable ideals, all of which are described to be applicable for leaders well beyond teaching and data science. Sharing a few of them here is actually one way by which I plan to have a useful log for my future self.</p><h3>Audience = Accountability</h3><blockquote>(You Don’t Know It Till you Teach It)</blockquote><p>You know something. But do you know it well enough to explain it to a complete novice? What about a seasoned professional in the field? And both of them at the same time for two hours in which more detail may be required on any minutia? Now add an uncompromising deadline of a week-away 10:00 AM lecture.</p><p>Teaching forced me to take topics with which I was comfortable and humble myself to realize I only know them with, say, 80 percent completeness. When faced with an eager class (whose career depends on clear delivery), I had a built-in accountability mechanism to go the extra mile to guarantee understanding. For instructors, it is estimated every in class hour takes three to four out of class hours or prep, even for proficient topics, to assure completeness in a lesson. When was the last time you treated all your work with four times the level of scrutiny and swiftness to improve?</p><blockquote>Creating accountability mechanisms — whether via peers or honest self-deadlines — is requisite to sustained high performance.</blockquote><h3>It’s All About Slope, Not Y-Intercept</h3><p>I repeatedly told my students that I placed little emphasis on their educational background’s subject area and instead cared about their propensity to want to learn more in this moment. Even if a student has a PhD in Physics, their ability to succeed in an uncomfortable, fast-paced environment using Python for machine learning depends on their desire to want to learn and grow more. Thus, a student’s willingness to want to learn (slope of new knowledge intake) is dramatically more important than their prior education (y-intercept). (Of course, prior education may be indicative of one’s willingness to learn.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*GU0DiSJscObW4p9dmYcKJQ.png" /></figure><p>This is not unique to students learning support vector machines one hour and the fundamentals of natural language processing the next hour.</p><blockquote>Everyone should strive to surround themselves with others that value their willingness to improve higher than what they already know, starting with oneself.</blockquote><p>As I saw Sam Altman <a href="https://twitter.com/sama/status/792823320441786368?lang=en">say</a>, hire for potential, not prior experience.</p><h3>Be Wikipedia, Not (Just) <a href="https://arxiv.org/">arXiv</a></h3><p>Teaching is the practice of effectively relaying information that is already known. Research is the process of uncovering new information. This is a critical difference. Teachers do need not to have been the ones to discover new information to be best at their job. Rather, it is critical that I could be the Wikipedia of all class topics: provide a detailed introduction with the ability to go into similarly approachable depths for all encompassing explanation (linked Wikipedia pages) and provide the option for research-based citation when extreme depth is necessary. I am the approachable, clear amalgamation of information, even if not its origin.</p><p>Contrast this with <a href="https://arxiv.org/">arXiv</a>, where new research is published. Reading and interpreting papers is important, but only insofar that I can index and share the information effectively. In this manner, I can be a central resource for student queries that continues to provide valuable understanding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JgkNLGAg9gmsJb95PL0wnQ.png" /><figcaption>Which tells you more about arXiv: Wikipedia or arXiv?</figcaption></figure><p>This is true for non-teachers. Imagine a manager consistently comes to you for ideas on improving the business and subsequently takes credit. As that manager becomes promoted for your work, you equally become indispensable in that manager’s workflow as he/she relies on your insight. You become the Wikipedia of the situation: you are the initial point of concisely offered knowledge. Even if you do not have the depth requisite on every query, if you can point in the right direction for more information and cite your process, you become the first stop for all future questions. As you continue to build relationships with others in your firm and reflect humility, it will become clear to others that value lies with you rather than your manager. (James Altucher <a href="http://www.jamesaltucher.com/2011/10/how-to-deal-with-crappy-bosses/">discusses</a> handling situations like this in great depth.)</p><blockquote>Building relationships and sharing your own wisdom, even if you are unaccredited, will yield better long-term results than attempting to suppress useful information.</blockquote><h3>Keep Learning</h3><p>As I noted, I happily sacrificed vacations to improve curriculum for our students. Our initial rollout required a hefty amount of retooling, which provided an exceptional opportunity to learn and relearn a wide array of topics. This culminated in one of my happiest achievements at GA. The second version of curriculum merged San Francisco’s iteration with D.C.’s, thereby making hundreds of hours of materials my team wrote become the global default. Students from Hong Kong to Seattle (and the long way around the earth!) are able to learn from curriculum I produced. GA even internally recognized this, awarding me a quarterly “GAccolade” as a top three performer across our 600-person operation in December 2016. (I still suspect they got the wrong Joseph, but shh.)</p><p>A tweet from Coursera Co-Founder Andrew Ng summarizes the need to learn quite well:</p><h3>Andrew Ng on Twitter</h3><p>If you didn&#39;t learn anything today, your skills are now slightly less relevant for your career than yesterday. So learn every day!</p><h3>Trust and Devolve</h3><p>When I was tasked with leading our Data Science Immersive program, I knew I needed help. I conned my good friend and Statistics M.S. Matt Brems into joining the instructional team. Matt equally has a passion for breaking down challenging advanced mathematics, statistics, and programming into digestible bits. He’ll be leading instruction in my absence.</p><p>But attracting Matt to the team was only the start. Encouraging and retaining top talent relies on entirely different principles. Ambitious, high performing individuals want nothing more than the autonomy to prove the value of their work yet proper recognition for their successes. When it came to scoping weeks and curriculum, I knew I could devolve total responsibility over specific lecture areas and be outdone by the result. I would make sure Matt knew I was impressed, and I would promote his work to our GA global counterparts to assure recognition was granted beyond myself. This had a positive feedback loop: I could set the tone for diligence, devolve a task, be impressed by the result, and assure recognition reinforced the cycle to continue.</p><blockquote>Ultimately, you should seek to work with individuals with whom you can entirely trust full devolution and be surprised by the result — not just because of how good it is, but because you, yourself, would not have considered doing it that extraordinary way.</blockquote><p>While this list is decidedly non-comprehensive of all I’ve been fortunate to learn from those around me, it is a good start at distilling general advice I would provide my previous and future self.</p><p>I owe an enormous thanks to many, but here I’d like to emphasize my gratitude to my four student cohorts, ranging from 12 students (DSI2) to 24 (DSI4). You all took an ineffable leap of faith to change your career in three months, and that has pushed me to do some of my best work. The effort you put in is symbiotic and reciprocated. Seeing your in-class for loop successes all the way to coding neural network chatbots on the job or deploying new T-SNE research methods has provided for exceptional meaning in the work I was able to do with the Data Science Immersive. I dedicated my career to improving yours, and you have over-delivered. Thank you.</p><p><em>Keep up to date on data science news, datasets, events, and jobs. </em><a href="https://www.josephofiowa.com/entropy"><em>Signup for Entropy</em></a><em>, a weekly newsletter. It’s also a great way to stay in touch with me. Thanks to </em><a href="https://medium.com/u/748f7cf0e1b8"><em>SFC</em></a><em> for copy edits.</em></p><p><em>If you enjoyed this story, please select the heart below so others may discover this content too.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=342031916e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Data Behind a Season Without Snow Days]]></title>
            <link>https://medium.com/the-ga-index/auditing-the-feds-what-determines-a-federal-government-snow-day-75a3432c613a?source=rss-690e8d667b35------2</link>
            <guid isPermaLink="false">https://medium.com/p/75a3432c613a</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[government]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[tech-skills]]></category>
            <dc:creator><![CDATA[Joseph Nelson]]></dc:creator>
            <pubDate>Mon, 03 Apr 2017 14:17:00 GMT</pubDate>
            <atom:updated>2018-05-21T16:05:34.862Z</atom:updated>
            <content:encoded><![CDATA[<h4>How behavioral Google search data and scientific weather forecast data play into the federal government’s snow day decision-making.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*MjCbEDBEd0UNgc2NyDVUXA.jpeg" /><figcaption>I took this on January 23, 2016, amid “Snowzilla,” which dumped ~22 inches on the Lincoln Memorial.</figcaption></figure><p>As spring arrives in Washington, D.C., we close the chapter on an abnormal winter in the District: For the first time in the last five years, the federal government did not declare a single full day closure due to snow.</p><p>D.C. had its federal snow day chances. On March 14, D.C. braced for Snowstorm Stella, which <a href="http://dc.curbed.com/2017/3/13/14910590/storm-stella-snow-winter-weather">threatened six or more inches</a>. Typically, such threats cause the all-powerful federal snow day authority Office of Personnel Management (OPM) to declare a closure. But OPM didn’t bite and only issued a three-hour delay with the option to work remotely. Even my office — <a href="https://generalassemb.ly/locations/washington-dc?utm_medium=social&amp;utm_source=blog&amp;utm_campaign=snow-days">General Assembly’s D.C. campus</a>, where I’m a full-time <a href="https://generalassemb.ly/education/data-science-immersive?utm_medium=social&amp;utm_source=blog&amp;utm_campaign=snow-days">Data Science Immersive</a> instructor — declared a snow day, as did many others. (OPM was probably right this time: Only a <a href="http://washington.cbslocal.com/2017/03/14/dc-area-storm-brings-rain-snow/">light dusting</a> followed exaggerated predictions.)</p><p>Because of the excitement surrounding impending snow, it seemed like a given that OPM would issue a closure, as it has in the past. It made me think about whether there was any relationship between the emotional buildup resulting from a snowy-weather forecast and the chances of the OPM actually declaring a snow day.</p><p>I wondered: <strong>Are OPM’s opaque closure decisions truly, entirely based on the forecast, or are they also susceptible to human impulse?</strong></p><p>To answer this question, I turned to <a href="https://generalassemb.ly/data/data-science">data science</a>.</p><h3>The Data</h3><p>To evaluate the root of OPM’s closure decisions, I decided I needed three datasets: the history of all federal government snow day closures, historic weather forecast data, and a heuristic method to determine human excitement leading up to a snow day.</p><h4>Federal Government Closure Data</h4><p>Gathering historic government data on federal closures proved simple. The Office of Personnel Management maintains a <a href="http://opm.gov/policy-data-oversight/snow-dismissal-procedures/status-archives/">Snow &amp; Dismissal Procedures archive</a>. I automated the data collection and <a href="https://github.com/josephofiowa/zenzic/blob/master/federal-snow/fedsnow-scraper.py">open sourced</a> the ability for you to do the same.</p><h4>Historic Weather Forecast Data</h4><p>Collecting historic weather forecast data proved surprisingly challenging. Note I’m not obtaining historic weather data, but historic weather <strong>forecast</strong> data. This difference is critical: I’m basing all my analysis on the weather data that was available to OPM at the time of its decision (which I’m assuming is 11 p.m. the night preceding a snow day).</p><p>While gathering historic weather data is quite straightforward, historic weather forecast data is a bit harder to find. I suspect this is because weather reporters would rather release what happened than what they <em>thought</em> would happen — I should audit weather reporters for my next project.</p><p>I used an API called <a href="https://darksky.net/dev/docs">Dark Sky</a> and <a href="https://github.com/josephofiowa/zenzic/blob/master/federal-snow/forecast-data.py">open sourced</a> my script for doing so.</p><h4>Behavioral Snow Day Excitement Data</h4><p>To collect behavioral data on the excitement surrounding a possible snow day, I turned to <a href="https://trends.google.com/trends/">Google Trends</a>. Google Trends enables anyone to see the popularity of a search term within a given geography and time range. This is an excellent way to encapsulate snow day excitement: Rumors of snow encourage searches for news coverage and forecasts.</p><p>Google supports the ability to collect the last five years of Trends data at the weekly level. Units are measured on a 0 to 100 scale based on relative search volume, where a term achieves a 100 at its most popular search frequency within the user-provided timeframe.</p><h3>The Analysis</h3><p>Before examining how each factor plays into a snow day, I first visualized what OPM’s closure decisions have been like over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jhVTqWvf08CG5_yTwf-c0w.png" /></figure><p>In the dates available on OPM’s public archive stretching back to 1998, the federal government has declared 13 closures and 13 delays. Delays are becoming increasingly common. Perhaps the advent of telework has enabled the federal government to trade what would have been delays to remote working. The first recorded telework notice available in the dataset is December 16, 2010. (Thanks, Obama.)</p><p>I then looked at the five-year Google searches for “snow” data within the D.C. area over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Wu861ry1HuPqwKEt-tJhA.png" /></figure><p>If you were to look at the graph above, could you guess what days were snow days based on relative Google “snow” search volume? Recall that this data is only available at the weekly level, so spikes correspond to a week’s aggregation of Googling. Y-axis values are relative search volumes, so weeks in December 2014 saw almost half the volume of “snow” Googling that Snowzilla saw in 2016.</p><p>Layering the federal closure data on top of the Google five-year weekly search volume yields an intriguing graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D8BYbUReE8lAqmIQ9er9fg.png" /></figure><p>Looking at this graph alone paints OPM to be fairly reactionary to Google behavioral snow day expectations. Almost every time Google “snow” search volume exceeds 20 percent of its relative Snowzilla 2016 peak, there has been a snow day. Immediately, the week of March 12, 2017, stands out. If Google searches are people saying they think there will be a snow day, this March proves extremely disappointing.</p><p>The weather data I collected provided temperature, 10-mile visibility, wind, precipitation probability, precipitation intensity, and precipitation type. I first plotted closures vs. forecasted precipitation probability and colored it by type (rain or snow).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VU2bR8AoB1smqPbCJfvh6A.png" /></figure><p>A couple of important trends emerge. Nearly every time expected snow probability exceeds 50 percent, a closure is expected. There were a few weeks in 2014 in which this was not the case, but subsequent forecasted snow pushed OPM over the edge. Starkly, the probability of snowfall in March 2017 surpassed that of Snowzilla 2016 by roughly 10 percent.</p><p>Moreover, there appear to be just two weeks where forecasted rain caused a closure, both in the 2012–2013 winter. This demonstrates the significance of interaction terms. Of course the federal government does not close every time rain is forecasted, but perhaps the interaction of low temperatures and pending rain will result in closure.</p><p>So, I plotted a 10-day rolling average of forecasted temperature versus closures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IT_vyjJlFLlfpjUcMFlOpw.png" /></figure><p>While it is hard to say a low temperature alone determines closure, the winter 2012 closure is explained. A heavy amount of forecasted precipitation in tandem with low temperatures caused OPM to call off work.</p><h3>Modeling</h3><p>While I won’t get into depth on the modeling tactics I used (see <a href="https://github.com/josephofiowa/zenzic/blob/master/federal-snow/fed-closure-analysis.ipynb">code</a>), I’ll provide intuition into my process. I built models to predict whether I can successfully determine whether OPM will have a snow day in a given week based on the average weather data for that week and the Google search volume for “snow” in D.C. (Recall my analysis must exist at the weekly level due to Google Trends data only being available for the previous five years at the weekly level.)</p><h4>Logistic Regression</h4><p>I first fit a <a href="http://scikit-learn.org/stable/modules/linear_model.html#logistic-regression">logistic regression</a>, which is a fancy way of saying created a line based on some inputs to best guess future points on that created line. A logistic regression enables me to accept or reject whether some given features — in our case, Google searches and weather information — explain a given output (OPM closures).</p><p>The most explanatory (statistically significant) features for an OPM snow day are forecasted temperature, forecasted precipitation intensity, the interaction of forecasted temperature and precipitation, and the forecasted snow intensity. In other words, OPM bases its decision most on temperature and precipitation. We can reject the idea that Google searches for “snow” explain whether a given week will include a snow day (at the 5% significance level, no less).</p><p>In addition, with this fit model, I tested whether the week of March 12, 2017, would include a likely snow day. The model assigned this a <strong>0.02% chance</strong> — if only I had built this before getting my hopes up.</p><h4>Random Forest Classifier</h4><p>The second model I built is a <a href="https://www.stat.berkeley.edu/~breiman/RandomForests/cc_home.htm">random forest classifier</a>. A random forest is a fun way of saying a collection of decision trees — like a simple way of determining whether you should go for a run on a given day. If it is over 50 degrees, perhaps you decide you should. If it is not warm, you then ask if you have a gym membership. If yes, you run at the gym. If not, you stay home.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*-PIuGEZlo9eC1O-lTsCVcA.png" /></figure><p>Decision trees measure the importance of a given feature based on how much information that feature provides when seeking an outcome. In this exercise example, having a gym membership alone may not mean I will go running. A gym membership is only relevant if the weather is cold. Thus, the added value of information regarding a gym membership (measured using something called <a href="http://www.saedsayad.com/decision_tree.htm">Entropy</a>) is lower than the weather information.</p><p>In the OPM problem at hand, I provided the random forest (the best weighted-average of a collection of decision trees) the same weather and search data. The model achieved a 95.4% accuracy in classifying whether a given week would have a snow day, and a 1.0 precision rate. I plotted the various feature importances (measured by Entropy, information gain).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2O97I2qxnBgJiev3pjBFtA.png" /></figure><p>The model found temperature to be incredibly important as well as wind. Perhaps OPM finds that wind makes for more dangerous weather, regardless of precipitation. Google searches for “snow” proved to be the third most valuable feature in classifying if a given week as likely to have a snow day or not while the interaction of precipitation type and temperatures also remain insightful.</p><p>I used this same highly accurate model to predict if the week of March 12, 2017, would contain an OPM closure, and it correctly predicted there would not be. Given both the logistic regression and random forest classifier correctly predicted there would not be a snow day, I am reminded of one of my favorite data comics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*FBkiRFFOS6_ooeqhGgnNVQ.jpeg" /></figure><h4>Results</h4><p>So where does that leave us in determining whether the Office of Personnel Management relies on purely scientific factors vs. behavioral ones in predicting a snow day? It appears that OPM largely, if not entirely, abides by weather forecasts. However, given the marginal explanatory power behavior-driven Google searches provided the second model, one is inclined to believe even bureaucrats may be prone to human excitement.</p><p><em>My full analysis, including the datasets and methods not covered in this writeup, are available on my </em><a href="https://github.com/josephofiowa/zenzic/tree/master/federal-snow"><em>Github</em></a><em>. If you’d like to stay up to date on tutorials of how I completed this, </em><a href="http://www.josephofiowa.com/entropy"><em>sign up for Entropy</em></a><em>.</em></p><p><em>Joseph Nelson is a full-time </em><a href="https://generalassemb.ly/education/data-science-immersive?utm_medium=social&amp;utm_source=blog&amp;utm_campaign=snow-days"><em>Data Science Immersive</em></a><em> instructor at </em><a href="https://generalassemb.ly/?utm_medium=social&amp;utm_source=blog&amp;utm_campaign=snow-days"><em>General Assembly</em></a><em>’s </em><a href="https://generalassemb.ly/locations/washington-dc?utm_medium=social&amp;utm_source=blog&amp;utm_campaign=snow-days"><em>Washington, D.C., campus</em></a><em>. Take a deep dive into data with DSI at our campuses across the globe, or learn </em><a href="https://generalassemb.ly/education/data-science?utm_medium=social&amp;utm_source=blog&amp;utm_campaign=snow-days"><em>data science</em></a><em> or </em><a href="https://generalassemb.ly/education/data-analytics?utm_medium=social&amp;utm_source=blog&amp;utm_campaign=snow-days"><em>data analytics</em></a><em> part-time on campus or </em><a href="https://generalassemb.ly/education/learn-data-analysis-online?utm_medium=social&amp;utm_source=blog&amp;utm_campaign=snow-days"><em>online</em></a><em>.</em></p><p><em>If you enjoyed this story, please select the heart below so others may discover this content too.</em></p><figure><a href="https://generalassemb.ly/hello/medium?utm_medium=social&amp;utm_source=the-index&amp;utm_campaign=snow-days"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y68cFzxUNENOjoRNDjty2g.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75a3432c613a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-ga-index/auditing-the-feds-what-determines-a-federal-government-snow-day-75a3432c613a">The Data Behind a Season Without Snow Days</a> was originally published in <a href="https://medium.com/the-ga-index">The Index @ General Assembly</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Real Fake News Says about Obama’s Presidency]]></title>
            <link>https://medium.com/hackernoon/what-real-fake-news-says-about-obamas-presidency-4bf42be71ff1?source=rss-690e8d667b35------2</link>
            <guid isPermaLink="false">https://medium.com/p/4bf42be71ff1</guid>
            <category><![CDATA[obama]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[fake-news]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Joseph Nelson]]></dc:creator>
            <pubDate>Thu, 02 Feb 2017 12:47:00 GMT</pubDate>
            <atom:updated>2019-05-02T10:56:48.340Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>Obama &amp; The Onion</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iZhGnft14nx7ASoz9vdaEg.png" /><figcaption>Generated using text The Onion wrote about Obama during his presidency</figcaption></figure><p>Fake news is nearly an epidemic. Some argue it <a href="https://www.washingtonpost.com/news/the-intersect/wp/2016/11/17/facebook-fake-news-writer-i-think-donald-trump-is-in-the-white-house-because-of-me/?utm_term=.5c283fb079c8">tipped the election</a> (<a href="https://www.poynter.org/2017/did-fake-news-help-elect-trump-not-likely-according-to-new-research/445724/">others disagree</a>), Facebook has <a href="https://www.nytimes.com/2016/12/15/technology/facebook-fake-news.html">dedicated significant attention</a> to minimize its spread, and viral misinformation has <a href="http://www.businessinsider.com/fake-news-impact-on-financial-markets-2016-12">swayed financial markets</a>.</p><p>But fake news hasn’t always been such a villain. Even deliberate fake news contains insightful commentary on current events and entertainment. Political satire, in particular, <a href="http://www.csmonitor.com/USA/Politics/2016/1229/Why-political-satire-may-become-even-more-important-in-Trump-era">plays a powerful role</a> in freedom of expression.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WQK4iqBKLmRjGvsWsqqTgA.png" /><figcaption>Generated using text The Onion wrote about Obama during his presidency</figcaption></figure><p>To illustrate this, I collected every story The Onion wrote about Obama during his presidency as determined by their ultimate Obama farewell, <a href="http://www.theonion.com/interactive/obama"><em>Black Man Does 8 Years</em></a>. The Onion is perhaps the stalwart of written political satire and what I deem to be “real fake news”: dependably entertaining, but reputably fake. (Though even this deserves an asterisk as current White House Press Secretary Sean Spicer recently <a href="http://www.snopes.com/sean-spicer-onion-retweet/">deleted a tweet</a> that commended an Onion article chiding him.)</p><p>While The Onion included 322 works on Obama in their feature, I narrowed my analysis to only include written stories, thereby omitting a combined 60 graphic and video productions. Of the remaining 262 stories, The Onion wrote about Obama at a fairly uniform rate over time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E9QMBB4yjZ1Xp1p5rHAQIg.png" /></figure><p>There’s a notable early increase between the initial 2008 Democratic primary and subsequent 2008 presidential election, which follows traditional coverage patterns from primary to general election candidacy. The Onion enjoys their electoral writing, as coverage rapidly increases in late 2012 heading into Obama’s second presidential election. Headlines during this era reflect this, including <a href="http://www.theonion.com/article/obama-takes-out-romney-with-mid-debate-drone-attac-30055"><em>Obama Takes Out Romney With Mid-Debate Drone Attack</em></a><em> </em>and <a href="http://www.theonion.com/blogpost/this-may-not-be-the-ideal-moment-politically-but-i-30203"><em>This May Not Be The Ideal Moment Politically, But It’s Time To Talk Reparations</em></a>. Throughout 2013, stories continued at a high rate, documenting Obama’s difficulty grappling with <a href="http://www.theonion.com/article/obama-deeply-concerned-after-syrians-gassed-to-dea-33590">instability in Syria</a> and lifestyle stories focusing on <a href="http://www.theonion.com/article/michelle-obama-finally-gets-around-to-reading-drea-33120">Michelle Obama</a> and the Obama family.</p><p>Every story The Onion publishes includes up to five different tags that editorial staff determines are relevant to the story’s content. While 89 unique content tags were used, the top ten content tags represented 79 percent of the total tags. In other words, there is a substantial concentration of similar content (as determined by the tags The Onion uses).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LPF4FsxhiSJdIC3V5tF4OQ.png" /></figure><p>This is reasonable. The purpose of tags is to consolidate information into a coherent set of lists. The specific tags used are not startling: “Politics,” “Barack Obama,” “Politicians,” and “News” make up the lion’s share of even the top ten most used descriptors. It appears, however, The Onion considers their Obama coverage to be some of their best, at least in the middle of his terms. “Our Annual Year 2012” and “Our Annual Year 2013,” which are roundups of top stories, both make an appearance in the top ten tags.</p><p>Whenever The Onion begins a story, they note the location followed by an em dash. I pulled location out from each story, only to find Washington makes up 73 percent of all stories. However, there were intriguing anomalies among the listed locations begging for further investigation.</p><p>1. <a href="http://www.theonion.com/article/obama-makes-surprise-visit-to-quantum-branching-mu-29763">Everywhere in Space-Time Simultaneously</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gO8hhn-RwMBaV248OTAF-w.png" /></figure><p>2. <a href="http://www.theonion.com/article/obama-takes-excited-daughters-out-for-day-of-drone-32702">Wana, Pakistan</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M4t0qiZR1I9_tqyN7paxLQ.png" /></figure><p>3. <a href="http://www.theonion.com/article/obamas-aunt-sends-him-article-mentioning-united-st-20734">Kalona, Iowa</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4RKt0IidG2TZdpInysNDzg.png" /><figcaption>(Yes, of course I included Iowa)</figcaption></figure><p>4. <a href="http://www.theonion.com/article/palestinians-israelis-come-together-to-mock-obamas-31767">Jerusalem</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5W1ujuMervthbNsbsOiEsQ.png" /></figure><p>5. <a href="http://www.theonion.com/article/us-continues-quagmire-building-effort-in-afghanist-2837">Kabul, Afghanistan</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IsiBID-3P-k09ihi-ceaBw.png" /></figure><p>Sometimes, outliers are quite fun.</p><h4><strong>TEXT ANALYSIS</strong></h4><p>Given a dataset of 623,270 words and 262 unique stories, I applied a series of text analysis techniques. I completed a process known as count vectorization, which is a fancy way of saying I counted the occurrences of how often a given word appeared across stories. I removed any frequently occurring terms (<a href="https://en.wikipedia.org/wiki/Stop_words">stop words</a>) that don’t add insight as to what a story is discussing (e.g. this, a, or, an). I also provided the ability for word counts to take into consideration two consecutive terms but be counted as a single entity. For example, “White House” is two words, yet those two words occurred next to each other so often the entity (called a bigram) was among the most commonly used in all stories. Finally, I separate the counts into Obama’s first and second term: 134 stories were from Obama’s first term, and 128 were written during his second term. I defined Obama’s second term to start on his second inauguration: January 20, 2013 (though he was publicly sworn in on January 21).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HOpmlUUbCbmk8C3V7iEi9A.png" /></figure><p>There are not too many surprises in the words The Onion used in their stories about Obama during his eight years as president. First term presidency word counts often outnumber the second term across categories not only because there were six more stories during the first term, but more importantly, because the average story length was 212 words compared to 163 words in Obama’s second term. Even despite this, both “White House” and “house” slightly edge out the first term in usage.</p><p>There is one key takeaway, however. Based on the number of times “American” was used in stories about Obama’s first versus second term, The Onion shows Obama was half as American during his second term compared to his first. (By this logic, he was also half as “Barack Obama” and “years.”)</p><blockquote>“The Onion shows Obama was half as American during his second term compared to his first.”</blockquote><p>I investigated what truly separated Obama’s first term from his second, as dictated by the words in The Onion’s stories. To do so, I built different models to most accurately predict in which term any given story may have been written. I trained my model on one random collection of the stories, where it could learn what words most likely are used in articles from Obama’s first or second term. I then tested my model by selecting a separate set of random stories the model had not seen before, and asked my model to make its best guess as to in which presidency the piece was written.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G5B_Yp1ijcZSL0OV6tHPNw.png" /><figcaption>President Obama’s <a href="https://commons.wikimedia.org/wiki/File:Official_portrait_of_Barack_Obama.jpg">portrait</a> recreated out of the words The Onion used to describe him</figcaption></figure><p>My best model achieved an 80 percent accuracy — about a 30 percent gain over guessing at random. (For the math-inclined, the model was a <a href="http://scikit-learn.org/stable/modules/naive_bayes.html">multinomial Naïve Bayes classifier</a>.) However, this particular model makes viewing which words best define one presidential term versus another quite challenging. Thus, I also built a separate model called a <a href="http://scikit-learn.org/stable/modules/ensemble.html#forest">random forest</a>, which is a fancy way to find the best possible decision tree. Decision trees make viewing which words split our stories between Obama’s first and second terms quite transparent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JANPVgjHt0LYZoKRFVD6NA.png" /></figure><p>In the above graph, I’ve plotted the 15 (of 5825 available to the model) most distinctive words between Obama’s first and second terms as determined by <a href="https://en.wikipedia.org/wiki/Decision_tree_learning#Gini_impurity">Gini Impurity</a>. The higher a word’s or bigram’s (collection of two words) Gini Index, the better it is, on average, at delineating between Obama’s first and second term. In this case, words related to campaigns are quite strong. This makes sense: both of Obama’s campaigns occurred prior to his second inauguration. These results are imperfect, however. This random forest achieved an average accuracy of 64 percent.</p><h4><strong>SENTIMENT ANALYSIS</strong></h4><p>Satire is a <a href="http://sentic.net/sentire2016reganti.pdf">famously difficult area</a> for text processing. Consider how challenging it is to decode a friend’s sarcastic text message. Even when considering all context of the situation and how well you know your friend, miscommunication occurs. The problem is amplified for computing, as a computer <a href="https://hackernoon.com/tagged/learning">learning</a> context is a grand endeavor.</p><p>Nonetheless, I used a standard sentiment evaluation tool to analyze The Onion’s Obama coverage. This particular <a href="https://textblob.readthedocs.io/en/dev/">Python library</a> tabulates pre-determined word counts and assigns a score. For example, words like “gross” and “bad” decrease a document’s score, while words like “happy” and “amazing” improve its score. Sentiment scores are bound between -1 (negative) to +1 (positive).</p><p>I calculated the ten-story sentiment rolling average over time. In other words, I scored the sentiment of ten stories, and then plotted a point for those ten stories. I repeated this across time, adding in a new story and dropping the oldest. A rolling average helps smooth an otherwise uninterpretable gyration of spikes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4nluPfJu7hihbebYWiCAvQ.png" /></figure><p>Even my rolling average is still quite variable. Nonetheless, it is insightful to see that a ten-story rolling average never dips below zero. That is, coverage is generally positive. Miscellaneous stories <a href="http://www.theonion.com/article/president-obama-mentions-hed-like-to-see-lebron-ja-17512">like Obama wanting to see Lebron in Chicago</a> or the <a href="http://www.theonion.com/article/white-house-jester-beheaded-for-making-fun-of-soar-17495">White House hiring a jester</a> drove an early 2010 positivity spike. The late 2011 and early 2012 negativity dip included stories about Obama’s major gaffe <a href="http://www.theonion.com/article/in-major-gaffe-obama-forgets-to-dumb-it-down-26820">forgetting to “dumb it down”</a> and stories about the <a href="http://www.theonion.com/article/backup-health-care-plan-involves-nation-sharing-on-27847">healthcare rollout</a>.</p><p>I also calculated the average sentiment as per The Onion content tags discussed previously.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GDC7SuOEkTyb43ntTP0Lkg.png" /></figure><p>Despite being satire, the most popular tag matches a frequent assumption about the American presidency: the family is typically off-limits for impolite word choice. However, despite this potential real world takeaway from fake news, Obama’s worst sentiment topic-area is “Environment,” yet he’s been <a href="http://nymag.com/news/features/obama-climate-change-2013-5/">praised for his achievements</a> in this area. Moreover, negative sentiment for “Our Annual Year 2012” contradicts Obama’s relatively <a href="http://www.presidency.ucsb.edu/data/popularity.php?pres=44&amp;sort=pop&amp;direct=DESC&amp;Submit=DISPLAY">high 2012 approval ratings</a>.</p><p>I, lastly, pulled Obama’s most positive and most negative story. Obama’s <a href="http://www.theonion.com/article/obama-praises-own-strength-resilience-face-hardshi-52152">most positive story</a> earned a 0.323 sentiment score and came on the heels of his final State of the Union.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wQy4BhsNZluBlDHPDn1J3g.png" /><figcaption>Obama’s most positive Onion story is Obama talking about… Obama</figcaption></figure><p>The Onion’s <a href="http://www.theonion.com/article/obama-returns-from-india-with-these-gross-candies--18468">most negative sentiment story</a> earned a -0.226 sentiment score and was published following Obama’s 2010 trip to India.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SCgBNvAEWLhgrofosjzFAA.png" /><figcaption>The Onion’s most negative story includes mentions of “gross,” “awful,” and “bad.”</figcaption></figure><p>Obama’s eight years provided great fodder for The Onion: he rapidly passed a stimulus package, overhauled the nation’s healthcare system, and carried a relatively youthful persona. The Onion excellently balanced <a href="http://www.theonion.com/article/defeated-man-victorious-30281">backhandedly praising his successes</a>, <a href="http://www.theonion.com/article/obama-hoping-jim-lehrer-doesnt-bring-up-us-economy-29782">poking jest in his mistakes</a>, and making him <a href="http://www.theonion.com/article/frustrated-obama-sends-nation-rambling-75000-word--18516">appear relatable</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UPwBLC9hUdjoCP5RUhzNew.png" /><figcaption>Generated using text The Onion wrote about Obama during his presidency</figcaption></figure><p>Ultimately, fake news requires vigilance on behalf of the reader, and an increasing number of tools to fight its spread. Nonetheless, deliberate satire, especially from a classic publication like The Onion, is a reminder that dispelling all fake news threatens entertainment and witty commentary. And while even The Onion admits the unpredictability of the recent election has made <a href="https://www.nytimes.com/2016/11/05/business/media/how-to-satirize-this-election-even-the-onion-is-having-trouble.html">satirizing the news challenging</a>, I look forward to seeing how they cover the next presidency. It’ll make for great data.</p><p><em>My full analysis, including the dataset and methods not covered in this write-up, are available on my </em><a href="https://github.com/josephofiowa/zenzic/tree/master/obama-onion"><em>Github</em></a><em>. If you’d like to stay up to date on tutorials of how I completed this, signup for Entropy: </em><a href="http://www.josephofiowa.com/entropy"><em>www.josephofiowa.com/entropy</em></a><em> If you’d like to become a data scientist, check out General Assembly’s </em><a href="https://hackernoon.com/tagged/data-science"><em>Data Science</em></a><em> Immersive, which I currently teach.</em></p><p><em>If you enjoyed this story, please select the heart below so others may discover this content too.</em></p><figure><a href="http://bit.ly/HackernoonFB"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0hqOaABQ7XGPT-OYNgiUBg.png" /></a></figure><figure><a href="https://goo.gl/k7XYbx"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vgw1jkA6hgnvwzTsfMlnpg.png" /></a></figure><figure><a href="https://goo.gl/4ofytp"><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gKBpq1ruUi0FVK2UM_I4tQ.png" /></a></figure><blockquote><a href="http://bit.ly/Hackernoon">Hacker Noon</a> is how hackers start their afternoons. We’re a part of the <a href="http://bit.ly/atAMIatAMI">@AMI</a> family. We are now <a href="http://bit.ly/hackernoonsubmission">accepting submissions</a> and happy to <a href="/service/mailto:partners@amipublications.com">discuss advertising &amp; sponsorship</a> opportunities.</blockquote><blockquote>If you enjoyed this story, we recommend reading our <a href="http://bit.ly/hackernoonlatestt">latest tech stories</a> and <a href="https://hackernoon.com/trending">trending tech stories</a>. Until next time, don’t take the realities of the world for granted!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*35tCjoPcvq6LbB3I6Wegqw.jpeg" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fdde502%3Fas_embed%3Dtrue&amp;dntp=1&amp;url=https%3A%2F%2Fupscri.be%2Fhackernoon%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href">https://medium.com/media/3c851dac986ab6dbb2d1aaa91205a8eb/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4bf42be71ff1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/hackernoon/what-real-fake-news-says-about-obamas-presidency-4bf42be71ff1">What Real Fake News Says about Obama’s Presidency</a> was originally published in <a href="https://medium.com/hackernoon">HackerNoon.com</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>