<?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 Toby Manders on Medium]]></title>
        <description><![CDATA[Stories by Toby Manders on Medium]]></description>
        <link>https://medium.com/@trm2124?source=rss-adde83d0b530------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*kV_SIVOv7ot4dwgLJmRiRw.jpeg</url>
            <title>Stories by Toby Manders on Medium</title>
            <link>https://medium.com/@trm2124?source=rss-adde83d0b530------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 17:21:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@trm2124/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[Deep Prognosis: Predicting Mortality in the ICU]]></title>
            <link>https://medium.com/insight-data/deep-prognosis-predicting-mortality-in-the-icu-900ffc8790a6?source=rss-adde83d0b530------2</link>
            <guid isPermaLink="false">https://medium.com/p/900ffc8790a6</guid>
            <category><![CDATA[insight-health-data]]></category>
            <category><![CDATA[healthcare]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Toby Manders]]></dc:creator>
            <pubDate>Tue, 05 Nov 2019 17:20:10 GMT</pubDate>
            <atom:updated>2020-01-17T20:34:22.521Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A-OvZXl5AEgjpw7jhKhnQA.png" /></figure><p><em>Originally posted on </em><a href="https://towardsdatascience.com/icu-mortality-5d0e80539b9e"><em>Towards Data Science</em></a><em>.</em></p><p>In medical school, we learn to identify lab abnormalities, their causes and treatments. When a patient is observed to have a blood potassium of 5.5 mmol/L, doctors can quickly identify the culprit (e.g. renal failure, acute kidney injury, ACE inhibitor-induced, etc.) in light of the patient’s history and presentation.</p><p>The more difficult questions for providers are: how exactly does this patient’s hyperkalemia affect her future health outcomes? What if the patient’s potassium were 5.2 instead of 5.5 mmol/L? What if her potassium rose from baseline in 3 days rather than 5? What if she has a history of chronic kidney disease? Furthermore, how do all the other items on a patient’s ‘problem list’ and in her past medical history affect her distribution of outcomes? What if their interplay is not merely additive? Can we ever hope to appreciate the interactions between hundreds or thousands of factors that shape outcomes for a single patient?</p><p>If we hope to succeed, we ought to look at complicated patients, who potentially offer the greatest insights and opportunities. Patients in the intensive care unit (ICU) are some of the most complicated in the hospital. In the dataset I used for this project, the average patient was ascribed 13 unique ICD-9 diagnosis codes while in the ICU alone. These patients have the highest mortality rates in the hospital: Each year there are 4 million ICU admissions in the U.S., approximately 500,000 of which result in death. And their care is some of the most expensive: With intensive therapies including mechanical ventilation, dialysis and infusions, a stay in the ICU could cost more than $10,000 per day. Most importantly for this project, these patients generate a tremendous amount of data — vital signs, lab results, interventions, progress notes, etc.</p><p><strong>Is it possible to use that abundant data to predict survival in these patients?</strong></p><p>Such a model would be able to answer the difficult questions above. Additionally, It would provide a single index of a patient’s acuity that could be easily interpreted by large and varied hospital teams. It would provide objective information that would be useful in end-of-life discussions between providers, patients and families. Importantly, the tool could remain flexible, so that it could predict events other than death.</p><h3>The Data: Preprocessing &amp; Feature Engineering</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*B1LoAwn7FVtFFmDL.png" /><figcaption>Overview of the Data</figcaption></figure><p>I used the eICU Collaborative Research Database for this project. Managed by MIT and distributed by Physionet, it’s publicly available, requiring only HIPAA before access. Collected over two years (2014 and 2015) from ICUs across the US, it contains an enormous amount of data about more than 200,000 patient-stays in the ICU. Of those patient-stays, a little more than 10,000 resulted in expiration.</p><p><strong>Data Preprocessing</strong></p><p>First, patients under 16 years old and those who stayed in the ICU less than 7 hours are removed from the dataset.</p><p>Different cleaning steps were needed for each type of dataset used: diagnoses, treatments, past medical history, periodic vital signs, aperiodic vitals, and lab results. Each was loaded and pre-processed independently according to its needs.</p><p>In order to train the model, positive and negative patients need to be identified, and timepoints for those events need to be saved for later extraction of features. Because I chose to keep the model flexible, different labeling algorithms were needed for identifying mortality and other events in the dataset. In the case of mortality prediction, all patients who expired are identified, and the last event (treatment or diagnosis) for that patient is used as the timestamp. In the case of a diagnosis, only patients who received that diagnosis more than three hours after admission are selected, and the first instance of that diagnosis is used for the timestamp.</p><p><strong>Feature Engineering</strong></p><p>After selecting positive and negative patients, feature vectors are generated for all of those examples. I used three categories of data — categorical, numerical and sequential.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/0*NlsaCWre5hqs8wMy.png" /></figure><p>Categorical features included ethnicity, gender, the admitting unit, and more. These are one-hot encoded.</p><p>Numerical features represented the bulk of the feature engineering work, and included vital signs, lab results, and static values like admission weight. I created 66 features here, employing my medical education. For example, one feature is the ratio of blood urea nitrogen (BUN) to serum creatinine, which is used to indicate the location of an acute kidney injury. For each feature, the maximum, minimum or mean value is calculated over one of three windows, a 4-hour window just prior to the ‘present moment’ (i.e. the prediction timepoint), a window extending from admission to the present moment, or a baseline window lasting the first six hours of admission. Other features, like the BUN-to-creatinine ratio, the creatinine change from baseline, or the arterial-to-inspired oxygen ratio (the PF ratio) are calculated from these first features. Missing values are tolerated for these features, although the 10% of examples missing the greatest number of features are removed. The remaining missing values are replaced with the feature mean and are scaled.</p><p>Finally, the sequential features include the past medical history diagnoses (given in English), diagnoses given in the ICU up until the present moment (given in English and ICD-9 codes) and therapeutic and diagnostic interventions up until the present moment. After translating all of the past medical history diagnoses to the common language of ICD-9 codes, all of these events are arranged by timestamp — in the order in which they actually happened.</p><h3>A Multimodal Deep Learning Model</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/0*o_UKlw6_b3H8k4KU.png" /><figcaption>A flexible, multimodal architecture for predicting diagnoses or survival from ICU data.</figcaption></figure><p>I chose to keep the diagnoses and treatments of each patient in sequential order so as to preserve the clinical patterns that I know to be important. For example, a patient with a history of malignancy who now has unilateral swelling of the leg is relatively likely to be diagnosed with a pulmonary embolism.</p><p>I needed a model architecture that would respect that sequential information, so I used a long short-term memory (LSTM) network with a bidirectional wrapper and 32 units. I also wanted the model to learn representations for each diagnosis and treatment, so I used an embedding layer with 32-element vectors, which the model learns as it trains.</p><p>With three 16-unit hidden layers, as determined by hyperparameter tuning, the RNN achieved an area under the ROC curve (AUROC) of 0.85.</p><p>Next, I trained a DNN on just the categorical and numerical data. Three hidden layers of 32 units each with 50% dropout between each layer worked best here, and after feature selection and engineering, the DNN achieved an AUROC of 0.87.</p><p>In order to combine the two models, I popped the last layer off of each model and concatenated the outputs. That layer serves as input for a 3-layer, 64-unit DNN with dropout. An additional auxiliary output from the categorical/numerical DNN ensures that part of the network learns a representation useful to the final task. So how did the composite model perform?</p><h3>Results</h3><p>At the final timepoint, the composite model achieves a state-of-the-art AUROC of 0.91. But even days out from the last observation, the model performs well — reliably identifying the patients with the worst prognoses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-Co3dZkGO4URFUHa.png" /><figcaption>At every timepoint, the composite model performs best. Even days out, the model performs well.</figcaption></figure><p>If we look at examples of individual patients’ predictions over time, we can see how the model responds to new information:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XX-_3WR-2O8cXiCK.png" /><figcaption>The model recognizes a patient’s worsening clinical picture.</figcaption></figure><p>As the patient’s clinical picture worsens with a sequence of inauspicious events — stroke, respiratory failure, pneumonia, shock — the model correctly escalates its output, demonstrating that the score can be viewed as a severity index.</p><p>Looking at a representation of the first principal components of the embeddings the model has learned, we see an interesting pattern:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Cov7eb5V2MP8BgpZ.png" /></figure><p>The pressors are far to the right — norepinephrine, vasopressin, phenylephrine. And mechanical ventilation is there, too. This stands to reason, as hemodynamic instability and ventilation ought to be markers of poor prognosis.</p><p>But as noted above, I wanted the model to remain flexible — so new models can be trained just by changing the diagnosis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/0*Bgz9tuLYwlUn1B8i.gif" /><figcaption>Training a new model is as easy as changing one input.</figcaption></figure><p>I included a wide variety of features — renal, pulmonary, hepatic, and cariovascular — so that the model performs well with other diagnoses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OCfOKHcbDb359mu_.png" /><figcaption>The model performs well across a variety of diagnoses.</figcaption></figure><h3>Conclusion</h3><p>In summary, I’ve built a multimodal, flexible deep learning model and tool for providers, hospitals and insurers, that not only provides a single metric for a patient’s severity and mortality likelihood, but can also predict other events.</p><p>I had a lot of fun on this project. Thanks for reading!</p><p><strong><em>Are you interested in working on high-impact projects and transitioning to a career in data? </em></strong><a href="https://notify.insightdatascience.com/notify?utm_source=deepprognosis&amp;utm_medium=blog">Sign up to learn more</a> about the <a href="https://www.insightdatascience.com/?utm_source=deepprognosis&amp;utm_medium=blog">Insight Fellows programs</a> and <a href="https://apply.insightdatascience.com/?utm_source=deepprognosis&amp;utm_medium=blog">start your application today</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=900ffc8790a6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/insight-data/deep-prognosis-predicting-mortality-in-the-icu-900ffc8790a6">Deep Prognosis: Predicting Mortality in the ICU</a> was originally published in <a href="https://medium.com/insight-data">Insight</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep Prognosis: Predicting Mortality in the ICU]]></title>
            <link>https://medium.com/data-science/icu-mortality-5d0e80539b9e?source=rss-adde83d0b530------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d0e80539b9e</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[healthcare]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[medicine]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Toby Manders]]></dc:creator>
            <pubDate>Fri, 18 Oct 2019 18:00:21 GMT</pubDate>
            <atom:updated>2019-10-19T03:42:53.255Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RwT21ER3kfKRRiNi4fNZ-Q.png" /></figure><p>In medical school, we learn to identify lab abnormalities, their causes and treatments. When a patient is observed to have a blood potassium of 5.5 mmol/L, doctors can quickly identify the culprit (e.g. renal failure, acute kidney injury, ACE inhibitor-induced, etc.) in light of the patient’s history and presentation.</p><p>The more difficult questions for providers are: how exactly does this patient’s hyperkalemia affect her future health outcomes? What if the patient’s potassium were 5.2 instead of 5.5 mmol/L? What if her potassium rose from baseline in 3 days rather than 5? What if she has a history of chronic kidney disease? Furthermore, how do all the other items on a patient’s ‘problem list’ and in her past medical history affect her distribution of outcomes? What if their interplay is not merely additive? Can we ever hope to appreciate the interactions between hundreds or thousands of factors that shape outcomes for a single patient?</p><p>If we hope to succeed, we ought to look at complicated patients, who potentially offer the greatest insights and opportunities. Patients in the intensive care unit (ICU) are some of the most complicated in the hospital. In the dataset I used for this project, the average patient was ascribed 13 unique ICD-9 diagnosis codes while in the ICU alone. These patients have the highest mortality rates in the hospital: Each year there are 4 million ICU admissions in the U.S., approximately 500,000 of which result in death. And their care is some of the most expensive: With intensive therapies including mechanical ventilation, dialysis and infusions, a stay in the ICU could cost more than $10,000 per day. Most importantly for this project, these patients generate a tremendous amount of data — vital signs, lab results, interventions, progress notes, etc.</p><p><strong>Is it possible to use that abundant data to predict survival in these patients?</strong></p><p>Such a model would be able to answer the difficult questions above. Additionally, It would provide a single index of a patient’s acuity that could be easily interpreted by large and varied hospital teams. It would provide objective information that would be useful in end-of-life discussions between providers, patients and families. Importantly, the tool could remain flexible, so that it could predict events other than death.</p><h3>The Data: Preprocessing &amp; Feature Engineering</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-lKWDk5JNgBNZtftH8a8VQ.png" /><figcaption>Overview of the Data</figcaption></figure><p>I used the eICU Collaborative Research Database for this project. Managed by MIT and distributed by Physionet, it’s publicly available, requiring only HIPAA before access. Collected over two years (2014 and 2015) from ICUs across the US, it contains an enormous amount of data about more than 200,000 patient-stays in the ICU. Of those patient-stays, a little more than 10,000 resulted in expiration.</p><p><strong>Data Preprocessing</strong></p><p>First, patients under 16 years old and those who stayed in the ICU less than 7 hours are removed from the dataset.</p><p>Different cleaning steps were needed for each type of dataset used: diagnoses, treatments, past medical history, periodic vital signs, aperiodic vitals, and lab results. Each was loaded and pre-processed independently according to its needs.</p><p>In order to train the model, positive and negative patients need to be identified, and timepoints for those events need to be saved for later extraction of features. Because I chose to keep the model flexible, different labeling algorithms were needed for identifying mortality and other events in the dataset. In the case of mortality prediction, all patients who expired are identified, and the last event (treatment or diagnosis) for that patient is used as the timestamp. In the case of a diagnosis, only patients who received that diagnosis more than three hours after admission are selected, and the first instance of that diagnosis is used for the timestamp.</p><p><strong>Feature Engineering</strong></p><p>After selecting positive and negative patients, feature vectors are generated for all of those examples. I used three categories of data — categorical, numerical and sequential.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*ln9XJzMwC97DWnLy8WkqWA.png" /></figure><p>Categorical features included ethnicity, gender, the admitting unit, and more. These are one-hot encoded.</p><p>Numerical features represented the bulk of the feature engineering work, and included vital signs, lab results, and static values like admission weight. I created 66 features here, employing my medical education. For example, one feature is the ratio of blood urea nitrogen (BUN) to serum creatinine, which is used to indicate the location of an acute kidney injury. For each feature, the maximum, minimum or mean value is calculated over one of three windows, a 4-hour window just prior to the ‘present moment’ (i.e. the prediction timepoint), a window extending from admission to the present moment, or a baseline window lasting the first six hours of admission. Other features, like the BUN-to-creatinine ratio, the creatinine change from baseline, or the arterial-to-inspired oxygen ratio (the PF ratio) are calculated from these first features. Missing values are tolerated for these features, although the 10% of examples missing the greatest number of features are removed. The remaining missing values are replaced with the feature mean and are scaled.</p><p>Finally, the sequential features include the past medical history diagnoses (given in English), diagnoses given in the ICU up until the present moment (given in English and ICD-9 codes) and therapeutic and diagnostic interventions up until the present moment. After translating all of the past medical history diagnoses to the common language of ICD-9 codes, all of these events are arranged by timestamp — in the order in which they actually happened.</p><h3>A Multimodal Deep Learning Model</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*Y3W53Vr5RE1LQ9uF-7WGDQ.png" /><figcaption>A flexible, multimodal model for predicting diagnoses or survival from ICU data.</figcaption></figure><p>I chose to keep the diagnoses and treatments of each patient in sequential order so as to preserve the clinical patterns that I know to be important. For example, a patient with a history of malignancy who now has unilateral swelling of the leg is relatively likely to be diagnosed with a pulmonary embolism.</p><p>I needed a model architecture that would respect that sequential information, so I used a long short-term memory (LSTM) network with a bidirectional wrapper and 32 units. I also wanted the model to learn representations for each diagnosis and treatment, so I used an embedding layer with 32-element vectors, which the model learns as it trains.</p><p>With three 16-unit hidden layers, as determined by hyperparameter tuning, the RNN achieved an area under the ROC curve (AUROC) of 0.85.</p><p>Next, I trained a DNN on just the categorical and numerical data. Three hidden layers of 32 units each with 50% dropout between each layer worked best here, and after feature selection and engineering, the DNN achieved an AUROC of 0.87.</p><p>In order to combine the two models, I popped the last layer off of each model and concatenated the outputs. That layer serves as input for a 3-layer, 64-unit DNN with dropout. An additional auxiliary output from the categorical/numerical DNN ensures that part of the network learns a representation useful to the final task. So how did the composite model perform?</p><h3><strong>Results</strong></h3><p>At the final timepoint, the composite model achieves a state-of-the-art AUROC of 0.91. But even days out from the last observation, the model performs well — reliably identifying the patients with the worst prognoses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SDSYVitEMOTv3ujWgouSTw.png" /><figcaption>At every timepoint, the composite model performs best. Even days out, the model performs well.</figcaption></figure><p>If we look at examples of individual patients’ predictions over time, we can see how the model responds to new information:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6DFxLYiBGs4HcjpevFSKiQ.png" /><figcaption>The model recognizes a patient’s worsening clinical picture.</figcaption></figure><p>As the patient’s clinical picture worsens with a sequence of inauspicious events — stroke, respiratory failure, pneumonia, shock — the model correctly escalates its output, demonstrating that the score can be viewed as a severity index.</p><p>Looking at a representation of the first principal components of the embeddings the model has learned, we see an interesting pattern:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p3s3h9TSvIBVAYnnK_VsfA.png" /></figure><p>The pressors are far to the right — norepinephrine, vasopressin, phenylephrine. And mechanical ventilation is there, too. This stands to reason, as hemodynamic instability and ventilation ought to be markers of poor prognosis.</p><p>But as noted above, I wanted the model to remain flexible —so new models can be trained just by changing the diagnosis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*nKaGbDlzhbS9nEOHfxl4ZA.gif" /><figcaption>Training a new model is as easy as changing one input.</figcaption></figure><p>I included a wide variety of features — renal, pulmonary, hepatic, and cariovascular — so that the model performs well with other diagnoses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TfItOhakjUu9YokYYUbnNQ.png" /><figcaption>The model performs well across a variety of diagnoses.</figcaption></figure><h3>Conclusion</h3><p>In summary, I’ve built a multimodal, flexible deep learning model and tool for providers, hospitals and insurers, that not only provides a single metric for a patient’s severity and mortality likelihood, but can also predict other events.</p><p>I had a lot of fun on this project. Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d0e80539b9e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/icu-mortality-5d0e80539b9e">Deep Prognosis: Predicting Mortality in the ICU</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[Scraping and Sentiment Analysis of 1.5 Million Audible Reviews]]></title>
            <link>https://medium.com/data-science/scraping-and-sentiment-analysis-of-1-5-million-audible-reviews-3502fa6bc86c?source=rss-adde83d0b530------2</link>
            <guid isPermaLink="false">https://medium.com/p/3502fa6bc86c</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Toby Manders]]></dc:creator>
            <pubDate>Mon, 08 Jul 2019 03:11:52 GMT</pubDate>
            <atom:updated>2019-07-08T16:18:38.416Z</atom:updated>
            <content:encoded><![CDATA[<h3>Sentiment Analysis of 1.5 Million Audible Reviews</h3><p>In <a href="https://towardsdatascience.com/scraping-and-exploring-the-entire-english-audible-catalog-ea279cd09f88">the first part</a> of this project, we collected and explored a dataset containing, among other fields, the <a href="https://en.wikipedia.org/wiki/Amazon_Standard_Identification_Number">ASIN</a>, number of ratings and an individual URL for every English-language program on Audible.</p><p>We’ll pick up where we left off by using these fields to scrape as many text reviews and accompanying ratings as possible. Then we’ll train a number of LSTM neural networks to classify reviews as either positive or negative.</p><p>(Note: You can jump to the scraping notebook <a href="https://github.com/tobymanders/Data_Analysis/blob/master/audible_eda/audible_reviews_scraper.ipynb">here </a>and the data pre-processing and sentiment analysis notebook <a href="https://github.com/tobymanders/Data_Analysis/blob/master/audible_eda/audible_review_classifier.ipynb">here</a>. You can download the dataset of all reviews <a href="https://drive.google.com/file/d/1Wka-rYvEykaG4fGR71zDis5d1NOFZlLX/view?usp=sharing">here</a>.)</p><h3>1. Scraping 1.5 Million Reviews</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M91PtdjRNcqC4UJxCnLwVg.png" /></figure><p>We previously examined the distribution of ratings across the Audible catalog, noting the extreme concentration of ratings for the select few programs at the top ( a roughly linear relationship between the log of the title’s rank and log of the number of reviews).</p><p>We’ll use that skewness to our advantage today in order to maximize the number of reviews we can scrape per hour. Assuming that the number of written reviews per title is proportional to the number of ratings per title, <strong>we can expect roughly 50% of all the site’s reviews to be concentrated in the top ~1% of programs</strong> in our dataset.</p><p>There’s one obstacle to scraping these reviews from the HTML. Most of the reviews of the most popular titles are hidden beneath a ‘See More’ button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*03R3DABVFWsyRYQVKEPjMA.png" /></figure><p>Inspecting the network requests when clicking that button provides us with a solution. We find a URL that points us to a spare page of just review text and ratings. By incrementing the page number in this URL until the HTML comes up blank, we can gather all of the reviews and ratings for a given program. Because this page is so quick to load (and because we’re using 16 threads), we’re able to scrape the top ~80% of all reviews from the top ~6% (26,101) of programs in a reasonable amount of time.</p><p>While scraping, we’ll take the opportunity to do a few housekeeping tasks. We’ll be using our text to train a machine learning model to classify reviews as favorable (4 or 5 stars) or unfavorable (1, 2 or 3 stars). If we leave the titles and authors in our review text, our model is likely to ‘memorize’ that, say, a given program has very high review scores. This does not bode well for generalization, so we’ll want to remove the authors and titles from the reviews. We’ll do it now so we don’t need to store that information for each review.</p><p>The process of replacing words with a common item — ‘&lt;unk&gt;’ , short for ‘unknown’— is called ‘unking’. In addition to unking the author and title from each review, we’ll also replace periods with the word ‘stop’, strip all other punctuation, and change all text to lower case. This reduces the number of ‘words’ in our dataset.</p><p>A few hours later we have more than 1.5 million reviews and ratings.</p><h3>2. Preparing the Data</h3><p>While we’ve actually scraped three ratings for each review, ‘overall’, ‘story’ and ‘performance’, we’re going to focus on the ‘overall’ column as our labels. The two other columns we’ll save for a future analysis.</p><p>In order to get our data and targets into the form we will need to train a model, we need to accomplish the following preprocessing tasks:</p><ol><li>Create a vocabulary from the top <em>vocab_size </em>words in our data by frequency, where <em>vocab_size</em> is a hyperparameter.</li><li>‘Unk’ — i.e. replace with “&lt;unk&gt;” — all of the words in our dataset that are not in our vocabulary.</li><li>Pad or truncate all entries to some common length, <em>seq_length</em>, also a hyperparameter.</li><li>Tokenize (i.e. convert to integers) all words in our dataset.</li><li>Create binary labels from the ‘overall’ column.</li></ol><p>Our goal is to have our data X as an array of integers with shape <em>(num_reviews, seq_length)</em> and our labels y as an vector of integers with length <em>num_reviews</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*Cj7i8yHAIU6IkzPmDYnvcQ.png" /><figcaption>The first few entries. Text normalized and authors and titles removed.</figcaption></figure><p>To decide on upper and lower length cutoffs, let’s look at the distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VGdf0NKdiWLcVKwr5v-hJw.png" /><figcaption>Distributions of text character and word length over all reviews.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_XMAu1TBW__FerlL6by-Qg.png" /></figure><p>The length vs. frequency plots above show what looks like an exponential decay. 96.4% of reviews are shorter than 250 words. We’ll choose that as our <em>seq_length</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*INYfar2Ti_Aub2tqvzgH2g.png" /></figure><p>What about the lower limit? The chart on the left shows us the vast majority (&gt;98%) of reviews left in our dataset (after earlier removing entries with blank text) have &gt; 10 words. We’ll use that as our lower cutoff.</p><p>Sorting what’s left by length in characters, we see the shortest reviews with more than 10 ‘words’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*2W4rTIchIgZBw0pS0xlCCQ.png" /><figcaption>Shortest reviews with &gt;10 ‘words’. Note that ‘words’ are everything between spaces.</figcaption></figure><p>Our next task is to construct a vocabulary from all of our reviews. We’ll use a counter dictionary to count the frequency of each word in our dataset, and then we’ll take the most frequent 10,000 words to build our vocabulary, which we’ll use to ‘unk’ our dataset — i.e. replace every word not in our vocabulary with the word ‘unk’. We also want to convert our dataset to an array of numbers — i.e. ‘tokens’ — and we can do both of these tasks in the same function.</p><p>Testing our function on some sample text:</p><pre>sample = ‘i really loved dfalkjf especially the introduction’<br>...<br>print(tokenize_text(sample))</pre><pre>Unk ID: 24<br>[4, 56, 79, 24, 301, 1, 1190]</pre><p>Notice that the unrecognized ‘dfalkjf’ was given the ‘unk’ token of 24. The rest of the tokens correspond to the rank of the word in our vocabulary.</p><p>After padding, truncating and tokenizing, here’s what our data look like:</p><pre>array([[  24,    0,    0, ...,   24,   24,   24],<br>       [  24,    9,   11, ...,   24,   24,   24],<br>       [ 149,  149,  149, ...,   24,   24,   24],<br>       ...,<br>       [ 131,   32,  873, ...,   24,   24,   24],<br>       [   5, 3312,  368, ...,   24,   24,   24],<br>       [ 172,  195,    1, ...,   24,   24,   24]])</pre><p>Notice the columns of 24 at the end of each row, this is padding with the ‘unk’ token.</p><p>Finally we create our binary labels from the ‘overall’ rating, and find that ~79% of reviews receive either a 4 or 5 star rating. This number is important to note because it means that even the simplest model (one that always predicts 1) will earn a 79% accuracy. That’s the number to beat.</p><h3>3. Training the Model(s)</h3><p>Now that the preparation step is out of the way, we can train our model. Using TensorFlow and Keras layers we can try a number of different architectures with different numbers of parameters. All of our models will have an embedding as the first layer, which turns each word into a vector of some length, a hyperparameter.</p><p>All our models will also have at least one RNN layer (specifically a long short-term memory or LSTM layer). This layer will be used in both a forward and backward pass. In each case the LSTM layer will feed into a dense layer with a relu activation function and an output layer with a sigmoid activation function, which will produce a value between 0 and 1 that will be thresholded to deliver a class prediction.</p><p>Other layers we’ll add in will be dropout layers to reduce overfitting, including a special type of dropout layer after our embedding layer that drops entire 1-D feature maps rather than individual words, and a 1-D convolutional layer that will learn a set of filters that will pull out features from relationships between neighboring words. We’ll also try stacking two layers of LSTMs.</p><p>We’ll make use of the binary crossentropy loss, the Adam optimizer, and we’ll employ the early stopping callback, which will stop training when the validation loss starts to increase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EAwR2oJ147FBTx_2U3u6AA.png" /><figcaption>The training set and validation set accuracy for one of our best models. The validation loss bottomed out on the 5th epoch and training was stopped early.</figcaption></figure><h3>3. Results</h3><p>The best-performing model was indeed the most complex of the bunch — with a <strong>93.8% accuracy</strong> on an unseen test set of ~155,000 reviews. It’s worth noting, however, that the least complex model achieved a 93.1% accuracy.</p><p>Our least complex model consisted of only three hidden layers: an embedding layer with embedding length of just 8, an LSTM with only 8 units, and a fully connected layer with just 16 units. It had a total of 81k parameters, and took 53 minutes to train.</p><pre>model = tf.keras.Sequential([</pre><pre>    <strong>tf.keras.layers.Embedding(vocab_size, 8),<br>    tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(8)),<br>    tf.keras.layers.Dense(16, activation=&#39;relu&#39;),</strong></pre><pre>    tf.keras.layers.Dense(1, activation=&#39;sigmoid&#39;)<br>])</pre><p>Our most complex model, and the winner overall, had 7 hidden layers including dropout, convolutional and pooling layers in addition to the LSTM layer:</p><pre>model = tf.keras.Sequential([</pre><pre>    <strong>tf.keras.layers.Embedding(vocab_size, 128),<br>    tf.keras.layers.SpatialDropout1D(rate=0.4),<br>    tf.keras.layers.Conv1D(filters=32, kernel_size=3,                                                           padding=&#39;same&#39;, activation=&#39;relu&#39;),<br>    tf.keras.layers.MaxPooling1D(pool_size=2),<br>    tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(128)),<br>    tf.keras.layers.Dense(128, activation=&#39;relu&#39;),<br>    tf.keras.layers.Dropout(rate=0.4),</strong></pre><pre>    tf.keras.layers.Dense(1, activation=&#39;sigmoid&#39;)<br>])</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CWQd-8pqPo8R6VRYxNlB1A.png" /></figure><p>For binary classification, the receiver operating characteristic (ROC) curve gives a good idea of the discriminatory power of a model. It reflects the fact that as you decrease the threshold on your final probability outputs, you capture more true positives, but also more false positives. A perfect model will assign higher probabilities to positive than to negative examples, and so decreasing the threshold will capture more positives without capturing more negatives. Thus the curve will hew closely to the upper left corner. The AUC equivalently measures the area under the ROC curve (the closer to 1 the better). Here our model has an AUC on test data of 0.975.</p><p>Let’s test our model by example and feed it a few pieces of text. We’ll give it four sequences. Less than 0.5, the model predicts negative; greater than 0.5, positive.</p><blockquote>“This dreadful book was terrible. Really, it was just awful.”</blockquote><p>Our model correctly scores this a 0.01 — i.e. about as close to 0 as possible.</p><blockquote>“I loved this book. It was outstanding, hilarious and amazing.”</blockquote><p>This gets a 0.99. How about something ambiguous:</p><blockquote>“This book was okay, but it made me feel sad.”</blockquote><p>0.52. Our model is torn. How about combining both positive and negative terms:</p><blockquote>“The story is really great, but the narrator is horrible.”</blockquote><p>0.72. The model weighs the ‘really great’ section more heavily than the ‘narrator is horrible’ section. Perhaps if we retrained our model on the ‘performance’ rating, we’d get a different result here.</p><p>Finally, let’s look at the word embeddings our model has learned. The learned vector for each word in our vocabulary should reflect some useful information about that word for predicting positive or negative reviews. In order to visualize the spatial relationships between these representations, we’ll need to reduce the word vectors to a more human-digestible number of dimensions.</p><p>Principal component analysis (PCA) is a method of transforming the data such that its most information-rich dimension (i.e. the dimension that contains the greatest variance) becomes axis-aligned (i.e. the first dimension of your result). We’ll use PCA to reduce our 128-dimensional embedding vectors to 2 dimensions so that we may visualize the relationships between words:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d3Vw4xmAvSAqvq31tm9xWw.png" /><figcaption>A 2D representation (the first two principal components) of our learned word embeddings for 61 key words.</figcaption></figure><p>The first two principal components of 61 common words in our vocabulary generate the striking chart above. Here generally unfavorable words, e.g. ‘fascinating’ and ‘excellent’ , are rendered in blue; favorable words, e.g. ‘terrible’ and ‘boring’, are rendered in red, and neutral words, e.g. ‘acting’ and ‘book’ are rendered in black.</p><p>Our embeddings clearly reflect the polarity of these terms. Even finer relationships seem to be represented. For example, we intuit the relationships between close pairs ‘monotonous’ and ‘monotone’ , ‘worse’ and ‘worst’, ‘tedious’ and ‘tiresome’, ‘sound’ and ‘narrator’, ‘audio’ and ‘quality’, and so on.</p><p>By repeating the process over the whole vocabulary and looking at just the first principle component, we can identify the words with the most positive and negative salience. The word with the highest value is ‘wellspent’ [sic].</p><p>The word with the lowest value?</p><p>‘Refund’.</p><p>Finally let’s generate predictions on the entire training set to find the ‘worst’ and ‘best’ reviews.</p><p>The ‘worst’ review:</p><blockquote>WASTE, WASTE, WASTE. SAVE YOUR CREDIT.</blockquote><blockquote><strong>What would have made &lt;title&gt; better?</strong></blockquote><blockquote>There is nothing that could make this book better. Be warned. This book is not even as funny as some say. Why buy a zombie horror book that is funny?</blockquote><blockquote><strong>What do you think your next listen will be?</strong></blockquote><blockquote>Not sure, other than to say something with zombies and or an apocalypse, but definitely nothing by the author or narrator of this book.</blockquote><blockquote><strong>What didn’t you like about &lt;narrator&gt;’s performance?</strong></blockquote><blockquote>The sound of her voice. That way she made all the characters sound alike.</blockquote><blockquote><strong>You didn’t love this book… but did it have any redeeming qualities?</strong></blockquote><blockquote>Zero… Even worse, since it’s digital media and not a physical book I can’t even burn it to warm up. I have read terms of service that would have been a much better listen/read than this book.</blockquote><blockquote><strong>Any additional comments?</strong></blockquote><blockquote>I’m a true fan of zombie and apocalypse stories in any format.. This book though should not have been written let alone…</blockquote><p>The ‘best’ review:</p><blockquote><strong>AWESOME</strong></blockquote><blockquote>Awesomeness awesomeness awesomeness awesomeness awesomeness &lt;unk&gt; awesomeness &lt;unk&gt; &lt;unk&gt; awesomeness awesomeness &lt;unk&gt; awesomeness &lt;unk&gt; awesomeness &lt;unk&gt; &lt;unk&gt; awesomeness awesomeness &lt;unk&gt; awesomeness &lt;unk&gt; awesomeness &lt;unk&gt; awesomeness awesomeness</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3502fa6bc86c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/scraping-and-sentiment-analysis-of-1-5-million-audible-reviews-3502fa6bc86c">Scraping and Sentiment Analysis of 1.5 Million Audible Reviews</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[Scraping and Exploring the Entire English Audible Catalog]]></title>
            <link>https://medium.com/data-science/scraping-and-exploring-the-entire-english-audible-catalog-ea279cd09f88?source=rss-adde83d0b530------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea279cd09f88</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[audible]]></category>
            <dc:creator><![CDATA[Toby Manders]]></dc:creator>
            <pubDate>Wed, 03 Jul 2019 01:53:15 GMT</pubDate>
            <atom:updated>2019-07-05T23:42:35.507Z</atom:updated>
            <content:encoded><![CDATA[<p>Last week I wrote a script using the HTML-Requests package for Python to scrape information from Audible about programs included in their current 2-for-1 credit sale. After experimenting with threading hyperparameters I managed to get my script’s performance up to about 55 entries per second, which meant Audible’s entire English-language catalog of ~400k programs could be scraped in about two hours. A couple hours later I had a complete dataset.</p><p>(Note: If you like code, you can jump straight to <a href="https://github.com/tobymanders/Data_Analysis/blob/master/audible_eda/audible_scraper.ipynb">the scraping notebook</a> and <a href="https://github.com/tobymanders/Data_Analysis/blob/master/audible_eda/audible_data_analysis.ipynb">the analysis notebook</a>. You can also download <a href="https://drive.google.com/file/d/1btf5Eq6U-GfG3iScpX6lMluCt6SgS45c/view?usp=sharing">the entire dataset</a>.)</p><p>After loading and processing the data to get rid of duplicates and convert object types, I had 352,686 entries with the following fields: title, author, category (genre), length, narrator, price, rating (rounded at the source to increments of 0.5), rating count, release date, and URL.</p><p><em># What’s the total length of audio represented in our data?</em></p><p>230 years, 235 days, 15 hours</p><p><em># Which are the largest categories by hours and ratings?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*09yHyPZD5y89lSeCMBlekg.png" /></figure><p>Interestingly, the top three categories by total length of offerings are the reverse of the top three by number of ratings. In other words, the engagement (i.e. number of reviews) per hour of content is much higher for ‘Sci-Fi &amp; Fantasy’ programs than for ‘Fiction’. Let’s see if we can quantify further. Since the number of reviews per hour may be a less fair metric than the number of reviews per title (we assume some genres have longer titles than others, on average), let’s adopt the latter. Let’s see if the engagement trend continues with this alternate metric.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DjlyXxer3yFCB0zoKszqqg.png" /><figcaption>Categories sorted from left to right by mean number of reviews.</figcaption></figure><p>A couple of interesting findings here: First, ‘Sci-Fi &amp; Fantasy’ continues to have the highest engagment by average number of reviews per title. Yet now it loses to ‘Romance’ when considering the median number of reviews rather than the mean (22 vs. 23). Furthermore, the distribution of ‘Romance’ reviews is tighter than that of any other category here. These findings taken together suggest that ‘Romance’ has a more bimodal distrubution than other categories. We should expect that a larger percentage of titles have few or no reviews, bringing the mean down. However the titles that are popular are getting a lot of reviews each, bringing the median up. In other words, ‘Romance’ listeners are less adventurous in their program selection than some other genre listeners.</p><p><em># How are ratings distributed across titles?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tUNOUOl87x820W7h4IixHQ.png" /></figure><p>Note: that first plot is not a mistake. Plotting without nonlinear axes means that the number of titles with very few reviews dominates the plot. In fact, more than 200k of our ~350k programs have fewer than 10 total reviews. The second plot, which as a straight x-axis and log-scale y-axis, demonstrates the tiny number of titles with greater than 100,000 reviews — 7, to be exact. The third plot shows us that the log of the rating count varies roughly linearly with the log of the frequency of that rating count. In other words it’s lonely at the top.</p><p><em># What are those rarified few books with &gt;100k ratings?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FhTyjnVRLk_Z8PDJbKjfnA.png" /><figcaption>Ready Player One dominates the field in number of ratings.</figcaption></figure><p>Some things to note: All of these titles are significantly more expensive than the $15.42 mean price of the entire Audible catalog. The categories represented are more diverse than we might expect: two science fiction, one fantasy, one thriller, two autobiographical and one self help title. All but one title were released in the past decade. Ready Player One has an enormous number of reviews. In fact, <strong>that one title has more reviews than 174,000 other programs combined</strong>.</p><p><em># Which authors have the greatest number of ratings overall?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5oHBESIn1PsErBUN2-N64g.png" /></figure><p>Stephen King wins for the total number of reviews across his books with more than 600,000 of them. Impressively <a href="https://www.audible.com/pd/11-22-63-Audiobook/B005UR3VFO?qid=1561787500&amp;sr=1-95&amp;pf_rd_p=e81b7c27-6880-467a-b5a7-13cef5d729fe&amp;pf_rd_r=4J20H7H6997HA7FQ79X1&amp;ref=a_search_c3_lProduct_2_45">his title with the greatest number of ratings</a> only has 51,695. His place at the top of the chart here is a testament to how prolific he’s been. He has 130 separate recordings on Audible not screened out by our duplicate search.</p><p>In the second plot we consider the average number of reviews per program for authors with more than two titles on Audible (in order to screen ‘one-hit wonders’ and their samples/alternate versions). Andy Weir takes the cake, buoyed by The Martian, which was the number two title overall.</p><p><em># Which authors have the greatest number of titles and recorded hours?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ITqgE6eF0n-lVjfhYoeJ8Q.png" /></figure><p>Continuing to investigate the most prolific authors in our dataset, we look at the total duration of audio and the number of recordings (excluding periodicals). Charles Dickens dominates the total duration battle with nearly 5,000 hours on audible. He and Arthur Conan Doyle, number two, seem to both be benefitting from the many renditions of their works on Audible. A Tale of Two Cities alone has 37 different versions! James Patterson doesn’t enjoy that advantage and wins among contemporary authors.</p><p>Slicing the cake slightly differently, Doyle and Dickens swap places for number of recordings on Audible. Arthur Conan Doyle has 706 versions of his works on Audible in total.</p><p><em># Which narrators have the greatest number of ratings?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cib5QZe2-Ge1D_xM2eXUxQ.png" /></figure><p>The titles Scott Brick has narrated (658 of them!) have racked up the greatest number of ratings by nearly a factor of two. Same as above, we look at the narrators with the greatest ‘impact’ (by number of ratings per work, at least) on the right. Roy Dotrice (with 10 titles) takes the top spot for his work narrating the A Song of Ice and Fire books, the first of which was on our list of the seven titles to break 100,000 ratings.</p><p><em># Which narrators have the greatest number of hours on Audible?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WbO_KMbXm-v75c9ie9T1vg.png" /></figure><p>We see two sides of the same coin — Scott Brick has the greatest output by number of hours, with 658 titles and an average of 12 hours 39 minutes per title. Cathy Dobson wins by number of titles with 1161 at an average of 2 hours 53 minutes each.</p><p><em># How does the title release date relate to the number of reviews</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tEFGxzyV3sTtCu-VjmkVNA.png" /><figcaption>We can see a spike for each of the 7 outliers above.</figcaption></figure><p>While we might expect older titles to benefit from having more time to accumulate ratings, we see the opposite trend. More recent programs have been more likely to garner more reviews.</p><p><em># How many titles have been released in each quarter since 1996?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IB8CoSFb6YWzk_zZwGDc9A.png" /><figcaption>Histogram of release dates with one bin per quarter.</figcaption></figure><p>Notice that there’s a large bin in the last quarter of 1999. In fact, the most frequent date in our dataset is 12/16/1999. Although you might think that date is retroactively applied to all earlier titles, that’s not the case. The minimum date in the dataset is 12/1/1995 — the same year Audible was founded. Moreover Google doesn’t return much from the news about Audible in December 1999, although the company was having an eventful year. The original founder had just passed in October.</p><p>The other interesting finding here is the three-quarters-long dip in releases during 2015. In fact — that dip makes 2015 the only year since 2002 in which fewer titles were released than in the previous year.</p><p>Side note: the latest date in the dataset is 12/10/2020 for The Poisoner by Sharon Bolton.</p><p><em># What is the distribution of prices over all programs?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m8hTNqG3EyVZFZKl-PVfWg.png" /></figure><p>The mean price of all books is $15.43, which incidentally is near the ~$15 price per credit for some of the Audible monthly plans. There are spikes at every $5 interval as we’d expect given _4.99 and _9.99 pricing schemes.</p><p># How do prices vary by category?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CBdCLWJd70Hk05PX_fbfSA.png" /><figcaption>Categories ranked, left to right, by mean price</figcaption></figure><p>‘Mysteries &amp; Thrillers’ has the largest average price at $20.53. ‘Newspapers &amp; Magazines’ has the cheapest average price at $2.81. No big surprises here.<br>We can see from our boxplot our likely most expensive title — the outlier in the ‘Language Instruction’ category. Let’s find out what it is.</p><p><em># What is the most expensive program on Audible?</em></p><p>$173.27 buys you <a href="https://www.audible.com/pd/Pimsleur-Spanish-Level-2-Audiobook/B00384HI5K?qid=1561790205&amp;sr=1-81&amp;pf_rd_p=e81b7c27-6880-467a-b5a7-13cef5d729fe&amp;pf_rd_r=WE6SNSRCHHR05XZN553B&amp;ref=a_search_c3_lProduct_2_31">the priciest English title on all of Audible</a> — and 982 minutes (~16 hours) of Spanish language instruction.</p><p><em># What is the most expensive program per hour?</em></p><p>The most expensive title per unit length is the 1-minute-long program Masterpiece by Jeff Hathaway, which costs $10.49 — or $629.40 per hour.</p><p><em># What’s the distribution of program lengths (excluding periodicals)?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jCQwcJlfsRaUU_hxD76cAQ.png" /></figure><p>‘Newspapers &amp; Magazines’, ‘Radio &amp; TV’, ‘Live Events’, and ‘Drama &amp; Poetry’ were excluded from this chart as they are dominated by very short programs. We can see that there are still quite a few short (&lt;5 hour) programs, but there’s a nice bell curve of longer titles with median right around 7 hours.</p><p>We might infer that this length plot is a composite result of combining a long-form distribution with a shorter-form distribution. Let’s look at categories and see if we can pinpoint which are which.</p><p><em># What are the length distributions by category?</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kKdhDOlYcDXQbpyukFHuxw.png" /><figcaption>Categories ordered, left to right, by decreasing mean length</figcaption></figure><p>Indeed we find disparate length distributions by category. ‘Newspapers &amp; Magazines’ has the shortest mean program length at 28 minutes. ‘Sci-Fi &amp; Fantasy’ has the longest mean length at just over 9 hours.</p><p>Right away we see some length outliers in our boxplot, and we’ll explore those in a moment, but first — let’s validate our theory about the composite distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dj-AKQcM5e6aoTnBzqr8hw.png" /></figure><p># Finally, what are the longest books on Audible?</p><pre>df.nlargest(5, &#39;length&#39;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iF9UzdUzNrOMxZfI98Gjsg.png" /></figure><p>4 of the 5 longest programs on Audible are in the ‘Religion &amp; Spirituality’ category. The longest is 154 hours. The only title outside of that category is Edward Gibbon’s expansive 19th century history, ‘The Decline and Fall of the Roman Empire,’ which has incidentally led to the decline and fall of my eyelids at night for years.</p><p>So there we have it. We’ve looked at most of our features in turn: author, narrator, rating count, release date, length, price and category. We looked at the most prolific names in the industry as well as the longest and most expensive titles. The only feature we haven’t explored quite yet is the ‘rating’ column itself — and that’s because when we were scraping, we were only able to capture gradations of 0.5 from the html we had access to. With the links in hand, we are free to rescrape more granular ratings from the pages for individual programs, but we’ll save that for another day.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea279cd09f88" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/scraping-and-exploring-the-entire-english-audible-catalog-ea279cd09f88">Scraping and Exploring the Entire English Audible Catalog</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[NYC Restaurant Inspection EDA]]></title>
            <link>https://medium.com/@trm2124/nyc-restaurant-inspection-eda-bded8047b2ef?source=rss-adde83d0b530------2</link>
            <guid isPermaLink="false">https://medium.com/p/bded8047b2ef</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[exploratory-data-analysis]]></category>
            <category><![CDATA[nyc]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Toby Manders]]></dc:creator>
            <pubDate>Thu, 27 Jun 2019 20:33:12 GMT</pubDate>
            <atom:updated>2019-06-27T20:34:58.523Z</atom:updated>
            <content:encoded><![CDATA[<p>An exploratory data analysis of ~400k NYC restaurant inspections from 2011–2017.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Bhd0Yho8pQjXyj74cWqKw.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1c42647ca43fca89f7a243be301665b9/href">https://medium.com/media/1c42647ca43fca89f7a243be301665b9/href</a></iframe><p>Data retrieved from Kaggle: <a href="https://www.kaggle.com/new-york-city/nyc-inspections">https://www.kaggle.com/new-york-city/nyc-inspections</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bded8047b2ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>