<?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 Anita Tran on Medium]]></title>
        <description><![CDATA[Stories by Anita Tran on Medium]]></description>
        <link>https://medium.com/@anita.tran38?source=rss-125f92a40ab2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*mFUGisXDbsdOlvYF54vNBQ.png</url>
            <title>Stories by Anita Tran on Medium</title>
            <link>https://medium.com/@anita.tran38?source=rss-125f92a40ab2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 16:25:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anita.tran38/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[Predicting wait times using emergency room hospital data]]></title>
            <link>https://medium.com/@anita.tran38/predicting-wait-times-using-emergency-room-hospital-data-4bb1f17d3d84?source=rss-125f92a40ab2------2</link>
            <guid isPermaLink="false">https://medium.com/p/4bb1f17d3d84</guid>
            <category><![CDATA[hospital]]></category>
            <category><![CDATA[medical]]></category>
            <category><![CDATA[current]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Anita Tran]]></dc:creator>
            <pubDate>Fri, 20 Mar 2020 17:13:15 GMT</pubDate>
            <atom:updated>2020-03-20T18:56:31.828Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever stepped foot in the emergency room of a hospital in Toronto either for a loved one or perhaps yourself, only to be met with a grueling long wait until you see any medical professional?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SqY2DpG_79Bb8sEIFxahcA.jpeg" /></figure><p>It sucks. And there should definitely be a better system, right? Having volunteered at Toronto Western Hospital Emergency Department and being able to experience both sides of the system, I wanted to dig deep at what’s really going on and to actually do something about it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ys1a3AGNJVaWJuEL2_KHFg.png" /></figure><p>Technologies Used<br>* Python<br>*Pandas<br>*pipenv — for local storage of credentials<br>*Beautiful Soup — Web Scraping<br>*SKLearn pipelines<br>*DataFrameMapper<br>*HDBSCAN clustering<br>*Flask<br>*Google Maps API</p><p>### Introduction</p><p>PATIENTLY WAITING was created as my capstone project for the Data Science Immersive program at Bitmaker / General Assembly. A beta version of this application can be found here! Check emergency room wait times around Toronto by choosing a day: <a href="https://patientlywaiting.herokuapp.com/">https://patientlywaiting.herokuapp.com/</a></p><h3><strong>Data Gathering</strong></h3><p>Detailed administrative data on date, patient flow, current and past examinations in Ontario was provided by:<br>* [National Ambulatory Care Reporting System (NACRS)](<a href="https://www.cihi.ca/en/national-ambulatory-care-reporting-system-metadata">https://www.cihi.ca/en/national-ambulatory-care-reporting-system-metadata</a>)</p><p>* [Canadian Institude for Health Information (CIHI)](<a href="https://www.cihi.ca/en/access-data-and-report">https://www.cihi.ca/en/access-data-and-report</a>)</p><h3><strong>Data Modeling</strong></h3><p>The ability to accurately and reliably predict waiting times at walk-in hospital facilities can increase both patient satisfaction and hospital efficiency via a better management of patient flow. My web-app implements machine learning (ML) models to predict waiting times in the Emergency Room (ER) of the largest public hospital in the Greater Toronto Area (GTA).</p><p>Several machine learning (ML) techniques were evaluated to find the most accurate and useful prediction to a user. I chose [Gradient Boosting](<a href="https://medium.com/mlreview/gradient-boosting-from-scratch-1e317ae4587d">https://medium.com/mlreview/gradient-boosting-from-scratch-1e317ae4587d</a>) among other regression models explored for predicting wait times.</p><p>*PATIENTLY WAITING** is currently in beta testing. If you notice any bugs, have any questions or suggestions, I’d love to hear from you: [<a href="/service/mailto:anita.tran38@gmail.com">anita.tran38@gmail.com</a>](<a href="/service/mailto:anita.tran38@gmail.com">anita.tran38@gmail.com</a>?subject=PatientlyWaiting).</p><p><a href="https://media.makeameme.org/created/me-patiently-waiting-399b1150e6.jpg">https://media.makeameme.org/created/me-patiently-waiting-399b1150e6.jpg</a></p><h3><strong>Planned Future Enhancements</strong></h3><p>* Docker for hosting database, nginx and flask web app<br>* Google API to read your location<br>* Actively scrape hospital data as it is released per month on hqontatio.ca<br>* Generate best route to hospital using combinatorial optimization</p><p>If you’d like to play around with the tool, a beta version is running here: <a href="https://patientlywaiting.herokuapp.com/">https://patientlywaiting.herokuapp.com/</a></p><p>The complete project source code (which is still in the process of being updated) can be found on [GitHub](<a href="https://github.com/anitatea/patiently_waiting">https://github.com/anitatea/patiently_waiting</a>).</p><p>```python</p><p>```</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4bb1f17d3d84" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Epic visualizations to plot epidemics]]></title>
            <link>https://medium.com/@anita.tran38/epic-visualizations-to-plot-epidemics-71274d131c76?source=rss-125f92a40ab2------2</link>
            <guid isPermaLink="false">https://medium.com/p/71274d131c76</guid>
            <category><![CDATA[visualization]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[opioids]]></category>
            <category><![CDATA[plotly]]></category>
            <dc:creator><![CDATA[Anita Tran]]></dc:creator>
            <pubDate>Mon, 27 Jan 2020 05:00:00 GMT</pubDate>
            <atom:updated>2020-04-30T18:26:04.233Z</atom:updated>
            <content:encoded><![CDATA[<h3>Epic Visualizations to Plot Anything</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cb1VNB6Gjgbt2Lqo5hu--w.jpeg" /><figcaption>Photo: Pexels.com</figcaption></figure><p>Data visualization is one of my favourite creative outlets — to draw out deeper insights from meaningful data.</p><p>Visualization packages in Python is far from scarce and there are great options for static graphs.</p><p>However, as data gets more complex and understanding becomes more distant, there is an obvious need for interactive visualizations to easily explore data. What I’m currently exploring is Plotly and my favourite part so far is the extensive documentation and highlighted projects made with Plotly.</p><h3>What’s <a href="https://plot.ly/">Plotly/Dash</a></h3><p>Their mission is<em> “Bringing data science out of the lab and into the business.”, </em>which I translate to making visualization a lot easier.</p><p>Formally only available for enterprise, Dash is now an open source library (free!) for creating interactive web-based visualizations. Highly interactive web application using Python or R.</p><p>HTML/CSS/JavaScript not required <em>(… and the door is that-a-way)</em>.</p><p>What I think makes it powerful is it is able to incorporate all the functionalities of Python for data manipulation and much more.</p><p>Amazon, Cisco, Shell, among other worldwide enterprises have been embracing this tool for large scale deployments.</p><h4>Let’s Get Started</h4><pre>pip install dash</pre><h4>Sample Interactive Bar Chart</h4><p>I used data from the <a href="https://data.cdc.gov/NCHS/NCHS-Drug-Poisoning-Mortality-by-State-United-Stat/44rk-q6r2">Centers for Disease Control and Prevention on Drug Poisoning Mortality by State in the United States</a>. I’m going to build an interactive bar chart that shows absolute deaths per state in 2016 and 2017. (The dataset has been updated on April 29, 2019 and so I believe this is the most accurate dataset to this date.)</p><p>Bring in all the dash modules and pandas for reading and manipulating the data. I saved this file as bar_app.py:</p><pre>import dash<br>import dash_core_components as dcc<br>import dash_html_components as html<br>import plotly.graph_objs as go<br>import pandas as pd # to manipulate our data</pre><p>For this simple example, I’m choosing to import the plotly.graph_objs whereas the documentation uses dcc.graph to build the plot.</p><p>Writing this article, I felt that it was easier to use the plotly graph object since there were a lot more examples online than there were the plain dcc.graph for the simple cases.</p><p>This is my preference and I do find it more straightforward to demonstrate this example.</p><p>Reading in the first few pieces of data and filtering for deaths by state in 2016 and 2017:</p><pre>df = pd.read_csv(&#39;data/NCHS_-_Drug_Poisoning_Mortality_by_State__United_States.csv&#39;)</pre><pre>df.iloc[:,:7].head()</pre><p>In our example, we’ll only be looking at the State, Year and Deaths columns.</p><pre>df = df[[&#39;State&#39;, &#39;Year&#39;,&#39;Deaths&#39;]]</pre><p>Taking a look at all the state names.</p><pre>df[&#39;State&#39;].unique()</pre><blockquote>Output:</blockquote><blockquote>array([‘Alabama’, ‘Alaska’, ‘Arizona’, ‘Arkansas’, ‘California’,<br> ‘Colorado’, ‘Connecticut’, ‘Delaware’, ‘District of Columbia’,<br> ‘Florida’, ‘Georgia’, ‘Hawaii’, ‘Idaho’, ‘Illinois’, ‘Indiana’,<br> ‘Iowa’, ‘Kansas’, ‘Kentucky’, ‘Louisiana’, ‘Maine’, ‘Maryland’,<br> ‘Massachusetts’, ‘Michigan’, ‘Minnesota’, ‘Mississippi’,<br> ‘Missouri’, ‘Montana’, ‘Nebraska’, ‘Nevada’, ‘New Hampshire’,<br> ‘New Jersey’, ‘New Mexico’, ‘New York’, ‘North Carolina’,<br> ‘North Dakota’, ‘Ohio’, ‘Oklahoma’, ‘Oregon’, ‘Pennsylvania’,<br> ‘Rhode Island’, ‘South Carolina’, ‘South Dakota’, ‘Tennessee’,<br> ‘Texas’, <strong>‘United States’</strong>, ‘Utah’, ‘Vermont’, ‘Virginia’,<br> ‘Washington’, ‘West Virginia’, ‘Wisconsin’, ‘Wyoming’],<br> dtype=object)</blockquote><p>“United States’” is obviously not a state. I suspect it captures deaths that are uncategorized.<br>To keep our visualization simple, we’ll drop these rows.</p><pre>indexUS = df[df[&#39;State&#39;] == &#39;United States&#39;].index<br>df = df.drop(indexUS)</pre><pre># filter for 2017<br>df_2016 = df[df[&#39;Year&#39;] == 2016]<br><br># filter for 2017<br>df_2017 = df[df[&#39;Year&#39;] == 2017]</pre><p>Now that the data is simply tabulated by state and total deaths; we can build out the bars in our graph.</p><p>The convention for plotly is that each item being plotted is usually called a trace. In this example, we want to plot State vs. Deaths.</p><pre>trace1 = go.Bar(x=df_2016[&#39;State&#39;], y=df_2016[&#39;Deaths&#39;], name=&#39;2016&#39;,<br>        marker=dict(color=&#39;rgb(55, 83, 109)&#39;) # darker blue<br>        )<br>trace2 = go.Bar(x=df_2017[&#39;State&#39;], y=df_2017[&#39;Deaths&#39;], name=&#39;2017&#39;,<br>        marker=dict(color=&#39;rgb(26, 118, 255)&#39;) # lighter blue<br>        )</pre><p>Now we’re ready to build the Dash app.</p><pre>app = dash.Dash()<br><br>app.layout = html.Div(children=[<br>    html.H1(children=&#39;Drug Poisoning in the United States in 2016 &amp; 2017&#39;),<br>    html.Div(children=&#39;&#39;&#39;(Hover over bars to view death count)&#39;&#39;&#39;),<br>    dcc.Graph(<br>        id=&#39;example-graph&#39;,<br>        figure={<br>            &#39;data&#39;: [trace1, trace2],<br>            &#39;layout&#39;:<br>            go.Layout(title=&#39;Drug Poisoning Mortality by State in 2016 &amp; 2017&#39;, barmode=&#39;group&#39;)<br>        })<br>])</pre><p>Most of the structure is dash building the app, using HTML components and creating the figure dictionary, containing instructions to build the graph and customize layout.</p><p>What I love is the simplicity of how dash integrates HTML components beautifully without having to deal with the standard HTML/CSS/JS boilerplate required for most modern web apps that you see.</p><p>Since I’m dealing with various code styles, Atom is my preferred editor to manage matching brackets, parentheses and such.</p><p>dcc.Graph defines the figure using a using a dictionary that contains the actual figure, plotted data and layout options. In this case, the layout was needed to define the title and bar type graph.</p><p>Once the app is laid out, we need to make sure it can run:</p><pre>if __name__ == &#39;__main__&#39;:<br>    app.run_server(debug=True)</pre><p>Running this in your terminal:</p><pre>python bar_app.py</pre><p>Here’s our nice interactive graph!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OIAvlEMZ54ZAe3AhrAKztw.gif" /><figcaption>Easier to navigate than my tabs</figcaption></figure><p>Pretty great when you think how much engagement you can get with a simple application of 35 lines of code. You can find the above example available on github.</p><p>Not only is the layout and look of dash clean and report-ready; Dash also took care of scaling the interactivity on different browsers. So we can focus on beautiful, pure python!</p><p>The entire code:</p><pre>import dash<br>import dash_core_components as dcc<br>import dash_html_components as html<br>import plotly.graph_objs as go<br>import pandas as pd<br><br>df = pd.read_csv(&#39;NCHS_-_Drug_Poisoning_Mortality_by_State__United_States.csv&#39;)<br><br>df = df[[&#39;State&#39;, &#39;Year&#39;,&#39;Deaths&#39;]]<br><br>indexUS = df[df[&#39;State&#39;] == &#39;United States&#39;].index<br>df = df.drop(indexUS)<br><br>df_2016 = df[df[&#39;Year&#39;] == 2016]<br>df_2017 = df[df[&#39;Year&#39;] == 2017]<br><br>trace1 = go.Bar(x=df_2016[&#39;State&#39;], y=df_2016[&#39;Deaths&#39;], name=&#39;2016&#39;,<br>        marker=dict(color=&#39;rgb(55, 83, 109)&#39;))<br>trace2 = go.Bar(x=df_2017[&#39;State&#39;], y=df_2017[&#39;Deaths&#39;], name=&#39;2017&#39;,<br>        marker=dict(color=&#39;rgb(26, 118, 255)&#39;))<br><br>app = dash.Dash()<br>app.layout = html.Div(children=[<br>    html.H1(children=&#39;Drug Poisoning in the United States in 2016 &amp; 2017&#39;),<br>    html.Div(children=&#39;&#39;&#39;(Hover over bars to view death count)&#39;&#39;&#39;),<br>    dcc.Graph(<br>        id=&#39;example-graph&#39;,<br>        figure={<br>            &#39;data&#39;: [trace1, trace2],<br>            &#39;layout&#39;:<br>            go.Layout(title=&#39;Drug Poisoning Mortality by State in 2016 &amp; 2017&#39;, barmode=&#39;group&#39;)<br>        })<br>])<br>if __name__ == &#39;__main__&#39;:<br>    app.run_server(debug=True)</pre><h3>For Fun: A More Complex Example</h3><p>It took some time and I focus more on aesthetics than I should but Plotly is pretty easy to pick up overall to put together any dashboard that’d impress your friends.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9GOOlTQKmmo1H7PJDMl4Cg.png" /><figcaption><a href="https://epic-epidemic.herokuapp.com/">https://epic-epidemic.herokuapp.com/</a></figcaption></figure><p>Dash’s real power shines in its ability to combine complex interactions — again all with Python. Dash provides several interactive components out of the box including Dropdowns, Multi-Select Dropdowns, Mapping, Radio Buttons, Checkboxes, Sliders, and Text Input. All of them can be easily constructed and tied into your plots to drive various interactive options.</p><p>Here’s the <a href="https://epic-epidemic.herokuapp.com/">link</a> to the dashboard. Layout inspired by examples from the Dash-Plotly gallery of even more amazing dashboards!</p><h3>Final Thoughts</h3><p>I’ve only scratched the surface of this powerful yet simplistic tool. My favourite pieces:</p><ul><li>Quick for building web-based visualization tools without prior knowledge of JavaScript and other web technologies</li><li>Default dashboard is already responsive</li><li>Ability to save, zoom, pan and interact with the display, on the display</li></ul><p>Presenting data-driven visualizations to non-technical colleagues can be a struggle, as if you are speaking two different languages without Google Translate. I’ve seen more than my fair share of presentations and the truly successful ones were the most engaging with their audience.</p><p><em>Originally published at </em><a href="https://anitatran.ca/2020/01/dash-plotly.html"><em>https://anitatran.ca</em></a><em> on January 27, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71274d131c76" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>