Data Study on Diabetes Treatment

Posted on Feb 4, 2019
The skills the author demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

Data Study on Diabetes Treatment

This project was conducted to analyze data from public reviews and deduce possible factors that might be responsible for the effectiveness ratings in diabetes treatment. A significant proportion of the world population is diabetic, according to the World Health Organization, 8.5% of the current world population is diabetic and in the, U.S, 9.4% amounting to 30.3 million people live with diabetes.


Although there are many health service stores online, WebMd was chosen for this project because of its independence and comprehensive database. It is an online source for health-related information with huge user review database that includes the name, date, gender, duration of treatment, age range, comments and most importantly ratings based on effectiveness, ease of use and satisfaction.

Data Study on Diabetes Treatment

Scrapy, an open source website scraping framework was used to extract data of 3 diabetes drugs. The drugs are Avandia Oral, Metformin HCl and Invokana. All the information needed appear on one URL of WebMD which makes Scrapy a perfect tool to scrap the website. Upon download, data cleaning was the first exercise that needed to be carried out and was done before I analyzed the data. Below is the image of the data frame before cleaning.

Data Study on Diabetes Treatment

Some features that are of importance to this analysis that needed to be cleaned are the condition column which has attached to it some links, and duration column which was downloaded as a string(text) and need to be converted to integers. Upon cleaning, a new feature was added, created from averaging the duration feature, average duration.

Data Study on Diabetes Treatment


Effectiveness reviews of the drugs, the core of this project, were analyzed alongside the satisfaction ratings.

Bar plot of Avandia's satisfaction and effectiveness ratings

Below is how the effectiveness and satisfaction ratings of Avandia drug stack together:

Avandia's ratings

Bar plot of Metformin's satisfaction and effectiveness ratings

Metformin's ratings

Bar plot of Invokana's satisfaction and effectiveness ratings

Invokana's ratings

Apart from metformin with slightly more than average review, the drugs are highly rated in terms of effectiveness. Satisfaction ratings vary from drug to drug, users are highly unsatisfied with Avandia and Metformin while Invokana has a relatively favorable satisfaction.

Plot of age-range and duration against effectiveness ratings of Avandia drug

Bar Plot of age-range and duration against effectiveness ratings of Metformin drug

Plot of age-range and duration against effectiveness ratings of Invokana drug

From the plots in Figures 5,6 and 7, duration of treatment produced more interesting visuals than age-range of the user.  Effectiveness of the drugs tends to increase with continued usage of all the drugs. Users of Avandia for over two years period gave a very high effectiveness ratings while those that treated their condition with either metformin or Invokana for at least three months rated the effectiveness 4 stars and above.

Bar plot of different categories of age-range analyzed

Plot of gender distribution

The 2 figures above show the demographic make-up of the users, majority of diabetic patients are between the ages of 45 to 74 years, and are mostly females.


Scraping and analyzing WebMD reviews of three type II diabetes drugs has given some insight into public perception of the treatment. Prior to carrying out this project, one might assume a 5-star rated effective drug would translate to customer satisfaction, but this analysis has shown that it is not always the case and both can be independent of each other.

Further work will include sentiment analysis of the comments which could help elucidate what is responsible for customer dissatisfaction.

Based on the reviews, effectiveness improves with increased duration of treatment, while age-range of the patient does not affect potency of the drugs.

Analyzing these reviews can help medical practitioners make informed decisions based on real-life feedback as against the usual practice of relying solely on the information supplied by the Pharmaceutical companies and the FDA. More importantly is the insight this will give the producing pharmaceutical companies of these 3 drugs and other diabetic drug manufacturers, on the factors that affect the effectiveness of these drugs. In marketing, companies should consider the messaging, and in production, manufacturers should consider the formulations, active pharmaceutical ingredients and excipients since most consumers will be advised to stay on the drugs for a long period of time.


Oluwole Alowolodu


About Author

Oluwole Alowolodu

Recent graduate of Biotechnology - MS. Data science fellow and AI enthusiast.
View all posts by Oluwole Alowolodu >

Leave a Comment

No comments found.

View Posts by Categories

Our Recent Popular Posts

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI