<?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 Ralph Brooks on Medium]]></title>
        <description><![CDATA[Stories by Ralph Brooks on Medium]]></description>
        <link>https://medium.com/@ralph-a-brooks?source=rss-3d6473be760d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*QX16HkMQESs_F1tNwHaZCg.png</url>
            <title>Stories by Ralph Brooks on Medium</title>
            <link>https://medium.com/@ralph-a-brooks?source=rss-3d6473be760d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 21:27:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ralph-a-brooks/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[Why are simulations the future of data science?]]></title>
            <link>https://ralph-a-brooks.medium.com/why-are-simulations-the-future-of-data-science-a5c949b1148f?source=rss-3d6473be760d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5c949b1148f</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Ralph Brooks]]></dc:creator>
            <pubDate>Wed, 14 Dec 2022 15:21:18 GMT</pubDate>
            <atom:updated>2022-12-14T15:21:18.154Z</atom:updated>
            <content:encoded><![CDATA[<h3>Data science will be defined by the 3D world and not just by Excel tables.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*AbYeNaZbMdUuiFJi.jpeg" /><figcaption>The City Sample in Unreal Engine is one approach that Data Scientists can use to solve urban planning problems such as highway placement.</figcaption></figure><p>Data science isn’t just about customer churn, and attempts to predict who is most likely to survive when the Titanic goes down. Data science can be applied to the 3-dimensional world as well. In this blog we are going to look at a couple of real world use cases, and then talk about an approach on how you can build your own simulations.</p><h3>Cell Phone Tower Use Case:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/0*guwrGeFEZWPKt3Zn.png" /><figcaption>Consulting firms help companies like Ericsson determine cell phone tower placement with the help of simulation software.</figcaption></figure><p>Consider the case where you want to place a cell tower in a city. This is a real use case for telecommunications companies that are constantly trying to figure out how they place expensive cell phone towers that give the most people strong reception. This case is not just as simple as saying, “OK, let’s take our cell phone towers and equally space them throughout the city.” You’re going to have challenges such as the wavelengths of the towers as well as the density of the materials in office buildings. Placement also becomes a lot more complex than using some sort of K-means process that builds off of population or some other variable.</p><p>In the world of cell tower placement, reception could be affected by the wavelengths of the tower and the density of materials in the office. It could be affected by other objects that are between the tower and a person’s cell phone (e.g. trees) which reduce a tower’s signal strength.</p><p>Said differently, understanding the number of trees is a city “might be a predictive signal“ in a tabular data and understanding the latitude and longitude of trees might get you more accuracy. You are going to get even better accuracy regarding optimal cell phone tower placement you know where an office worker is located (“What floor?”) and how tall the tree is (a “simulation” of relevant objects). In a perfect simulation, you know if the signal is going to get from the tower to some hallway in the interior of an office building because you are aware of the trees in the “line of sight”, you are aware of the type of material used for the exterior of the building, and you know how many interior walls stand between the person who is holding the cell phone and the tower.</p><h3>Highway Use Case:</h3><p>Now think about what you would need to do if you were trying to plan a highway. This is MUCH more complex than a cell tower placement. Now you’re looking at millions of residents where some of them drive cars and some of them don’t. Some of them have needs to drive at rush hour and others don’t. You could start with a basic data science model that just says “for X number of people who live in a city, we’re going to need Y number of highways.” In the next iteration, you would put highways that are closer to urban centers than they would be to places with less population. Again, sooner or later you start to get from what would otherwise be tabular data into information that’s much more 3 dimensional.</p><h3>Other Use Cases:</h3><p>Simulations aren’t just for highway planning and cell phone towers. There are a large number of use cases that require a good 2D or 3D understanding of the world. They include:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/762/0*lKGAhRUjnn_cZo79.png" /><figcaption>White Owl Education has put together a <a href="https://www.whiteowleducation.com/courses/data-visualization-metaverse/">course for data scientists</a> who want to build their own simulations. The course covers an “easy” uses case of population density, but lessons can be applied to other use cases.</figcaption></figure><ul><li>Understanding population density based off of Census Data</li><li>Understanding wave and weather patterns so that cargo ships lose less shipping containers</li><li>Optimal factory layout in order to increase the production level of anything that you can manufacture (e.g. cars and potato chips).</li></ul><h3>Current State of Simulations</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qsf_4LcsQRFzSR23.png" /><figcaption>Nvidia uses deep learning models to predict weather patterns known as atmospheric rivers. These patterns provide key rainfall for the Western United States.</figcaption></figure><p>If you look at some of the research that Nvidia is doing, you’ll see planet wide simulations of weather. Nvidia calls it Deep Learning Weather Prediction. If you do more digging, you will see that Nvidia has invested a lot of resources into development of their Omniverse project. Based of what I have seen about Omniverse, it is a tool that has strengths in collaboration with team members, but I never got the feeling that it is the best at looking at the interaction between objects.</p><p>So if you want to do simulations in order to make accurate predictions, it seems to me that you need a tool that can do interactions between objects incredibly well.</p><p><strong>Now here is the plot twist.</strong> The tool that does simulations incredibly is a VIDEO GAME ENGINE. Game engines (such as Unreal Engine from Epic games) can do massively open worlds. They have the underlying mechanics and physics for objects to interact, and their recent tech allows you to place at least 500,000 objects in game visible within one screen at the same time.</p><h3>How Can You Build Your Own Simulations?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*lpLTyGd6ZrXPMLgo.jpeg" /><figcaption>The City Sample in Unreal Engine allows you to simulate photorealistic traffic jams.</figcaption></figure><p>The <a href="https://www.unrealengine.com/marketplace/en-US/product/city-sample">City Sample in Unreal</a> was built as part of the promotion for the Matrix 4 movie, and it does a really good job of putting together a procedurally generated city. The City Sample was created for a brief promo interactive game (“Matrix Awakens”) so that Neo and Trinity could drive around a city and escape from agents in the Matrix.</p><p>Why is this relevant? <strong>Epic Games MADE ALL OF THIS CODE available to the public for FREE</strong>. This City Sample is a cool simulation that allows you to drive around town and even create traffic jams (relevant to urban planning).</p><p>There is a little bit of a learning curve to Unreal Engine though. Because of this, I thought there would be value if data scientists knew how to build out a basic simulation before making predictive models based off of City Sample. To that end, I put together an online course that walks you through step-by-step how to look at a basic 3D use case (population density) and that teaches you all of the Python and C++ that you would need in order to be ready to tackle City Sample or put together simulations for your own use case.</p><p>The online course is available now, and I invite you to check it out by clicking on this link: <a href="https://www.whiteowleducation.com/courses/data-visualization-metaverse/">https://www.whiteowleducation.com/courses/data-visualization-metaverse/</a> .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5c949b1148f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Generate Logs with Vertex AI in Google Cloud]]></title>
            <link>https://medium.com/geekculture/how-do-i-create-logs-in-google-cloud-with-vertex-ai-8b6da73b70c2?source=rss-3d6473be760d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b6da73b70c2</guid>
            <category><![CDATA[google-cloud]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Ralph Brooks]]></dc:creator>
            <pubDate>Wed, 16 Jun 2021 04:17:46 GMT</pubDate>
            <atom:updated>2022-02-22T19:42:18.648Z</atom:updated>
            <content:encoded><![CDATA[<p>Use Vertex AI notebooks to communicate with centralized logging in Google Cloud.</p><figure><img alt="Blue Spiral Image" src="https://cdn-images-1.medium.com/max/1024/1*9bDSTLJQHUz0p3aL-reaWw.jpeg" /></figure><p>Vertex AI was announced at Google I/O 2021. More than just a rebranding of the Google AI Platform, this product starts to unify a lot of different APIs (including AutoML) under one product offering. Google states in a press release that this allows companies to start to implement MLOps easier.</p><p>In this blog, we are going to do the equivalent of “Hello World” for Data Science using the Vertex AI platform. In short, we are going to use a Vertex AI “Jupyter” Notebook to communicate with the logging service of Google Cloud. Think of a notebook as a way of running Python code in an iterative manner that allows you to capture the results along the way.</p><h3><strong>TLDR — Show me the code!</strong></h3><p>If you use a Vertex AI notebook, you can easily test out the <a href="https://googleapis.dev/python/logging/latest/usage.html#writing-log-entries">python library</a> for Cloud Logging within Google Cloud. The notebook that you need in order to test Cloud Logging can be found in the full article at <a href="https://www.whiteowleducation.com/using-logging-in-a-vertex-ai-notebook/">https://www.whiteowleducation.com/using-logging-in-a-vertex-ai-notebook/</a></p><h3><strong>Prerequisites</strong></h3><p>In order to complete the steps in this blog, you need to have the following:</p><p>1) You need to have a Google Cloud Account. If you don’t already have an account, take a look at <a href="https://courses.whiteowleducation.com/courses/machine-learning-mastery/lectures/30703728">this video</a> which shows how to set up an account.</p><p>2) You need to enable the Cloud Logging API. After you have set up an account, you can find details about enabling this API at <a href="https://console.cloud.google.com/apis/api/logging.googleapis.com">https://console.cloud.google.com/apis/api/logging.googleapis.com</a> .</p><p>3) You need to go to <a href="https://console.cloud.google.com/vertex-ai/notebooks">https://console.cloud.google.com/vertex-ai/notebooks</a>. Enable the notebooks API if you see a corresponding warning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PO9thgO2tf95llh6LNWF5A.png" /><figcaption>Image courtesy of <a href="https://www.whiteowleducation.com/">https://www.whiteowleducation.com</a></figcaption></figure><h3><strong>Create a Vertex AI notebook</strong></h3><p>Within the Vertex AI console, the first step that we need to do is we need to create a notebook instance. This instance is this is going to be backed by a CPU, so the key is to run this exercise, and when you’re done, be sure to delete the notebook instance so that you don’t incur additional fees.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uIzcLsCTcViQTI38vVEj8w.png" /><figcaption>Make sure to delete the notebook instance after you get done using it. This is important to manage costs.</figcaption></figure><p>As seen above, I’m creating a notebook called test-logging in us-central1 (and you should create your instance in a location that is close to you). I create this notebook with libraries such as TensorFlow and Pandas that would typically be used in data science, and I do this by selecting the TensorFlow Enterprise 2.5 environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6rCV2eyoxD-lyXgBMglp9Q.png" /><figcaption>If we are just examining logging, I am minimizing CPU usage to manage costs.</figcaption></figure><p>After clicking create, you will see the test-logging notebook appear in the console, and click on “OPEN JUPTYERLAB” in order to continue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ERpEGljmCpqHDd7kE5E6jA.png" /></figure><p>Once you are in JupyterLab, click on Python [conda env:root] in order to open up a notebook for experimentation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nMESvuq9ewXlSj7xm6CWtg.png" /></figure><p>Now go ahead and …</p><p>Take a look at <a href="https://www.whiteowleducation.com/using-logging-in-a-vertex-ai-notebook/">https://www.whiteowleducation.com/using-logging-in-a-vertex-ai-notebook/</a> for the remainder of the article which includes:</p><h3>Python Logging Code</h3><h3><strong>Verify Results</strong></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b6da73b70c2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/how-do-i-create-logs-in-google-cloud-with-vertex-ai-8b6da73b70c2">How to Generate Logs with Vertex AI in Google Cloud</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Best Practices to Become a Data Engineer]]></title>
            <link>https://ralph-a-brooks.medium.com/best-practices-to-become-a-data-engineer-7c16fcddb70c?source=rss-3d6473be760d------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c16fcddb70c</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Ralph Brooks]]></dc:creator>
            <pubDate>Fri, 07 May 2021 20:27:04 GMT</pubDate>
            <atom:updated>2022-02-22T19:37:51.697Z</atom:updated>
            <content:encoded><![CDATA[<h4>Steps to go from doing data analysis to ingesting and cleaning data in order get better insights.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*arx9bMj54Ihiz4eOHIaQrw.jpeg" /><figcaption>Image courtesy of pexels.com</figcaption></figure><p><strong>Q: I come from a business intelligence background. I’m looking to make the transition to a data engineer. How do I go about doing this? Do I need to learn NumPy? Do I need to learn Pandas? What are the key concepts that I need to understand in order to ramp up on data engineering quickly?</strong></p><p>If you’re doing business intelligence, maybe you’re working with data visualization tools such as Power BI or Tableau. Either way, you’re doing a lot of analysis. At some point, you will be ready to ingest new data so that you can derive richer, deeper insights — you’re ready to start the journey to become a data engineer.</p><p><strong>AUTHOR NOTE:</strong></p><p><em>See a full copy of the article at</em> <a href="https://www.whiteowleducation.com/best-practices-to-become-a-data-engineer/">https://www.whiteowleducation.com/best-practices-to-become-a-data-engineer/</a></p><p><strong>Master the basics first.</strong></p><p>The following are the six main things that you need to do in order to get to the next level in your career as a future data engineer:</p><h3>Step 1: Learn the Basics of SQL</h3><p>If you have never done ANY programming before, then the first place that you want to start is by learning to sift through data. The way this is done is by learning a language called SQL (Structured Query Language). Among others things, SQL is a tool that can be used to look at relevant information in TABLES and to filter information with WHERE and SELECT statements.</p><h3>GOOD RESOURCES TO GET STARTED WITH SQL</h3><ol><li><a href="https://www.khanacademy.org/computing/computer-programming/sql/sql-basics/v/welcome-to-sql">khanacademy.org</a> — Khan Academy has a good set of videos that goes through the basics of SQL. The videos cover how to select data, and how to join data together.</li><li><a href="https://www.amazon.com/dp/B006QNDJZI/ref=dp-kindle-redirect?_encoding=UTF8&amp;btkr=1">Head First SQL</a> — When I was first starting out, I definitely looked at one or two. Head First books published by O’Reilly. Head First covers the basics of a topic while focusing on different ways to engage the brain so that you learn the material quickly.</li><li><a href="https://www.amazon.com/SQL-Cookbook-Query-Solutions-Techniques/dp/1492077445/ref=sr_1_1?dchild=1&amp;gclid=Cj0KCQjw1a6EBhC0ARIsAOiTkrFnexKQYh8wu-h-nOzvf4jPebcmpVPaOXBYeWLzuKAcUfskwv_D108aAmw6EALw_wcB&amp;hvadid=241663586626&amp;hvdev=c&amp;hvlocphy=9026808&amp;hvnetw=g&amp;hvqmt=e&amp;hvrand=7614006686566039404&amp;hvtargid=kwd-1023089072&amp;hydadcr=16371_10302015&amp;keywords=sql+cookbook&amp;qid=1619811009&amp;sr=8-1">SQL Cookbook</a> — SQL Cookbook gives step by step instructions on ways to look at data (“recipes”) and different ways to think about how to analyze data. The book helps someone form an intuition about how to approach data analysis.</li><li><a href="https://cloud.google.com/bigquery/docs/#docs">Google Cloud Reference Documentation for Big Query</a></li></ol><p>I am a big fan of jumping into the deep end of the pool and learning how to swim quickly. Frankly, there’s no better way to do this than Standard SQL with BigQuery in Google Cloud.</p><p>If you start your SQL journey with Big Query, then you are learning about Google Cloud technology while you are learning data analysis. If you are going this route, then a good place to start is to go through the <a href="https://www.qwiklabs.com/quests/68">BigQuery for Data Warehousing</a> tutorial.</p><p>When you learn this Google version of SQL (<a href="https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types">Standard SQL</a>), you will not only learn how to analyze data, but you will also learn how to make predictions on data. For example, you could use this flavor of SQL to predict sales with a <a href="https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-create">linear regression</a>. As another example, you could also use this language to do a basic prediction as to whether or not a customer will make a transaction with a <a href="https://cloud.google.com/bigquery-ml/docs/bigqueryml-web-ui-start">logistic regression</a>.</p><h3>Step 2: Learn the Basics of Python</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m7JyLtq1ssptclHUwMsz5Q.jpeg" /><figcaption><em>Python (the programming language) has nothing to do with a snake which has the same name (Image courtesy of pexels.com)</em></figcaption></figure><p>If you want to get to the next level in your career, it is almost essential to learn some type of programming language. Personally I would recommend learning Python. Python’s flexible and it is relatively straight forward to learn. You can use to process streaming data with data pipelines, to analyze data with Jupyter notebooks, and to build artificial intelligence models. For me, it is one language that does a lot, and it is super flexible.</p><p>These are some top resources to learn Python, but they are not all free resources. In some cases, you “get what you pay for”, and paying for something may save you a lot of time in the long run.</p><h3>BEST RESOURCES TO GET STARTED WITH PYTHON</h3><ul><li><a href="https://learnpythonthehardway.org/python3/">Learn Python 3 the Hard Way</a> — White Owl Education has no affiliation with the author of “Learn Python 3 the Hard Way”, but when I was learning Python this one was one of the books that I used in order to ramp up. One note here — The book is very specific about what editor to use and how to get through the class. I would follow the instructions in the book to the letter without deviation.</li><li><a href="https://docs.python.org/3/tutorial/introduction.html">Official Python Tutorial</a> — The official Python tutorial (which is part of the reference documentation) is actually pretty good, but it doesn’t endorse any particular software for writing Python. Because of this, you’re still better off using a book like “Learn Python the Hard Way” before jumping into the official tutorial.</li><li><a href="https://docs.python.org/">Official Python Documentation</a> — Think of the official Python Documentation like a dictionary. You’re not going to read this front to back, but it is definitely a reference that you may want to use from time to time.</li></ul><p><strong>Take a look at </strong><a href="https://www.whiteowleducation.com/best-practices-to-become-a-data-engineer/"><strong>https://www.whiteowleducation.com/best-practices-to-become-a-data-engineer/</strong></a><strong> for the remainder of the article which covers the following</strong>:</p><h3>Step 3: Learn How to Navigate Code Quickly</h3><h3>Step 4: Learn the Basics of NumPy</h3><h3>Step 5: Learn the Basics of Pandas</h3><h3>Step 6: Learn How to Build Data Pipelines</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c16fcddb70c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[4 Ways to Effectively Debug Data Pipelines in Apache Beam]]></title>
            <link>https://medium.com/data-science/4-ways-to-effectively-debug-data-pipelines-in-apache-beam-6508a880f0b4?source=rss-3d6473be760d------2</link>
            <guid isPermaLink="false">https://medium.com/p/6508a880f0b4</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[mlops]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ralph Brooks]]></dc:creator>
            <pubDate>Mon, 29 Mar 2021 19:56:11 GMT</pubDate>
            <atom:updated>2022-02-22T19:50:18.674Z</atom:updated>
            <content:encoded><![CDATA[<h4>Save time debugging by running unit tests before deploying to the cloud, by using modular construction, and by programmatically generating unique labels</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*ktxccXIG9YqF2zjiBt6PJw.png" /><figcaption>Image by Author</figcaption></figure><p>Apache Beam is an open source framework that is useful for cleaning and processing data at scale. It is also useful for processing streaming data in real time. In fact, you can even develop in Apache Beam on your laptop and deploy it to Google Cloud for processing (the Google Cloud version is called DataFlow).</p><p>Beyond this, Beam touches into the world of artificial intelligence. More formally, it is used as a part of a machine learning pipelines or in automated deployments of machine learning models ( MLOps ). As a specific example, Beam could be used to clean up spelling errors or punctuation from a Twitter data before the data is sent to a machine learning model that determines if the tweet represents emotion that is happy or sad.</p><p>One of the challenges though when working with Beam is how to approach debugging and how to debug basic functionality on your laptop. In this blog post, I am going to show 4 ways that can help you improve your debugging.</p><p><strong>QUICK NOTE:</strong></p><p>This blog gives a high level overview of how to debug data pipelines. For a deeper dive, you may want to check out <a href="https://courses.whiteowleducation.com/courses/machine-learning-mastery/lectures/30683503">this video</a> which talks about unittests with Apache Beam and <a href="https://courses.whiteowleducation.com/courses/machine-learning-mastery/lectures/31386945">this video</a> which walks you through the debugging process for a basic data pipeline.</p><p><strong>1) Only run time-consuming unit tests if dependent libraries are installed</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ea275572a5bb111a75997928fe73f37/href">https://medium.com/media/6ea275572a5bb111a75997928fe73f37/href</a></iframe><p>If you are using unittest, it is helpful to have a test that only runs if the correct libraries are installed. In the above Python example, I have a try block which looks for a class within a Google Cloud library. If the class isn’t found, the unit test is skipped, and a message is displayed that says ‘GCP dependencies are not installed.’</p><p><strong>2) Use TestPipeline when running local unit tests</strong></p><p>Apache Beam uses a Pipeline object in order to help construct a <a href="https://en.wikipedia.org/wiki/Directed_acyclic_graph">directed acyclic graph</a> (DAG) of transformations. You could also use apache_beam.testing.TestPipeline so that you do less configuration when constructing basic tests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*cnz78hz0iVTO79ansnGTig.png" /><figcaption>Example of a directed acyclic graph (courtesy of <a href="https://en.wikipedia.org/wiki/Directed_acyclic_graph">https://en.wikipedia.org/wiki/Directed_acyclic_graph</a> )</figcaption></figure><p><strong>For 2 additional tips on how to debug data pipelines. Take a look at </strong><a href="https://www.whiteowleducation.com/4-ways-to-effectively-debug-data-pipelines-in-apache-beam/"><strong>https://www.whiteowleducation.com/4-ways-to-effectively-debug-data-pipelines-in-apache-beam/</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6508a880f0b4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/4-ways-to-effectively-debug-data-pipelines-in-apache-beam-6508a880f0b4">4 Ways to Effectively Debug Data Pipelines in Apache Beam</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[Best Practices for NLP Classification in TensorFlow 2.0]]></title>
            <link>https://medium.com/data-science/best-practices-for-nlp-classification-in-tensorflow-2-0-a5a3d43b7b73?source=rss-3d6473be760d------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5a3d43b7b73</guid>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Ralph Brooks]]></dc:creator>
            <pubDate>Fri, 08 Nov 2019 14:40:28 GMT</pubDate>
            <atom:updated>2023-01-03T15:34:33.416Z</atom:updated>
            <content:encoded><![CDATA[<h4>Use Data Pipelines, Transfer Learning and BERT to achieve 85% accuracy in Sentiment Analysis</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0rri8DhVm_23LK020vAjVQ.jpeg" /><figcaption>Photo by <a href="https://www.shutterstock.com/g/jirsak">Jirsak</a>, courtesy of <a href="https://www.shutterstock.com/image-photo/best-practice-concept-manager-businessman-coach-389578870?src=6771d7ae-169b-49d0-b929-1e0e91347c57-1-30">Shutterstock</a></figcaption></figure><p>When I first started working with Deep Learning, I went through Coursera and <a href="https://www.fast.ai/">fast.ai</a> courses, but afterwards I wondered where to go from here. I started asking questions like “How do I develop a data pipeline for a model?” and “How do I implement state-of-the-art research?”.</p><p>This blog post answers these questions. The post covers the development a deep learning model in TensorFlow 2.0 from the ingestion of data all the way to the point where deep learning determines the emotion of a Yelp review (positive or negative). After reading this post, you will also be able to use <a href="https://github.com/huggingface/transformers">Huggingface’s Transformers library</a> [1] in order to create state of the art models using a new technique called transfer learning and using a “model backbone” from Google (<a href="https://arxiv.org/abs/1810.04805">BERT</a> [2]) that was pre-trained on Wikipedia.</p><h3>Complete code for this example</h3><p>The full code is located on my GitHub at <a href="https://github.com/ralphbrooks/tensorflow-tutorials">https://github.com/ralphbrooks/tensorflow-tutorials</a></p><h3>Best Practices for Model Construction</h3><p><strong>One of the keys to success in Deep Learning is to iterate quickly</strong>. If we are going to build a predictive model, it makes sense to store data once and write multiple experimental models based on that data. If we are going to build a predictive model, we want to put together a data pipeline where we can look at rows of information but where we don’t have to process all of the information before we train our model.</p><p>To illustrate these best practices, I am going to walk through the steps of creating a model that predicts sentiment (‘Negative’ or ‘Positive’ sentiment) based on a Yelp reviews of cell phone stores. I will use the Yelp API to extract random reviews for stores associated with the keyword “AT&amp;T”. and the associated rating (the “sentiment”). Our goal is to see if we can create a deep learning model that can determine sentiment based ONLY on the text.</p><h3>STEP 1: Store raw, clean data efficiently</h3><p>Our goal is to predict sentiment. The TensorFlow abstraction of understanding the relationships between labels (the Yelp ratings) and features (the reviews) is commonly referred to as a model.</p><p>The first step in this process is to think about the necessary inputs that will feed into this model. At this stage, it is helpful to think about the reviews and the sentiment score as a logical grouping. TensorFlow refers to this logical grouping as a tf.train.Example.</p><p>For our use case, we should start by defining the example. That definition is as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fb5a474195d365177354ebed1d0ee706/href">https://medium.com/media/fb5a474195d365177354ebed1d0ee706/href</a></iframe><p>Next, we are going to store these examples in an efficient manner in files called TFRecords.</p><p>Example code that writes out this information looks like the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9aefe8136d6ef4065afa25f160596b79/href">https://medium.com/media/9aefe8136d6ef4065afa25f160596b79/href</a></iframe><p>In summary, using TFRecords for storage allows you to do to a preliminary cleanup of data, and to store this data efficiently for use by multiple models.</p><h3>STEP 2: Build a pipeline for model specific transformations of data</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6RqYSJyx1Q8u8x41rTd0jg.jpeg" /><figcaption>We create pipelines to transform our raw, clean data into something that is gradually ingested by a model. Photo by <a href="https://www.shutterstock.com/g/nifty">Neale Cousland</a>- — Courtesy of <a href="https://www.shutterstock.com/image-photo/water-pipelines-hydroelectric-power-station-australias-489908086?src=efd217dd-e435-4544-b5b3-fc39eeffb747-1-15">Shutterstock</a></figcaption></figure><p>The second step is to create a data pipeline that will feed your features (the reviews) and the labels (the sentiment score) from the saved file (the TFRecord) into some type of neural network. In TensorFlow, data pipelines can be implemented using tf.data.Dataset.</p><p>tf.data.Dataset sets up your transformations without actually processing them until your model starts to train. This is critical if you are testing out your pipeline. Said differently, the last thing in the world that you want to do is to wait 3–4 minutes during different steps of data transformation because the previous transformation step is still running on all available data. It is better to have each step of the transformation pipeline operate on a small amount of data (a single batch of data) so that you can debug your pipeline faster.</p><p>The following code will help to make this concept more concrete:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dfb4cc72d1459356baebf6b71924101a/href">https://medium.com/media/dfb4cc72d1459356baebf6b71924101a/href</a></iframe><p>As seen below, a pipeline can also be used to clean up data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/01cf05803b9c5d13be67719ad8e151fd/href">https://medium.com/media/01cf05803b9c5d13be67719ad8e151fd/href</a></iframe><h3><strong>STEP 3: Use Transfer Learning Approach to Build model</strong></h3><p>In our example, we are attempting to get an understanding of human language and what emotion is contained in sentences. The first challenge that we have limited data; our model will only examine 738 reviews in order to determine sentiment.</p><p>If we predicted missing words from all pages in Wikipedia, the deep learning model would have enough data to detect basic language patterns, but I do not have enough computing power to process this information.</p><p>Because of these constraints, we are going to look at a model that has been pre-trained by another company and fine-tune this model with our limited training data (a concept typically called transfer learning). Specifically, we will use the BERT model from Google which has already been trained on Wikipedia information.</p><p><strong>Another best practice is to use proven frameworks when available.</strong> A startup company called Hugging Face has a framework called Transformers that makes it easier to use pre-trained models, and the following code shows how to convert words into numbers (tokenization) and to use the BERT model (TFBertForSequenceClassification)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88f6d2914b7243b11947bbc9dc0bf85a/href">https://medium.com/media/88f6d2914b7243b11947bbc9dc0bf85a/href</a></iframe><p>The Hugging Face Transformers framework also makes it easy to convert our data pipelines into something that can be understood by the BERT model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f07b2109e31ed65eaef0bbe53a58e7ea/href">https://medium.com/media/f07b2109e31ed65eaef0bbe53a58e7ea/href</a></iframe><h3>STEP 4: Train and Evaluate the NLP model</h3><p>Now, we are ready to train the model. If we run the model for 3 iterations (epochs), we see <strong>accuracy of 85 %.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/65c551a448eef6455d8341810d843906/href">https://medium.com/media/65c551a448eef6455d8341810d843906/href</a></iframe><p>This is still good considering that the Yelp rating captures the full sentiment of the user, but that in many cases, the Yelp API is only giving you part of the actual text review.</p><p>The visualization of the 85% accuracy looks like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*Nd4UmlseKLKq1qi4SlzjUw.gif" /></figure><p>The matrix above shows the following:</p><p>· If the person is expressing negative sentiment, the classifier gets it right 91% of the time.</p><p>· If the customer expresses positive sentiment, our model gets this right roughly 66% of the time.</p><p><strong>Congratulations! </strong>You made it to the end of the blog post, and you now have a process that takes you from building a data pipeline to having an accurate model.</p><h3>References:</h3><p>1) T. Wolf, L. Debut, V. Sanh, J. Chaumond, C. Delangue, and A. Moi. Huggingface’s Transformers: State-of-the-art Natural Language Processing. arXiv e-prints, October 2019.</p><p>2) J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova. BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. arXiv e-prints, October 2018.</p><h3>About White Owl Education</h3><p>Do you want to keep up with the current trends in artificial intelligence? Are you looking to process streaming data in real time or are you looking to deploy models into production?</p><p>If so, my company can help — Check us at out https://www.whiteowleducation.com</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5a3d43b7b73" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/best-practices-for-nlp-classification-in-tensorflow-2-0-a5a3d43b7b73">Best Practices for NLP Classification in TensorFlow 2.0</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>
    </channel>
</rss>