Category Archives: Health System Performance

Health System Performance

Understanding indicators used to measure health quality

Justetc Social Services (non-profit)

Justetc Social Services (non-profit)Jan 31 · 16 min read

This code works with the data on the excel file: indicator-methodology.xls

Purpose:

  1. Find out prominant indicators — this might also mean the critical aspect of health
  2. Find out the measurements that are used to find the quality

Code Reference: This code heavily makes use of the code provided on the Text Visualization Lab. The methods might have been used as is i.e used as libraries

# COMMENT IF PACKAGES ALREADY INSTALLED (if pip does not work use pip3)
# !pip install nltk
# !pip install wordcloud
# !pip install pytagcloud
# !pip install pygame
# !pip install simplejson
# !pip install bs4
# !pip install networkx
# !pip install gensimimport nltk
#nltkownload() ##choose stopwords to download
from nltk.corpus import stopwords
from nltk.util import ngrams
from bs4 import BeautifulSoup
# import urllib2
import urllib.request as urllib2
import re
from collections import Counter
from wordcloud import WordCloud
import matplotlib.pyplot as plt
%matplotlib inline
from pytagcloud import create_tag_image, make_tags, LAYOUT_MIX
import operator
from IPython.display import Image
import nltk.data
import networkx as nx
import sys
sys.setrecursionlimit(10000)
nltk.download('stopwords')
nltk.download('punkt')
# nltk.download() ## download stopwords and punkt

import networkx as nx
import randompygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html


[nltk_data] Downloading package stopwords to C:\Users\Sayed
[nltk_data] Ahmed\AppData\Roaming\nltk_data...
[nltk_data] Package stopwords is already up-to-date!
[nltk_data] Downloading package punkt to C:\Users\Sayed
[nltk_data] Ahmed\AppData\Roaming\nltk_data...
[nltk_data] Package punkt is already up-to-date!# https://www.kaggle.com/c/word2vec-nlp-tutorial/details/part-1-for-beginners-bag-of-words
def clean_text( raw_review ):
# Function to convert a raw review to a string of words
# The input is a single string (a raw movie review), and
# the output is a single string (a preprocessed movie review)
#
# 1. Remove HTML
review_text = BeautifulSoup(raw_review)
#Remove javascript elements
for script in review_text(["script", "style"]):
script.extract() # rip it out

# get text
review_text = review_text.get_text()
# 2. Remove non-letters
letters_only = re.sub("[^a-zA-Z]", " ", review_text)
#
# 3. Convert to lower case, split into individual words
words = letters_only.lower().split()
#
# 4. In Python, searching a set is much faster than searching
# a list, so convert the stop words to a set
stops = set(stopwords.words("english"))
#
# 5. Remove stop words
meaningful_words = [w for w in words if not w in stops]
#
# 6. Join the words back into one string separated by space,
# and return the result.
return( " ".join( meaningful_words ))


def constructtree(lst,tree,factor, parent=None):
if lst==[]:
return {}
else:
word =lst[0]
if parent:
edges.append((parent, word))
else:
edges.append(('root', word))
if not word in tree.keys(): #tree.has_key(word): for python 2
tree[word]={'name':word,'value':1/factor,"children":{}}
tree[word]["children"]=constructtree(lst[1:],tree[word]["children"],factor, word)
else:
#print 22
tree[word]["value"]+=1/factor
tree[word]["children"]=constructtree(lst[1:],tree[word]["children"],factor, word)
return tree

def doall(wl,tree):
for x in wl:
# print (11,x) #
# print()
tree2=constructtree(x,tree,1)
tree=tree2
# print (1,tree) #
# print()
return tree, edges



def hierarchy_pos(G, root=None, width=10., vert_gap = 0.2, vert_loc = 0, xcenter = 0.5):

'''
From Joel's answer at https://stackoverflow.com/a/29597209/2966723

If the graph is a tree this will return the positions to plot this in a
hierarchical layout.

G: the graph (must be a tree)

root: the root node of current branch
- if the tree is directed and this is not given, the root will be found and used
- if the tree is directed and this is given, then the positions will be just for the descendants of this node.
- if the tree is undirected and not given, then a random choice will be used.

width: horizontal space allocated for this branch - avoids overlap with other branches

vert_gap: gap between levels of hierarchy

vert_loc: vertical location of root

xcenter: horizontal location of root
'''
if not nx.is_tree(G):
raise TypeError('cannot use hierarchy_pos on a graph that is not a tree')

if root is None:
if isinstance(G, nx.DiGraph):
root = next(iter(nx.topological_sort(G))) #allows back compatibility with nx version 1.11
else:
root = random.choice(list(G.nodes))

def _hierarchy_pos(G, root, width=1., vert_gap = 0.2, vert_loc = 0, xcenter = 0.5, pos = None, parent = None):
'''
see hierarchy_pos docstring for most arguments

pos: a dict saying where all nodes go if they have been assigned
parent: parent of this branch. - only affects it if non-directed

'''

if pos is None:
pos = {root:(xcenter,vert_loc)}
else:
pos[root] = (xcenter, vert_loc)
children = list(G.neighbors(root))
if not isinstance(G, nx.DiGraph) and parent is not None:
children.remove(parent)
if len(children)!=0:
dx = width/len(children)
nextx = xcenter - width/2 - dx/2
for child in children:
nextx += dx
pos = _hierarchy_pos(G,child, width = dx, vert_gap = vert_gap,
vert_loc = vert_loc-vert_gap, xcenter=nextx,
pos=pos, parent = root)
return pos


return _hierarchy_pos(G, root, width, vert_gap, vert_loc, xcenter)

Fetch Indicator Data i.e. indicator methodology

This will give an idea what are the primary indicators used to measure healthcare quality

import pandas as pdindicator_methodology = pd.read_excel('../data/indicator-methodology.xls')
indicator_methodology.columns
indicator_methodology.head()
png
indicator_methodology['Indicator definition'][:5]0    Number of deaths due to cancer per 100,000 fem...
1 Number of deaths due to cancer per 100,000 males.
2 Number of deaths due to ischemic heart disease...
3 Number of deaths due to cerebrovascular diseas...
4 Number of deaths due to transport accidents \n...
Name: Indicator definition, dtype: object# get all indicators in a raw text variable
raw_indicator = ''
raw_measure = ''

for aRow in range(indicator_methodology.shape[0]):
raw_indicator += ' ' + indicator_methodology['Indicator label'][aRow] + str('')
raw_measure += ' ' + str(indicator_methodology['Indicator definition'][aRow])

#raw = pd.merge(indicator_methodology['Indicator label'], indicator_methodology['Indicator definition'])

raw_indicator[:100], raw_measure[:100]
raw_measure' Number of deaths due to cancer per 100,000 females. Number of deaths due to cancer per 100,000 males. Number of deaths due to ischemic heart disease \nper 100,000 population.Number of deaths due to ischemic heart disease \nper 100,000 population.Number of deaths due to ischemic heart disease \nper 100,000 population.Number of deaths due to ischemic heart disease \nper 100,000 population. Number of deaths due to cerebrovascular diseases \nper 100,000 population.Number of deaths due to cerebrovascular diseases \nper 100,000 population.Number of deaths due to cerebrovascular diseases \nper 100,000 population.Number of deaths due to cerebrovascular diseases \nper 100,000 population. Number of deaths due to transport accidents \nper 100,000 females.Number of deaths due to transport accidents \nper 100,000 females.Number of deaths due to transport accidents \nper 100,000 females.Number of deaths due to transport accidents \nper 100,000 females. Number of deaths due to transport accidents \nper 100,000 males.Number of deaths due to transport accidents \nper 100,000 males.Number of deaths due to transport accidents \nper 100,000 males.Number of deaths due to transport accidents \nper 100,000 males. Number of deaths due to suicide per 100,000 females. Number of deaths due to suicide per 100,000 males. Deaths of children younger than 1 year per 1,000 live births. Percentage of the population age 15+ who report their health to be “good” or better. Average number of years that a female can be expected to live, assuming that age-specific mortality levels remain constant. Average number of years that a male can be expected to live, assuming that age-specific mortality levels remain constant. Percentage of the population age 15+ who report eating fruit at least once per day. Percentage of the population age 15+ who report eating vegetables at least once per day. Percentage of the female population age 15+ who report that they are daily smokers. Percentage of the male population age 15+ who report that they are daily smokers. Average annual alcohol consumption in litres per capita \n(age 15+).Average annual alcohol consumption in litres per capita \n(age 15+).Average annual alcohol consumption in litres per capita \n(age 15+). Percentage of adults who are obese (body mass index higher than 30 kg/m²), self-report. Median wait time (in days) from specialist assessment \n(booking date) to cataract surgery.Median wait time (in days) from specialist assessment \n(booking date) to cataract surgery.Median wait time (in days) from specialist assessment \n(booking date) to cataract surgery. Median wait time (in days) from specialist assessment \n(booking date) to hip replacement.Median wait time (in days) from specialist assessment \n(booking date) to hip replacement.Median wait time (in days) from specialist assessment \n(booking date) to hip replacement. Median wait time (in days) from specialist assessment \n(booking date) to knee replacement.Median wait time (in days) from specialist assessment \n(booking date) to knee replacement.Median wait time (in days) from specialist assessment \n(booking date) to knee replacement. Percentage of people able to get an appointment to see a doctor or a nurse on the same or next day last time they were sick or needed medical attention. Percentage of people who needed care after hours and reported difficulty getting medical care in the evenings, on weekends or on holidays without going to the hospital emergency department/emergency room. Percentage of adults who waited for 4 weeks or more after they were advised to see or decided to see a specialist. Percentage of people who had a medical problem but did not consult/visit a doctor because of the cost. Percentage of people with a regular doctor or place of care. Percentage of adults age 65+ who received an influenza vaccination within the past year. Number of hospital discharges for COPD of people age 15 and older per 100,000 population. Number of hospital discharges for asthma of people age 15 and older per 100,000 population. Number of hospital discharges for diabetes of people age 15 and older per 100,000 population. Percentage of adults who report that their regular doctor always or often spent enough time with them. Percentage of adults who report that their regular doctor always or often explains things in a way that is easy to\xa0understand. Percentage of older adults (age 55+) who report that their regular doctor always or often gave them an opportunity to ask questions or raise concerns. Percentage of adults who report that their regular doctor always or often involved them as much as they wanted in decisions about their care and treatment. 5-year relative survival rate for breast cancer. Number of deaths due to breast cancer, per 100,000 females. 5-year relative survival rate for cervical cancer. Number of deaths due to cervical cancer, per 100,000 females. 5-year relative survival rate for colorectal cancer. Number of deaths due to colorectal cancer, \nper 100,000 population.Number of deaths due to colorectal cancer, \nper 100,000 population. Percentage of patients (age 45+) who die in hospital within 30 days of being admitted with a primary diagnosis of acute myocardial infarction (AMI). Percentage of patients (age 45+) who die in hospital within 30 days of being admitted with a primary diagnosis of \nischemic stroke.Percentage of patients (age 45+) who die in hospital within 30 days of being admitted with a primary diagnosis of \nischemic stroke. Rate of a foreign body left inside the patient’s body during a procedure, per 100,000 hospital discharges (age 15+). Rate of post-operative pulmonary embolism, per 100,000 discharges for hip and knee replacement (age 15+). Rate of post-operative sepsis, per 100,000 discharges for abdominal surgery (age 15+). Percentage of vaginal deliveries with third- or fourth-degree obstetric trauma, per 100 instrument-assisted vaginal deliveries. Percentage of vaginal deliveries with third- or fourth-degree obstetric trauma, per 100 vaginal deliveries without instrument\xa0assistance. Percentage of patients with diabetes with prescription of first-choice antihypertensive medication. Number per 1,000 patients age 65+ with prescriptions of more than 365 daily doses of benzodiazepines or related drugs. Number per 1,000 patients age 65+ with at least one prescription of long-acting benzodiazepines or related drugs. Total volume of antibiotics prescribed for systemic use, in defined daily doses per 1,000 population per day. Volume of second-line antibiotics as a percentage of all antibiotics prescribed. nan nan nan'

Clean data

text = clean_text(raw_indicator)

# I wrote similar code as part of NLP assignments
# remove punctuations
from nltk.tokenize import RegexpTokenizer
tokenizer = RegexpTokenizer("[\w]+")
text = tokenizer.tokenize(text)

text


# get the list of stop words
from nltk.corpus import stopwords
stops = set(stopwords.words('english'))
print ('stop word count', len(stops) )

# just to show a partial list of stop words
stop_l = list(stops)
stop_l[:5]


# remove stopwords
text_list = [] #text.split(" ")
for aTok in text:
if aTok not in stops:
text_list.append(aTok)

text_liststop word count 179





['cancer',
'mortality',
'f',
'cancer',
'mortality',
'heart',
'disease',
'mortality',
'stroke',
'mortality',
'transport',
'accident',
'mortality',
'f',
'transport',
'accident',
'mortality',
'suicide',
'f',
'suicide',
'infant',
'mortality',
'perceived',
'health',
'status',
'life',
'expectancy',
'birth',
'f',
'life',
'expectancy',
'birth',
'fruit',
'consumption',
'adults',
'vegetable',
'consumption',
'adults',
'smoking',
'adults',
'f',
'smoking',
'adults',
'alcohol',
'consumption',
'adults',
'obesity',
'reported',
'adults',
'wait',
'time',
'cataract',
'surgery',
'wait',
'time',
'hip',
'replacement',
'wait',
'time',
'knee',
'replacement',
'next',
'day',
'appt',
'poor',
'weekend',
'evening',
'care',
'wait',
'time',
'specialist',
'inability',
'pay',
'medical',
'bills',
'regular',
'doctor',
'influenza',
'vaccination',
'avoidable',
'admissions',
'copd',
'avoidable',
'admissions',
'asthma',
'avoidable',
'admissions',
'diabetes',
'time',
'spent',
'doctor',
'easy',
'understand',
'doctor',
'know',
'important',
'medical',
'history',
'involvement',
'decisions',
'breast',
'cancer',
'survival',
'breast',
'cancer',
'mortality',
'cervical',
'cancer',
'survival',
'cervical',
'cancer',
'mortality',
'colorectal',
'cancer',
'survival',
'colorectal',
'cancer',
'mortality',
'day',
'hospital',
'fatality',
'ami',
'day',
'hospital',
'fatality',
'ischemic',
'stroke',
'foreign',
'body',
'left',
'post',
'op',
'pe',
'hip',
'knee',
'post',
'op',
'sepsis',
'abdominal',
'ob',
'trauma',
'instrument',
'ob',
'trauma',
'instrument',
'diabetes',
'high',
'blood',
'pressure',
'medication',
'benzodiazepines',
'chronic',
'use',
'benzodiazepines',
'long',
'acting',
'antibiotics',
'total',
'volume',
'systemic',
'use',
'antibiotics',
'proportion',
'second',
'line',
'notes',
'oecd',
'organisation',
'economic',
'co',
'operation',
'development',
'province',
'determined',
'patient',
'residence',
'indicators',
'except',
'patient',
'safety',
'dimension',
'calculated',
'facility',
'province']# find all unigrams


unigrams = ngrams(text_list, 1) # resulting object is an iterator
# bigrams = ngrams(text_list, 2) #
unigrams = list(ngrams(text_list, 1)) # resulting object is an iterator

#for uni in unigrams: #
#print(uni); #

freq = Counter(unigrams)
#print(freq) #

topN = freq.most_common()[1:20] #top frequent 20 words
#print(topN) #
wordscount = {w[0]:f for w, f in topN}
sorted_wordscount = sorted(wordscount.items(), key=operator.itemgetter(1),reverse=True)
#print(sorted_wordscount) #


## use pytag package
create_tag_image(make_tags(sorted_wordscount[:],maxsize=40), 'filename.png', size=(250,200), background=(0, 0, 0, 255), layout=LAYOUT_MIX, fontname='Molengo', rectangular=True)
Image("filename.png")
png
text_again = ''
for aWord in text_list:
if len(aWord) > 2:
text_again += ' ' + aWord

text_again' cancer mortality cancer mortality heart disease mortality stroke mortality transport accident mortality transport accident mortality suicide suicide infant mortality perceived health status life expectancy birth life expectancy birth fruit consumption adults vegetable consumption adults smoking adults smoking adults alcohol consumption adults obesity reported adults wait time cataract surgery wait time hip replacement wait time knee replacement next day appt poor weekend evening care wait time specialist inability pay medical bills regular doctor influenza vaccination avoidable admissions copd avoidable admissions asthma avoidable admissions diabetes time spent doctor easy understand doctor know important medical history involvement decisions breast cancer survival breast cancer mortality cervical cancer survival cervical cancer mortality colorectal cancer survival colorectal cancer mortality day hospital fatality ami day hospital fatality ischemic stroke foreign body left post hip knee post sepsis abdominal trauma instrument trauma instrument diabetes high blood pressure medication benzodiazepines chronic use benzodiazepines long acting antibiotics total volume systemic use antibiotics proportion second line notes oecd organisation economic operation development province determined patient residence indicators except patient safety dimension calculated facility province'## using wordcloud package
wordcloud = WordCloud(max_font_size=40).generate(text_again)
plt.figure()
plt.imshow(wordcloud)
plt.axis("off")
plt.show()

## use custom scoring
wordscount = {w[0]:f for w, f in topN}

wordcloud = WordCloud(max_font_size=40)
wordcloud.fit_words(wordscount)
plt.figure()
plt.imshow(wordcloud)
plt.axis("off")
plt.show()
png
png

Word Association

# split text into sentences
# each sentence is a "market basket"
tokenizer = nltk.data.load('tokenizers/punkt/english.pickle')
#tokenizer = nltk.data.load('tokenizers/punkt/english.pickle')
#review_text = BeautifulSoup(raw_indicator)
review_text = BeautifulSoup(raw_indicator)
for script in review_text(["script", "style"]):
script.extract() # rip it out
# get text
review_text = review_text.get_text()
sentences = tokenizer.tokenize(review_text)


##naive implementation
word_association = Counter()
for sent in sentences:
bigrams = Counter(ngrams([w for w in sent.lower().split(" ") if not w in stopwords.words('english')], 2))
word_association.update(bigrams)

topN = word_association.most_common()[1:20]

G = nx.Graph()
for edge in topN:
G.add_edge(edge[0][0], edge[0][1], weight=edge[1])
pos=nx.circular_layout(G)

plt.figure(3,figsize=(6,6))
nx.draw(G, pos, with_labels = True, font_size=10, edge_color='blue', node_color='white', font_weight='bold')
plt.show()

# http://stackoverflow.com/questions/13429094/implementing-a-word-tree-using-nested-dictionaries-in-python
edges = []



word_sents_arrays = []
for sent in sentences[1:5]:
word_sents_arrays.append(clean_text(sent).split())
print(sentences[1:5])


mnn, edges= doall(word_sents_arrays,{})




G=nx.Graph()
G.add_edges_from(edges)
G1 = nx.Graph(nx.minimum_spanning_edges(G))
pos = hierarchy_pos(G1,'root')

plt.figure(3,figsize=(10,10))
nx.draw(G1, pos=pos, with_labels=True, edge_color='blue', node_size=30, font_size=10, node_color='white')
plt.show()
png
['Province is determined by patient residence for all indicators except those in the patient safety dimension, which are calculated by facility province.']
png

Understanding what are measured

text = clean_text(raw_measure)

# I wrote similar code as part of NLP assignments
# remove punctuations
from nltk.tokenize import RegexpTokenizer
tokenizer = RegexpTokenizer("[\w]+")
text = tokenizer.tokenize(text)

text


# get the list of stop words
from nltk.corpus import stopwords
stops = set(stopwords.words('english'))
print ('stop word count', len(stops) )

# just to show a partial list of stop words
stop_l = list(stops)
stop_l[:5]


# remove stopwords
text_list = [] #text.split(" ")
for aTok in text:
if aTok not in stops:
text_list.append(aTok)

text_liststop word count 179





['number',
'deaths',
'due',
'cancer',
'per',
'females',
'number',
'deaths',
'due',
'cancer',
'per',
'males',
'number',
'deaths',
'due',
'ischemic',
'heart',
'disease',
'per',
'population',
'number',
'deaths',
'due',
'ischemic',
'heart',
'disease',
'per',
'population',
'number',
'deaths',
'due',
'ischemic',
'heart',
'disease',
'per',
'population',
'number',
'deaths',
'due',
'ischemic',
'heart',
'disease',
'per',
'population',
'number',
'deaths',
'due',
'cerebrovascular',
'diseases',
'per',
'population',
'number',
'deaths',
'due',
'cerebrovascular',
'diseases',
'per',
'population',
'number',
'deaths',
'due',
'cerebrovascular',
'diseases',
'per',
'population',
'number',
'deaths',
'due',
'cerebrovascular',
'diseases',
'per',
'population',
'number',
'deaths',
'due',
'transport',
'accidents',
'per',
'females',
'number',
'deaths',
'due',
'transport',
'accidents',
'per',
'females',
'number',
'deaths',
'due',
'transport',
'accidents',
'per',
'females',
'number',
'deaths',
'due',
'transport',
'accidents',
'per',
'females',
'number',
'deaths',
'due',
'transport',
'accidents',
'per',
'males',
'number',
'deaths',
'due',
'transport',
'accidents',
'per',
'males',
'number',
'deaths',
'due',
'transport',
'accidents',
'per',
'males',
'number',
'deaths',
'due',
'transport',
'accidents',
'per',
'males',
'number',
'deaths',
'due',
'suicide',
'per',
'females',
'number',
'deaths',
'due',
'suicide',
'per',
'males',
'deaths',
'children',
'younger',
'year',
'per',
'live',
'births',
'percentage',
'population',
'age',
'report',
'health',
'good',
'better',
'average',
'number',
'years',
'female',
'expected',
'live',
'assuming',
'age',
'specific',
'mortality',
'levels',
'remain',
'constant',
'average',
'number',
'years',
'male',
'expected',
'live',
'assuming',
'age',
'specific',
'mortality',
'levels',
'remain',
'constant',
'percentage',
'population',
'age',
'report',
'eating',
'fruit',
'least',
'per',
'day',
'percentage',
'population',
'age',
'report',
'eating',
'vegetables',
'least',
'per',
'day',
'percentage',
'female',
'population',
'age',
'report',
'daily',
'smokers',
'percentage',
'male',
'population',
'age',
'report',
'daily',
'smokers',
'average',
'annual',
'alcohol',
'consumption',
'litres',
'per',
'capita',
'age',
'average',
'annual',
'alcohol',
'consumption',
'litres',
'per',
'capita',
'age',
'average',
'annual',
'alcohol',
'consumption',
'litres',
'per',
'capita',
'age',
'percentage',
'adults',
'obese',
'body',
'mass',
'index',
'higher',
'kg',
'self',
'report',
'median',
'wait',
'time',
'days',
'specialist',
'assessment',
'booking',
'date',
'cataract',
'surgery',
'median',
'wait',
'time',
'days',
'specialist',
'assessment',
'booking',
'date',
'cataract',
'surgery',
'median',
'wait',
'time',
'days',
'specialist',
'assessment',
'booking',
'date',
'cataract',
'surgery',
'median',
'wait',
'time',
'days',
'specialist',
'assessment',
'booking',
'date',
'hip',
'replacement',
'median',
'wait',
'time',
'days',
'specialist',
'assessment',
'booking',
'date',
'hip',
'replacement',
'median',
'wait',
'time',
'days',
'specialist',
'assessment',
'booking',
'date',
'hip',
'replacement',
'median',
'wait',
'time',
'days',
'specialist',
'assessment',
'booking',
'date',
'knee',
'replacement',
'median',
'wait',
'time',
'days',
'specialist',
'assessment',
'booking',
'date',
'knee',
'replacement',
'median',
'wait',
'time',
'days',
'specialist',
'assessment',
'booking',
'date',
'knee',
'replacement',
'percentage',
'people',
'able',
'get',
'appointment',
'see',
'doctor',
'nurse',
'next',
'day',
'last',
'time',
'sick',
'needed',
'medical',
'attention',
'percentage',
'people',
'needed',
'care',
'hours',
'reported',
'difficulty',
'getting',
'medical',
'care',
'evenings',
'weekends',
'holidays',
'without',
'going',
'hospital',
'emergency',
'department',
'emergency',
'room',
'percentage',
'adults',
'waited',
'weeks',
'advised',
'see',
'decided',
'see',
'specialist',
'percentage',
'people',
'medical',
'problem',
'consult',
'visit',
'doctor',
'cost',
'percentage',
'people',
'regular',
'doctor',
'place',
'care',
'percentage',
'adults',
'age',
'received',
'influenza',
'vaccination',
'within',
'past',
'year',
'number',
'hospital',
'discharges',
'copd',
'people',
'age',
'older',
'per',
'population',
'number',
'hospital',
'discharges',
'asthma',
'people',
'age',
'older',
'per',
'population',
'number',
'hospital',
'discharges',
'diabetes',
'people',
'age',
'older',
'per',
'population',
'percentage',
'adults',
'report',
'regular',
'doctor',
'always',
'often',
'spent',
'enough',
'time',
'percentage',
'adults',
'report',
'regular',
'doctor',
'always',
'often',
'explains',
'things',
'way',
'easy',
'understand',
'percentage',
'older',
'adults',
'age',
'report',
'regular',
'doctor',
'always',
'often',
'gave',
'opportunity',
'ask',
'questions',
'raise',
'concerns',
'percentage',
'adults',
'report',
'regular',
'doctor',
'always',
'often',
'involved',
'much',
'wanted',
'decisions',
'care',
'treatment',
'year',
'relative',
'survival',
'rate',
'breast',
'cancer',
'number',
'deaths',
'due',
'breast',
'cancer',
'per',
'females',
'year',
'relative',
'survival',
'rate',
'cervical',
'cancer',
'number',
'deaths',
'due',
'cervical',
'cancer',
'per',
'females',
'year',
'relative',
'survival',
'rate',
'colorectal',
'cancer',
'number',
'deaths',
'due',
'colorectal',
'cancer',
'per',
'population',
'number',
'deaths',
'due',
'colorectal',
'cancer',
'per',
'population',
'percentage',
'patients',
'age',
'die',
'hospital',
'within',
'days',
'admitted',
'primary',
'diagnosis',
'acute',
'myocardial',
'infarction',
'ami',
'percentage',
'patients',
'age',
'die',
'hospital',
'within',
'days',
'admitted',
'primary',
'diagnosis',
'ischemic',
'stroke',
'percentage',
'patients',
'age',
'die',
'hospital',
'within',
'days',
'admitted',
'primary',
'diagnosis',
'ischemic',
'stroke',
'rate',
'foreign',
'body',
'left',
'inside',
'patient',
'body',
'procedure',
'per',
'hospital',
'discharges',
'age',
'rate',
'post',
'operative',
'pulmonary',
'embolism',
'per',
'discharges',
'hip',
'knee',
'replacement',
'age',
'rate',
'post',
'operative',
'sepsis',
'per',
'discharges',
'abdominal',
'surgery',
'age',
'percentage',
'vaginal',
'deliveries',
'third',
'fourth',
'degree',
'obstetric',
'trauma',
'per',
'instrument',
'assisted',
'vaginal',
'deliveries',
'percentage',
'vaginal',
'deliveries',
'third',
'fourth',
'degree',
'obstetric',
'trauma',
'per',
'vaginal',
'deliveries',
'without',
'instrument',
'assistance',
'percentage',
'patients',
'diabetes',
'prescription',
'first',
'choice',
'antihypertensive',
'medication',
'number',
'per',
'patients',
'age',
'prescriptions',
'daily',
'doses',
'benzodiazepines',
'related',
'drugs',
'number',
'per',
'patients',
'age',
'least',
'one',
'prescription',
'long',
'acting',
'benzodiazepines',
'related',
'drugs',
'total',
'volume',
'antibiotics',
'prescribed',
'systemic',
'use',
'defined',
'daily',
'doses',
'per',
'population',
'per',
'day',
'volume',
'second',
'line',
'antibiotics',
'percentage',
'antibiotics',
'prescribed',
'nan',
'nan',
'nan']# text = clean_text(raw_measure)
# text_list = text.split(" ")


