<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Albert Opoku on Medium]]></title>
        <description><![CDATA[Stories by Albert Opoku on Medium]]></description>
        <link>https://medium.com/@opalkabert?source=rss-330a394e350a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*d9oI2Aj46zaeLVK6iCNUog.jpeg</url>
            <title>Stories by Albert Opoku on Medium</title>
            <link>https://medium.com/@opalkabert?source=rss-330a394e350a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 09:27:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@opalkabert/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Download YouTube Audio in MP3 format -Python Code]]></title>
            <link>https://medium.com/@opalkabert/download-youtube-audio-in-mp3-format-python-code-b74f6354df1c?source=rss-330a394e350a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b74f6354df1c</guid>
            <dc:creator><![CDATA[Albert Opoku]]></dc:creator>
            <pubDate>Mon, 11 Sep 2023 06:09:57 GMT</pubDate>
            <atom:updated>2023-09-11T06:09:57.482Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*dsL52m16aqnpr87rUX1XGg.jpeg" /></figure><p>TLDR: Let say you need to listen to only the mp3 audio of a YouTube post offline. There may be apps out there that can help you download the audio but they may have some fees or if you are not careful, your identity may be compromised. If you know your way around programming in python, then this simple code can be used to download any audio on YouTube.</p><p>You fist need to pip install the package pytube as:</p><pre>!pip install pytube</pre><p>After that run this code below, remember to include the url of the YouTube video you are trying to get the audio.</p><pre>import pytube<br>import os<br>video = pytube.YouTube(&quot;YouTube URL&quot;).streams.filter(only_audio=True).first().download()<br><br># save the file<br>base, ext = os.path.splitext(video )<br>new_file = base + &#39;.mp3&#39;<br>os.rename(video, new_file)</pre><p>The mp3 file will be found at your working directory or run in the next cell</p><pre>new_file</pre><p>I hope this helps, you can checkout my blog posts at:</p><p><a href="https://opokualbert.com/">https://opokualbert.com/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b74f6354df1c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Classification of Customer Complaints using Tensorflow: Text Classification with Word Embeddings]]></title>
            <link>https://medium.com/@opalkabert/classification-of-customer-complaints-using-tensorflow-text-classification-with-word-embeddings-e87952b5147c?source=rss-330a394e350a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e87952b5147c</guid>
            <category><![CDATA[text-classification]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[tensorflow-hub]]></category>
            <category><![CDATA[transfer-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Albert Opoku]]></dc:creator>
            <pubDate>Thu, 20 Sep 2018 00:17:37 GMT</pubDate>
            <atom:updated>2018-09-20T00:17:37.492Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kNshKdwHupVaUcEL" /><figcaption>“blue wooden door surrounded by book covered wall” by <a href="https://unsplash.com/@eugi1492?utm_source=medium&amp;utm_medium=referral">Eugenio Mazzone</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this post, I show how to classify consumer complaints text into these categories: Debt collection, Consumer Loan, Mortgage, Credit card, Credit reporting, Student loan, Bank account or service, Payday loan, Money transfers, Other financial service, Prepaid card.</p><p>This kind of model will be very useful for a customer service department that wants to classify the complaints they receive from their customers. The classification of the issues they have received into buckets will help the department to provide customized solutions to the customers in each group.</p><p>This model can also be expanded into a system, that can recommend automatic solutions to future complaints as they come in. In the past, performing these kinds of tasks were done manually by multiple employees and of course, take a long time to accomplish, delaying swift response to the complaints received.</p><p>Machine learning and AI are here to solve this caliber of problems. Imagine you can classify new complaints with 95% accuracy and route them to the right team to resolve the issue. That will be a win and time saving to any business. Your customers will be happy because the right expert from your business will talk to your customers in trying to resolving their complaints. This will translate into lowering churning rate which means more revenue.</p><p>I trained a text classifier with 66,806 of data on customers that have made a complaint to consumer financial protection bureau — CFPB about US financial institutions on the services they have rendered to these consumers. The dataset is on kaggle.com at this link .</p><p>I used the universal-sentence-encoder-large/3 module on the new tensorflowhub platform to leverage the power of transfer learning which according to Wikipedia, is a research problem in machine learning that focuses on storing knowledge gained while solving one problem and applying it to a different but related problem. Google and other teams have made available on tensorflowhub, models that took them about 62,000 GPU hours to train for our free use.</p><p>This dataset is relatively not large but this kind of machine learning process requires more compute power so I chose to use Google’s colab, which gives the option to train a model with free GPU. I have a previous blog post on downloading Kaggle datasets into Google Colab on my <a href="https://opokualbert.com/post.html#colab">website</a>, you may want to check it out if you are interested in downloading this dataset to follow along with this demo.</p><p>I will walk through the steps and in the end, we will classify new complaints and see how the model performed.</p><p>We import the needed packages for this work.</p><pre>import os<br>import numpy as np<br>import pandas as pd<br>import tensorflow as tf<br>import tensorflow_hub as hub<br>import json<br>import pickle<br>import urllib<br><br>from sklearn.preprocessing import LabelBinarizer<br><br>print(tf.__version__)</pre><h3>Data Preparation and Cleaning</h3><p>Take a look at the data with pandas.</p><pre>data = data[pd.notnull(data[&#39;consumer_complaint_narrative&#39;])]<br>data.head()</pre><p>We convert the consumer_complaint_narrative column to lower case, perfect for NLP.</p><pre>pd.set_option(&#39;max_colwidth&#39;, 1000)<br>data[&#39;consumer_complaint_narrative&#39;] = data[&#39;consumer_complaint_narrative&#39;].str.lower()<br>data.head()</pre><p>We remove characters that do not have predictive power and can misinform the model.</p><pre>import re<br>data[&#39;consumer_complaint_narrative&#39;] = data[&#39;consumer_complaint_narrative&#39;].str.replace(&#39;x&#39;, &#39;&#39;)<br>data[&#39;consumer_complaint_narrative&#39;] = data[&#39;consumer_complaint_narrative&#39;].str.replace(&#39;{&#39;, &#39;&#39;)<br>data[&#39;consumer_complaint_narrative&#39;] = data[&#39;consumer_complaint_narrative&#39;].str.replace(&#39;}&#39;, &#39;&#39;)<br>data[&#39;consumer_complaint_narrative&#39;] = data[&#39;consumer_complaint_narrative&#39;].str.replace(&#39;/&#39;, &#39;&#39;)<br>data.head()</pre><p>We assign the the complaint text and the product type to variables to be able to preprocess. We also set aside 0.0001 for testing after we train the model. The remainder of the data is split into train and validation sets.</p><pre>data_comp=data[[&#39;consumer_complaint_narrative&#39;]]<br>data_prod=data[[&#39;product&#39;]]<br><br>train_size = int(len(data_comp) * .999)<br>train_descriptions = data_comp[:train_size].astype(&#39;str&#39;)<br>train_prod = data_prod[:train_size]<br>test_descriptions = data_comp[train_size:].astype(&#39;str&#39;)<br>test_prod =data_prod[train_size:]<br><br>train_size = int(len(train_descriptions) * .8)<br>train_desc = train_descriptions[:train_size]<br>train_pr = train_prod[:train_size]<br>val_desc = train_descriptions[train_size:]<br>val_pr =train_prod[train_size:]</pre><p>We will use scikit learn to encode the labels into one-hot vector. We also print encoder.classes_ to show the list of all the classes the model will be predicting.</p><pre>from sklearn import preprocessing<br>encoder = preprocessing.LabelBinarizer()<br>encoder.fit_transform(train_pr)<br>train_encoded = encoder.transform(train_pr)<br>val_encoded = encoder.transform(val_pr)<br>num_classes = len(encoder.classes_)<br><br># Print all possible products and the label for the first complaint in our training dataset<br>print(encoder.classes_)<br>print(train_encoded[0])</pre><h3>Model training using TensorFlow DNNEstimator</h3><p>We will download the tfhub pre-trained text embeddings universal-sentence-encoder-large/3 to encode the complaint text into high dimensional text vectors. Be aware that this can take a few minutes to download.</p><pre>description_embeddings = hub.text_embedding_column(&quot;descriptions&quot;, module_spec=&quot;https://tfhub.dev/google/universal-sentence-encoder-large/3&quot;, trainable=False)</pre><p>We are going to use a DNNEstimator to train a deep neural net.The model will have 2 hidden layers of 64 neurons in the first layer and 10 neurons in the second layer. We also use a batch_size of 100 and 10 epochs. These are parameters you can tune to find the perfect combination. We also pass the inputs, in this case, the features and label as well as the description_embeddings.</p><p>Batch_size represent the number of examples that will be passed to our model during one iteration, and num_epochs is the number of times our model will go through the entire training set.</p><pre>multi_label_head  = tf.contrib.estimator.multi_label_head(<br>    num_classes,<br>    loss_reduction=tf.losses.Reduction.SUM_OVER_BATCH_SIZE<br>)<br>features = {<br>  &quot;descriptions&quot;: np.array(train_desc).astype(np.str)<br>}<br>labels = np.array(train_encoded).astype(np.int32)<br>train_input_fn = tf.estimator.inputs.numpy_input_fn(features, labels, shuffle=True, batch_size=100, num_epochs=10)<br>estimator = tf.contrib.estimator.DNNEstimator(<br>    head=multi_label_head,<br>    hidden_units=[64,10],<br>    feature_columns=[description_embeddings])</pre><p>We are ready to train the model. We will time it to know how long it took to finish training.</p><pre>%%timeit<br>estimator.train(input_fn=train_input_fn)<br><br>#This is optional to run to get the training accuracy so that we can compare with the validation accuracy to check for overfitting<br>%%timeit<br>train_input_fn_1 = tf.estimator.inputs.numpy_input_fn({&quot;descriptions&quot;: np.array(train_desc).astype(np.str)}, train_encoded.astype(np.int32), shuffle=False)<br>estimator.evaluate(input_fn=train_input_fn_1)</pre><p>It is time to evaluate our model with the evaluation dataset we set aside. The results is pretty good at 95%. You can tune the hyperparameters to achieve a better results.</p><pre>eval_input_fn = tf.estimator.inputs.numpy_input_fn({&quot;descriptions&quot;: np.array(val_desc).astype(np.str)}, val_encoded.astype(np.int32), shuffle=False)<br>estimator.evaluate(input_fn=eval_input_fn)</pre><p>Finally, let us test our model and see how it will do on classifying new data. We will test the model with 67 records. It got a few incorrect. You will see that those the model could not predict correctly also had low confidence values.</p><pre>predict_input_fn = tf.estimator.inputs.numpy_input_fn({&quot;descriptions&quot;: np.array(test_descriptions).astype(np.str)}, shuffle=False)<br>results = estimator.predict(predict_input_fn)<br>for product in results:<br>  top = product[&#39;probabilities&#39;].argsort()[-1:]<br>  for prod in top:<br>    text_prod = encoder.classes_[prod]<br>    print(text_prod + &#39;: &#39; + str(round(product[&#39;probabilities&#39;][prod] * 100, 2)) + &#39;%&#39;)<br>  print(&#39;&#39;)</pre><p>The complete code is saved on <a href="https://github.com/opokualbert/Classification-of-customer-complaints-using-tensorflow---Text-Classification-with-Word-Embeddings/blob/master/Consumer%20Complaints%20Classification.ipynb">Github</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e87952b5147c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Downloading Kaggle Datasets into Google Colab]]></title>
            <link>https://medium.com/@opalkabert/downloading-kaggle-datasets-into-google-colab-fb9654c94235?source=rss-330a394e350a------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb9654c94235</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[gpu]]></category>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Albert Opoku]]></dc:creator>
            <pubDate>Mon, 03 Sep 2018 20:23:28 GMT</pubDate>
            <atom:updated>2018-09-03T20:23:28.429Z</atom:updated>
            <content:encoded><![CDATA[<h3>Easy Steps to Access Kaggle Datasets in Colab</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/1*Lad06lrjlU9UZgSTHUoyfA.png" /></figure><p>In this tutorial, I show how to download kaggle datasets into google colab. Kaggle has been and remains the de factor platform to try your hands on data science projects. The platform has huge rich free datasets for machine learning projects.</p><p>Another product from google, the company behind kaggle is colab, a platform suitable for training machine learning models and deep neural network free of charge without any installation requirement. One key thing that makes colab a game changer, especially for people who do not own GPU laptop is that users have the option to train their models with free GPU. Colab does not have the trove of datasets kaggle host on its platform therefore, it will be nice if you could access the datasets on kaggle from colab. There is in fact a kaggle API which we can use in colab but setting it up to work is not so easy. I would want to show how to use the API in a few simple steps.</p><h3>Step 1</h3><p>Create a kaggle account if you do not have one already. Click on your user name, click on account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*XWyvY6DETwE1G7us2Acvgw.png" /></figure><p>Scroll down to click on create new API token. This will download a file unto your PC. Note the location of the downloaded file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*jRvlte2MylmEnriavqYnMA.png" /></figure><h3>Step 2</h3><p>Go to colab via this link: <a href="https://colab.research.google.com/notebooks/welcome.ipynb">Colab</a> and under file, click on new python 3 notebook. In the first cell, type this code to install kaggle API and make a directory called kaggle.</p><pre>!pip install -U -q kaggle<br>!mkdir -p ~/.kaggle</pre><h3>Step 3</h3><p>Type this code into the next cell and run to import the API key into colab.</p><pre>from google.colab import files<br>files.upload()</pre><p>In the next cell, run this code to copy the API key to the kaggle directory we created.</p><pre>!cp kaggle.json ~/.kaggle/</pre><p>The datasets should be available for us to use. Let us list the datasets with this code.</p><pre>!kaggle datasets list</pre><h3>Step 4</h3><p>We can download files now by using this sample code. In this case the US consumer finance complaints was downloaded.</p><pre>!kaggle datasets download -d cfpb/us-consumer-finance-complaints<br>!ls</pre><h3>Step 5</h3><p>We use pandas to read the data we have downloaded by unzipping the file first. This line of code works in most situations.</p><pre>import pandas as pd<br>data2 = pd.read_csv(&#39;/content/us-consumer-finance-complaints.zip&#39;, compression=&#39;zip&#39;, header=0, sep=&#39;,&#39;, quotechar=&#39;&quot;&#39;)</pre><p>It did not work here because the zipped file also contains a sqlite database. I will use a different method below to extract only the CSV.</p><pre>from zipfile import ZipFile<br>zip_file = ZipFile(&#39;/content/us-consumer-finance-complaints.zip&#39;)<br>fields= [&#39;product&#39;,&#39;consumer_complaint_narrative&#39;] <br>data=pd.read_csv(zip_file.open(&#39;consumer_complaints.csv&#39;), usecols=fields)<br>data.head()</pre><p>You can get the entire code on at <a href="https://github.com/opokualbert/Downloading-Kaggle-Datasets-into-Google-Colab">GitHub</a> or from <a href="https://opokualbert.com/post.html">website</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb9654c94235" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Causes of Death of Soccer Players]]></title>
            <link>https://medium.com/@opalkabert/exploring-causes-of-death-of-soccer-players-316d7927c3aa?source=rss-330a394e350a------2</link>
            <guid isPermaLink="false">https://medium.com/p/316d7927c3aa</guid>
            <category><![CDATA[wikidata]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pandas]]></category>
            <category><![CDATA[sparql]]></category>
            <dc:creator><![CDATA[Albert Opoku]]></dc:creator>
            <pubDate>Sat, 14 Jul 2018 21:14:10 GMT</pubDate>
            <atom:updated>2018-07-14T21:14:10.528Z</atom:updated>
            <content:encoded><![CDATA[<h4>Exploring the Causes of Death of Soccer Players</h4><p>SPARQL and Python Tutorial</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*ntdP2uj9G84oUbuFNuVJjQ.jpeg" /><figcaption>Maritzburg United in shock after player Ntshangase passes away. Credit: Times Live</figcaption></figure><p>As we watch soccer players exhibit their skills on the pitch at the world cup stage, we would think these players are healthy in all sense, given the amount of work they put in before and during each game. Health experts advise, exercising is paramount for avoiding many diseases. In that context, I wondered what is the impact of exercise on sports men and women, and in particular, soccer players.</p><p>These questions cannot be answered for players currently playing in the game because I do not have access to their medical records so I decided to use a public data on Wikipedia which show the causes of death of soccer players on earth.</p><p>I decided to make this more of a tutorial so I will share steps of the data acquisition through to the analysis. I wanted to find out the average age at death, and the causes of death of soccer players that have passed away.</p><h3>Load the required python packages</h3><pre>#%reload_ext signature <br># To sign my name at the end of code .You need to have a script saved before it works. You can remove it.<br>%matplotlib inline<br>import requests<br>import pandas as pd<br>import matplotlib as mpl<br>import matplotlib.pyplot as plt<br>import io</pre><pre>chartinfo = ‘Author: Albert Opoku• Data source: wikidata.org’<br>infosize = 12</pre><h4>Querying data from Wikipedia using SPARQL language</h4><p>SPARQL developed by W3C is an RDF query language, that is, a semantic query language for databases, able to retrieve and manipulate data stored in Resource Description Framework (RDF) format. I decided to write my SPARQL code in python because python with pandas gives me the ability do my analysis without changing to another programming language.</p><p>I will query the following information: Name, Country of citizenship, Cause of death, date of birth and date of death for each soccer player reported dead on Wikipedia.</p><p>I would like to acknowledge Ramiro Gómez for sharing his SPARQL python code on GitHub.</p><pre>query = ‘’’PREFIX wikibase: &lt;<a href="http://wikiba.se/ontology#">http://wikiba.se/ontology#</a>&gt;<br>PREFIX wd: &lt;<a href="http://www.wikidata.org/entity/">http://www.wikidata.org/entity/</a>&gt;<br>PREFIX wdt: &lt;<a href="http://www.wikidata.org/prop/direct/">http://www.wikidata.org/prop/direct/</a>&gt;<br>PREFIX rdfs: &lt;<a href="http://www.w3.org/2000/01/rdf-schema#">http://www.w3.org/2000/01/rdf-schema#</a>&gt;<br>SELECT ?name ?cause ?dob ?dod ?country WHERE {<br> ?pid wdt:P106 wd:Q937857 . <br> ?pid wdt:P509 ?cid .<br> ?pid wdt:P569 ?dob .<br> ?pid wdt:P570 ?dod .<br> ?pid wdt:P27 ?cot.<br>OPTIONAL {<br> ?pid rdfs:label ?name filter (lang(?name) = “en”) .<br> }<br> OPTIONAL {<br> ?cid rdfs:label ?cause filter (lang(?cause) = “en”) .<br> }<br> OPTIONAL {<br> ?cot rdfs:label ?country filter (lang(?country) = “en”) .<br> }<br>}’’’</pre><pre>url = ‘<a href="https://query.wikidata.org/bigdata/namespace/wdq/sparql&#39;">https://query.wikidata.org/bigdata/namespace/wdq/sparql&#39;</a><br>data = requests.get(url, params={‘query’: query, ‘format’: ‘json’}).json()</pre><p>I will use the code below to parse the values we need out of the json and save in a pandas DataFrame for analysis. There are 1,390 soccer players reported dead on Wikipedia at the time of writing.</p><pre>soccer = []<br>for item in data[&#39;results&#39;][&#39;bindings&#39;]:<br>    try:<br>        soccer.append({<br>        &#39;name&#39;: item[&#39;name&#39;][&#39;value&#39;],<br>        &#39;country&#39;: item[&#39;country&#39;][&#39;value&#39;],<br>        &#39;cause_of_death&#39;: item[&#39;cause&#39;][&#39;value&#39;],<br>        &#39;date_of_birth&#39;: item[&#39;dob&#39;][&#39;value&#39;],<br>        &#39;date_of_death&#39;: item[&#39;dod&#39;][&#39;value&#39;]})<br>    except KeyError:<br>        pass<br>df = pd.DataFrame(soccer)<br>print(len(df))<br>df.head()</pre><p>Let us use df.info() to check the data types and also find out if there are missing values in any of the columns. We will also use the df.describe() to get the summary statistics on the data. Turns out the fields are all object type and there are no missing values.</p><pre>df.info()<br>df.describe()</pre><p>Let us extract the year out of the date of birth and date of death fields so that we can calculate the age of each player.</p><pre>df[‘date_of_death’] = df.date_of_death.str.slice(0, 4).astype(int)<br>df[‘date_of_birth’] = df.date_of_birth.str.slice(0, 4).astype(int)<br>df[&#39;age&#39;]=df.date_of_death - df.date_of_birth<br>print(df.head())<br>df.describe()</pre><p>It does look like Jackie Benyon was born in the year 2000 but died in 1937. How could that be? That is what you deal with when you work with raw data. We will exclude Jackie Benyon from the data soon. Data on Xie Hui also doesn’t seem to be correct.</p><pre>df[(df[&#39;date_of_death&#39;]==426)|(df[&#39;age&#39;]==-63)]</pre><pre>df=df[df[&#39;age&#39;]!=-63]<br>df=df[df[&#39;date_of_death&#39;]!=426]<br>df.describe()</pre><p>After excluding these two players, the average age at death for soccer players is 55.</p><p>Now let us visualize the causes of death for the players. I will visualize the top 20 causes. It is worth to note that Wikipedia sometimes publish multiple cause of death for an individual. It could be that doctors attribute multiple diseases as the cause of death for some patients.</p><pre>title = &#39;Association Football(Soccer) players top 20 Causes of Death According to Wikipedia&#39;<br>footer =  chartinfo<br>    <br>df[&#39;cause of death&#39;] = df[&#39;cause_of_death&#39;].apply(lambda x: x.capitalize())<br>s = df.groupby(&#39;cause_of_death&#39;).agg(&#39;count&#39;)[&#39;name&#39;].sort_values().tail(20)</pre><pre>ax = s.plot(kind=&#39;barh&#39;, figsize=(9, 8), title=title,color=&#39;xkcd:sky blue&#39;)<br>ax.yaxis.set_label_text(&#39;&#39;)<br>ax.xaxis.set_label_text(&#39;Cause of death count&#39;)</pre><pre>ax.annotate(footer, xy=(-0.1, -0.14), xycoords=&#39;axes fraction&#39;, fontsize=infosize)<br>plt.savefig(&#39;img&#39;,dpi=300, bbox_inches = &quot;tight&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HewSz4mZQkiBYBsWl8nRGw.png" /></figure><p>The result is not as expected. You would think people that workout that much won’t develop myocardial infarction aka “heart attack”. Perhaps they stop exercising when they retired from active football or food choices may be blamed. The doctors can help us out. Traffic accident at position number three is interesting. I can’t think about any reason behind this, there surely maybe something going on with these players that is not captured in this data. Have fun, explore the rest of the graph. You can also try your hands on the code. I have saved it on my GitHub page <a href="https://github.com/opalbert/Causes-of-Death-for-Soccer-Players">here</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=316d7927c3aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>