# print(text_list) #
unigrams = ngrams(text_list, 1) # resulting object is an iterator
# bigrams = ngrams(text_list, 2) #
unigrams = list(ngrams(text_list, 1)) # resulting object is an iterator

#for uni in unigrams: #
#print(uni); #

freq = Counter(unigrams)
#print(freq) #

topN = freq.most_common()[1:20] #top frequent 20 words
#print(topN) #
wordscount = {w[0]:f for w, f in topN}
sorted_wordscount = sorted(wordscount.items(), key=operator.itemgetter(1),reverse=True)
#print(sorted_wordscount) #


## use pytag package
create_tag_image(make_tags(sorted_wordscount[:],maxsize=40), 'filename.png', size=(250,200), background=(0, 0, 0, 255), layout=LAYOUT_MIX, fontname='Molengo', rectangular=True)
Image("filename.png")
png
text_again = ''
for aWord in text_list:
if len(aWord) > 2:
text_again += ' ' + aWord

text_again

## using wordcloud package
wordcloud = WordCloud(max_font_size=40).generate(text_again)
plt.figure()
plt.imshow(wordcloud)
plt.axis("off")
plt.show()

## use custom scoring
wordscount = {w[0]:f for w, f in topN}

wordcloud = WordCloud(max_font_size=40)
wordcloud.fit_words(wordscount)
plt.figure()
plt.imshow(wordcloud)
plt.axis("off")
plt.show()
png
png
# split text into sentences
# each sentence is a "market basket"
tokenizer = nltk.data.load('tokenizers/punkt/english.pickle')
#tokenizer = nltk.data.load('tokenizers/punkt/english.pickle')
review_text = BeautifulSoup(raw_measure)
for script in review_text(["script", "style"]):
script.extract() # rip it out
# get text
review_text = review_text.get_text()
sentences = tokenizer.tokenize(review_text)


##naive implementation
word_association = Counter()
for sent in sentences:
bigrams = Counter(ngrams([w for w in sent.lower().split(" ") if not w in stopwords.words('english')], 2))
word_association.update(bigrams)

topN = word_association.most_common()[1:20]

G = nx.Graph()
for edge in topN:
G.add_edge(edge[0][0], edge[0][1], weight=edge[1])
pos=nx.circular_layout(G)

plt.figure(3,figsize=(6,6))
nx.draw(G, pos, with_labels = True, font_size=10, edge_color='blue', node_color='white', font_weight='bold')
plt.show()

# http://stackoverflow.com/questions/13429094/implementing-a-word-tree-using-nested-dictionaries-in-python
edges = []

word_sents_arrays = []
for sent in sentences[1:5]:
word_sents_arrays.append(clean_text(sent).split())
print(sentences[1:5])


mnn, edges= doall(word_sents_arrays,{})




G=nx.Graph()
G.add_edges_from(edges)
G1 = nx.Graph(nx.minimum_spanning_edges(G))
pos = hierarchy_pos(G1,'root')

plt.figure(3,figsize=(10,10))
nx.draw(G1, pos=pos, with_labels=True, edge_color='blue', node_size=30, font_size=10, node_color='white')
plt.show()
png
['Number of deaths due to cancer per 100,000 males.', 'Number of deaths due to ischemic heart disease \nper 100,000 population.Number of deaths due to ischemic heart disease \nper 100,000 population.Number of deaths due to ischemic heart disease \nper 100,000 population.Number of deaths due to ischemic heart disease \nper 100,000 population.', 'Number of deaths due to cerebrovascular diseases \nper 100,000 population.Number of deaths due to cerebrovascular diseases \nper 100,000 population.Number of deaths due to cerebrovascular diseases \nper 100,000 population.Number of deaths due to cerebrovascular diseases \nper 100,000 population.', 'Number of deaths due to transport accidents \nper 100,000 females.Number of deaths due to transport accidents \nper 100,000 females.Number of deaths due to transport accidents \nper 100,000 females.Number of deaths due to transport accidents \nper 100,000 females.']
png

reference:

  1. pd.merge reference: https://www.shanelynn.ie/merge-join-dataframes-python-pandas-index-1/ : though I could just read and string concatenate in a loop

Quality of Care, Health System Performance, Canada and Other Countries

Justetc Social Services (non-profit)

Justetc Social Services (non-profit)Jan 31 · 5 min read

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inlinefrom __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetsquality_of_care = pd.read_excel('../data/quality-of-care.xls')
quality_of_care.head()
png
# find all indicators
quality_of_care.set_index(['Indicator'])
indicators = pd.Index(quality_of_care['Indicator']).unique()

# find all years
years = quality_of_care['Data year'].dropna().unique()
indicators[0], years('30-Day In-Hospital Fatality: AMI',
array([2015, 2014, 2013, 'Not applicable', '2013', '2014', '2015',
'2012 to 2014', '2013 to 2015', '2010 to 2014', '2003 to 2008',
'2006 to 2011', '2008 to 2013', '2007 to 2012', '2004 to 2009',
2016, '2016'], dtype=object))# sort years
years = [ int(aYear) for aYear in years if (aYear != 'Not applicable') and len( str(aYear).split(' ')) <= 1 ]
years = sorted(years)
years

all_years = [0] + years
all_years[0, 2013, 2013, 2014, 2014, 2015, 2015, 2016, 2016]plt.rcParams['figure.figsize'] = [10, 10]
def plot_quality_of_care(year, indicator, bubble_scale, all_years=all_years):
# print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]
if ( year > 1 ):
indicator_data = quality_of_care.loc[ (quality_of_care['Indicator'] == indicator) & (quality_of_care['Data year'] == year) ]
ax.scatter(indicator_data['Data year'], indicator_data['Region'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = quality_of_care.loc[ (quality_of_care['Indicator'] == indicator) & (quality_of_care['Data year'] == aYear) ]
ax.scatter(indicator_data['Data year'], indicator_data['Region'], s = indicator_data['Value'] * bubble_scale )
f.canvas.draw()# create the interactive interface
def f(x):
return x


indicator = interactive(f, x=indicators);
display(indicator)
indicator.result

year = interactive(f, x=all_years);
display(year)
year.result


bubble_scale = interactive(f, x=(0, 100, 1));
display(bubble_scale)
bubble_scale.resultinteractive(children=(Dropdown(description='x', options=('30-Day In-Hospital Fatality: AMI', '30-Day In-Hospit…



interactive(children=(Dropdown(description='x', options=(0, 2013, 2013, 2014, 2014, 2015, 2015, 2016, 2016), v…



interactive(children=(IntSlider(value=50, description='x'), Output()), _dom_classes=('widget-interact',))





50plot_quality_of_care(year.result, indicator.result, bubble_scale.result)C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\figure.py:445: UserWarning: Matplotlib is currently using module://ipykernel.pylab.backend_inline, which is a non-GUI backend, so cannot show the figure.
% get_backend())
png
plt.rcParams['figure.figsize'] = [20, 10]
def plot_quality_of_care_by_regions(year, indicator, bubble_scale, all_years=all_years):
#print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]

if ( year > 1 ):
#indicator_data = indicator_data [ indicator_data['Data year'] == year]
indicator_data = quality_of_care.loc[ (quality_of_care['Indicator'] == indicator) & (quality_of_care['Data year'] == year) ]
#print(indicator_data)
ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = quality_of_care.loc[ (quality_of_care['Indicator'] == indicator) & (quality_of_care['Data year'] == aYear) ]
ax.scatter(indicator_data['Region'], indicator_data['Value'], s = indicator_data['Value'] * bubble_scale )
f.canvas.draw()print('Select parameter to visualize across countries over years')
# create the interactive interface
def f(x):
return x


indicator = interactive(f, x=indicators);
display(indicator)
indicator.result

year = interactive(f, x=all_years);
display(year)
year.result


bubble_scale = interactive(f, x=(0, 100, 1));
display(bubble_scale)
bubble_scale.resultSelect parameter to visualize across countries over years



interactive(children=(Dropdown(description='x', options=('30-Day In-Hospital Fatality: AMI', '30-Day In-Hospit…



interactive(children=(Dropdown(description='x', options=(0, 2013, 2013, 2014, 2014, 2015, 2015, 2016, 2016), v…



interactive(children=(IntSlider(value=50, description='x'), Output()), _dom_classes=('widget-interact',))





50plot_quality_of_care_by_regions(year.result, indicator.result, bubble_scale.result)
png
plt.rcParams['figure.figsize'] = [20, 10]
def plot_quality_of_care_by_countries(year, indicator, bubble_scale, selected_countries, all_years=all_years):
#print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]

if ( year > 1 ):
#indicator_data = indicator_data [ indicator_data['Data year'] == year]
indicator_data = quality_of_care.loc[ (quality_of_care['Indicator'] == indicator) & (quality_of_care['Data year'] == str(year) ) & (quality_of_care['Type of region'] == 'Country' ) ]
#print(indicator_data)

if ( len(selected_countries) > 1 ):
indicator_data = indicator_data[ indicator_data['Region'].isin(selected_countries)]

ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = quality_of_care.loc[ (quality_of_care['Indicator'] == indicator) & (quality_of_care['Data year'] == str(aYear) ) & (quality_of_care['Type of region'] == 'Country' ) ]
if ( len(selected_countries) > 1 ):
indicator_data = indicator_data[ indicator_data['Region'].isin(selected_countries)]

#print(indicator_data)
ax.scatter(indicator_data['Region'], indicator_data['Value'], s = indicator_data['Value'] * bubble_scale )
f.canvas.draw()countries = quality_of_care[ quality_of_care['Type of region'] == 'Country' ]['Region']
countries = sorted (countries.unique())
#countries = ['Canada'] + countries
if 'Canada' in countries:
countries = ['Canada'] + countries

#countriesprint('Select parameters to visualize across countries over years\n')
# create the interactive interface
def f(x):
return x

print('Select chart type:')
chart_types = ['Bubble', 'Bar', 'Pie', 'Line']
chart = interactive(f, x=chart_types);
display(chart)
chart.result

print('Select Indicator')
indicator_country = interactive(f, x=indicators);
display(indicator_country)
indicator_country.result

print('Select Year: 0 = all years')
year_country = interactive(f, x=all_years);
display(year_country)
year_country.result

print('Select bubble size')
bubble_scale_country = interactive(f, x=(0, 100, 1));
display(bubble_scale_country)
bubble_scale_country.result

print('Max country count to compare with')
country_count = interactive(f, x=range(1, 20));
display(country_count)
country_count.result

print('Select countries')
print('Compare with Canada')
all_countries = interactive(f, x=True);
display(all_countries)
all_countries.result

country_0 = interactive(f, x = countries);
country_1 = interactive(f, x = countries);
#country_str = "var%d = interactive(f, x = countries)"
display(country_0)
display(country_1)
country_0.result

print('Compare with Canada')
compare_canada = interactive(f, x=True);
display(compare_canada)
compare_canada.resultSelect parameters to visualize across countries over years

Select chart type:



interactive(children=(Dropdown(description='x', options=('Bubble', 'Bar', 'Pie', 'Line'), value='Bubble'), Out…


Select Indicator



interactive(children=(Dropdown(description='x', options=('30-Day In-Hospital Fatality: AMI', '30-Day In-Hospit…


Select Year: 0 = all years



interactive(children=(Dropdown(description='x', options=(0, 2013, 2013, 2014, 2014, 2015, 2015, 2016, 2016), v…


Select bubble size



interactive(children=(IntSlider(value=50, description='x'), Output()), _dom_classes=('widget-interact',))


Max country count to compare with



interactive(children=(Dropdown(description='x', options=(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16…


Select countries
Compare with Canada



interactive(children=(Checkbox(value=True, description='x'), Output()), _dom_classes=('widget-interact',))



interactive(children=(Dropdown(description='x', options=('Austria', 'Belgium', 'Chile', 'Czech Republic', 'Den…



interactive(children=(Dropdown(description='x', options=('Austria', 'Belgium', 'Chile', 'Czech Republic', 'Den…


Compare with Canada



interactive(children=(Checkbox(value=True, description='x'), Output()), _dom_classes=('widget-interact',))





Truecountry_0.result'Austria'selected_countries = []
if (all_countries.result == False):
selected_countries = [country_0.result, country_1.result]

#print(year_country.result, indicator_country.result, bubble_scale_country.result)
plot_quality_of_care_by_countries(year_country.result, indicator_country.result, bubble_scale_country.result, selected_countries)
#print(country_0, country_1)
png
quality_of_care.loc[  (quality_of_care['Indicator'] == indicators[0])  & (quality_of_care['Data year'] == '2013') & (quality_of_care['Type of region'] == 'Country')     ]
png

Appendix

"""
print('Select countries')
for i in range(country_count.result):
#country_str = interactive(f, x = countries);
country_str = "var%d = interactive(f, x = countries)"
display(country)
country.result
"""

for i in range(country_count.result):
country_str = "var%d = interactive(f, x = countries)" %(i)

exec(country_str)
country_str

for i in [0, 2]:
'var' + str(i)

primary-prescribing, Health System Performance, Canada and Others

Justetc Social Services (non-profit)

Justetc Social Services (non-profit)Jan 31 · 5 min read

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inlinefrom __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetsprescribing_primary = pd.read_excel('../data/prescribing-primary.xls')
prescribing_primary.head()
png
# find all indicators
prescribing_primary.set_index(['Indicator'])
indicators = pd.Index(prescribing_primary['Indicator']).unique()

# find all years
years = prescribing_primary['Data year'].dropna().unique()
indicators[0], years('Antibiotics: Proportion of Second Line',
array(['2015', '2014', 2015, 'Not applicable', 2014], dtype=object))# sort years
years = [ int(aYear) for aYear in years if (aYear != 'Not applicable') and len( str(aYear).split(' ')) <= 1 and (len(str(aYear)) <= 4) ]
print(years)
#years_ = [aYear for aYear in years if str(aYear).replace('-', '') ]

#print(years_)
years = sorted(years)
years

all_years = [0] + years
all_years[2015, 2014, 2015, 2014]





[0, 2014, 2014, 2015, 2015]plt.rcParams['figure.figsize'] = [10, 10]
def plot_prescribing_primary(year, indicator, bubble_scale, all_years=all_years):
# print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]
if ( year > 1 ):
indicator_data = prescribing_primary.loc[ (prescribing_primary['Indicator'] == indicator) & (prescribing_primary['Data year'] == year) ]
ax.scatter(indicator_data['Data year'], indicator_data['Region'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = prescribing_primary.loc[ (prescribing_primary['Indicator'] == indicator) & (prescribing_primary['Data year'] == aYear) ]
ax.scatter(indicator_data['Data year'], indicator_data['Region'], s = indicator_data['Value'] * bubble_scale )
f.canvas.draw()# create the interactive interface
def f(x):
return x


indicator = interactive(f, x=indicators);
display(indicator)
indicator.result

year = interactive(f, x=all_years);
display(year)
year.result


bubble_scale = interactive(f, x=(0, 100, 1));
display(bubble_scale)
bubble_scale.resultinteractive(children=(Dropdown(description='x', options=('Antibiotics: Proportion of Second Line', 'Antibiotic…



interactive(children=(Dropdown(description='x', options=(0, 2014, 2014, 2015, 2015), value=0), Output()), _dom…



interactive(children=(IntSlider(value=50, description='x'), Output()), _dom_classes=('widget-interact',))





50plot_prescribing_primary(year.result, indicator.result, bubble_scale.result)C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\figure.py:445: UserWarning: Matplotlib is currently using module://ipykernel.pylab.backend_inline, which is a non-GUI backend, so cannot show the figure.
% get_backend())
png
plt.rcParams['figure.figsize'] = [20, 10]
def plot_prescribing_primary_by_regions(year, indicator, bubble_scale, all_years=all_years):
#print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]

if ( year > 1 ):
#indicator_data = indicator_data [ indicator_data['Data year'] == year]
indicator_data = prescribing_primary.loc[ (prescribing_primary['Indicator'] == indicator) & (prescribing_primary['Data year'] == year) ]
#print(indicator_data)
ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = prescribing_primary.loc[ (prescribing_primary['Indicator'] == indicator) & (prescribing_primary['Data year'] == aYear) ]
ax.scatter(indicator_data['Region'], indicator_data['Value'], s = indicator_data['Value'] * bubble_scale )
f.canvas.draw()print('Select parameter to visualize across countries over years')
# create the interactive interface
def f(x):
return x


indicator = interactive(f, x=indicators);
display(indicator)
indicator.result

year = interactive(f, x=all_years);
display(year)
year.result


bubble_scale = interactive(f, x=(0, 100, 1));
display(bubble_scale)
bubble_scale.resultSelect parameter to visualize across countries over years



interactive(children=(Dropdown(description='x', options=('Antibiotics: Proportion of Second Line', 'Antibiotic…



interactive(children=(Dropdown(description='x', options=(0, 2014, 2014, 2015, 2015), value=0), Output()), _dom…



interactive(children=(IntSlider(value=50, description='x'), Output()), _dom_classes=('widget-interact',))





50plot_prescribing_primary_by_regions(year.result, indicator.result, bubble_scale.result)
png
plt.rcParams['figure.figsize'] = [20, 10]
def plot_prescribing_primary_by_countries(year, indicator, bubble_scale, selected_countries, all_years=all_years):
#print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]

if ( year > 1 ):
#indicator_data = indicator_data [ indicator_data['Data year'] == year]
indicator_data = prescribing_primary.loc[ (prescribing_primary['Indicator'] == indicator) & (prescribing_primary['Data year'] == str(year) ) & (prescribing_primary['Type of region'] == 'Country' ) ]
#print(indicator_data)

if ( len(selected_countries) > 1 ):
indicator_data = indicator_data[ indicator_data['Region'].isin(selected_countries)]

ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = prescribing_primary.loc[ (prescribing_primary['Indicator'] == indicator) & (prescribing_primary['Data year'] == str(aYear) ) & (prescribing_primary['Type of region'] == 'Country' ) ]
if ( len(selected_countries) > 1 ):
indicator_data = indicator_data[ indicator_data['Region'].isin(selected_countries)]

#print(indicator_data)
ax.scatter(indicator_data['Region'], indicator_data['Value'], s = indicator_data['Value'] * bubble_scale )
f.canvas.draw()countries = prescribing_primary[ prescribing_primary['Type of region'] == 'Country' ]['Region']
countries = sorted (countries.unique())
#countries = ['Canada'] + countries
if 'Canada' in countries:
countries = ['Canada'] + countries

#countriesprint('Select parameters to visualize across countries over years\n')
# create the interactive interface
def f(x):
return x

print('Select chart type:')
chart_types = ['Bubble', 'Bar', 'Pie', 'Line']
chart = interactive(f, x=chart_types);
display(chart)
chart.result

print('Select Indicator')
indicator_country = interactive(f, x=indicators);
display(indicator_country)
indicator_country.result

print('Select Year: 0 = all years')
year_country = interactive(f, x=all_years);
display(year_country)
year_country.result

print('Select bubble size')
bubble_scale_country = interactive(f, x=(0, 100, 1));
display(bubble_scale_country)
bubble_scale_country.result

print('Max country count to compare with')
country_count = interactive(f, x=range(1, 20));
display(country_count)
country_count.result

print('Select countries')
print('Compare with Canada')
all_countries = interactive(f, x=True);
display(all_countries)
all_countries.result

country_0 = interactive(f, x = countries);
country_1 = interactive(f, x = countries);
#country_str = "var%d = interactive(f, x = countries)"
display(country_0)
display(country_1)
country_0.result

print('Compare with Canada')
compare_canada = interactive(f, x=True);
display(compare_canada)
compare_canada.resultSelect parameters to visualize across countries over years

Select chart type:



interactive(children=(Dropdown(description='x', options=('Bubble', 'Bar', 'Pie', 'Line'), value='Bubble'), Out…


Select Indicator



interactive(children=(Dropdown(description='x', options=('Antibiotics: Proportion of Second Line', 'Antibiotic…


Select Year: 0 = all years



interactive(children=(Dropdown(description='x', options=(0, 2014, 2014, 2015, 2015), value=0), Output()), _dom…


Select bubble size



interactive(children=(IntSlider(value=50, description='x'), Output()), _dom_classes=('widget-interact',))


Max country count to compare with



interactive(children=(Dropdown(description='x', options=(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16…


Select countries
Compare with Canada



interactive(children=(Checkbox(value=True, description='x'), Output()), _dom_classes=('widget-interact',))



interactive(children=(Dropdown(description='x', options=('Austria', 'Belgium', 'Czech Republic', 'Denmark', 'E…



interactive(children=(Dropdown(description='x', options=('Austria', 'Belgium', 'Czech Republic', 'Denmark', 'E…


Compare with Canada



interactive(children=(Checkbox(value=True, description='x'), Output()), _dom_classes=('widget-interact',))





Truecountry_0.result'Austria'selected_countries = []
if (all_countries.result == False):
selected_countries = [country_0.result, country_1.result]

#print(year_country.result, indicator_country.result, bubble_scale_country.result)
plot_prescribing_primary_by_countries(year_country.result, indicator_country.result, bubble_scale_country.result, selected_countries)
#print(country_0, country_1)
png
prescribing_primary.loc[  (prescribing_primary['Indicator'] == indicators[0])  & (prescribing_primary['Data year'] == '2013') & (prescribing_primary['Type of region'] == 'Country')     ]
png

Appendix

"""
print('Select countries')
for i in range(country_count.result):
#country_str = interactive(f, x = countries);
country_str = "var%d = interactive(f, x = countries)"
display(country)
country.result
"""

for i in range(country_count.result):
country_str = "var%d = interactive(f, x = countries)" %(i)

exec(country_str)
country_str

for i in [0, 2]:
'var' + str(i)

patient-safety, Health System Performance, Canada and Others

Justetc Social Services (non-profit)

Justetc Social Services (non-profit)Jan 31 · 5 min read

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inlinefrom __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetspatient_safety = pd.read_excel('../data/patient-safety.xls')
patient_safety.head()
png
# find all indicators
patient_safety.set_index(['Indicator'])
indicators = pd.Index(patient_safety['Indicator']).unique()

# find all years
years = patient_safety['Data year'].dropna().unique()
indicators[0], years('Foreign Body Left In',
array([2015, '2014–2015', 'Not applicable', 2014], dtype=object))# sort years
years = [ aYear for aYear in years if (aYear != 'Not applicable') and len( str(aYear).split(' ')) <= 1 and (len(str(aYear)) <= 4) ]
#years_ = [aYear for aYear in years if str(aYear).replace('-', '') ]

#print(years_)
years = sorted(years)
years

all_years = [0] + years
all_years[0, 2014, 2015]len(str('2014-2015').split('-'))2plt.rcParams['figure.figsize'] = [10, 10]
def plot_patient_safety(year, indicator, bubble_scale, all_years=all_years):
# print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]
if ( year > 1 ):
indicator_data = patient_safety.loc[ (patient_safety['Indicator'] == indicator) & (patient_safety['Data year'] == year) ]
ax.scatter(indicator_data['Data year'], indicator_data['Region'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = patient_safety.loc[ (patient_safety['Indicator'] == indicator) & (patient_safety['Data year'] == aYear) ]
ax.scatter(indicator_data['Data year'], indicator_data['Region'], s = indicator_data['Value'] * bubble_scale )
f.canvas.draw()# create the interactive interface
def f(x):
return x


indicator = interactive(f, x=indicators);
display(indicator)
indicator.result

year = interactive(f, x=all_years);
display(year)
year.result


bubble_scale = interactive(f, x=(0, 100, 1));
display(bubble_scale)
bubble_scale.resultinteractive(children=(Dropdown(description='x', options=('Foreign Body Left In', 'OB Trauma: Instrument', 'OB …



interactive(children=(Dropdown(description='x', options=(0, 2014, 2015), value=0), Output()), _dom_classes=('w…



interactive(children=(IntSlider(value=50, description='x'), Output()), _dom_classes=('widget-interact',))





50plot_patient_safety(year.result, indicator.result, bubble_scale.result)C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\figure.py:445: UserWarning: Matplotlib is currently using module://ipykernel.pylab.backend_inline, which is a non-GUI backend, so cannot show the figure.
% get_backend())
png
plt.rcParams['figure.figsize'] = [20, 10]
def plot_patient_safety_by_regions(year, indicator, bubble_scale, all_years=all_years):
#print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]

if ( year > 1 ):
#indicator_data = indicator_data [ indicator_data['Data year'] == year]
indicator_data = patient_safety.loc[ (patient_safety['Indicator'] == indicator) & (patient_safety['Data year'] == year) ]
#print(indicator_data)
ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = patient_safety.loc[ (patient_safety['Indicator'] == indicator) & (patient_safety['Data year'] == aYear) ]
ax.scatter(indicator_data['Region'], indicator_data['Value'], s = indicator_data['Value'] * bubble_scale )
f.canvas.draw()print('Select parameter to visualize across countries over years')
# create the interactive interface
def f(x):
return x


indicator = interactive(f, x=indicators);
display(indicator)
indicator.result

year = interactive(f, x=all_years);
display(year)
year.result


bubble_scale = interactive(f, x=(0, 100, 1));
display(bubble_scale)
bubble_scale.resultSelect parameter to visualize across countries over years



interactive(children=(Dropdown(description='x', options=('Foreign Body Left In', 'OB Trauma: Instrument', 'OB …



interactive(children=(Dropdown(description='x', options=(0, 2014, 2015), value=0), Output()), _dom_classes=('w…



interactive(children=(IntSlider(value=50, description='x'), Output()), _dom_classes=('widget-interact',))





50plot_patient_safety_by_regions(year.result, indicator.result, bubble_scale.result)
png
plt.rcParams['figure.figsize'] = [20, 10]
def plot_patient_safety_by_countries(year, indicator, bubble_scale, selected_countries, all_years=all_years):
#print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]

if ( year > 1 ):
#indicator_data = indicator_data [ indicator_data['Data year'] == year]
indicator_data = patient_safety.loc[ (patient_safety['Indicator'] == indicator) & (patient_safety['Data year'] == str(year) ) & (patient_safety['Type of region'] == 'Country' ) ]
#print(indicator_data)

if ( len(selected_countries) > 1 ):
indicator_data = indicator_data[ indicator_data['Region'].isin(selected_countries)]

ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = patient_safety.loc[ (patient_safety['Indicator'] == indicator) & (patient_safety['Data year'] == str(aYear) ) & (patient_safety['Type of region'] == 'Country' ) ]
if ( len(selected_countries) > 1 ):
indicator_data = indicator_data[ indicator_data['Region'].isin(selected_countries)]

#print(indicator_data)
ax.scatter(indicator_data['Region'], indicator_data['Value'], s = indicator_data['Value'] * bubble_scale )
f.canvas.draw()countries = patient_safety[ patient_safety['Type of region'] == 'Country' ]['Region']
countries = sorted (countries.unique())
#countries = ['Canada'] + countries
if 'Canada' in countries:
countries = ['Canada'] + countries

#countriesprint('Select parameters to visualize across countries over years\n')
# create the interactive interface
def f(x):
return x

print('Select chart type:')
chart_types = ['Bubble', 'Bar', 'Pie', 'Line']
chart = interactive(f, x=chart_types);
display(chart)
chart.result

print('Select Indicator')
indicator_country = interactive(f, x=indicators);
display(indicator_country)
indicator_country.result

print('Select Year: 0 = all years')
year_country = interactive(f, x=all_years);
display(year_country)
year_country.result

print('Select bubble size')
bubble_scale_country = interactive(f, x=(0, 100, 1));
display(bubble_scale_country)
bubble_scale_country.result

print('Max country count to compare with')
country_count = interactive(f, x=range(1, 20));
display(country_count)
country_count.result

print('Select countries')
print('Compare with Canada')
all_countries = interactive(f, x=True);
display(all_countries)
all_countries.result

country_0 = interactive(f, x = countries);
country_1 = interactive(f, x = countries);
#country_str = "var%d = interactive(f, x = countries)"
display(country_0)
display(country_1)
country_0.result

print('Compare with Canada')
compare_canada = interactive(f, x=True);
display(compare_canada)
compare_canada.resultSelect parameters to visualize across countries over years

Select chart type:



interactive(children=(Dropdown(description='x', options=('Bubble', 'Bar', 'Pie', 'Line'), value='Bubble'), Out…


Select Indicator



interactive(children=(Dropdown(description='x', options=('Foreign Body Left In', 'OB Trauma: Instrument', 'OB …


Select Year: 0 = all years



interactive(children=(Dropdown(description='x', options=(0, 2014, 2015), value=0), Output()), _dom_classes=('w…


Select bubble size



interactive(children=(IntSlider(value=50, description='x'), Output()), _dom_classes=('widget-interact',))


Max country count to compare with



interactive(children=(Dropdown(description='x', options=(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16…


Select countries
Compare with Canada



interactive(children=(Checkbox(value=True, description='x'), Output()), _dom_classes=('widget-interact',))



interactive(children=(Dropdown(description='x', options=('Belgium', 'Denmark', 'Estonia', 'Finland', 'Ireland'…



interactive(children=(Dropdown(description='x', options=('Belgium', 'Denmark', 'Estonia', 'Finland', 'Ireland'…


Compare with Canada



interactive(children=(Checkbox(value=True, description='x'), Output()), _dom_classes=('widget-interact',))





Truecountry_0.result'Belgium'selected_countries = []
if (all_countries.result == False):
selected_countries = [country_0.result, country_1.result]

#print(year_country.result, indicator_country.result, bubble_scale_country.result)
plot_patient_safety_by_countries(year_country.result, indicator_country.result, bubble_scale_country.result, selected_countries)
#print(country_0, country_1)
png
patient_safety.loc[  (patient_safety['Indicator'] == indicators[0])  & (patient_safety['Data year'] == '2013') & (patient_safety['Type of region'] == 'Country')     ]
png

Appendix

"""
print('Select countries')
for i in range(country_count.result):
#country_str = interactive(f, x = countries);
country_str = "var%d = interactive(f, x = countries)"
display(country)
country.result
"""

for i in range(country_count.result):
country_str = "var%d = interactive(f, x = countries)" %(i)

exec(country_str)
country_str

for i in [0, 2]:
'var' + str(i)

non_med_determinants_visualizations, Health System Performance, Canada and Others

Justetc Social Services (non-profit)

Justetc Social Services (non-profit)Jan 31 · 5 min read

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inlinefrom __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetsnon_med_determinants = pd.read_excel('../data/non-med-determinants.xls')
non_med_determinants.head()
png
# find all indicators
non_med_determinants.set_index(['Indicator'])
indicators = pd.Index(non_med_determinants['Indicator']).unique()

# find all years
years = non_med_determinants['Data year'].dropna().unique()
indicators[0], years('Alcohol Consumption: Adults',
array(['2014', '2015', '2013', 2015, 'Not applicable', '2016'],
dtype=object))# sort years
years = [ int(aYear) for aYear in years if (aYear != 'Not applicable') and len( str(aYear).split(' ')) <= 1 ]
years = sorted(years)
years

all_years = [0] + years
all_years[0, 2013, 2014, 2015, 2015, 2016]plt.rcParams['figure.figsize'] = [10, 10]
def plot_non_med_determinants(year, indicator, bubble_scale, all_years=all_years):
# print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]

if ( year > 1 ):
indicator_data = non_med_determinants.loc[ (non_med_determinants['Indicator'] == indicator) & (non_med_determinants['Data year'] == year) ]
ax.scatter(indicator_data['Data year'], indicator_data['Region'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = non_med_determinants.loc[ (non_med_determinants['Indicator'] == indicator) & (non_med_determinants['Data year'] == aYear) ]
ax.scatter(indicator_data['Data year'], indicator_data['Region'], s = indicator_data['Value'] * bubble_scale )
f.canvas.draw()# create the interactive interface
def f(x):
return x


indicator = interactive(f, x=indicators);
display(indicator)
indicator.result

year = interactive(f, x=all_years);
display(year)
year.result


bubble_scale = interactive(f, x=(0, 100, 1));
display(bubble_scale)
bubble_scale.resultinteractive(children=(Dropdown(description='x', options=('Alcohol Consumption: Adults', 'Fruit Consumption: Ad…



interactive(children=(Dropdown(description='x', options=(0, 2013, 2014, 2015, 2015, 2016), value=0), Output())…



interactive(children=(IntSlider(value=50, description='x'), Output()), _dom_classes=('widget-interact',))





50plot_non_med_determinants(year.result, indicator.result, bubble_scale.result)C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\figure.py:445: UserWarning: Matplotlib is currently using module://ipykernel.pylab.backend_inline, which is a non-GUI backend, so cannot show the figure.
% get_backend())
png
plt.rcParams['figure.figsize'] = [20, 10]
def plot_non_med_determinants_by_regions(year, indicator, bubble_scale, all_years=all_years):
#print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]

if ( year > 1 ):
#indicator_data = indicator_data [ indicator_data['Data year'] == year]
indicator_data = non_med_determinants.loc[ (non_med_determinants['Indicator'] == indicator) & (non_med_determinants['Data year'] == year) ]
#print(indicator_data)
ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = non_med_determinants.loc[ (non_med_determinants['Indicator'] == indicator) & (non_med_determinants['Data year'] == aYear) ]
ax.scatter(indicator_data['Region'], indicator_data['Value'], s = indicator_data['Value'] * bubble_scale )
f.canvas.draw()print('Select parameter to visualize across countries over years')
# create the interactive interface
def f(x):
return x


indicator = interactive(f, x=indicators);
display(indicator)
indicator.result

year = interactive(f, x=all_years);
display(year)
year.result


bubble_scale = interactive(f, x=(0, 100, 1));
display(bubble_scale)
bubble_scale.resultSelect parameter to visualize across countries over years



interactive(children=(Dropdown(description='x', options=('Alcohol Consumption: Adults', 'Fruit Consumption: Ad…



interactive(children=(Dropdown(description='x', options=(0, 2013, 2014, 2015, 2015, 2016), value=0), Output())…



interactive(children=(IntSlider(value=50, description='x'), Output()), _dom_classes=('widget-interact',))





50plot_non_med_determinants_by_regions(year.result, indicator.result, bubble_scale.result)
png
plt.rcParams['figure.figsize'] = [20, 10]
def plot_non_med_determinants_by_countries(year, indicator, bubble_scale, selected_countries, all_years=all_years):
#print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]

if ( year > 1 ):
#indicator_data = indicator_data [ indicator_data['Data year'] == year]
indicator_data = non_med_determinants.loc[ (non_med_determinants['Indicator'] == indicator) & (non_med_determinants['Data year'] == str(year) ) & (non_med_determinants['Type of region'] == 'Country' ) ]
#print(indicator_data)

if ( len(selected_countries) > 1 ):
indicator_data = indicator_data[ indicator_data['Region'].isin(selected_countries)]

ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = non_med_determinants.loc[ (non_med_determinants['Indicator'] == indicator) & (non_med_determinants['Data year'] == str(aYear) ) & (non_med_determinants['Type of region'] == 'Country' ) ]
if ( len(selected_countries) > 1 ):
indicator_data = indicator_data[ indicator_data['Region'].isin(selected_countries)]

#print(indicator_data)
ax.scatter(indicator_data['Region'], indicator_data['Value'], s = indicator_data['Value'] * bubble_scale )
f.canvas.draw()countries = non_med_determinants[ non_med_determinants['Type of region'] == 'Country' ]['Region']
countries = sorted (countries.unique())
#countries = ['Canada'] + countries
if 'Canada' in countries:
countries = ['Canada'] + countries

#countriesprint('Select parameters to visualize across countries over years\n')
# create the interactive interface
def f(x):
return x

print('Select chart type:')
chart_types = ['Bubble', 'Bar', 'Pie', 'Line']
chart = interactive(f, x=chart_types);
display(chart)
chart.result

print('Select Indicator')
indicator_country = interactive(f, x=indicators);
display(indicator_country)
indicator_country.result

print('Select Year: 0 = all years')
year_country = interactive(f, x=all_years);
display(year_country)
year_country.result

print('Select bubble size')
bubble_scale_country = interactive(f, x=(0, 100, 1));
display(bubble_scale_country)
bubble_scale_country.result

print('Max country count to compare with')
country_count = interactive(f, x=range(1, 20));
display(country_count)
country_count.result

print('Select countries')
print('Compare with Canada')
all_countries = interactive(f, x=True);
display(all_countries)
all_countries.result

country_0 = interactive(f, x = countries);
country_1 = interactive(f, x = countries);
#country_str = "var%d = interactive(f, x = countries)"
display(country_0)
display(country_1)
country_0.result

print('Compare with Canada')
compare_canada = interactive(f, x=True);
display(compare_canada)
compare_canada.resultSelect parameters to visualize across countries over years

Select chart type:



interactive(children=(Dropdown(description='x', options=('Bubble', 'Bar', 'Pie', 'Line'), value='Bubble'), Out…


Select Indicator



interactive(children=(Dropdown(description='x', options=('Alcohol Consumption: Adults', 'Fruit Consumption: Ad…


Select Year: 0 = all years



interactive(children=(Dropdown(description='x', options=(0, 2013, 2014, 2015, 2015, 2016), value=0), Output())…


Select bubble size



interactive(children=(IntSlider(value=50, description='x'), Output()), _dom_classes=('widget-interact',))


Max country count to compare with



interactive(children=(Dropdown(description='x', options=(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16…


Select countries
Compare with Canada



interactive(children=(Checkbox(value=True, description='x'), Output()), _dom_classes=('widget-interact',))



interactive(children=(Dropdown(description='x', options=('Austria', 'Belgium', 'Chile', 'Czech Republic', 'Den…



interactive(children=(Dropdown(description='x', options=('Austria', 'Belgium', 'Chile', 'Czech Republic', 'Den…


Compare with Canada



interactive(children=(Checkbox(value=True, description='x'), Output()), _dom_classes=('widget-interact',))





Truecountry_0.result'Austria'selected_countries = []
if (all_countries.result == False):
selected_countries = [country_0.result, country_1.result]

#print(year_country.result, indicator_country.result, bubble_scale_country.result)
plot_non_med_determinants_by_countries(year_country.result, indicator_country.result, bubble_scale_country.result, selected_countries)
#print(country_0, country_1)
png
non_med_determinants.loc[  (non_med_determinants['Indicator'] == indicators[0])  & (non_med_determinants['Data year'] == '2013') & (non_med_determinants['Type of region'] == 'Country')     ]
png

Appendix

"""
print('Select countries')
for i in range(country_count.result):
#country_str = interactive(f, x = countries);
country_str = "var%d = interactive(f, x = countries)"
display(country)
country.result
"""

for i in range(country_count.result):
country_str = "var%d = interactive(f, x = countries)" %(i)

exec(country_str)
country_str

for i in [0, 2]:
'var' + str(i)

interactive_health_status_visualizations, Health System Performance, Canada and Others

Justetc Social Services (non-profit)

Justetc Social Services (non-profit)Jan 31 · 5 min read

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inlinefrom __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetshealth_status = pd.read_excel('../data/health-status.xls')
health_status.head()
png
# find all indicators
health_status.set_index(['Indicator'])
indicators = pd.Index(health_status['Indicator']).unique()

# find all years
years = health_status['Data year'].unique()
indicators[0], years[0]('Cancer Mortality (F)', '2013')# sort years
years = [ int(aYear) for aYear in years if (aYear != 'Not applicable') and len( str(aYear).split(' ')) <= 1 ]
years = sorted(years)
years

all_years = [0] + years
all_years[0, 2012, 2013, 2013, 2014, 2014, 2015, 2015]plt.rcParams['figure.figsize'] = [10, 10]
def plot_health_status(year, indicator, bubble_scale, all_years=all_years):
# print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]

if ( year > 1 ):
indicator_data = health_status.loc[ (health_status['Indicator'] == indicator) & (health_status['Data year'] == year) ]
ax.scatter(indicator_data['Data year'], indicator_data['Region'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = health_status.loc[ (health_status['Indicator'] == indicator) & (health_status['Data year'] == aYear) ]
ax.scatter(indicator_data['Data year'], indicator_data['Region'], s = indicator_data['Value'] * bubble_scale )
f.canvas.draw()# create the interactive interface
def f(x):
return x


indicator = interactive(f, x=indicators);
display(indicator)
indicator.result

year = interactive(f, x=all_years);
display(year)
year.result


bubble_scale = interactive(f, x=(0, 100, 1));
display(bubble_scale)
bubble_scale.resultinteractive(children=(Dropdown(description='x', options=('Cancer Mortality (F)', 'Cancer Mortality (M)', 'Hear…



interactive(children=(Dropdown(description='x', options=(0, 2012, 2013, 2013, 2014, 2014, 2015, 2015), value=0…



interactive(children=(IntSlider(value=50, description='x'), Output()), _dom_classes=('widget-interact',))





50plot_health_status(year.result, indicator.result, bubble_scale.result)
png
plt.rcParams['figure.figsize'] = [20, 10]
def plot_health_status_by_regions(year, indicator, bubble_scale, all_years=all_years):
#print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]

if ( year > 1 ):
#indicator_data = indicator_data [ indicator_data['Data year'] == year]
indicator_data = health_status.loc[ (health_status['Indicator'] == indicator) & (health_status['Data year'] == year) ]
#print(indicator_data)
ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = health_status.loc[ (health_status['Indicator'] == indicator) & (health_status['Data year'] == aYear) ]
ax.scatter(indicator_data['Region'], indicator_data['Value'], s = indicator_data['Value'] * bubble_scale )
f.canvas.draw()print('Select parameter to visualize across countries over years')
# create the interactive interface
def f(x):
return x


indicator = interactive(f, x=indicators);
display(indicator)
indicator.result

year = interactive(f, x=all_years);
display(year)
year.result


bubble_scale = interactive(f, x=(0, 100, 1));
display(bubble_scale)
bubble_scale.resultSelect parameter to visualize across countries over years



interactive(children=(Dropdown(description='x', options=('Cancer Mortality (F)', 'Cancer Mortality (M)', 'Hear…



interactive(children=(Dropdown(description='x', options=(0, 2012, 2013, 2013, 2014, 2014, 2015, 2015), value=0…



interactive(children=(IntSlider(value=50, description='x'), Output()), _dom_classes=('widget-interact',))





50plot_health_status_by_regions(year.result, indicator.result, bubble_scale.result)
png
plt.rcParams['figure.figsize'] = [20, 10]
def plot_health_status_by_countries(year, indicator, bubble_scale, selected_countries, all_years=all_years):
#print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]

if ( year > 1 ):
#indicator_data = indicator_data [ indicator_data['Data year'] == year]
indicator_data = health_status.loc[ (health_status['Indicator'] == indicator) & (health_status['Data year'] == str(year) ) & (health_status['Type of region'] == 'Country' ) ]
#print(indicator_data)

if ( len(selected_countries) > 1 ):
indicator_data = indicator_data[ indicator_data['Region'].isin(selected_countries)]

ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = health_status.loc[ (health_status['Indicator'] == indicator) & (health_status['Data year'] == str(aYear) ) & (health_status['Type of region'] == 'Country' ) ]
if ( len(selected_countries) > 1 ):
indicator_data = indicator_data[ indicator_data['Region'].isin(selected_countries)]

#print(indicator_data)
ax.scatter(indicator_data['Region'], indicator_data['Value'], s = indicator_data['Value'] * bubble_scale )
f.canvas.draw()countries = health_status[ health_status['Type of region'] == 'Country' ]['Region']
countries = sorted (countries.unique())
#countries = ['Canada'] + countries
if 'Canada' in countries:
countries = ['Canada'] + countries

#countriesprint('Select parameters to visualize across countries over years\n')
# create the interactive interface
def f(x):
return x

print('Select chart type:')
chart_types = ['Bubble', 'Bar', 'Pie', 'Line']
chart = interactive(f, x=chart_types);
display(chart)
chart.result

print('Select Indicator')
indicator_country = interactive(f, x=indicators);
display(indicator_country)
indicator_country.result

print('Select Year: 0 = all years')
year_country = interactive(f, x=all_years);
display(year_country)
year_country.result

print('Select bubble size')
bubble_scale_country = interactive(f, x=(0, 100, 1));
display(bubble_scale_country)
bubble_scale_country.result

print('Max country count to compare with')
country_count = interactive(f, x=range(1, 20));
display(country_count)
country_count.result

print('Select countries')
print('Compare with Canada')
all_countries = interactive(f, x=True);
display(all_countries)
all_countries.result

country_0 = interactive(f, x = countries);
country_1 = interactive(f, x = countries);
#country_str = "var%d = interactive(f, x = countries)"
display(country_0)
display(country_1)
country_0.result

print('Compare with Canada')
compare_canada = interactive(f, x=True);
display(compare_canada)
compare_canada.resultSelect parameters to visualize across countries over years

Select chart type:



interactive(children=(Dropdown(description='x', options=('Bubble', 'Bar', 'Pie', 'Line'), value='Bubble'), Out…


Select Indicator



interactive(children=(Dropdown(description='x', options=('Cancer Mortality (F)', 'Cancer Mortality (M)', 'Hear…


Select Year: 0 = all years



interactive(children=(Dropdown(description='x', options=(0, 2012, 2013, 2013, 2014, 2014, 2015, 2015), value=0…


Select bubble size



interactive(children=(IntSlider(value=50, description='x'), Output()), _dom_classes=('widget-interact',))


Max country count to compare with



interactive(children=(Dropdown(description='x', options=(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16…


Select countries
Compare with Canada



interactive(children=(Checkbox(value=True, description='x'), Output()), _dom_classes=('widget-interact',))



interactive(children=(Dropdown(description='x', options=('Austria', 'Belgium', 'Chile', 'Czech Republic', 'Den…



interactive(children=(Dropdown(description='x', options=('Austria', 'Belgium', 'Chile', 'Czech Republic', 'Den…


Compare with Canada



interactive(children=(Checkbox(value=True, description='x'), Output()), _dom_classes=('widget-interact',))





Truecountry_0.result'Austria'selected_countries = []
if (all_countries.result == False):
selected_countries = [country_0.result, country_1.result]

#print(year_country.result, indicator_country.result, bubble_scale_country.result)
plot_health_status_by_countries(year_country.result, indicator_country.result, bubble_scale_country.result, selected_countries)
#print(country_0, country_1)
png
health_status.loc[  (health_status['Indicator'] == indicators[0])  & (health_status['Data year'] == '2013') & (health_status['Type of region'] == 'Country')     ]
png

Appendix

"""
print('Select countries')
for i in range(country_count.result):
#country_str = interactive(f, x = countries);
country_str = "var%d = interactive(f, x = countries)"
display(country)
country.result
"""

for i in range(country_count.result):
country_str = "var%d = interactive(f, x = countries)" %(i)

exec(country_str)
country_str

for i in [0, 2]:
'var' + str(i)

health_status_visualizations, Health System Performance, Canada and Others

Justetc Social Services (non-profit)

Justetc Social Services (non-profit)Jan 31 · 4 min read

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inlinefrom __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetshealth_status = pd.read_excel('../data/health-status.xls')
health_status.head()
png
health_status.set_index(['Indicator'])
#health_status.loc[health_status['Cancer Mortality (F)']]
#health_status.index.unique()
indicators = pd.Index(health_status['Indicator']).unique()
years = health_status['Data year'].unique()
indicators[0], years[0]('Cancer Mortality (F)', '2013')cancer_mortality_2013 = health_status.loc[ (health_status['Indicator'] == indicators[0]) & (health_status['Data year'] == years[0]) ]
cancer_mortality = health_status.loc[ (health_status['Indicator'] == indicators[0]) & (health_status['Data year'] != 2012) ]
cancer_mortality
png
plt.rcParams['figure.figsize'] = [15, 9]
#plt.scatter(cancer_mortality['Data year'], cancer_mortality['Value']) #, s=cancer_mortality['Value']*10)
for aYear in years:
data = health_status.loc[ (health_status['Indicator'] == indicators[0]) & (health_status['Data year'] == aYear) ]
plt.scatter(data['Data year'], data['Region'], s=cancer_mortality['Value']*10 )
plt.show()
png
png
png
png
png
png
png
png
png
png
png
years = [ int(aYear) for aYear in years if (aYear != 'Not applicable') and len( str(aYear).split(' ')) <= 1 ]
years = sorted(years)
years[2012, 2013, 2013, 2014, 2014, 2015, 2015]plt.rcParams['figure.figsize'] = [8, 15]
from matplotlib import pyplot as plt
f = plt.figure()
ax = f.gca()
f.show()
#years = [2012, 2013, 2014, 2015, 2016, 2017, 2018]
for aYear in years:
#print(aYear)
if (aYear=='Not applicable'):
continue
#ax = fig.add_subplot(111)
data = health_status.loc[ (health_status['Indicator'] == indicators[0]) & (health_status['Data year'] == aYear) ]
ax.scatter(data['Data year'], data['Region'], s=cancer_mortality['Value']*20 )
#line1.set_ydata(data['Region'])
f.canvas.draw()
#plt.show()
#plt.pause(1)
#ax.clear()
#fig.canvas.draw()

#plt.legend()C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\figure.py:445: UserWarning: Matplotlib is currently using module://ipykernel.pylab.backend_inline, which is a non-GUI backend, so cannot show the figure.
% get_backend())
png
plt.rcParams['figure.figsize'] = [5, 5]
plt.ion()
fig = plt.figure()
ax = fig.add_subplot(111)
#line1, = ax.plot(cancer_mortality_2013['Data year'], cancer_mortality_2013['Region'], 'b')
#pl = ax.scatter(cancer_mortality_2013['Data year'], cancer_mortality_2013['Region'], s=cancer_mortality_2013['Value']*30 )

fig = plt.figure()
ax = fig.add_subplot(111)
years = [2012, 2013, 2014, 2015]
for aYear in years:
print(aYear)
ax = fig.add_subplot(111)
data = health_status.loc[ (health_status['Indicator'] == indicators[0]) & (health_status['Data year'] == aYear) ]
ax.scatter(data['Data year'], data['Region'], s=cancer_mortality['Value']*10 )
#line1.set_ydata(data['Region'])
plt.show()
plt.pause(0.0001)
ax.clear()
#fig.canvas.draw()

#for phase in np.linspace(0, 10*np.pi, 100):
#line1.set_ydata(np.sin(0.5 * x + phase))
#fig.canvas.draw()2012


C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\figure.py:98: MatplotlibDeprecationWarning:
Adding an axes using the same arguments as a previous axes currently reuses the earlier instance. In a future version, a new instance will always be created and returned. Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.
"Adding an axes using the same arguments as a previous axes "
png
png
2013
2014
2015plt.rcParams['figure.figsize'] = [15, 9]
plt.scatter(cancer_mortality_2013['Data year'], cancer_mortality_2013['Region'], s=cancer_mortality_2013['Value']*30 )
plt.show()
png
plt.rcParams['figure.figsize'] = [15, 9]
plt.scatter(cancer_mortality_2013['Region'], cancer_mortality_2013['Value'], s=cancer_mortality_2013['Value']*30 )
plt.show()
png
plt.rcParams['figure.figsize'] = [100, 50]
from matplotlib import pyplot as plt
f = plt.figure()
ax = f.gca()
f.show()
#years = [2012, 2013, 2014, 2015, 2016, 2017, 2018]
for aYear in years:
#print(aYear)
if (aYear=='Not applicable'):
continue
#ax = fig.add_subplot(111)
data = health_status.loc[ (health_status['Indicator'] == indicators[0]) & (health_status['Data year'] == aYear) ]
#ax.scatter(data['Data year'], data['Region'], s=cancer_mortality['Value']*20 )
ax.scatter(data['Region'], data['Value'], s=cancer_mortality['Value']*100 )
#line1.set_ydata(data['Region'])
f.canvas.draw()
#plt.show()
#plt.pause(1)
#ax.clear()
#fig.canvas.draw()

#plt.legend()
png
def f(x):
return x


w = interact(f, x=indicators);
interact(f, x=years);interactive(children=(Dropdown(description='x', options=('Cancer Mortality (F)', 'Cancer Mortality (M)', 'Hear…



interactive(children=(Dropdown(description='x', options=(2012, 2013, 2014, 2015), value=2012), Output()), _dom…w = interactive(f, x=indicators);type(w)ipywidgets.widgets.interaction.interactivew.children(Dropdown(description='x', options=('Cancer Mortality (F)', 'Cancer Mortality (M)', 'Heart Disease Mortality', 'Infant Mortality', 'Life Expectancy at Birth (F)', 'Life Expectancy at Birth (M)', 'Perceived Health Status', 'Stroke Mortality', 'Suicide (F)', 'Suicide (M)', 'Transport Accident Mortality (F)', 'Transport Accident Mortality (M)'), value='Cancer Mortality (F)'),
Output())display(w)interactive(children=(Dropdown(description='x', options=('Cancer Mortality (F)', 'Cancer Mortality (M)', 'Hear…w.result'Perceived Health Status'

access_to_care, primary-prescribing, Health System Performance, Canada and Others

Justetc Social Services (non-profit)

Justetc Social Services (non-profit)Jan 31 · 5 min read

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inlinefrom __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetsaccess_to_care = pd.read_excel('../data/access-to-care.xls')
access_to_care.head()
png
# find all indicators
access_to_care.set_index(['Indicator'])
indicators = pd.Index(access_to_care['Indicator']).unique()

# find all years
years = access_to_care['Data year'].dropna().unique()
indicators[0], years('Inability to Pay for Medical Bills',
array(['2016', 2016, 'Not applicable', '2015', '2013'], dtype=object))# sort years
years = [ int(aYear) for aYear in years if (aYear != 'Not applicable') and len( str(aYear).split(' ')) <= 1 ]
years = sorted(years)
years

all_years = [0] + years
all_years[0, 2013, 2015, 2016, 2016]plt.rcParams['figure.figsize'] = [10, 10]
def plot_access_to_care(year, indicator, bubble_scale, all_years=all_years):
# print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]
if ( year > 1 ):
indicator_data = access_to_care.loc[ (access_to_care['Indicator'] == indicator) & (access_to_care['Data year'] == year) ]
ax.scatter(indicator_data['Data year'], indicator_data['Region'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = access_to_care.loc[ (access_to_care['Indicator'] == indicator) & (access_to_care['Data year'] == aYear) ]
ax.scatter(indicator_data['Data year'], indicator_data['Region'], s = indicator_data['Value'] * bubble_scale )
f.canvas.draw()# create the interactive interface
def f(x):
return x


indicator = interactive(f, x=indicators);
display(indicator)
indicator.result

year = interactive(f, x=all_years);
display(year)
year.result


bubble_scale = interactive(f, x=(0, 100, 1));
display(bubble_scale)
bubble_scale.resultinteractive(children=(Dropdown(description='x', options=('Inability to Pay for Medical Bills', 'Poor Weekend/E…



interactive(children=(Dropdown(description='x', options=(0, 2013, 2015, 2016, 2016), value=0), Output()), _dom…



interactive(children=(IntSlider(value=50, description='x'), Output()), _dom_classes=('widget-interact',))





50plot_access_to_care(year.result, indicator.result, bubble_scale.result)C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\figure.py:445: UserWarning: Matplotlib is currently using module://ipykernel.pylab.backend_inline, which is a non-GUI backend, so cannot show the figure.
% get_backend())
png
plt.rcParams['figure.figsize'] = [20, 10]
def plot_access_to_care_by_regions(year, indicator, bubble_scale, all_years=all_years):
#print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]

if ( year > 1 ):
#indicator_data = indicator_data [ indicator_data['Data year'] == year]
indicator_data = access_to_care.loc[ (access_to_care['Indicator'] == indicator) & (access_to_care['Data year'] == year) ]
#print(indicator_data)
ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = access_to_care.loc[ (access_to_care['Indicator'] == indicator) & (access_to_care['Data year'] == aYear) ]
ax.scatter(indicator_data['Region'], indicator_data['Value'], s = indicator_data['Value'] * bubble_scale )
f.canvas.draw()print('Select parameter to visualize across countries over years')
# create the interactive interface
def f(x):
return x


indicator = interactive(f, x=indicators);
display(indicator)
indicator.result

year = interactive(f, x=all_years);
display(year)
year.result


bubble_scale = interactive(f, x=(0, 100, 1));
display(bubble_scale)
bubble_scale.resultSelect parameter to visualize across countries over years



interactive(children=(Dropdown(description='x', options=('Inability to Pay for Medical Bills', 'Poor Weekend/E…



interactive(children=(Dropdown(description='x', options=(0, 2013, 2015, 2016, 2016), value=0), Output()), _dom…



interactive(children=(IntSlider(value=50, description='x'), Output()), _dom_classes=('widget-interact',))





50plot_access_to_care_by_regions(year.result, indicator.result, bubble_scale.result)
png
plt.rcParams['figure.figsize'] = [20, 10]
def plot_access_to_care_by_countries(year, indicator, bubble_scale, selected_countries, all_years=all_years):
#print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]

if ( year > 1 ):
#indicator_data = indicator_data [ indicator_data['Data year'] == year]
indicator_data = access_to_care.loc[ (access_to_care['Indicator'] == indicator) & (access_to_care['Data year'] == str(year) ) & (access_to_care['Type of region'] == 'Country' ) ]
#print(indicator_data)

if ( len(selected_countries) > 1 ):
indicator_data = indicator_data[ indicator_data['Region'].isin(selected_countries)]

ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = access_to_care.loc[ (access_to_care['Indicator'] == indicator) & (access_to_care['Data year'] == str(aYear) ) & (access_to_care['Type of region'] == 'Country' ) ]
if ( len(selected_countries) > 1 ):
indicator_data = indicator_data[ indicator_data['Region'].isin(selected_countries)]

#print(indicator_data)
ax.scatter(indicator_data['Region'], indicator_data['Value'], s = indicator_data['Value'] * bubble_scale )
f.canvas.draw()countries = access_to_care[ access_to_care['Type of region'] == 'Country' ]['Region']
countries = sorted (countries.unique())
#countries = ['Canada'] + countries
if 'Canada' in countries:
countries = ['Canada'] + countries

#countriesprint('Select parameters to visualize across countries over years\n')
# create the interactive interface
def f(x):
return x

print('Select chart type:')
chart_types = ['Bubble', 'Bar', 'Pie', 'Line']
chart = interactive(f, x=chart_types);
display(chart)
chart.result

print('Select Indicator')
indicator_country = interactive(f, x=indicators);
display(indicator_country)
indicator_country.result

print('Select Year: 0 = all years')
year_country = interactive(f, x=all_years);
display(year_country)
year_country.result

print('Select bubble size')
bubble_scale_country = interactive(f, x=(0, 100, 1));
display(bubble_scale_country)
bubble_scale_country.result

print('Max country count to compare with')
country_count = interactive(f, x=range(1, 20));
display(country_count)
country_count.result

print('Select countries')
print('Compare with Canada')
all_countries = interactive(f, x=True);
display(all_countries)
all_countries.result

country_0 = interactive(f, x = countries);
country_1 = interactive(f, x = countries);
#country_str = "var%d = interactive(f, x = countries)"
display(country_0)
display(country_1)
country_0.result

print('Compare with Canada')
compare_canada = interactive(f, x=True);
display(compare_canada)
compare_canada.resultSelect parameters to visualize across countries over years

Select chart type:



interactive(children=(Dropdown(description='x', options=('Bubble', 'Bar', 'Pie', 'Line'), value='Bubble'), Out…


Select Indicator



interactive(children=(Dropdown(description='x', options=('Inability to Pay for Medical Bills', 'Poor Weekend/E…


Select Year: 0 = all years



interactive(children=(Dropdown(description='x', options=(0, 2013, 2015, 2016, 2016), value=0), Output()), _dom…


Select bubble size



interactive(children=(IntSlider(value=50, description='x'), Output()), _dom_classes=('widget-interact',))


Max country count to compare with



interactive(children=(Dropdown(description='x', options=(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16…


Select countries
Compare with Canada



interactive(children=(Checkbox(value=True, description='x'), Output()), _dom_classes=('widget-interact',))



interactive(children=(Dropdown(description='x', options=('Belgium', 'Chile', 'Denmark', 'Estonia', 'Finland', …



interactive(children=(Dropdown(description='x', options=('Belgium', 'Chile', 'Denmark', 'Estonia', 'Finland', …


Compare with Canada



interactive(children=(Checkbox(value=True, description='x'), Output()), _dom_classes=('widget-interact',))





Truecountry_0.result'Belgium'selected_countries = []
if (all_countries.result == False):
selected_countries = [country_0.result, country_1.result]

#print(year_country.result, indicator_country.result, bubble_scale_country.result)
plot_access_to_care_by_countries(year_country.result, indicator_country.result, bubble_scale_country.result, selected_countries)
#print(country_0, country_1)
png
access_to_care.loc[  (access_to_care['Indicator'] == indicators[0])  & (access_to_care['Data year'] == '2013') & (access_to_care['Type of region'] == 'Country')     ]
png

Appendix

"""
print('Select countries')
for i in range(country_count.result):
#country_str = interactive(f, x = countries);
country_str = "var%d = interactive(f, x = countries)"
display(country)
country.result
"""

for i in range(country_count.result):
country_str = "var%d = interactive(f, x = countries)" %(i)

exec(country_str)
country_str

for i in [0, 2]:
'var' + str(i)

How to use ipywidgets, interactive as used in the project

Justetc Social Services (non-profit)

Justetc Social Services (non-profit)Jan 31 · 1 min read

from __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetsdef f(x):
return xinteract(f, x=10);interactive(children=(IntSlider(value=10, description='x', max=30, min=-10), Output()), _dom_classes=('widget-…interact(f, x=True);interactive(children=(Checkbox(value=True, description='x'), Output()), _dom_classes=('widget-interact',))interact(f, x='Hi there!');interactive(children=(Text(value='Hi there!', description='x'), Output()), _dom_classes=('widget-interact',))@interact(x=True, y=1.0)
def g(x, y):
return (x, y)interactive(children=(Checkbox(value=True, description='x'), FloatSlider(value=1.0, description='y', max=3.0, …interact(f, x=['apples','oranges']);interactive(children=(Dropdown(description='x', options=('apples', 'oranges'), value='apples'), Output()), _do…from IPython.display import display
def f(a, b):
display(a + b)
return a+bw = interactive(f, a=10, b=20)type(w)ipywidgets.widgets.interaction.interactivew.children(IntSlider(value=10, description='a', max=30, min=-10),
IntSlider(value=20, description='b', max=60, min=-20),
Output())display(w)interactive(children=(IntSlider(value=10, description='a', max=30, min=-10), IntSlider(value=20, description='…

IPywidgets, interactive

Justetc Social Services (non-profit)

Justetc Social Services (non-profit)·Jan 31

from __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetsdef f(x):
return xinteract(f, x=10);interactive(children=(IntSlider(value=10, description='x', max=30, min=-10), Output()), _dom_classes=('widget-…interact(f, x=True);interactive(children=(Checkbox(value=True, description='x'), Output()), _dom_classes=('widget-interact',))interact(f, x='Hi there!');interactive(children=(Text(value='Hi there!', description='x'), Output()), _dom_classes=('widget-interact',))@interact(x=True, y=1.0)
def g(x, y):
return (x, y)interactive(children=(Checkbox(value=True, description='x'), FloatSlider(value=1.0, description='y', max=3.0, …interact(f, x=['apples','oranges']);interactive(children=(Dropdown(description='x', options=('apples', 'oranges'), value='apples'), Output()), _do…from IPython.display import display
def f(a, b):
display(a + b)
return a+bw = interactive(f, a=10, b=20)type(w)ipywidgets.widgets.interaction.interactivew.children(IntSlider(value=10, description='a', max=30, min=-10),
IntSlider(value=20, description='b', max=60, min=-20),
Output())display(w)interactive(children=(IntSlider(value=10, description='a', max=30, min=-10), IntSlider(value=20, description='…

Get Justetc Social Services (non-profit)'s stories in your inbox

You cannot subscribe to yourself

More from Justetc Social Services (non-profit)

All proceeds from Medium will go to Justetc Social Services ( non-profit). Justetc Social Services provides services in the Training and Education Areas.

Published in Health System Performance·Jan 31

from __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetsdef f(x):
return xinteract(f, x=10);interactive(children=(IntSlider(value=10, description='x', max=30, min=-10), Output()), _dom_classes=('widget-…interact(f, x=True)…

Read more in Health System Performance · 1 min read


Published in Health System Performance·Jan 31

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inlinefrom __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetsaccess_to_care = pd.read_excel('../data/access-to-care.xls')
access_to_care.head()
png
# find all indicators
access_to_care.set_index(['Indicator'])
indicators = pd.Index(access_to_care['Indicator']).unique()

# find all years
years = access_to_care['Data year'].dropna().unique()
indicators[0], years('Inability to Pay for Medical Bills',
array(['2016', 2016, 'Not applicable', '2015', '2013'], dtype=object))# sort years
years = [ int(aYear) for aYear in years if (aYear != 'Not applicable') and len( str(aYear).split(' ')) <= 1 ]
years = sorted(years)
years

all_years = [0] + years
all_years[0, 2013, 2015, 2016, 2016]plt.rcParams['figure.figsize'] = [10, 10]
def plot_access_to_care(year, indicator, bubble_scale, all_years=all_years):
# print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]
if ( year > 1 ):
indicator_data = access_to_care.loc[ (access_to_care['Indicator'] == indicator) & (access_to_care['Data year'] == year) ]
ax.scatter(indicator_data['Data year'], indicator_data['Region'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = access_to_care.loc[ (access_to_care['Indicator'] == indicator) & (access_to_care['Data year'] == aYear) ]
ax.scatter(indicator_data['Data …

Read more in Health System Performance · 5 min read


Published in Health System Performance·Jan 31

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inlinefrom __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetshealth_status = pd.read_excel('../data/health-status.xls')
health_status.head()
png
health_status.set_index(['Indicator'])
#health_status.loc[health_status['Cancer Mortality (F)']]
#health_status.index.unique()
indicators = pd.Index(health_status['Indicator']).unique()
years = health_status['Data year'].unique()
indicators[0], years[0]('Cancer Mortality (F)', '2013')cancer_mortality_2013 = health_status.loc[ (health_status['Indicator'] == indicators[0]) & (health_status['Data year'] == years[0]) ]
cancer_mortality = health_status.loc[ (health_status['Indicator'] == indicators[0]) & (health_status['Data year'] != 2012) ]
cancer_mortality

Read more in Health System Performance · 4 min read


Published in Health System Performance·Jan 31

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inlinefrom __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetshealth_status = pd.read_excel('../data/health-status.xls')
health_status.head()
png
# find all indicators
health_status.set_index(['Indicator'])
indicators = pd.Index(health_status['Indicator']).unique()

# find all years
years = health_status['Data year'].unique()
indicators[0], years[0]('Cancer Mortality (F)', '2013')# sort years
years = [ int(aYear) for aYear in years if (aYear != 'Not applicable') and len( str(aYear).split(' ')) <= 1 ]
years = sorted(years)
years

all_years = [0] + years
all_years[0, 2012, 2013, 2013, 2014, 2014, 2015, 2015]plt.rcParams['figure.figsize'] = [10, 10]
def plot_health_status(year, indicator, bubble_scale, all_years=all_years):
# print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]

if ( year > 1 ):
indicator_data = health_status.loc[ (health_status['Indicator'] == indicator) & (health_status['Data year'] == year) ]
ax.scatter(indicator_data['Data year'], indicator_data['Region'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = health_status.loc[ (health_status['Indicator'] == indicator) & (health_status['Data year'] == aYear) ]
ax.scatter(indicator_data['Data …

Read more in Health System Performance · 5 min read


Published in Health System Performance·Jan 31

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inlinefrom __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgetsnon_med_determinants = pd.read_excel('../data/non-med-determinants.xls')
non_med_determinants.head()
png
# find all indicators
non_med_determinants.set_index(['Indicator'])
indicators = pd.Index(non_med_determinants['Indicator']).unique()

# find all years
years = non_med_determinants['Data year'].dropna().unique()
indicators[0], years('Alcohol Consumption: Adults',
array(['2014', '2015', '2013', 2015, 'Not applicable', '2016'],
dtype=object))# sort years
years = [ int(aYear) for aYear in years if (aYear != 'Not applicable') and len( str(aYear).split(' ')) <= 1 ]
years = sorted(years)
years

all_years = [0] + years
all_years[0, 2013, 2014, 2015, 2015, 2016]plt.rcParams['figure.figsize'] = [10, 10]
def plot_non_med_determinants(year, indicator, bubble_scale, all_years=all_years):
# print('year, indicator', year, indicator)
plt.ion()
f = plt.figure()
ax = f.gca()
f.show()

#indicator_data = health_status.loc[ (health_status['Indicator'] == indicators[0] ) ]

if ( year > 1 ):
indicator_data = non_med_determinants.loc[ (non_med_determinants['Indicator'] == indicator) & (non_med_determinants['Data year'] == year) ]
ax.scatter(indicator_data['Data year'], indicator_data['Region'], s=indicator_data['Value'] * bubble_scale )
plt.show()

else:
for aYear in all_years:
indicator_data = non_med_determinants.loc[ (non_med_determinants['Indicator'] == indicator) & (non_med_determinants['Data year'] == aYear) ]
ax.scatter(indicator_data['Data …

Read more in Health System Performance · 5 min read

This file will contain visualization code for 6 health performance aspects

Justetc Social Services (non-profit)

Justetc Social Services (non-profit)Jan 31 · 29 min read

Indicator visualizations will be in a separate ipynb file (visualize-indicators-final.ipynb)

Visualizations can be created using the UI interface i.e. Select options and execute the code block after to get the visualizations.

I have placed a separate section at the end of this file where research questions and plots as I placed on my documents and presentations are placed (Code there will generate the plots for that section)

For research question section, corresponding health status will need to be selected and data reloaded to re — execute (UI selections will not matter)

#!conda install basemapimport pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import numpy as np

from __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets

import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline# it is important
# from geopy.geocoders import Nominatim

# for geo maps
# !conda install basemap
import conda
import os
if 'PROJ_DIR' in os.environ:
pyproj_datadir = os.environ['PROJ_DIR']
else:
conda_file_dir = conda.CONDA_PACKAGE_ROOT
conda_dir = conda_file_dir.split('lib')[0]
pyproj_datadir = os.path.join(os.path.join(conda_dir, 'Library'),'share')
os.environ['PROJ_LIB'] = pyproj_datadir

#important
#from mpl_toolkits.basemap import Basemap

Location of the Data Files Folder.

Data folder will have data files, one for one aspect of healthcare performance. I will load data file names(aspects) in a drop down — to act upon that. Hence, any new data files with similar structures (likely) can be easily integrated with the visualizations.

import os

data_folder = './data/'
measure_files = os.listdir(data_folder)
measure_files['.~lock.health-status.xls#',
'access-to-care.xls',
'health-status.xls',
'non-med-determinants.xls',
'patient-safety.xls',
'prescribing-primary.xls',
'quality-of-care.xls']

Select a measure/aspect to visualize upon

If you see: [‘.~lock.health-status.xls#’, or similar that needs to be ignored

Note: when a health-aspect i.e. measure will be changed in the drop-down below, some code need to be re-executed to load related data.

I am marking with START-RELOAD-DATA and END-RELOAD-DATA

print('Select a health measure/aspect to visualize\n')
# create the interactive interface
def f(measure):
return measure

print('Select a measure:')
measure_file = interactive(f, measure = measure_files);
display(measure_file)Select a health measure/aspect to visualize

Select a measure:



interactive(children=(Dropdown(description='measure', options=('.~lock.health-status.xls#', 'access-to-care.xl…

Test what aspect/measure we have selected

START-RELOAD-DATA

'Selected: ' + measure_file.result'Selected: access-to-care.xls'if (measure_file.result == ''):
measure_file.result = 'health-status.xls'

Load Data and Display

data_file = data_folder + measure_file.result
measure_data = pd.read_excel(data_file)
measure_data.head()
png

Find all the performance indicators under this aspect/measure

irrespective we have data for Canada or not

# find details on Indicators
# find all indicators
measure_data.set_index(['Indicator'])
indicators = pd.Index(measure_data['Indicator']).unique()
indicatorsIndex(['Inability to Pay for Medical Bills', 'Poor Weekend/Evening Care',
'Regular Doctor', 'Same or Next Day Appt',
'Wait Time: Cataract Surgery', 'Wait Time: Hip Replacement',
'Wait Time: Knee Replacement', 'Wait Time: Specialist'],
dtype='object', name='Indicator')

Find the performance indicators under this aspect/measure when Canada must have data

# indicators that must have canadian data

# first where canada do exist
data_with_canada = measure_data[measure_data['Region'] == 'Canada']

#indicators when canada also have data
indicators_with_canada = data_with_canada['Indicator'].unique()

print('All indicators\n', indicators)
print('Indicators where canada also has Data\n', indicators_with_canada)
'Indicator Counts', len(indicators_with_canada), len(indicators)All indicators
Index(['Inability to Pay for Medical Bills', 'Poor Weekend/Evening Care',
'Regular Doctor', 'Same or Next Day Appt',
'Wait Time: Cataract Surgery', 'Wait Time: Hip Replacement',
'Wait Time: Knee Replacement', 'Wait Time: Specialist'],
dtype='object', name='Indicator')
Indicators where canada also has Data
['Inability to Pay for Medical Bills' 'Poor Weekend/Evening Care'
'Regular Doctor' 'Same or Next Day Appt' 'Wait Time: Cataract Surgery'
'Wait Time: Hip Replacement' 'Wait Time: Knee Replacement'
'Wait Time: Specialist']





('Indicator Counts', 8, 8)

Find years as we can see in the data

All years, also seprately when we have data for Canada

# find all years
years = measure_data['Data year'].dropna().unique()
years_with_canada = data_with_canada['Data year'].dropna().unique()


print('Years we have data\n', years)
print('Years where canada also has data\n', years_with_canada)Years we have data
['2016' 2016 'Not applicable' '2015' '2013']
Years where canada also has data
[2016]

Years when we have data for Canada

# sort years for all data
years = [ int(aYear) for aYear in years if (aYear != 'Not applicable') and len( str(aYear).split(' ')) <= 1 ]
years = sorted(years)
years

all_years = [0] + years
all_years[0, 2013, 2015, 2016, 2016]

Sort the years so that we can show them in drop down in ascending format

0 means all years selected

# sort years
years_with_canada = [ int(aYear) for aYear in years_with_canada if (aYear != 'Not applicable') and len( str(aYear).split(' ')) <= 1 ]
years_with_canada = sorted(years_with_canada)
years_with_canada

all_years_canada = [0] + years_with_canada
all_years_canada[0, 2016]

All countries

countries = measure_data[ (measure_data['Type of region'] == 'Country') | (measure_data['Type of region'] == 'Canada') ]['Region']
countries = sorted (countries.unique())
#print(countries)
#countries = ['Canada'] + countries

# bring Canada at the top
if 'Canada' in countries:
countries = ['Canada'] + countries

countries[:1]['Canada']

unique color code for each country

color will be used as a third dimension in some plots

# countries unique color code
all_regions = measure_data['Region'].unique()
region_colors = []
region_colors_dict = {}
import random
random.seed(0)
for aRegion in all_regions:
region_colors_dict[aRegion] = np.random.randint(0, 255)

list(region_colors_dict.keys())[:5], list(region_colors_dict.values())[:5](['United Kingdom',
'Saskatchewan',
'Germany',
'British Columbia',
'Australia'],
[227, 16, 56, 193, 232])# latitude and longitude information
geolocator = Nominatim(user_agent="chrome")
lats, lons = [], []
lats_dict = {}
lons_dict = {}
#for aCountry in countries:
for aRegion in all_regions:
try:
location = geolocator.geocode(aRegion)
lats.append(location.latitude)
lons.append(location.longitude)
lats_dict[aRegion] = location.latitude
lons_dict[aRegion] = location.longitude
except:
continue

lats_dict['Canada']
#list(zip(lats, lons))---------------------------------------------------------------------------

NameError Traceback (most recent call last)

<ipython-input-17-1521376715a3> in <module>()
1 # latitude and longitude information
----> 2 geolocator = Nominatim(user_agent="chrome")
3 lats, lons = [], []
4 lats_dict = {}
5 lons_dict = {}


NameError: name 'Nominatim' is not defined# Province unique color code
all_provinces = measure_data[ measure_data['Type of region'] == 'Province' ]['Region'].unique()
province_colors = []
province_colors_dict = {}
import random
random.seed(0)
for aProvince in all_provinces:
province_colors_dict[aProvince] = np.random.randint(0, 255)

list(province_colors_dict.keys()), list(province_colors_dict.values())(['Saskatchewan',
'British Columbia',
'Newfoundland and Labrador',
'Manitoba',
'Alberta',
'Quebec',
'New Brunswick',
'Ontario',
'Nova Scotia',
'Prince Edward Island'],
[172, 161, 91, 156, 3, 216, 153, 234, 191, 96])

latitude longitude for all regions (countries, provinces)

will be used in map/geo plots

# latitude and longitude information
geolocator = Nominatim(user_agent="chrome")
lats, lons = [], []
lats_dict = {}
lons_dict = {}
#for aCountry in countries:
for aRegion in all_regions:
try:
location = geolocator.geocode(aRegion)
lats.append(location.latitude)
lons.append(location.longitude)
lats_dict[aRegion] = location.latitude
lons_dict[aRegion] = location.longitude
except:
continue

lats_dict['Canada']
#list(zip(lats, lons))---------------------------------------------------------------------------

NameError Traceback (most recent call last)

<ipython-input-19-1521376715a3> in <module>()
1 # latitude and longitude information
----> 2 geolocator = Nominatim(user_agent="chrome")
3 lats, lons = [], []
4 lats_dict = {}
5 lons_dict = {}


NameError: name 'Nominatim' is not defined

Test to check the OECD Data: Benchmark data

for anIndicator in indicators:
oecd_data = measure_data.loc[ (measure_data['Indicator'] == anIndicator) & (measure_data['Region'] == 'OECD average') ]
#oecd_data['Value'].tolist()[0]
print(oecd_data[ ['Indicator', 'Value', 'Data year' ]])

#print(all_years)
for aYear in all_years:
indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicators[0]) & ( (measure_data['Data year'] == aYear) & (measure_data['Type of region'].isin(['Country', 'Canada']) ) ) | \
( (measure_data['Indicator'] == indicators[0]) & (measure_data['Region'] == 'OECD average')) ]

#print(indicator_data[ ['Indicator', 'Value', 'Data year' ]])
#print(indicator_data['Value'])Indicator Value Data year
17 Inability to Pay for Medical Bills 8.7 Not applicable
Indicator Value Data year
27 Poor Weekend/Evening Care 54.1 Not applicable
Indicator Value Data year
57 Regular Doctor 94.6 Not applicable
Indicator Value Data year
84 Same or Next Day Appt 59.2 Not applicable
Indicator Value Data year
110 Wait Time: Cataract Surgery 98.0 Not applicable
Indicator Value Data year
128 Wait Time: Hip Replacement 115.2 Not applicable
Indicator Value Data year
161 Wait Time: Knee Replacement 204.6 Not applicable
Indicator Value Data year
174 Wait Time: Specialist 41.9 Not applicable

END-RELOAD-DATA

Method to plot over years or only for a year.

#Note: All combinations of UI selections might not work as that will require extensive testing and adjust (adjust with data and real life) #country might be represented by colors when applicable #supports plots such as: Bubble, Line, Bar, Hor Bar, Pie #other plot types can also be added. Once implemented will work for all measures and indicators (with proper data format provided) #Note: it is known to me that code can be improved here. similar codes are in multiple places — could be reduced

#plt.rcParams['figure.figsize'] = [10, 15]
def plot_measure_by_years(year, indicator, bubble_scale, chart_type = '', ratios=[10, 1], animate=False, provincial_only=False, all_years=all_years, fig_size=[10, 10], sec_fig=True):
plt.rcParams['figure.figsize'] = fig_size

# redundend code to address a last minute bug
# countries unique color code
all_regions = measure_data['Region'].unique()
region_colors = []
region_colors_dict = {}
import random
random.seed(0)
for aRegion in all_regions:
region_colors_dict[aRegion] = np.random.randint(0, 255)


# print('year, indicator', year, indicator)

# keep these, I might need this

"""
plt.ion()
f = plt.figure()
ax = f.gca()

#top box
f.show()
"""

# benchmark data
oecd_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & (measure_data['Region'] == 'OECD average') ]
#benchmark_value = oecd_data['Value']
#print(type(benchmark_value), benchmark_value)
benchmark_value = oecd_data['Value'].tolist()[0]


# one improvement that can be made: usually I kept, two plots side by side. where the right one shows country and color
# as in other cases we do not need the right one, code to hide the right one or just to create and use one subplot is more
# appropriate
# if (sec_fig == True):
fig, axs = plt.subplots(1, 2, figsize=fig_size, sharey=False, gridspec_kw = {'width_ratios':ratios})
#else:
#axs = plt.subplots(1, 1, figsize=fig_size )


#plt.xticks(rotation=90)

# for one year
if ( year > 1 ):

indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & ( (measure_data['Data year'] == year) & (measure_data['Type of region'].isin(['Country', 'Canada']) ) ) | \
( (measure_data['Indicator'] == indicator) & (measure_data['Region'] == 'OECD average')) ]
if (provincial_only == True):
indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & \
(measure_data['Data year'] == year) & (measure_data['Type of region'].isin(['Province']))]

#print(indicator_data)

# for country color codes
if (provincial_only == False):
c = [ region_colors_dict[x] for x in indicator_data['Region'] ]
m = [ x for x in indicator_data['Region'] ]
c_code = [ x[0:3] for x in indicator_data['Region'] ]
else:
#province_colors_dict
c = [ province_colors_dict[x] for x in indicator_data['Region'] ]
m = [ x for x in indicator_data['Region'] ]
c_code = [ x[0:3] for x in indicator_data['Region'] ]
region_colors_dict = province_colors_dict



# this block might not apply to anything for one single year plot

color_as_a_dimension = False
if color_as_a_dimension == True:
axs[1].scatter([1]*len(c), [i*5 for i in range(len(c))], s=300, c=c, marker='^')
count = list(region_colors_dict.keys())
#print(count)
for j in range(len(c)):
axs[1].annotate(count[j], (1.0001, j*5))

axs[1].set_xlabel('Country and Colors')
axs[1].set_ylabel('')

axs[1].set_xticks([])
axs[1].set_yticks([])





if chart_type == 'Line':
# best to use only for one year



axs[0].plot(indicator_data['Value'], indicator_data['Region']) #, c=c
axs[0].set_xticklabels(indicator_data['Value'], rotation=90) # can be turned off
# https://stackoverflow.com/questions/10998621/rotate-axis-text-in-python-matplotlib
plt.suptitle(indicator + ' For a Year')
axs[0].set_xlabel('Values')
axs[0].set_ylabel('Countries/Regions')

fig.savefig('./saved_images_from_visualizations/' + 'line_' +indicator.replace(' ', '_')[0:10] + '_' + str(np.random.randint(0, 99999)) + '.png')

plt.show()

fig, axs = plt.subplots(1, 2, figsize=fig_size, sharey=False, gridspec_kw = {'width_ratios':ratios})
axs[0].plot(indicator_data['Region'], indicator_data['Value']) #, c=c
axs[0].set_xticklabels(indicator_data['Region'], rotation=90) # can be turned off

plt.suptitle(indicator + ' Over a Year')
axs[0].set_xlabel('Regions/Countries')
axs[0].set_ylabel('Values')

#fig.savefig('./saved_images_from_visualizations/cancer_mortality_2017_country_region_x.png')
fig.savefig('./saved_images_from_visualizations/' + 'line_' + indicator.replace(' ', '_')[0:12] + '_' + str(np.random.randint(0, 99999)) + '.png')

plt.show()


elif chart_type == 'Bar':
#fig, axs = plt.subplots(1, 2, figsize=(10, 8), sharey=False, gridspec_kw = {'width_ratios':ratios})
axs[0].bar(indicator_data['Region'], indicator_data['Value']) #, c=c
axs[0].set_xticklabels(indicator_data['Region'], rotation=90) # can be turned off

plt.suptitle(indicator + ' Over a Year')
axs[0].set_xlabel('Regions/Countries')
axs[0].set_ylabel('Values')

#fig.savefig('./saved_images_from_visualizations/cancer_mortality_2017_country_region_x.png')
fig.savefig('./saved_images_from_visualizations/' + 'bar_' + indicator.replace(' ', '_')[0:12] + '_' + str(np.random.randint(0, 99999)) + '.png')

plt.show()

elif chart_type == 'Hor Bar':
#fig, axs = plt.subplots(1, 2, figsize=(10, 8), sharey=False, gridspec_kw = {'width_ratios':ratios})
axs[0].barh(indicator_data['Region'], indicator_data['Value']) #, c=c
#axs[0].set_xticklabels(indicator_data['Region'], rotation=90) # can be turned off

plt.suptitle(indicator + ' Over a Year')
axs[0].set_xlabel('Values')
axs[0].set_ylabel('Regions/Countries')

#fig.savefig('./saved_images_from_visualizations/cancer_mortality_2017_country_region_x.png')
fig.savefig('./saved_images_from_visualizations/' + 'hor_bar' + indicator.replace(' ', '_')[0:12] + '_' + str(np.random.randint(0, 99999)) + '.png')

plt.show()

elif chart_type == 'Pie':
#ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
#plt.barh(indicator_data['Region'], indicator_data['Value'])
#ax.pie(indicator_data['Value'], labels=indicator_data['Data year'], autopct="%1.1f%%")


axs[0].pie(indicator_data['Value'], labels=indicator_data['Region']) #, c=c
axs[0].set_xticklabels(indicator_data['Value'], rotation=90) # can be turned off
# https://stackoverflow.com/questions/10998621/rotate-axis-text-in-python-matplotlib
plt.suptitle(indicator + ' For a Year')
axs[0].set_xlabel('Values')
axs[0].set_ylabel('Countries/Regions')



fig.savefig('./saved_images_from_visualizations/' + 'pie_' + indicator.replace(' ', '_')[0:10] + '_' + str(np.random.randint(0, 99999)) + '.png')

plt.show()

else:

#print(indicator_data)
# for country color codes
if (provincial_only == False):
c = [ region_colors_dict[x] for x in indicator_data['Region'] ]
m = [ x for x in indicator_data['Region'] ]

else:
#province_colors_dict
c = [ province_colors_dict[x] for x in indicator_data['Region'] ]
m = [ x for x in indicator_data['Region'] ]
#c_code = [ x[0:3] for x in indicator_data['Region'] ]
region_colors_dict = province_colors_dict


#ax.scatter(indicator_data['Data year'], indicator_data['Region'], s=indicator_data['Value'] * bubble_scale, c=c )
axs[0].scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale, c=c )
#axs[0].set_xticks([year])
#axs[0].set_yticks(indicator_data['Value'])

plt.suptitle(indicator + ' Over a Year ' + str(year) )
axs[0].set_xlabel('Regions')
axs[0].set_ylabel('Values')
axs[0].set_xticklabels(indicator_data['Region'], rotation=90) # can be turned off


axs[1].scatter([1]*len(c), [i*5 for i in range(len(c))], s=300, c=c, marker='^')
count = list(region_colors_dict.keys())
#print(count)
for j in range(len(c)):
axs[1].annotate(count[j], (1.0001, j*5))

axs[1].set_xlabel('Country and Colors')
axs[1].set_ylabel('')

axs[1].set_xticks([])
axs[1].set_yticks([])

fig.savefig('./saved_images_from_visualizations/' + 'bubble_' + indicator.replace(' ', '_')[0:10] + '_' + str(np.random.randint(0, 99999)) + '.png')


#plt.show()
else:
# for multiple years
# though this method is primarily to use for one year, unless in some specific cases
"""
plt.ion()
f = plt.figure()
#ax = f.gca()

#top box
f.show()
"""



# redundend code to address a last minute bug
# countries unique color code
all_regions = measure_data['Region'].unique()
region_colors = []
region_colors_dict = {}
import random
random.seed(0)
for aRegion in all_regions:
region_colors_dict[aRegion] = np.random.randint(0, 255)

#list(region_colors_dict.keys())[:5], list(region_colors_dict.values())[:5]




#print(all_years)
for aYear in all_years:
if aYear == 0:
continue

if aYear == 'Not applicable':
continue

# older : original #
#indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & (measure_data['Data year'] == aYear) ]

"""
indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & ( (measure_data['Data year'] == aYear) & (measure_data['Type of region'].isin(['Country', 'Canada']) ) ) | \
( (measure_data['Indicator'] == indicator) & (measure_data['Region'] == 'OECD average')) ]

"""

indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & (measure_data['Data year'] == aYear) & (measure_data['Type of region'].isin(['Country', 'Canada']) ) ]
if (provincial_only == True):
indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & \
(measure_data['Data year'] == aYear) & (measure_data['Type of region'].isin(['Province']))]

#print(indicator_data)


#print(indicator_data)
# for country color codes
#print(region_colors_dict)
if (provincial_only == False):
c = [ region_colors_dict[x] for x in indicator_data['Region'] ]
m = [ x for x in indicator_data['Region'] ]

else:
#province_colors_dict
c = [ province_colors_dict[x] for x in indicator_data['Region'] ]
m = [ x for x in indicator_data['Region'] ]
#c_code = [ x[0:3] for x in indicator_data['Region'] ]
region_colors_dict = province_colors_dict



#c = [ region_colors_dict[x] for x in indicator_data['Region'] ]
#m = [ x for x in indicator_data['Region'] ]

#print( list(zip(m,c)))

if chart_type == 'Line':
# plt.plot(indicator_data['Data year'], indicator_data['Value'], c=c)
# plt.xticks(indicator_data['Value'])


# was here axs[0].plot(indicator_data['Data year'], indicator_data['Value']) #, c=c
# was here axs[0].set_xticks(indicator_data['Value'])

# brought from one year
# best to use only for one year
#plt.plot(indicator_data['Data year'], indicator_data['Value'], c=c)
#plt.xticks(indicator_data['Value'])

#axs[0].plot(indicator_data['Data year'], indicator_data['Value']) #, c=c
axs[0].plot(indicator_data['Data year'], indicator_data['Value']) #, c=c
#axs[0].plot(165, 'OECD', color='Red')
#axs[0].set_xticklabels(indicator_data['Data year'], rotation=90) # can be turned off
# https://stackoverflow.com/questions/10998621/rotate-axis-text-in-python-matplotlib
#plt.suptitle(indicator + ' For a Year')
#axs[0].set_xlabel('Years')
#axs[0].set_ylabel('Values')

fig.savefig('./saved_images_from_visualizations/cancer_mortality_years_country.png')

#plt.show()

"""
fig, axs = plt.subplots(1, 2, figsize=(10, 8), sharey=False, gridspec_kw = {'width_ratios':ratios})
axs[0].plot(indicator_data['Region'], indicator_data['Value']) #, c=c
axs[0].set_xticklabels(indicator_data['Region'], rotation=90) # can be turned off

plt.suptitle(indicator + ' Over a Year')
axs[0].set_xlabel('Regions/Countries')
axs[0].set_ylabel('Values')

fig.savefig('./saved_images_from_visualizations/cancer_mortality_2017_country_region_x.png')

plt.show()
"""

# end of brought from one year

#f.canvas.draw()





elif chart_type == 'Bar':
#ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
plt.bar(indicator_data['Data year'], indicator_data['Value'])
elif chart_type == 'Hor Bar':
#ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
plt.barh(indicator_data['Region'], indicator_data['Value'])
elif chart_type == 'Pie':
#ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
#plt.barh(indicator_data['Region'], indicator_data['Value'])
ax.pie(indicator_data['Value'], labels=indicator_data['Data year'], autopct="%1.1f%%")
else:
indicator_data['Value'] = indicator_data['Value'].div(benchmark_value)

# for country color codes
c = [ region_colors_dict[x] for x in indicator_data['Region'] ]
m = [ x for x in indicator_data['Region'] ]


axs[0].scatter(indicator_data['Data year'], indicator_data['Value'], s = indicator_data['Value'] * bubble_scale, c=c)

plt.suptitle(indicator + ' Over Years \n Values are in multiples of Benchmark (' + str(benchmark_value) + ')' )
axs[0].set_xlabel('Years')
axs[0].set_ylabel('Values/Becnhmark Value(' + str(benchmark_value) +')' )

fig.savefig('./saved_images_from_visualizations/transport_mortality_over_years.png')

#plt.show()


# show country colors
axs[1].scatter([1]*len(c), [i*5 for i in range(len(c))], s=300, c=c, marker='o')

count = list(m) #list(region_colors_dict.keys())
#print(count)
for j in range(len(c)):
axs[1].annotate(count[j], (1, j*5))

axs[1].set_xlabel('Country and Colors')
axs[1].set_ylabel('')

axs[1].set_xticks([])
axs[1].set_yticks([])

if (animate):
plt.pause(0.01)
#f.canvas.draw()

#plt.show()

Plot over a region for different countries

Some of the plots as can be generated from this method can also be generated using the method above. The use of this method will be mostly averaging over years. However, in the dataset, data for all years might not be available; hence, to make the visualization, the years selected need to make sense consideringreal-world Ideally, I could give options to select multiple years individually and show info to the users what data are there and what are appropriate (I am considering that out of scope for now)

plt.rcParams['figure.figsize'] = [10, 10]
def plot_measure_by_regions(year, indicator, bubble_scale, chart_type = '', ratios=[3,1], provincial_only=False, all_years=all_years):
#print('year, indicator', year, indicator)
plt.ion()
# now f = plt.figure()
# now ax = f.gca()
#plt.xticks([])
# now f.show()

# indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicators[0] ) ]
# (20, 10)
fig, axs = plt.subplots(1, 2, figsize=(20, 10), sharey=False, gridspec_kw = {'width_ratios':ratios})
#plt.xticks(rotation=90)

if ( year > 1 ):
#indicator_data = indicator_data [ indicator_data['Data year'] == year]
indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & (measure_data['Data year'] == year) ]

# for country color codes
c = [ region_colors_dict[x] for x in indicator_data['Region'] ]
m = [ x for x in indicator_data['Region'] ]
c_code = [ x[0:3] for x in indicator_data['Region'] ]


#print(indicator_data)
if chart_type == 'Line':
#ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
#plt.plot(indicator_data['Region'], indicator_data['Value'])


axs[0].plot(indicator_data['Region'], indicator_data['Value']) #, s=indicator_data['Value'] * bubble_scale, c=c )
plt.suptitle(indicator + ' Over Regions')
axs[0].set_xlabel('Regions and Countries')
axs[0].set_ylabel('Values')
axs[0].set_xticklabels(indicator_data['Region'], rotation=90) # can be turned off

fig.savefig('./saved_images_from_visualizations/' + 'line_' + indicator.replace(' ', '_')[0:10] + '_' + str(np.random.randint(0, 99999)) + '.png')


elif chart_type == 'Bar':
#ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
#plt.bar(indicator_data['Region'], indicator_data['Value'])

indicator_data = indicator_data.sort_values(by=['Value'])
axs[0].bar(indicator_data['Region'], indicator_data['Value']) #, s=indicator_data['Value'] * bubble_scale, c=c )
plt.suptitle(indicator + ' Over Regions')
axs[0].set_xlabel('Regions and Countries')
axs[0].set_ylabel('Values')
axs[0].set_xticklabels(indicator_data['Region'], rotation=90) # can be turned off

fig.savefig('./saved_images_from_visualizations/' + 'bar_' + indicator.replace(' ', '_')[0:10] + '_' + str(np.random.randint(0, 99999)) + '.png')


elif chart_type == 'Hor Bar':
#ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
#plt.barh(indicator_data['Region'], indicator_data['Value'])

indicator_data = indicator_data.sort_values(by=['Value'])
axs[0].barh(indicator_data['Region'], indicator_data['Value']) #, s=indicator_data['Value'] * bubble_scale, c=c )
plt.suptitle(indicator + ' Over Regions')
axs[0].set_xlabel('Regions and Countries')
axs[0].set_ylabel('Values')
#axs[0].set_xticklabels(indicator_data['Region'], rotation=90) # can be turned off

fig.savefig('./saved_images_from_visualizations/' + 'hor_bar_' + indicator.replace(' ', '_')[0:10] + '_' + str(np.random.randint(0, 99999)) + '.png')

elif chart_type == 'Pie':
#ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
#plt.barh(indicator_data['Region'], indicator_data['Value'])
#ax.pie(indicator_data['Value'], labels=indicator_data['Region'], autopct="%1.1f%%")


axs[0].pie(indicator_data['Value'], labels = indicator_data['Region'], ) #, s=indicator_data['Value'] * bubble_scale, c=c )
plt.suptitle(indicator + ' Over Regions')
axs[0].set_xlabel('Regions and Countries')
axs[0].set_ylabel('Values')
axs[0].set_xticklabels(indicator_data['Region'], rotation=90) # can be turned off

fig.savefig('./saved_images_from_visualizations/' + 'pie_' + indicator.replace(' ', '_')[0:10] + '_' + str(np.random.randint(0, 99999)) + '.png')

else:
axs[0].scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale, c=c )
plt.suptitle(indicator + ' Over Regions')
axs[0].set_xlabel('Regions and Countries')
axs[0].set_ylabel('Values')
axs[0].set_xticklabels(indicator_data['Region'], rotation=90) # can be turned off



# plt.show()
# show country colors
axs[1].scatter([1]*len(c), [i*5 for i in range(len(c))], s=300, c=c, marker='o')

count = list(m) #list(region_colors_dict.keys())
#print(count)
for j in range(len(c)):
axs[1].annotate(count[j], (1, j*5))

axs[1].set_xlabel('Country and Colors')
axs[1].set_ylabel('')

axs[1].set_xticks([])
axs[1].set_yticks([])

fig.savefig('./saved_images_from_visualizations/' + 'bubble_' + indicator.replace(' ', '_')[0:10] + '_' + str(np.random.randint(0, 99999)) + '.png')



# now plt.show()

# multiple year selected
else:
#indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & (measure_data['Data year'] == aYear) & (measure_data['Type of region'].isin(['Country', 'Canada']) ) ]
indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & (measure_data['Type of region'].isin(['Country', 'Canada']) ) ]
if (provincial_only == True):
indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & \
(measure_data['Data year'] == aYear) & (measure_data['Type of region'].isin(['Province']))]


# for country color codes
c = [ region_colors_dict[x] for x in indicator_data['Region'] ]
m = [ x for x in indicator_data['Region'] ]
c_code = [ x[0:3] for x in indicator_data['Region'] ]

indicator_data = indicator_data.set_index(['Region'])


x = indicator_data.groupby(['Region']).mean()



#print(x.index, x['Value'])


### for aYear in all_years:
# now indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & (measure_data['Data year'] == aYear) ]

"""
indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & (measure_data['Data year'] == aYear) & (measure_data['Type of region'].isin(['Country', 'Canada']) ) ]
if (provincial_only == True):
indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & \
(measure_data['Data year'] == aYear) & (measure_data['Type of region'].isin(['Province']))]


indicator_data = indicator_data.set_index(['Region'])
indicator_data['mean'] = indicator_data.groupby(['Region']).mean()
print(indicator_data)
"""



if chart_type == 'Line':

axs[0].plot(x.index, x['Value']) #, s = x['Value'] * bubble_scale, c=c )

# though I am repeating this block of code - this can be just placed at the end of the else block
# just trying to save on debug time
plt.suptitle(indicator + ' Over Regions')
axs[0].set_xlabel('Regions and Countries')
axs[0].set_ylabel('Values')
axs[0].set_xticklabels(x.index, rotation=90) # can be turned off

fig.savefig('./saved_images_from_visualizations/' + 'line_' + indicator.replace(' ', '_')[0:10] + '_' + str(np.random.randint(0, 99999)) + '.png')



elif chart_type == 'Bar':
#ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
# now plt.bar(indicator_data['Region'], indicator_data['Value'])


x = x.sort_values(by=['Value'])
axs[0].bar(x.index, x['Value']) #, s = x['Value'] * bubble_scale, c=c )

# though I am repeating this block of code - this can be just placed at the end of the else block
# just trying to save on debug time
plt.suptitle(indicator + ' Over Regions')
axs[0].set_xlabel('Regions and Countries')
axs[0].set_ylabel('Values')
axs[0].set_xticklabels(x.index, rotation=90) # can be turned off

fig.savefig('./saved_images_from_visualizations/' + 'bar_' + indicator.replace(' ', '_')[0:10] + '_' + str(np.random.randint(0, 99999)) + '.png')


elif chart_type == 'Hor Bar':
#ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
#plt.barh(indicator_data['Region'], indicator_data['Value'])

x = x.sort_values(by=['Value'])
axs[0].barh(x.index, x['Value']) #, s = x['Value'] * bubble_scale, c=c )

# though I am repeating this block of code - this can be just placed at the end of the else block
# just trying to save on debug time
plt.suptitle(indicator + ' Over Regions')
#axs[0].set_xlabel('Regions and Countries')
axs[0].set_xlabel('Values')
axs[0].set_ylabel('Regions and Countries')
#axs[0].set_xticklabels(x.index, rotation=90) # can be turned off
fig.savefig('./saved_images_from_visualizations/' + 'hor_bar_' + indicator.replace(' ', '_')[0:10] + '_' + str(np.random.randint(0, 99999)) + '.png')


elif chart_type == 'Pie':
#ax.scatter(indicator_data['Region'], indicator_data['Value'], s=indicator_data['Value'] * bubble_scale )
#plt.barh(indicator_data['Region'], indicator_data['Value'])
# now ax.pie(indicator_data['Value'], labels=indicator_data['Region'], autopct="%1.1f%%")




axs[0].pie(x['Value'], labels=x.index) #, c=c
axs[0].set_xticklabels(x['Value'], rotation=90) # can be turned off
# https://stackoverflow.com/questions/10998621/rotate-axis-text-in-python-matplotlib
plt.suptitle(indicator + ' Over Regions')
#axs[0].set_xlabel('Values')
axs[0].set_ylabel('Countries/Regions')

fig.savefig('./saved_images_from_visualizations/' + 'pie_' + indicator.replace(' ', '_')[0:10] + '_' + str(np.random.randint(0, 99999)) + '.png')

plt.show()



else:
#axs[0].scatter(indicator_data['Region'], indicator_data['Value'], s = indicator_data['Value'] * bubble_scale, c=c )
axs[0].scatter(x.index, x['Value'], s = x['Value'] * bubble_scale, c=c )

plt.suptitle(indicator + ' Over Regions')
axs[0].set_xlabel('Regions and Countries')
axs[0].set_ylabel('Values')
#axs[0].set_xticklabels(indicator_data['Region'], rotation=90) # can be turned off
axs[0].set_xticklabels(x.index, rotation=90) # can be turned off

#plt.show()
# show country colors
axs[1].scatter([1]*len(c), [i*5 for i in range(len(c))], s=300, c=c, marker='o')

count = list(m) #list(region_colors_dict.keys())
#print(count)
for j in range(len(c)):
axs[1].annotate(count[j], (1, j*5))

axs[1].set_xlabel('Country and Colors')
axs[1].set_ylabel('')

axs[1].set_xticks([])
axs[1].set_yticks([])

fig.savefig('./saved_images_from_visualizations/' + 'bubble_' + indicator.replace(' ', '_')[0:10] + '_' + str(np.random.randint(0, 99999)) + '.png')

#now f.canvas.draw()

#plt.suptitle(indicator + 'Over Regions and Years')
#plt.xlabel('Regions and Countries')
#plt.ylabel('Values')

Geo Plot, Map Plot on a World Map

"""
magnitudes = measure_data[['Region', 'Value']]
magnitudes['Region'][1]

year = 2015
indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicators[0]) & (measure_data['Data year'] == 2015) ]
#print(indicator_data)
magnitudes = indicator_data[['Region', 'Value', 'Data year']]

for r, v in zip(magnitudes['Region'], magnitudes['Value']):
print(r, v)
""""\nmagnitudes = measure_data[['Region', 'Value']]\nmagnitudes['Region'][1]\n\nyear = 2015\nindicator_data = measure_data.loc[ (measure_data['Indicator'] == indicators[0]) & (measure_data['Data year'] == 2015) ] \n#print(indicator_data)\nmagnitudes = indicator_data[['Region', 'Value', 'Data year']]\n\nfor r, v in zip(magnitudes['Region'], magnitudes['Value']):\n print(r, v)\n"def plot_map_measure_by_regions(year, indicator, bubble_scale, chart_type = '', provincial_only=False, all_years=all_years):
#print('year, indicator', year, indicator)

if ( year > 1 ):

indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & (measure_data['Data year'] == year) ]
#print(indicator_data)
magnitudes = indicator_data[['Region', 'Value']]


# Make this plot larger.
plt.figure(figsize=(16,12))


eq_map = Basemap(projection='robin', resolution = 'l', area_thresh = 1000.0,
lat_0=0, lon_0=-130)
eq_map.drawcoastlines()
eq_map.drawcountries()
eq_map.fillcontinents(color = 'gray')
eq_map.drawmapboundary()
eq_map.drawmeridians(np.arange(0, 360, 30))
eq_map.drawparallels(np.arange(-90, 90, 30))

min_marker_size = 2.5 #* bubble_scale
#for lon, lat, mag in zip(lons, lats, magnitudes):
#for i in range(indicator_data.shape[0]):
for reg, val in zip(magnitudes['Region'], magnitudes['Value']):
#try:
#reg = magnitudes[i:i+1]['Region']
#reg = magnitudes['Region'][i]
#print(reg)
lat = lats_dict[reg]
lon = lons_dict[reg]

#print(lat, lon)
x, y = eq_map(lon, lat)
mag = val #magnitudes['Value'][i] #magnitudes[i:i+1]['Value']
#print(mag)
msize = mag * min_marker_size/bubble_scale
#print(msize, msize)
#marker_string = get_marker_color(mag)
#eq_map.plot(x, y, marker_string, markersize=msize)
eq_map.plot(x, y, marker='o', markersize=msize)

#x, y = eq_map(0, 0)
#eq_map.plot(x, y, marker='D',color='m')

#plt.show()

#except:
#print('hello')
#continue

title_string = indicator
title_string += ' for year ' + str(year)
plt.title(title_string)
#plt.show()

plt.savefig('./saved_images_from_visualizations/' + 'geo_plot_for_a_year_' +indicator.replace(' ', '_')[0:5] + '_' + str(np.random.randint(0, 99999)) + '.png')
plt.show()


#plt.suptitle(indicator + 'Over Regions and Years')
#plt.xlabel('Regions and Countries')
#plt.ylabel('Values')
#plt.show()

else:
# this is to plot over multiple years
# average taken over multiple years will be plotted
# I could make this more user friendly and data friendly
# by giving users the option to select years, countries; also by informing to what extent data are available (skipping as that will extend the work much)

#indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & (measure_data['Data year'] == aYear) & (measure_data['Type of region'].isin(['Country', 'Canada']) ) ]
indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & (measure_data['Type of region'].isin(['Country', 'Canada']) ) ]
if (provincial_only == True):
indicator_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & \
(measure_data['Data year'] == aYear) & (measure_data['Type of region'].isin(['Province']))]

#print(indicator_data)
# for country color codes
"""
c = [ region_colors_dict[x] for x in indicator_data['Region'] ]
m = [ x for x in indicator_data['Region'] ]
c_code = [ x[0:3] for x in indicator_data['Region'] ]
"""

indicator_data = indicator_data.set_index(['Region'])
x = indicator_data.groupby(['Region']).mean()

#print(x)
#print(x['Value'][0])



#print(indicator_data)
# not used
magnitudes = pd.DataFrame()
magnitudes['Region'] = x.index
magnitudes['Value'] = x['Value']

#print(magnitudes)

# Make this plot larger.
plt.figure(figsize=(16,12))


eq_map = Basemap(projection='robin', resolution = 'l', area_thresh = 1000.0,
lat_0=0, lon_0=-130)
eq_map.drawcoastlines()
eq_map.drawcountries()
eq_map.fillcontinents(color = 'gray')
eq_map.drawmapboundary()
eq_map.drawmeridians(np.arange(0, 360, 30))
eq_map.drawparallels(np.arange(-90, 90, 30))

min_marker_size = 2.5 #* bubble_scale
#for lon, lat, mag in zip(lons, lats, magnitudes):
#for i in range(indicator_data.shape[0]):
#for reg, val in zip(magnitudes['Region'], magnitudes['Value']):
for reg, val in zip(x.index, x['Value']):
try:
#reg = magnitudes[i:i+1]['Region']
#reg = magnitudes['Region'][i]
#print(reg, val)
lat = lats_dict[reg]
lon = lons_dict[reg]

#print(lat, lon)
x, y = eq_map(lon, lat)
mag = val #magnitudes['Value'][i] #magnitudes[i:i+1]['Value']
#print(mag)
msize = mag * min_marker_size/bubble_scale
#print(msize, msize)
#marker_string = get_marker_color(mag)
#eq_map.plot(x, y, marker_string, markersize=msize)
eq_map.plot(x, y, marker='o', markersize=msize)

#x, y = eq_map(0, 0)
#eq_map.plot(x, y, marker='D',color='m')

#plt.show()

except:
#print('hello')
continue

title_string = indicator
title_string += ' Average for selected years '
plt.title(title_string)
#plt.show()

plt.savefig('./saved_images_from_visualizations/' + 'geo_plot_average_over_multiple_years_' +indicator.replace(' ', '_')[0:5] + '_' + str(np.random.randint(0, 99999)) + '.png')
plt.show()

Heatmap to compare across indicators and countries

Options implemented:

Heatmap for one year, one indicator for a health-aspect across countries Heatmap for one year, all indicator for a health-aspect across countries

Heatmap for one year, one indicator for a health-aspect across Canadian province Heatmap for one year, all indicator for a health-aspect across Canadian province

Heatmap for all years with mean values, one indicator for a health-aspect across countries Heatmap for all years with mean values, all indicator for a health-aspect across countries

Heatmap for all years with mean values, one indicator for a health-aspect across Canadian province Heatmap for all years with mean values, all indicator for a health-aspect across Canadian province

Whether taking mean over multiple years is a pragmatic approach or not: — it can be an effective way of measurements provided data exist for all those years (otherwise the years with data will dominate) — in my case, data will not be available for all indicators for all years — we can then just plot for one year or I could give an interface to select years, indicators, countries for custom comparison — that can be a long task. Hence, I am giving the tool that can be extended in different ways

# ref : https://cmdlinetips.com/2019/01/how-to-make-heatmap-with-seaborn-in-python/


import pandas as pd
import seaborn as sns
import matplotlib.pyplot as pltdef plot_heatmap_across_indicators(year, indicator = '', ratios = [3,1], provincial_only = False, all_years = all_years, fig_size = [10, 10]):

if ( year > 1 ):
heatmap_data = measure_data.loc[ (measure_data['Data year'] == year) & (measure_data['Type of region'].isin(['Country', 'Canada']) ) ]
if ( provincial_only == True ):
heatmap_data = measure_data.loc[ (measure_data['Data year'] == year) & (measure_data['Type of region'].isin(['Province']) ) ]

if ( indicator != ''):
heatmap_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & (measure_data['Data year'] == year) & ( measure_data['Type of region'].isin(['Country', 'Canada']) ) ]
if ( provincial_only == True ):
heatmap_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & (measure_data['Data year'] == year) & (measure_data['Type of region'].isin(['Province']) ) ]

#print(heatmap_data)
indicator_data_heatmap = heatmap_data[ ['Region', 'Value', 'Indicator', 'Data year'] ]

#print(indicator_data_heatmap)


heatmap1_data = pd.pivot_table(indicator_data_heatmap, values='Value', index=['Region'], columns='Indicator')
plt.figure(figsize=fig_size)
ax = sns.heatmap(heatmap1_data, cmap="YlGnBu")

# https://stackoverflow.com/questions/48470251/move-tick-marks-at-the-top-of-the-seaborn-plot?noredirect=1&lq=1
ax.xaxis.set_ticks_position('top')
ax.set_xticklabels(indicator_data_heatmap['Indicator'], rotation=90) # can be turned off

#plt.show()


title_string = measure_file.result[0:len(measure_file.result)-4] + ':' + indicator
title_string += ' for year ' + str(year)
plt.title(title_string)
#plt.show()

plt.savefig('./saved_images_from_visualizations/' + 'heatmap_' + measure_file.result[0:len(measure_file.result)-4] + indicator.replace(' ', '_')[0:5] + '_' + str(np.random.randint(0, 99999)) + '.png')
#plt.show()



else:
# this is to plot over multiple years
# average taken over multiple years will be plotted
# I could make this more user friendly and data friendly
# by giving users the option to select years, countries; also by informing to what extent data are available (skipping as that will extend the work much)


heatmap_data = measure_data.loc[ (measure_data['Type of region'].isin(['Country', 'Canada']) ) ]
if ( provincial_only == True ):
heatmap_data = measure_data.loc[ (measure_data['Type of region'].isin(['Province']) ) ]

if ( indicator != '' ):
heatmap_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & (measure_data['Type of region'].isin(['Country', 'Canada']) ) ]
if ( provincial_only == True ):
heatmap_data = measure_data.loc[ (measure_data['Indicator'] == indicator) & (measure_data['Type of region'].isin(['Province']) ) ]

#print(heatmap_data)
indicator_data_heatmap = heatmap_data[ ['Region', 'Value', 'Indicator', 'Data year'] ]


indicator_data = indicator_data_heatmap.set_index(['Region'])

# x is not used, mean is calculated by seaborn
#x = indicator_data.groupby(['Region', 'Indicator']).mean()
#print(x.index)
#print(x)


#heatmap1_data = pd.pivot_table(indicator_data_heatmap, values='Value', index=['Region'], columns='Indicator')
#heatmap1_data = pd.pivot_table(x, values='Value', index=x.index, columns='Indicator')
heatmap1_data = pd.pivot_table(indicator_data, index = indicator_data.index, columns='Indicator', values='Value', aggfunc = 'mean')
plt.figure(figsize=fig_size)
#ax =
sns.heatmap(heatmap1_data, cmap="YlGnBu")

#ax.xaxis.set_ticks_position('top')
#ax.set_xticklabels(indicator_data_heatmap['Indicator'], rotation=90) # can be turned off


#plt.show()


title_string = measure_file.result[0:len(measure_file.result)-4] + ':' + indicator

all_years_str = ''
for aYear in all_years:
if (aYear > 0):
all_years_str += str(aYear) + ', '


year_str = ' for year ' + str(year) if year > 0 else ' Mean over years \n' + all_years_str
title_string += year_str
plt.title(title_string)
#plt.show()

plt.savefig('./saved_images_from_visualizations/' + 'heatmap_over_years_' + measure_file.result[0:len(measure_file.result)-4] + indicator.replace(' ', '_')[0:5] + '_' + str(np.random.randint(0, 99999)) + '.png')
#plt.show()

Create the components for the UI interface

Users will be interact with the system to generate custom visualizations

START-RELOAD-DAT

this UI component creation might not be the must

# create the interactive interface
def f(indicator):
return indicator

#print ('Measure' + measure_file.result)
#print('Select parameters\n')
#print('Select Indicator with or without Canadian data')
indicator_country = interactive(f, indicator=indicators);
#display(indicator_country)
indicator_country.result


def f(canada_indicator):
return canada_indicator

#print('Select Indicator with Canadian data')
indicator_canada = interactive(f, canada_indicator=indicators_with_canada);
#display(indicator_canada)
indicator_canada.result


def f(year):
return year

#print('Select Year: 0 = all years')
year_country = interactive(f, year=all_years);
#display(year_country)
year_country.result

#print('Select Year: 0 = all years')
year_canada = interactive(f, year=all_years_canada);
#display(year_canada)
year_canada.result


def f(what_to_plot):
return what_to_plot

#print('Select what to plt:')
what_to_plot = {}
# this can come from an excel file as well
what_to_plot['health-status.xls'] = ['Indicator Values over years', 'Indicator Values over countries', 'Geo plot', 'Heatmap']
what_to_plot['access-to-care.xls'] = ['Indicator Values over years', 'Indicator Values over countries', 'Geo plot', 'Heatmap']
#what_to_plot['indicator-methodology.xls'] = ['Indicator Values over years', 'Indicator Values over countries']
what_to_plot['non-med-determinants.xls'] = ['Indicator Values over years', 'Indicator Values over countries', 'Geo plot', 'Heatmap']
what_to_plot['patient-safety.xls'] = ['Indicator Values over years', 'Indicator Values over countries', 'Geo plot', 'Heatmap']
what_to_plot['prescribing-primary.xls'] = ['Indicator Values over years', 'Indicator Values over countries', 'Geo plot', 'Heatmap']
what_to_plot['quality-of-care.xls'] = ['Indicator Values over years', 'Indicator Values over countries', 'Geo plot', 'Heatmap']


plots = interactive(f, what_to_plot=what_to_plot[measure_file.result]);
#display(plots)
plots.result


def f(chart_type):
return chart_type

#print('Select chart type:')
chart_types = ['Bubble', 'Bar', 'Hor Bar', 'Pie', 'Line']
chart = interactive(f, chart_type=chart_types);
#display(chart)
chart.result


def f(scale):
return scale

#print('Select bubble size')
bubble_scale_country = interactive(f, scale=(0, 100, 1));
#display(bubble_scale_country)
#bubble_scale_country.result = 10

def f(x):
return x

#print('Max country count to compare with')
country_count = interactive(f, x=range(1, 20));
#display(country_count)
country_count.result

#print('Select countries')
#print('Compare with Canada')
all_countries = interactive(f, x=True);
#display(all_countries)
all_countries.result

country_0 = interactive(f, x = countries);
country_1 = interactive(f, x = countries);
#country_str = "var%d = interactive(f, x = countries)"
#display(country_0)
#display(country_1)
country_0.result

def f(com_with_cdn):
return com_with_cdn

#print('Compare with Canada')
compare_canada = interactive(f, com_with_cdn=False);
#display(compare_canada)
compare_canada.result

def f(use_data_with_canada):
return use_data_with_canada

use_data_with_canada = interactive(f, use_data_with_canada=False);
#display(use_data_with_canada)
use_data_with_canada.result


def f(provincial_only):
return provincial_only

provincial_only_plot = interactive(f, provincial_only=False);
#display(use_data_with_canada)
provincial_only_plot.result


# animate over time
def f(animate):
return animate

#print('Compare with Canada')
animate_ = interactive(f, animate=False);
#display(compare_canada)
animate_.result


# for heatmap, do we consider the indicator or not
def f(heatmap_consider_indicator):
return heatmap_consider_indicator

heatmap_consider_indicator_ = interactive(f, heatmap_consider_indicator=False);
#display(heatmap_consider_indicator_)
heatmap_consider_indicator_.result

Render the UI controls

Note: use_data_with_canada — is to indicate that when canadian data are available. Also, Canada_Indicator and Year from the right will be used

com_with_cdn and animate controls are not used so far

Must as part of reload data

# Reference: https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20Styling.html
print('Indicator and year list on the right, represent where Canadian data exist')
from ipywidgets import Button, GridBox, Layout, ButtonStyle
GridBox(children=[
use_data_with_canada, compare_canada,
indicator_country, indicator_canada,
year_country, year_canada,
plots, chart,
bubble_scale_country, provincial_only_plot,
heatmap_consider_indicator_, animate_
],

layout=Layout(
width='100%',
grid_template_rows='auto auto',
grid_template_columns='50%50%',
)
)Indicator and year list on the right, represent where Canadian data exist



---------------------------------------------------------------------------

ImportError Traceback (most recent call last)

<ipython-input-28-5b8e7f56abb0> in <module>()
1 # Reference: https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20Styling.html
2 print('Indicator and year list on the right, represent where Canadian data exist')
----> 3 from ipywidgets import Button, GridBox, Layout, ButtonStyle
4 GridBox(children=[
5 use_data_with_canada, compare_canada,


ImportError: cannot import name 'GridBox'

END-RELOAD-DATA

# assign a default value
bubble_scale_country.result = 10

Create the Plot Based on User Selections

plt.rcParams['figure.figsize'] = [10, 8]
#print(chart.result)
#provincial_only = False
heatmap_consider_indicator = heatmap_consider_indicator_.result
# Data irrespective Canada has data or not
if use_data_with_canada.result == False:
indicator = indicator_country.result
year = year_country.result
bubble_scale = bubble_scale_country.result

# when we are saying data for canada must exist there
else:
indicator = indicator_canada.result
year = year_canada.result
bubble_scale = bubble_scale_country.result
#provincial_only = provincial_only_plot.result

#print(indicator, year, bubble_scale)
if plots.result == 'Indicator Values over years':
plot_measure_by_years(year, indicator, bubble_scale, chart_type=chart.result, ratios=[3,1], animate = animate_.result,
provincial_only=provincial_only_plot.result, fig_size=[20,10], sec_fig=False)
elif plots.result == 'Geo plot':
plot_map_measure_by_regions(year, indicator, bubble_scale, chart_type=chart.result, \
provincial_only=provincial_only_plot.result)

elif plots.result == 'Heatmap':
if ( heatmap_consider_indicator == False ):
indicator = ''
plot_heatmap_across_indicators(year, indicator, provincial_only=provincial_only_plot.result, fig_size=[10, 10])
else: # Indicator Values over countries
plot_measure_by_regions(year, indicator, bubble_scale, chart_type=chart.result, \
ratios=[3,1], provincial_only=provincial_only_plot.result)

Section: Research Questions and Answers

Please Select the related measure and reload all data (as marked with Start-Reload, End-Reload). Otherwise the following visualizations might not work unless that is for currently selected measures

A better solution could be: I could place the measure selection here and could execute all the data reload code

Visualizations plotted independently for the visualizations used in the detail prsentation document

All these can be generated using the UI, I am just showing specific cases as I plotted using UI and provided on my report

How does Canada compare for a health status indicator such as : Cancer Mortality (F) for 2017 (per 100k)? Example: Cancer Mortality, 2017:

year = 2017
indicator = 'Cancer Mortality (F)'

# does not matter
bubble_scale = 11

chart_type = 'Line'

# subplot ratios
ratios = [1000, 1]

# not implemented
animate = False

# if for Provinces - Canada
provincial_only = False

# figure size
fig_size = [5, 5]

# not important
sec_fig = True

print('The right line on the plot does not count; comes from the right subplot; that is not relevant for this case')
plot_measure_by_years(year, indicator, bubble_scale, chart_type, ratios, animate, provincial_only, fig_size=fig_size)The right line on the plot does not count; comes from the right subplot; that is not relevant for this case
png
png

Research Question: how does an indicator such as Transport Mortality changed over time for different countries?

year = 0
indicator = 'Transport Accident Mortality (M)'

# does not matter
bubble_scale = 100

chart_type = 'Bubble'

# subplot ratios
# as we will show countries by colors, ratios are useful
ratios = [3, 1]

# not implemented
animate = False

# if for Provinces - Canada
provincial_only = False

# figure size
fig_size = [20, 10]

# not important
sec_fig = True

print('Note: Y axis values need to be multiplied by Benchmark value to get actual values')
plot_measure_by_years(year, indicator, bubble_scale, chart_type, ratios, animate, provincial_only, fig_size=fig_size)Note: Y axis values need to be multiplied by Benchmark value to get actual values


C:\ProgramData\Anaconda3\lib\site-packages\ipykernel_launcher.py:346: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead

See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
png

Research Question: How do Canadian provinces perform for Transport Mortality (M) for 2017?

year = 2017
indicator = 'Transport Accident Mortality (M)'

# does not matter
bubble_scale = 100

# will plot for other chart types as well
chart_type = 'Line'

# subplot ratios
# as we will show countries by colors, ratios are useful
ratios = [10, 1]

# not implemented
animate = False

# Matters as we are plotting for Canadian provinces
provincial_only = True

# figure size
fig_size = [10, 8]

# not important
sec_fig = True

print('Note: Y axis values need to be multiplied by Benchmark value to get actual values')
plot_measure_by_years(year, indicator, bubble_scale, chart_type, ratios, animate, provincial_only, fig_size=fig_size)Note: Y axis values need to be multiplied by Benchmark value to get actual values
png
png

Research, Analysis, and Visualization Concern:

How does the transport mortality compare against countries on 2017 based on the data we have? Visualize in different format

chart_types = ['Bubble', 'Bar', 'Hor Bar', 'Pie', 'Line']

year = 2017
indicator = 'Transport Accident Mortality (M)'

# does not matter
bubble_scale = 32

# will plot for other chart types as well
chart_type = 'Line'

# subplot ratios
# as we will show countries by colors, ratios are useful
ratios = [10, 1]

# not implemented
animate = False

# Matters as we are plotting for Canadian provinces
provincial_only = False

# figure size
fig_size = [5, 5]

# not important
sec_fig = True


for chart_type in chart_types:
plot_measure_by_years(year, indicator, bubble_scale, chart_type, ratios, animate, provincial_only, fig_size=fig_size)
png
png
png
png
png
png

How does the transport mortality compare against Canadian provinces on 2017 based on the data we have? Visualize in different format

Note: the code from the above cell need to be executed first as I am reusing some variables

# Matters as we are plotting for Canadian provinces
provincial_only = True

# figure size
fig_size = [10, 8]

# not important
sec_fig = True

ratios = [3, 1]

for chart_type in chart_types:
plot_measure_by_years(year, indicator, bubble_scale, chart_type, ratios, animate, provincial_only, fig_size=fig_size)
png
png
png
png
png
png

For Research Question: What are average alcohol consumption across countries over last couple of years

# you can add or remove years, to get average measures over those years
year = 0 # 0 indicates all years for the list all_years
all_years = [2013, 2014, 2015, 2016, 2017]
indicator = 'Alcohol Consumption: Adults'
bubble_scale = 91 # NA
chart_type='Bar' # change to Line, Bubble, Pie, 'Hor Bar'
provincial_only = False # if you set true only provincial data will be plotted

# plot_measure_by_regions(year, indicator, bubble_scale, chart_type = '', ratios=[3,1], provincial_only=False, all_years=all_years):
plot_measure_by_regions(year, indicator, bubble_scale, chart_type, ratios=[3,1], provincial_only=provincial_only, all_years=all_years)
png

the above case just for year 2015

#year = 0 # 0 indicates all years for the list all_years
#all_years = [2013, 2014, 2015, 2016, 2017]
indicator = 'Alcohol Consumption: Adults'
#bubble_scale = 91 # NA
#chart_type='Bar' # change to Line, Bubble, Pie, 'Hor Bar'
provincial_only = False # if you set true only provincial data will be plotted


print('if you want for only one year change as follows')
print('For Research Question: What are average alcohol consumption across countries for 2015')
# if you want for only one year change as follows
year = 2015
# other chart type sych as bar will work though will have issues
chart_type='Bar'
#plot_measure_by_regions(year, indicator, bubble_scale, chart_type, ratios=[3,1], provincial_only)
plot_measure_by_regions(year, indicator, bubble_scale, chart_type, ratios=[3,1], provincial_only=provincial_only, all_years=all_years)if you want for only one year change as follows
For Research Question: What are average alcohol consumption across countries for 2015
png

Research Question: For 2015, which country smoked the most? Used Geo plot. However, plots like above sections could also be used

chart_type'Bar'year = 2015
indicator = 'Smoking: Adults (M)'

# the plot on the presentation used 2
# note : this is inverse size of the bubble
bubble_scale = 3
chart_type = ''
# are not relevant
# chart_type = '', all_years=all_years, also provincial_only=False

plot_map_measure_by_regions(year, indicator, bubble_scale, chart_type = '', provincial_only=False, all_years=all_years)
png

Research Question: Where in the world obesity are more common?

year = 0
indicator = 'Obesity Reported: Adults'
# the plot on the presentation used 2
# note : this is inverse size of the bubble
bubble_scale = 2
chart_type = ''
# are not relevant
# chart_type = '', all_years=all_years, also provincial_only=False

plot_map_measure_by_regions(year, indicator, bubble_scale, chart_type = '', provincial_only=False, all_years=all_years)
png

Research Question: Using a Heatmap, How different countries compare for their Non Medical Determinants aspect for 2014

Note: current selection needs to be: Non Medical Determinants.

You can change the Health Measure and then all data have to be reloaded by executing the sections marked: START-Reload, END-Reload

indicator = ''
year = 2014
indicator = ''
provincial_only_plot = False
plot_heatmap_across_indicators(year, indicator, provincial_only=provincial_only_plot, fig_size=[10, 10])
png

Research question: How do different countries compare for health status indicators over years

Note: current selection needs to be: Health status with code from START-Reload-data to END-RELOAD-Data need to be executed)

indicator = ''
year = 0
indicator = ''
provincial_only_plot = False
plot_heatmap_across_indicators(year, indicator, provincial_only=provincial_only_plot, fig_size=[10, 10])
png

Research question: How do Canadian Provinces compare for health status indicators over years

Note: current selection needs to be: Health status (otherwise, plots will be using current health aspect/measure that I may or may not have tested)

indicator = ''
year = 0
indicator = ''
provincial_only_plot = True
fig_size_=[7, 5]
plot_heatmap_across_indicators(year, indicator, provincial_only=provincial_only_plot, fig_size=fig_size_)
png
year, indicator(2017, 'Transport Accident Mortality (F)')

Research Question: How does transport mortality (Female) compare acrosss countries for 2017

This is just an example to show heatmap plot when ‘heatmap_consider_indicator’ option is selected and an indicator is selected

year = 2017
indicator = 'Transport Accident Mortality (F)'
fig_size_=[3, 5]
plot_heatmap_across_indicators(year, indicator, provincial_only=provincial_only_plot.result, fig_size=fig_size_)
png

Access to Care

Please select Access to Care Measure, and reload all data

Wait time for specialists in Days

year = 0
indicator = 'Wait Time: Specialist'
bubble_scale = 10
chart_type = 'Bubble'
provincial_only=False
ratios=[3,1]

plot_measure_by_regions(year, indicator, bubble_scale, chart_type=chart_type, ratios=ratios, provincial_only=False)
png

Access to Care: same or next day appointment

year, indicator, bubble_scale(0, 'Same or Next Day Appt', 10)year = 0
indicator = 'Same or Next Day Appt'
bubble_scale = 10
chart_type = 'Bubble'
provincial_only=True
ratios=[3,1]

plot_measure_by_regions(year, indicator, bubble_scale, chart_type=chart_type, ratios=ratios, provincial_only=True)
png

Heatmap: Access to Care Indicators

year,indicator(0, '')year = 0
indicator = ''
plot_heatmap_across_indicators(year, indicator, provincial_only=False, fig_size=[10, 10])
png

The following code are supposed to be removed at the final step

Code reused from lab 06 the geoplot

# references
# https://pypi.org/project/geopy/

Health System Performance

Health System Performance

Following

About the Project : Benchmarking Canada’s Health Care Systems: International Comparisons, 2017

Justetc Social Services (non-profit)

Justetc Social Services (non-profit)Jan 31 · 1 min read

Image for post

Project : Benchmarking Canada’s Health Care Systems: International Comparisons, 2017

By Sayed Ahmed

Objective:

Visualize the performance of Canadian Healthcare System Performance against other countries

Short Description :

Analyze, compare, and visualize the performance of Canadian healthcare system against other

countries using public dataset. The dataset provides benchmark comparison data on health

care performance indicators. I will visualize the performance on some key performance

indicators as well as will draw an overall comparison and visualize the summary.

Data source :

Benchmarking Canada’s Health Care Systems: International Comparisons, 2017

Dataset URL:

https://www.cihi.ca/sites/default/files/document/oecd-benchmarking-canadas-health-systems

-2017-en-web.xlsx

Dataset Content:

1 Indicator methodology 2017

2 Health status 2017

3 Non-med determinants 2017

4 Access to care 2017

5 Quality of care 2017

6 Patient safety 2017

7 Prescribing in primary 2017

Technologies :

Python, Python Libraries, Jupyter Notebook, Anaconda, ipywidgets.

Optionally might introduce interactivity in the visualization using technologies such as

ipywidgets

Reference:

https://ipywidgets.readthedocs.io/en/stableHealth System Performance

Health System Performance

Following

Aspect: Patient Safety: Post-Op Sepsis: Abdominal 2015. Compare countries including Canada and Canadian Provinces

Aspect: Patient Safety: Post-Op Sepsis: Abdominal 2015. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you need more information, feel free to inform us

['Measurement units used: Crude rate per 100,000 abdominal surgery discharges. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with dataset for other purpose
Data earlier than 2017 might be plotted when sufficient data for 2017 was not there. For such cases, 2017 plots might be primarily for Canadian Provinces
Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2015_for indicator_PostOpSepsisAbdominal_for_plot_heatmap_across_indicators csv_data_file_for_2015_for indicator_PostOpSepsisAbdominal_for_plot_measure_by_years csv_data_file_for_2015_for indicator_PostOpSepsisAbdominal_forplot_map_measure_by_regions csv_data_file_for_2015_for indicator_PostOpSepsisAbdominal_forplot_measure_by_regions

Aspect: Patient Safety: Post-Op PE: Hip and Knee 2015. Compare countries including Canada and Canadian Provinces

Aspect: Patient Safety: Post-Op PE: Hip and Knee 2015. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you need more information, feel free to inform us

['Measurement units used: Crude rate per 100,000 hip or knee replacement surgery discharges. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with dataset for other purpose
Data earlier than 2017 might be plotted when sufficient data for 2017 was not there. For such cases, 2017 plots might be primarily for Canadian Provinces
Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2015_for indicator_PostOpPEHipandKnee_for_plot_heatmap_across_indicators csv_data_file_for_2015_for indicator_PostOpPEHipandKnee_for_plot_measure_by_years csv_data_file_for_2015_for indicator_PostOpPEHipandKnee_forplot_map_measure_by_regions csv_data_file_for_2015_for indicator_PostOpPEHipandKnee_forplot_measure_by_regions

Aspect: Patient Safety: OB Trauma: No Instrument 2015. Compare countries including Canada and Canadian Provinces

Aspect: Patient Safety: OB Trauma: No Instrument 2015. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you need more information, feel free to inform us

['Measurement units used: Crude rate per 100 vaginal deliveries without instrument. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with dataset for other purpose
Data earlier than 2017 might be plotted when sufficient data for 2017 was not there. For such cases, 2017 plots might be primarily for Canadian Provinces
Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2015_for indicator_OBTraumaNoInstrument_for_plot_heatmap_across_indicators csv_data_file_for_2015_for indicator_OBTraumaNoInstrument_for_plot_measure_by_years csv_data_file_for_2015_for indicator_OBTraumaNoInstrument_forplot_map_measure_by_regions csv_data_file_for_2015_for indicator_OBTraumaNoInstrument_forplot_measure_by_regions

Aspect: Patient Safety: OB Trauma: Instrument 2015. Compare countries including Canada and Canadian Provinces

Aspect: Patient Safety: OB Trauma: Instrument 2015. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you need more information, feel free to inform us

['Measurement units used: Crude rate per 100 vaginal deliveries with instrument. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with dataset for other purpose
Data earlier than 2017 might be plotted when sufficient data for 2017 was not there. For such cases, 2017 plots might be primarily for Canadian Provinces
Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2015_for indicator_OBTraumaInstrument_for_plot_heatmap_across_indicators csv_data_file_for_2015_for indicator_OBTraumaInstrument_for_plot_measure_by_years csv_data_file_for_2015_for indicator_OBTraumaInstrument_forplot_map_measure_by_regions csv_data_file_for_2015_for indicator_OBTraumaInstrument_forplot_measure_by_regions

Aspect: Patient Safety: Foreign Body Left In 2015. Compare countries including Canada and Canadian Provinces

Aspect: Patient Safety: Foreign Body Left In 2015. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you need more information, feel free to inform us

['Measurement units used: Crude rate per 100,000 hospital discharges. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with dataset for other purpose
Data earlier than 2017 might be plotted when sufficient data for 2017 was not there. For such cases, 2017 plots might be primarily for Canadian Provinces

csv_data_file_for_2015_for indicator_ForeignBodyLeftIn_for_plot_heatmap_across_indicators csv_data_file_for_2015_for indicator_ForeignBodyLeftIn_for_plot_measure_by_years csv_data_file_for_2015_for indicator_ForeignBodyLeftIn_forplot_map_measure_by_regions csv_data_file_for_2015_for indicator_ForeignBodyLeftIn_forplot_measure_by_regions

Aspect: Non-medical Determinants (Social, Habitual): Vegetable Consumption: Adults 2015. Compare countries including Canada and Canadian Provinces

Aspect: Non-medical Determinants (Social, Habitual): Vegetable Consumption: Adults 2015. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you need more information, feel free to inform us

['Measurement units used: Percentage. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with dataset for other purpose
Data earlier than 2017 might be plotted when sufficient data for 2017 was not there. For such cases, 2017 plots might be primarily for Canadian Provinces
Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2015_for indicator_VegetableConsumptionAdults_for_plot_heatmap_across_indicators csv_data_file_for_2015_for indicator_VegetableConsumptionAdults_for_plot_measure_by_years csv_data_file_for_2015_for indicator_VegetableConsumptionAdults_forplot_map_measure_by_regions csv_data_file_for_2015_for indicator_VegetableConsumptionAdults_forplot_measure_by_regions csv_data_file_for_2017_for indicator_VegetableConsumptionAdults_for_plot_heatmap_across_indicators csv_data_file_for_2017_for indicator_VegetableConsumptionAdults_for_plot_measure_by_years csv_data_file_for_2017_for indicator_VegetableConsumptionAdults_forplot_map_measure_by_regions csv_data_file_for_2017_for indicator_VegetableConsumptionAdults_forplot_measure_by_regions

Smoking. Aspect: Non-medical Determinants (Social, Habitual): Smoking: Adults (M) 2015. Compare countries including Canada and Canadian Provinces

Aspect: Non-medical Determinants (Social, Habitual): Smoking: Adults (M) 2015. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you need more information, feel free to inform us

['Measurement units used: Percentage. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with dataset for other purpose
Data earlier than 2017 might be plotted when sufficient data for 2017 was not there. For such cases, 2017 plots might be primarily for Canadian Provinces
Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2017_for indicator_SmokingAdultsM_for_plot_measure_by_years csv_data_file_for_2017_for indicator_SmokingAdultsM_for_plot_heatmap_across_indicators csv_data_file_for_2015_for indicator_SmokingAdultsM_forplot_measure_by_regions csv_data_file_for_2015_for indicator_SmokingAdultsM_forplot_map_measure_by_regions csv_data_file_for_2015_for indicator_SmokingAdultsM_for_plot_measure_by_years csv_data_file_for_2015_for indicator_SmokingAdultsM_for_plot_heatmap_across_indicators

Aspect: Non-medical Determinants (Social, Habitual): Smoking: Adults (F) 2015. Compare countries including Canada and Canadian Provinces

Aspect: Non-medical Determinants (Social, Habitual): Smoking: Adults (F) 2015. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you need more information, feel free to inform us

['Measurement units used: Percentage. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with dataset for other purpose
Data earlier than 2017 might be plotted when sufficient data for 2017 was not there. For such cases, 2017 plots might be primarily for Canadian Provinces

Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2017_for indicator_SmokingAdultsF_for_plot_heatmap_across_indicators csv_data_file_for_2017_for indicator_SmokingAdultsF_for_plot_measure_by_years

Aspect: Non-medical Determinants (Social, Habitual): Obesity Reported: Adults 2017. Compare countries including Canada and Canadian Provinces

Aspect: Non-medical Determinants (Social, Habitual): Obesity Reported: Adults 2017. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you need more information, feel free to inform us

['Measurement units used: Percentage. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with dataset for other purpose
Data earlier than 2017 might be plotted when sufficient data for 2017 was not there. For such cases, 2017 plots might be primarily for Canadian Provinces

Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2017_for indicator_ObesityReportedAdults_for_plot_heatmap_across_indicators csv_data_file_for_2017_for indicator_ObesityReportedAdults_for_plot_measure_by_years csv_data_file_for_2017_for indicator_ObesityReportedAdults_forplot_map_measure_by_regions csv_data_file_for_2017_for indicator_ObesityReportedAdults_forplot_measure_by_regions csv_data_file_for_2015_for indicator_ObesityReportedAdults_for_plot_heatmap_across_indicators csv_data_file_for_2015_for indicator_ObesityReportedAdults_for_plot_measure_by_years csv_data_file_for_2015_for indicator_ObesityReportedAdults_forplot_map_measure_by_regions csv_data_file_for_2015_for indicator_ObesityReportedAdults_forplot_measure_by_regions

Aspect: Non-medical Determinants (Social, Habitual): Fruit Consumption: Adults 2015. Compare countries including Canada and Canadian Provinces

Aspect: Access to Care: Fruit Consumption: Adults 2015. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you need more information, feel free to inform us

['Measurement units used: Percentage. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with dataset for other purpose
Data earlier than 2017 might be plotted when sufficient data for 2017 was not there. For such cases, 2017 plots might be primarily for Canadian Provinces
Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2015_for indicator_FruitConsumptionAdults_for_plot_heatmap_across_indicators csv_data_file_for_2015_for indicator_FruitConsumptionAdults_for_plot_measure_by_years csv_data_file_for_2015_for indicator_FruitConsumptionAdults_forplot_map_measure_by_regions csv_data_file_for_2015_for indicator_FruitConsumptionAdults_forplot_measure_by_regions csv_data_file_for_2017_for indicator_FruitConsumptionAdults_for_plot_heatmap_across_indicators csv_data_file_for_2017_for indicator_FruitConsumptionAdults_for_plot_measure_by_years csv_data_file_for_2017_for indicator_FruitConsumptionAdults_forplot_map_measure_by_regions csv_data_file_for_2017_for indicator_FruitConsumptionAdults_forplot_measure_by_regions

Aspect: Non-medical Determinants (Social, Habitual): Alcohol Consumption: Adults 2015. Compare countries including Canada and Canadian Provinces

Aspect: Access to Care: Alcohol Consumption: Adults 2015. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you need more information, feel free to inform us

['Measurement units used: Litres per capita. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with dataset for other purpose
Data earlier than 2017 might be plotted when sufficient data for 2017 was not there. For such cases, 2017 plots might be primarily for Canadian Provinces
Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2015_for indicator_AlcoholConsumptionAdults_for_plot_heatmap_across_indicators csv_data_file_for_2015_for indicator_AlcoholConsumptionAdults_for_plot_measure_by_years csv_data_file_for_2015_for indicator_AlcoholConsumptionAdults_forplot_map_measure_by_regions csv_data_file_for_2015_for indicator_AlcoholConsumptionAdults_forplot_measure_by_regions csv_data_file_for_2017_for indicator_AlcoholConsumptionAdults_for_plot_heatmap_across_indicators csv_data_file_for_2017_for indicator_AlcoholConsumptionAdults_for_plot_measure_by_years csv_data_file_for_2017_for indicator_AlcoholConsumptionAdults_forplot_map_measure_by_regions csv_data_file_for_2017_for indicator_AlcoholConsumptionAdults_forplot_measure_by_regions

Aspect: Access to Care: Wait Time: Specialist 2016. Compare countries including Canada and Canadian Provinces

Aspect: Access to Care: Wait Time: Specialist 2016. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you see any mistakes, or if you need more information, feel free to inform us

['Measurement units used: Percentage. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with dataset for other purpose
Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2016_for indicator_WaitTimeSpecialist_forplot_measure_by_regions csv_data_file_for_2016_for indicator_WaitTimeSpecialist_forplot_map_measure_by_regions csv_data_file_for_2016_for indicator_WaitTimeSpecialist_for_plot_measure_by_years csv_data_file_for_2016_for indicator_WaitTimeSpecialist_for_plot_heatmap_across_indicators

Aspect: Access to Care: Wait Time: Knee Replacement 2016. Compare countries including Canada and Canadian Provinces

Aspect: Access to Care: Wait Time: Knee Replacement 2016. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you see any mistakes, or if you need more information, feel free to inform us

['Measurement units used: Days. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with dataset for other purpose
Not much Data. Though data might be there for Canada and Canadian Provinces
Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2016_for indicator_WaitTimeKneeReplacement_for_plot_measure_by_years

Aspect: Access to Care: Wait Time: Hip Replacement 2016. Compare countries including Canada and Canadian Provinces

Aspect: Access to Care: Wait Time: Hip Replacement 2016. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you see any mistakes, or if you need more information, feel free to inform us

['Measurement units used: Days. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with dataset for other purpose
Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2016_for indicator_WaitTimeHipReplacement_for_plot_measure_by_years csv_data_file_for_2016_for indicator_WaitTimeHipReplacement_for_plot_heatmap_across_indicators

Aspect: Access to Care: Wait Time: Cataract Surgery 2016. Compare countries including Canada and Canadian Provinces

Aspect: Access to Care: Wait Time: Cataract Surgery 2016. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you see any mistakes, or if you need more information, feel free to inform us

['Measurement units used: Days. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with dataset for other purpose
Not much Data. Though data might be there for Canada and Canadian Provinces
Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2016_for indicator_WaitTimeCataractSurgery_forplot_measure_by_regions csv_data_file_for_2016_for indicator_WaitTimeCataractSurgery_forplot_map_measure_by_regions csv_data_file_for_2016_for indicator_WaitTimeCataractSurgery_for_plot_measure_by_years

Aspect: Access to Care: Same or Next Day Appt 2016. Compare countries including Canada and Canadian Provinces

Aspect: Access to Care: Same or Next Day Appt 2016. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you see any mistakes, or if you need more information, feel free to inform us

['Measurement units used: Percentage. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with dataset for other purpose
Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2016_for indicator_SameorNextDayAppt_forplot_measure_by_regions csv_data_file_for_2016_for indicator_SameorNextDayAppt_forplot_map_measure_by_regions csv_data_file_for_2016_for indicator_SameorNextDayAppt_for_plot_measure_by_years csv_data_file_for_2016_for indicator_SameorNextDayAppt_for_plot_heatmap_across_indicators

Aspect: Access to Care: Regular Doctor 2016. Compare countries including Canada and Canadian Provinces

Aspect: Access to Care: Regular Doctor 2016. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you see any mistakes, or if you need more information, feel free to inform us

['Measurement units used: Percentage. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with dataset for other purpose

Not Much Data. Though Data might be there for Canada
Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2016_for indicator_RegularDoctor_forplot_measure_by_regions csv_data_file_for_2016_for indicator_RegularDoctor_forplot_map_measure_by_regions csv_data_file_for_2016_for indicator_RegularDoctor_for_plot_measure_by_years

Aspect: Access to Care: Poor Weekend/Evening Care 2016. Compare countries including Canada and Canadian Provinces

Aspect: Access to Care: Poor Weekend/Evening Care 2016. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you see any mistakes, or if you need more information, feel free to inform us

['Measurement units used: Percentage. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with dataset for other purpose
Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2016_for indicator_PoorWeekendEveningCare_forplot_measure_by_regions csv_data_file_for_2016_for indicator_PoorWeekendEveningCare_forplot_map_measure_by_regions csv_data_file_for_2016_for indicator_PoorWeekendEveningCare_for_plot_measure_by_years csv_data_file_for_2016_for indicator_PoorWeekendEveningCare_for_plot_heatmap_across_indicators

Aspect: Access to Care: Inability to Pay for Medical Bills 2016. Compare countries including Canada and Canadian Provinces

Aspect: Access to Care: Inability to Pay for Medical Bills 2016. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you see any mistakes, or if you need more information, feel free to inform us ['Measurement units used: Percentage. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with dataset for other purpose
Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2016_for indicator_Inability_to_Pay_for_Medical_Bills_for_plot_heatmap_across_indicators csv_data_file_for_2016_for indicator_Inability_to_Pay_for_Medical_Bills_for_plot_measure_by_years csv_data_file_for_2016_for indicator_Inability_to_Pay_for_Medical_Bills_forplot_map_measure_by_regions csv_data_file_for_2016_for indicator_Inability_to_Pay_for_Medical_Bills_forplot_measure_by_regions

Health Status: Transport Accident Mortality (M) 2017 and 2015 . Compare countries including Canada and Canadian Provinces

Health Status: Transport Accident Mortality (M) 2017 and 2015 . [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you see any mistakes, or if you need more information, feel free to inform us

['Measurement units used: Age-standardized rate per 100,000 males. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with data for other purpose
Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2017_for indicator_Transport_Accident_Mortality_(M)_for_plot_heatmap_across_indicators csv_data_file_for_2017_for indicator_Transport_Accident_Mortality_(M)_for_plot_measure_by_years csv_data_file_for_2017_for indicator_Transport_Accident_Mortality_(M)_forplot_map_measure_by_regions csv_data_file_for_2017_for

---

indicator_Transport_Accident_Mortality_(M)_forplot_measure_by_regions csv_data_file_for_2015_for indicator_Transport_Accident_Mortality_(M)_for_plot_heatmap_across_indicators csv_data_file_for_2015_for indicator_Transport_Accident_Mortality_(M)_for_plot_measure_by_years csv_data_file_for_2015_for indicator_Transport_Accident_Mortality_(M)_forplot_map_measure_by_regions csv_data_file_for_2015_for indicator_Transport_Accident_Mortality_(M)_forplot_measure_by_regions

Health Status: Transport Accident Mortality (F) 2015. Compare countries including Canada and Canadian Provinces

Health Status: Transport Accident Mortality (F) 2015. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you see any mistakes, or if you need more information, feel free to inform us

['Measurement units used: Age-standardized rate per 100,000 females. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with data for other purpose
Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2015_for indicator_Transport_Accident_Mortality_(F)_forplot_measure_by_regions csv_data_file_for_2015_for indicator_Transport_Accident_Mortality_(F)_forplot_map_measure_by_regions csv_data_file_for_2015_for indicator_Transport_Accident_Mortality_(F)_for_plot_measure_by_years csv_data_file_for_2015_for indicator_Transport_Accident_Mortality_(F)_for_plot_heatmap_across_indicators

---

csv_data_file_for_2017_for indicator_Transport_Accident_Mortality_(F)_forplot_measure_by_regions csv_data_file_for_2017_for indicator_Transport_Accident_Mortality_(F)_forplot_map_measure_by_regions csv_data_file_for_2017_for indicator_Transport_Accident_Mortality_(F)_for_plot_measure_by_years csv_data_file_for_2017_for indicator_Transport_Accident_Mortality_(F)_for_plot_heatmap_across_indicators

Health Status: Suicide (M) 2015. Compare countries including Canada and Canadian Provinces

Health Status: Suicide (M) 2015. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you see any mistakes, or if you need more information, feel free to inform us

['Measurement units used: Age-standardized rate per 100,000 males. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with data for other purpose

csv_data_file_for_2015_for indicator_Suicide_(M)_for_plot_heatmap_across_indicators csv_data_file_for_2015_for indicator_Suicide_(M)_for_plot_measure_by_years csv_data_file_for_2015_for indicator_Suicide_(M)_forplot_map_measure_by_regions csv_data_file_for_2015_for indicator_Suicide_(M)_forplot_measure_by_regions

Health Status: Suicide (F) 2015. Compare countries including Canada and Canadian Provinces

Health Status: Suicide (F) 2015. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you see any mistakes, or if you need more information, feel free to inform us

['Measurement units used: Age-standardized rate per 100,000 females. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with data for other purpose

csv_data_file_for_2015_for indicator_Suicide_(F)_for_plot_heatmap_across_indicators csv_data_file_for_2015_for indicator_Suicide_(F)_for_plot_measure_by_years csv_data_file_for_2015_for indicator_Suicide_(F)_forplot_map_measure_by_regions csv_data_file_for_2015_for indicator_Suicide_(F)_forplot_measure_by_regions

Health Status: Stroke Mortality for 2017 and 2015. Compare countries including Canada and Canadian Provinces

Health Status: Stroke Mortality for 2017 and 2015. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you see any mistakes, or if you need more information, feel free to inform us

['Measurement units used: Age–sex-standardized rate per 100,000 population. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with data for other purpose

csv_data_file_for_2017_for indicator_Stroke_Mortality_for_plot_heatmap_across_indicators csv_data_file_for_2017_for indicator_Stroke_Mortality_for_plot_measure_by_years csv_data_file_for_2017_for indicator_Stroke_Mortality_forplot_map_measure_by_regions csv_data_file_for_2017_for indicator_Stroke_Mortality_forplot_measure_by_regions csv_data_file_for_2015_for indicator_Stroke_Mortality_for_plot_heatmap_across_indicators csv_data_file_for_2015_for indicator_Stroke_Mortality_for_plot_measure_by_years csv_data_file_for_2015_for indicator_Stroke_Mortality_forplot_map_measure_by_regions csv_data_file_for_2015_for indicator_Stroke_Mortality_forplot_measure_by_regions

Health Status: Perceived Health Status 2015. Compare countries including Canada and Canadian Provinces

Health Status: Perceived Health Status 2015. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you see any mistakes, or if you need more information, feel free to inform us

['Measurement units used: Percentage. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with data for other purpose

csv_data_file_for_2015_for indicator_Perceived_Health_Status_for_plot_heatmap_across_indicators csv_data_file_for_2015_for indicator_Perceived_Health_Status_for_plot_measure_by_years csv_data_file_for_2015_for indicator_Perceived_Health_Status_forplot_map_measure_by_regions csv_data_file_for_2015_for indicator_Perceived_Health_Status_forplot_measure_by_regions

Health Status: Life Expectancy at Birth (M) 2015. Compare countries including Canada and Canadian Provinces

Health Status: Life Expectancy at Birth (M) 2015. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you see any mistakes, or if you need more information, feel free to inform us

['Measurement units used: Years. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with data for other purpose

[attach 1]

[attach 2]

[attach 3]

[attach 4]

[attach 5]

[attach 6]

[attach 7]

[attach 8]

[attach 9]

[attach 10]

[attach 11]

[attach 12]

[attach 13]

csv_data_file_for_2015_for indicator_Life_Expectancy_at_Birth_(M)_forplot_measure_by_regions csv_data_file_for_2015_for indicator_Life_Expectancy_at_Birth_(M)_forplot_map_measure_by_regions csv_data_file_for_2015_for indicator_Life_Expectancy_at_Birth_(M)_for_plot_measure_by_years csv_data_file_for_2015_for indicator_Life_Expectancy_at_Birth_(M)_for_plot_heatmap_across_indicators

Health Status: Life Expectancy at Birth (F) 2017. Compare countries including Canada and Canadian Provinces

Health Status: Life Expectancy at Birth (F) 2017. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you see any mistakes, or if you need more information, feel free to inform us

['Measurement units used: Years. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with data for other purpose

csv_data_file_for_2017_for indicator_Life_Expectancy_at_Birth_(F)_for_plot_heatmap_across_indicators csv_data_file_for_2017_for indicator_Life_Expectancy_at_Birth_(F)_for_plot_measure_by_years csv_data_file_for_2017_for indicator_Life_Expectancy_at_Birth_(F)_forplot_map_measure_by_regions csv_data_file_for_2017_for indicator_Life_Expectancy_at_Birth_(F)_forplot_measure_by_regions

Health Status: Infant Mortality 2017. Compare countries including Canada and Canadian Provinces

Health Status: Infant Mortality 2017. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you see any mistakes, or if you need more information, feel free to inform us

['Measurement units used: Deaths per 1,000 live births.

Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with data for other purpose

csv_data_file_for_2017_for indicator_Infant_Mortality_forplot_measure_by_regions csv_data_file_for_2017_for indicator_Infant_Mortality_forplot_map_measure_by_regions csv_data_file_for_2017_for indicator_Infant_Mortality_for_plot_measure_by_years csv_data_file_for_2017_for indicator_Infant_Mortality_for_plot_heatmap_across_indicators

Health Status: Heart Disease Mortality 2017. Compare countries including Canada and Canadian Provinces

Health Status: Heart Disease Mortality 2017. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you see any mistakes, or if you need more information, feel free to inform us

['Measurement units used: Age–sex-standardized rate per 100,000 population.

Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small Python based tool developed on 2019. The tool can generate many more of such plots easily, and will work with data for other purpose

Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

csv_data_file_for_2017_for indicator_Heart_Disease_Mortality_for_plot_heatmap_across_indicators csv_data_file_for_2017_for indicator_Heart_Disease_Mortality_for_plot_measure_by_years csv_data_file_for_2017_for indicator_Heart_Disease_Mortality_forplot_map_measure_by_regions csv_data_file_for_2017_for indicator_Heart_Disease_Mortality_forplot_measure_by_regions

Health Status: Cancer Mortality (M) 2017. Compare countries including Canada and Canadian Provinces

Health Status: Cancer Mortality (M) 2017. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached at the bottom. If you see any mistakes, or if you need more information, feel free to inform us

['Measurement units used: Age-standardized rate per 100,000 males. Heatmap might show relative comparisons; not absolute values. The primary goal of these visualizations are to compare. If units are not provided, interpret them as relative values']

These are outputs from a small tool developed on 2019. The tool can generate many more of such plots easily, and will work with data for other purpose


























csv_data_file_for_2017_for indicator_Cancer_Mortality_(M)_for_plot_heatmap_across_indicators

csv_data_file_for_2017_for indicator_Cancer_Mortality_(M)_for_plot_measure_by_years

csv_data_file_for_2017_for indicator_Cancer_Mortality_(M)_forplot_map_measure_by_regions

csv_data_file_for_2017_for indicator_Cancer_Mortality_(M)_forplot_measure_by_regions

Health Status: Cancer Mortality (F) 2017. Compare countries including Canada and Canadian Provinces

Health Status: Cancer Mortality (F)2017. [Compare countries including Canada and Canadian Provinces]

Dataset: from CIHI, Canada. The same information plotted with different charts. Data files are also attached. If you see any mistakes, or if you need more information, feel free to inform us

['Measurement units used: Age-standardized rate per 100,000 females. Heatmap might show relative comparisons; not absolute values.

The primary goal of these visualizations are to compare. If units are not provided, interpret values as relative values']

Quality of Care: Health System Performance

Quality of Care: Health System Performance

'30-Day In-Hospital Fatality: AMI',

'30-Day In-Hospital Fatality: Ischemic\xa0Stroke',

'Avoidable Admissions: Asthma', 'Avoidable Admissions: COPD',

'Avoidable Admissions: Diabetes', 'Breast Cancer Mortality',

'Breast Cancer Survival', 'Cervical Cancer Mortality',

'Cervical Cancer Survival', 'Colorectal Cancer Mortality',

'Colorectal Cancer Survival', 'Easy to Understand Doctor',

'Influenza Vaccination: 65+', 'Involvement in Decisions',

'Know Important Medical History', 'Time Spent With Doctor'

Reference: A dataset from CIHI, Canada.

Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

Prescribing Primary: Health System Performance

Prescribing Primary: Health System Performance

'Antibiotics: Proportion of Second Line',

'Antibiotics: Total Volume for Systemic Use',

'Benzodiazepines (65+): Chronic Use ',

'Benzodiazepines (65+): Long-Acting',

'Diabetes: High Blood Pressure Medication'

Reference: A dataset from CIHI, Canada.

Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

Patient Safety Indicators: Health System Performance

Patient Safety Indicators: Health System Performance

'Foreign Body Left In',

'OB Trauma: Instrument',

'OB Trauma: No Instrument',

'Post-Op PE: Hip and Knee',

'Post-Op Sepsis: Abdominal'

Reference: A dataset from CIHI, Canada.

Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

Non Medical Determinants (for Health) Indicators: Health System Performance

Non Medical Determinants (for Health) Indicators: Health System Performance

'Alcohol Consumption: Adults',

'Fruit Consumption: Adults',

'Obesity Reported: Adults',

'Smoking: Adults (F)',

'Smoking: Adults (M)',

'Vegetable Consumption: Adults'

Reference: A dataset from CIHI, Canada.

Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

Access to Care Indicators: Health System Performance

Access to Care Indicators: Health System Performance

'Inability to Pay for Medical Bills',

'Poor Weekend/Evening Care',

'Regular Doctor',

'Same or Next Day Appt',

'Wait Time: Cataract Surgery',

'Wait Time: Hip Replacement',

'Wait Time: Knee Replacement',

'Wait Time: Specialist'

Reference: A dataset from CIHI, Canada

Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

Health Status Indicators: Health System Performance

Health Status Indicators: Health System Performance
Health Status Measurements Indicators: Dataset from CIHI, Canada

Cancer Mortality (F)', 'Cancer Mortality (M)',

'Heart Disease Mortality', 'Infant Mortality',

'Life Expectancy at Birth (F)', 'Life Expectancy at Birth (M)',

'Perceived Health Status', 'Stroke Mortality', 'Suicide (F)',

'Suicide (M)', 'Transport Accident Mortality (F)',

'Transport Accident Mortality (M)'

Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com

Prescribing Primary: Benzodiazepines (65+): Long-Acting. Compare countries including Canada and Canadian Provinces

Prescribing Primary: Benzodiazepines (65+): Long-Acting. [Compare countries including Canada and Canadian Provinces]

Plotted for mean values over multiple years: Dataset: from CIHI, Canada. The same information with different plots such as Bar, Line, Bubble, GeoMap, Pie might be published in future.

If you see any mistakes, feel free to inform us ['Measurement units used: Per 1,000 persons age 65 and older. Heatmap shows relative comparisons; not absolute values. The goal here is to compare']

Prescribing Primary: https://www.oecd-ilibrary.org/docserver/health_glance-2017-30-en.pdf?expires=1563803064&id=id&accname=guest&checksum=E13908163EDBFCA6AE179BE6B533BC04

Prescribing Primary: Diabetes: High Blood Pressure Medication

Prescribing Primary: Diabetes: High Blood Pressure Medication. [Compare countries including Canada and Canadian Provinces] Plotted for mean values over multiple years: Dataset: from CIHI, Canada. The same information with different plots such as Bar, Line, Bubble, GeoMap, Pie might be published in future. If you see any mistakes, feel free to inform us ['Measurement units used: Per 100 patients with diabetes prescribed high blood pressure medications. Heatmap shows relative comparisons; not absolute values. The goal here is to compare'] Prescribing Primary: https://www.oecd-ilibrary.org/docserver/health_glance-2017-30-en.pdf?expires=1563803064&id=id&accname=guest&checksum=E13908163EDBFCA6AE179BE6B533BC04

Prescribing Primary: Benzodiazepines (65+): Chronic Use

Prescribing Primary: Benzodiazepines (65+): Chronic Use . [Compare countries including Canada and Canadian Provinces]

Plotted for mean values over multiple years: Dataset: from CIHI, Canada. The same information with different plots such as Bar, Line, Bubble, GeoMap, Pie might be published in future. If you see any mistakes, feel free to inform us ['Measurement units usedPer 1,000 persons age 65 and older. Heatmap shows relative comparisons; not absolute values. The goal here is to compare']

Prescribing Primary: https://www.oecd-ilibrary.org/docserver/health_glance-2017-30-en.pdf?expires=1563803064&id=id&accname=guest&checksum=E13908163EDBFCA6AE179BE6B533BC04 

Prescribing Primary: Antibiotics: Total Volume for Systemic Use. Compare countries including Canada and Canadian Provinces

Plotted for mean values over multiple years: Dataset: from CIHI, Canada. The same information with different plots such as Bar, Line, Bubble, GeoMap, Pie might be published in future. If you see any mistakes, feel free to inform us ['Measurement units usedDDDs per 1,000 population per day. Heatmap shows relative comparisons; not absolute values. The goal here is to compare']

Prescribing Primary: https://www.oecd-ilibrary.org/docserver/health_glance-2017-30-en.pdf?expires=1563803064&id=id&accname=guest&checksum=E13908163EDBFCA6AE179BE6B533BC04

Prescribing Primary: Antibiotics: Proportion of Second Line. Compare countries including Canada and Canadian Provinces

Prescribing Primary: Antibiotics: Proportion of Second Line. [Compare countries including Canada and Canadian Provinces] Plotted for mean values over multiple years: Dataset: from CIHI, Canada. The same information with different plots such as Bar, Line, Bubble, GeoMap, Pie might be published in future. If you see any mistakes, feel free to inform us ['Measurement units usedPercentage of total volume of antibiotics prescribed. Heatmap shows relative comparisons; not absolute values. The goal here is to compare']

Prescribing Primary: https://www.oecd-ilibrary.org/docserver/health_glance-2017-30-en.pdf?expires=1563803064&id=id&accname=guest&checksum=E13908163EDBFCA6AE179BE6B533BC04

Quality of Care Breast Cancer Mortality Compare countries including Canada and Canadian Provinces

Quality of Care Breast Cancer Mortality Compare countries including Canada and Canadian Provinces Over multiple years: together and separately. Dataset: from CIHI, Canada. The same information with different plots such as Bar, Line, Heatmap, GeoMap, Pie might be published in future. If you see any mistakes, feel free to inform us

Bubble Chart: Quality of care: Avoidable Admissions: Asthma: Compare countries including Canada.

Over multiple years separately, and together.
Quality of care: Avoidable Admissions: Asthma: Compare countries including Canada. The sane information will be posted using other charts such as Line, Pie, Geoplot, Heatmap or similar as applicable. Dataset: CIHI, Canada. (if you see any mistakes, fell free to inform us)

How different countries including Canada compare for Patient Safety Measures?

Patient safety measures as used: 
['Foreign Body Left In', 
'OB Trauma: Instrument',
'OB Trauma: No Instrument', 
'Post-Op PE: Hip and Knee',
'Post-Op Sepsis: Abdominal']
Dataset: from CIHI, Canada (Open and public data). Data for 2014-2015

Units for measurements for the indicators:
 
['Crude rate per 100,000 hospital discharges',
'Crude rate per 100 non c-section deliveries with instrument',
'Crude rate per 100 non c-section deliveries without instrument',
'Crude rate per 100,000 hip or knee replacement surgery discharges',
'Crude rate per 100,000 abdominal surgery discharges']
 
However, for the plot/Heatmap the values are normalized; hence, units can be ignored. Values are for relative comparisons.
 

How does Canada compare with other countries for Waiting time for Specialists?

How does Canada compare with some other countries for Waiting time for Specialists? Apparently, from the data and the visualization: Canada does not perform great. Values are in days (you can simply consider them as relative scales as well). The plot took averages/mean of the available data for couple of years.

Wait time for Specialists in Days
Wait time for Specialists in Days

41% reported waiting two months or more, 7% more than the country ranked second-lowest; and: [Matched with the visualization.] Reference: https://www.cihi.ca/sites/default/files/document/hcic2012_intro_en.pdf

How different Canadian Regions/Provinces compare for Health Status Indicators?

As my code found using a dataset (on Health System Performance) from CIHI, Canada.

Available Data Averaged for 2013 to 2017

Health Status Indicators:

['Cancer Mortality (F)',
'Cancer Mortality (M)',
'Heart Disease Mortality',
'Infant Mortality',
'Life Expectancy at Birth (F)',
'Life Expectancy at Birth (M)',
'Perceived Health Status',
'Stroke Mortality',
'Suicide (F)',
'Suicide (M)',
'Transport Accident Mortality (F)',
'Transport Accident Mortality (M)'],

Transport Accident Mortality (Male) over a year : 2017

Compare Transport Accident Mortality (Male) for 2017 across countries (based on the data available). The same information plotted in different ways.

The values either indicate per 100k or just indicate a relative scale

Colors in the Bubble chart (also in the pie chart) were used to indicate different countries

Colors in bar charts do not add any additional meaning

Pie chart is not the best use case for this type of information. Pie chart is best suited to show information where there is one (or very few) prominent player(s)

Dataset: from CIHI, Canada

AI and ML in 2019: Health/personalized medicine and AI/ML/DL/NLP

Keeping up with AI in 2019. What is the next big thing in AI and ML?
https://medium.com/thelaunchpad/what-is-the-next-big-thing-in-ai-and-ml-904a3f3345ef
---

A Technical Overview of AI & ML (NLP, Computer Vision, Reinforcement Learning) in 2018 & Trends for 2019
https://www.analyticsvidhya.com/blog/2018/12/key-breakthroughs-ai-ml-2018-trends-2019/
---
AI Research Trends
https://ai100.stanford.edu/2016-report/section-i-what-artificial-intelligence/ai-research-trends
---
Artificial intelligence in healthcare: past, present and future
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5829945/pdf/svn-2017-000101.pdf
---

From hype to reality: data science enabling personalized medicine
https://bmcmedicine.biomedcentral.com/articles/10.1186/s12916-018-1122-7
---
AI Applications for Managing Chronic Kidney Disease
https://emerj.com/ai-sector-overviews/ai-managing-chronic-kidney-disease/
---
Machine Learning, Imaging Analytics Predict Kidney Function
https://healthitanalytics.com/news/machine-learning-imaging-analytics-predict-kidney-function
---
Artificial Intelligence for Diabetes Management and Decision Support: Literature Review
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6000484/
---
Big science and big data in nephrology
https://www.sciencedirect.com/science/article/pii/S0085253819301115
--
Explainable AI for Trees: From Local Explanations to Global
Understanding
https://arxiv.org/pdf/1905.04610.pdf

---

Unrelated:
Tk 50cr for scientific research
https://www.thedailystar.net/bangladesh-national-budget-2019-20/taka-50cr-for-bangladesh-scientific-research-1756498
---

IT gets Tk1,930 crore boost
Tk100 crore to boost startup ventures
Posts and Telecom gets Tk3,456 crore
https://www.dhakatribune.com/business/economy/2019/06/13/it-gets-tk1-930-crore-boost

Sayed Ahmed

Linkedin: https://ca.linkedin.com/in/sayedjustetc

Blog: http://sitestree.com, http://bangla.salearningschool.com