<?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 Kelechi on Medium]]></title>
        <description><![CDATA[Stories by Kelechi on Medium]]></description>
        <link>https://medium.com/@Kelechukwu_?source=rss-55112e71dd2b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RZij-rZhD2ZVoJRoHCgmlw.jpeg</url>
            <title>Stories by Kelechi on Medium</title>
            <link>https://medium.com/@Kelechukwu_?source=rss-55112e71dd2b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 14 Nov 2026 23:08:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Kelechukwu_/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[How we trained a translation model from West African Pidgin to English without parallel sentences]]></title>
            <link>https://medium.com/data-science/how-we-trained-a-translation-model-from-west-african-pidgin-to-english-without-parallel-sentences-e54efa9f8353?source=rss-55112e71dd2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/e54efa9f8353</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Kelechi]]></dc:creator>
            <pubDate>Wed, 28 Aug 2019 11:06:00 GMT</pubDate>
            <atom:updated>2019-11-07T16:51:27.688Z</atom:updated>
            <content:encoded><![CDATA[<h3>How we trained a translation model from West African Pidgin to English without a single parallel sentence</h3><h4>“Every act of communication is a miracle of translation.” <br>― <strong>Ken Liu</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Q8c5RlS26gTYS1ZI7G9tg.jpeg" /><figcaption>source — <a href="https://unsplash.com/photos/I_LgQ8JZFGE">https://unsplash.com/photos/I_LgQ8JZFGE</a></figcaption></figure><p><strong>TLDR:</strong> We trained a model that can translate sentences from West African Pidgin (Creole) to English — and vice versa — without showing it a single parallel sentence (a Pidgin sentence and its English equivalent) to learn from. You can skip to the Results section at the end of the article to see some example translations by our model and the link to the code on github.</p><h4>Introduction</h4><p>Translation is an important area of research in Artificial Intelligence, and, most of all, communication. Many Machine Translation works have focused on popular languages like English, French, German, Chinese and so on. However, little work has been done on African languages.</p><p>Over 1000 languages are spoken across West and Central Africa, with over 250 of them being Nigerian. Despite the obvious diversity amongst these languages, one language significantly unifies them all — Pidgin English. There are over <a href="https://www.pulse.ng/gist/pidgin-english-the-language-that-unites-75m-nigerians/sj8l2sm">75 million speakers in Nigeria</a> alone, however, there is no known Natural Language Processing work on this language.</p><p>The problems this research addresses are the following:</p><ol><li><strong>Provision of a Pidgin corpus and training of Pidgin Word Vectors</strong></li><li><strong>Cross-lingual embedding of Pidgin and English</strong></li><li><strong>Unsupervised Machine Translation from Pidgin to English</strong></li></ol><h4><strong>1. Obtaining Corpus and Training Word Vectors</strong></h4><p>In total, we obtained a corpus consisting of <strong>56048</strong> sentences and <strong>32925</strong> unique words by scraping pidgin news websites. Below are examples of sentences in the corpus:</p><p><em>I. dis one na one of di first songs wey commot dis year for nigeria but as dem release am, yawa dey.</em></p><p><em>II. dem say na serious gbege if dem catch anybody with biabia for inside di campus</em></p><p>We initialized word vectors with Glove and fine tuned on the corpus with a CBOW model trained with <strong>8</strong> negative samples, window size of <strong>5</strong>, dimension of <strong>300</strong> and a batch size of <strong>3000</strong> for <strong>5</strong> epochs.</p><h4><strong>2. Training Cross-Lingual Embeddings</strong></h4><p>Given the absence of parallel data, we performed Unsupervised Translation, which relies on cross-lingual embeddings. A dictionary consisting of <strong>1097</strong> word pairs was scraped and manually edited for supervised alignment. Evaluation of methods was done on a validation set of <strong>108 </strong>pairs.</p><p>Alignment of the word vectors was performed with the Procrustes method in which an orthogonal weight matrix is learned to map source to target word vectors (Conneau et al., 2018) and with the Retrieval Criterion following (Joulin et al., 2018). The latter method outperformed the former achieving a Nearest Neighbor accuracy of 0.1282, compared to 0.0853 for the former and a baseline of 0.009, which is the probability of selecting the right nearest neighbor from the validation set of 108 pairs.</p><p>Given a word, below are some examples of its three English nearest neighbor words after alignment and their cosine similarity:</p><p><em>pikin — child (0.7461), infant (0.5493), children (0.5357)</em></p><p><em>presido — president (0.9173), vice (0.6589), presidents (0.5875)</em></p><p><em>wahala — problem (0.7265), problems (0.6983), trouble (0.6906)</em></p><h4><strong>3. Unsupervised NMT</strong></h4><p>For this, we used the Transformer with 10 attention heads. There are 4 encoder and 4 decoder layers with 3 encoder and decoder layers shared across both languages.</p><p>For a decoder to work well, its inputs should be produced by the encoder it was trained with or they should come from a similar distribution as that encoder. Hence, we make sure the encoder encodes sentences from source and target languages to the same latent space. This ensures the decoder can translate regardless of the input source language. We perform this enforcement by adversarial training following (Lample et al., 2018a) where we constrain the encoder to map the two languages to the same feature space. We do this by training a discriminator to classify encodings of source and target sentences. The encoder is trained to fool the discriminator such that latent representations of both source or target are indistinguishable.</p><p>We also make sure the same latent space is used for both language modelling and translation so that the language model can be transferred nicely to the translation task.</p><p>At each training step, we perform the following:</p><ol><li>Discriminator training which aims to predict the language of an encoded sentence.</li><li>Denoising autoencoder training on each language (this is equivalent to training a language model as the model learns useful patterns for reconstruction and becomes immune to noisy input sentences)</li><li>On-the-fly back translation such that a given sentence is translated with the current translation model M and we then attempt to reconstruct it from the translation while leveraging the trained language model in step 2 above.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CMU5cHjGKyvMEQCbqAF14g.jpeg" /><figcaption>algorithm for our PidginUNMT</figcaption></figure><p>Thus, our final objective function is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R1ZsoZx97-CHkgjM" /><figcaption>objective function</figcaption></figure><p>The discriminator loss is minimized in parallel.</p><p>We trained for 8 epochs on a V100 (approx 3 days). To select the best model, we evaluated on a test parallel set of sentences.</p><h3>Results</h3><p>The best performing model achieves a BLEU score of <strong>7.93</strong> from Pidgin to English and <strong>5.18</strong> from English to Pidgin on a test set of 2101 sentence pairs.</p><p>Below are some translations made by our model.</p><p>NB: [pd — Pidgin, en — English]</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*xu2lln5HYcFHf0Cc3UwPYg.png" /><figcaption>translations from model</figcaption></figure><p>From these results, we can see that the language model helps with performing translations that are not necessarily word-for-word, but also grammatically correct as in translation 2.</p><p>Code, trained translation model, aligned pidgin word vectors and more translations by the model can be seen in the project’s Github repository — <a href="https://github.com/keleog/PidginUNMT">https://github.com/keleog/PidginUNMT</a></p><h3>Conclusion</h3><p>There has been some interesting NLP work done on African languages, however it barely scratches the surface in comparison to more popular languages. This is the very first NLP work - that we know of - performed on West African Pidgin. We hope that this work spurs the exploration of more unsupervised research for African languages.</p><h4>Acknowldgements</h4><ul><li>Special thanks to my amazing colleagues at <a href="https://www.instadeep.com/">Instadeep</a> for constant support and constructive feedback throughout the project.</li><li>Thanks to <a href="http://naijalingo.com/">Naijalingo.com</a> for permission to scrape their website to create a Pidgin to English dictionary.</li><li>Thanks to <a href="https://deepquestai.com/">Deepquest AI</a> and <a href="https://aisaturdayslagos.github.io/">AI Saturday&#39;s Lagos</a> for computation support.</li><li>Test set was obtained from the JW300 dataset [6] and preprocessed by the <a href="https://www.masakhane.io/">Masakhane</a> group <a href="https://github.com/masakhane-io/masakhane/tree/master/jw300_utils/test">here</a></li></ul><p><strong><em>References</em></strong></p><p>1. Mikel Artetxe, Gorka Labaka, and Eneko Agirre. 2017. Learning bilingual word embeddings with (almost) no bilingual data.</p><p>2. Alexis Conneau, Guillaume Lample, Marc’Aurelio Ranzato, Ludovic Denoyer, and Herv Jegou. 2018. Word translation without parallel data. In ICLR</p><p>3. Guillaume Lample, Alexis Conneau, Ludovic Denoyer, and Marc’Aurelio Ranzato. 2018a. Unsupervised machine translation using monolingual corpora only. In ICLR.</p><p>4. Guillaume Lample, Myle Ott, Alexis Conneau, Ludovic Denoyer, and Marc’Aurelio Ranzato. 2018b. Phrase-based &amp; neural unsupervised machine translation. In EMNLP.</p><p>5. A. Joulin, P. Bojanowski, T. Mikolov, H. Jegou, E. Grave, Loss in Translation: Learning Bilingual Word Mapping with a Retrieval Criterion, In EMNLP.</p><p>6. Željko Agić, Ivan Vulić: “JW300: A Wide-Coverage Parallel Corpus for Low-Resource Languages”, In Proceedings of the 57th Annual Meeting of the Association for Computational Linguistics (ACL), 2019.</p><p>7. J. Tiedemann: “Parallel Data, Tools and Interfaces in OPUS.” In Proceedings of the 8th International Conference on Language Resources and Evaluation, 2012.</p><p><strong>Update: </strong>Edit about BLEU scores made on 7/11/2019after final testing of model on more parallel sentences.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e54efa9f8353" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/how-we-trained-a-translation-model-from-west-african-pidgin-to-english-without-parallel-sentences-e54efa9f8353">How we trained a translation model from West African Pidgin to English without parallel sentences</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I analyzed a Women’s Shoes Prices Data Set and here’s what I discovered!]]></title>
            <link>https://medium.com/@Kelechukwu_/i-analyzed-a-womens-shoes-prices-data-set-and-here-s-what-i-discovered-437aa795c96f?source=rss-55112e71dd2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/437aa795c96f</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[sneakers]]></category>
            <category><![CDATA[womens-shoes]]></category>
            <category><![CDATA[shoes]]></category>
            <dc:creator><![CDATA[Kelechi]]></dc:creator>
            <pubDate>Sun, 20 Jan 2019 13:45:01 GMT</pubDate>
            <atom:updated>2019-01-21T12:50:29.274Z</atom:updated>
            <content:encoded><![CDATA[<h4>Exploratory Data Analysis</h4><blockquote><em>“Give a girl the right shoes, and she can conquer the world.” — Marilyn Monroe</em></blockquote><p>Shoes have an incredible history.<a href="https://www.livescience.com/4964-shoes-worn-40-000-years.html"> Anthropological research</a> has revealed that humans may have started wearing shoes some 40,000 years ago. The<a href="https://news.nationalgeographic.com/news/2010/06/100609-worlds-oldest-leather-shoe-armenia-science/"> oldest leather shoe found</a> has been dated to be about 5500 years old, which gives you a fair idea of how old footwear is. However, shoes have greatly changed in the present modern times.<a href="https://techcrunch.com/2019/01/17/nikes-auto-laced-future/"> Nike is now making auto-lacing shoes</a> that can be laced from your smartphone and other fancy stuff!</p><p>But that’s not why you are here 😊 Yesterday, I discovered this<a href="https://data.world/datafiniti/womens-shoe-prices"> dataset on Women’s shoes prices</a> which seemed quite interesting. I decided to do some minor analysis and see what I could get out of it. The data set is largely a mess, so I had to do a bit of cleaning.</p><p>The data set contains information on 10,000 shoes spread across 110 brands. To ensure the stability of results, I considered only brands with at least 15 listed products which should be enough to give us a fair idea about their general pricing.</p><p>For each shoe, there are two columns in the data that provide information about its price: <strong>minimum shoe price</strong> and <strong>maximum shoe price</strong>. We shall focus on these two price columns, along with two other main features: <strong>brand </strong>and <strong>colors</strong>. This means we will see how the prices vary across different brands and different colors.</p><p>Let’s begin.</p><h3>Brand</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/1*XvrmH3VBCRidflmRyNrHhA.png" /><figcaption>Word cloud of the shoe brands in the dataset (created with Tableau)</figcaption></figure><p>I was interested to see how prices vary across the different brands. The median minimum shoe price across various brands can be seen in the bar plot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*nv0Y3LouNfItUFSWnv-gJg.png" /><figcaption>Median Minimum prices by brand</figcaption></figure><p>The shoe brand with the highest median minimum price is Brooks at around $120. Other brands with high such prices are Salomon and Altra.</p><p>The lowest median minimum prices come from the following brands — Lauren Conrad, Apt 9 and, guess who? (hint: my former celebrity crush), J Lo by Jenifer Lopez.</p><p>Some brands with averagely priced minimum prices include Vans and Dr. Scholls. shoes and 2 lips shoes.</p><p>Any sneaker heads in the house?? I have got you!</p><p>Among sneaker brands, we can see that the highest priced sneaker brand is Asics followed by Adidas and Nike. We then have Skechers, New Balance, Vans and Fila.</p><p><strong>Median maximum prices by brand</strong></p><p>Also, the median maximum shoe price across the various shoe brands can be seen below as well:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*VZhszqNurm4p7PwYYdnvwQ.png" /><figcaption>Median maximum prices by brand</figcaption></figure><p>We can see that Altra and Salmon take top place with a median maximum price of $129 dollars. The other brand in the top three is Brooks, ensuring the top three is unchanged from the median minimum.</p><p>Asics and Rampage no longer appear in the top ten. New entries to the top ten brands with expensive shoe prices include Dr Scholls and Style Charles.</p><p>One of my favorite brands appears among the top ten — Clarks :)</p><p>The shoes with the least median maximum prices include Hush Puppies, Union bay and Lauren Conrad</p><p><strong>Range of prices by brand</strong></p><p>I noticed something interesting from the range (subtracting the lowest from the highest) of both maximum and minimum prices across the brands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*MOoQzZHXLXV6b0ajL9a4Ag.png" /><figcaption>Range of minimum prices by brand</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*lNqt1MizugMejHDvET0vsA.png" /><figcaption>Range of maximum prices by brand</figcaption></figure><p>As we can see, sneaker brands lead the pack. New balance has the highest range between minimum prices. The second is Asics while the third is Adidas.</p><p>Also, in the range of maximum prices, sneaker brands are totally killing it! The top four spots are dominated by sneaker brands — NB, Nike, Asics and Adidas.</p><p>I am not sure why sneaker brands seem to have the highest price range, but I could make a guess.</p><p>While many sneaker brands are available for moderate prices as indicated by the median maximum and minimum prices, they seem to offer some niche products that people want to pay more for. When we think high end niche sneakers, we immediately think basketball and celebrity signature sneakers. Some Jordans, LeBrons and Adidas Pharrells <a href="https://www.complex.com/sneakers/most-expensive-sneakers-2018/adidas-pharrell-nmd-hu-china-pack-happy-friends-family">could cost well </a>over a thousand dollars.</p><p>I suspect the slides usually made by sneaker brands are responsible for the low minimum prices, thus increasing the range. Notice that other sneaker brands like Vans and Fila do not have high ranges? That could be because these brands are mostly focused on more affordable shoes. Vans is a top streetwear sneaker that mostly looks to offer basic comfortable shoes that primarily differ in color rather than athletic benefits, niche construction or styles.</p><h3>Colors</h3><p>Women love colors and seem to know a whole lot about colors than men. In fact, some research works (<a href="https://news.nationalgeographic.com/news/2012/09/120907-men-women-see-differently-science-health-vision-sex/">here</a> and <a href="https://www.psychologytoday.com/intl/blog/brain-babble/201504/when-it-comes-color-men-women-arent-seeing-eye-eye">here</a> ) have indicated that the wiring of the visual cortex of the brain of women help them distinguish color better.</p><p>In our data set, we will consider only colors that appear in at least 40 shoes.</p><p>Curious about how the prices of women’s shoes vary according to color? Let’s take a look.</p><p><strong>Medium Minimum Price by Color</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*x4XwNDMoiSvz5o44xsYH_w.png" /><figcaption>Median minimum price by colors</figcaption></figure><p>We see here that the highest median minimum price belongs to shoes with Dark Gray and Stucco colors (I had no idea there was a color called stucco until now!)</p><p>Many of the colors have relatively average median minimum prices with the lowest going to shoes with Burgundy and Mushroom colors.</p><p><strong>Median Maximum price by color</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*HUwUR7OAAmp-gnWA4Q4Axg.png" /><figcaption>Median maximum price by colors</figcaption></figure><p>We can see that Whiskey colored shoes have the highest median maximum prices. This is closely followed by Slate and chestnut colored shoes. At the bottom of the pile, we have blush and pewter colored shoes</p><p><strong>Range of prices by color</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*Ure5IkSrRo95vf8geGCm8g.png" /><figcaption>Range of Maximum prices by color</figcaption></figure><p>Here, we can see that tan has the highest range of maximum prices. Followed by black and blue.</p><p>The lowest range belongs to Lux Navy and white sand. Lurking somewhere at the bottom is…wait for it…White black! How many types of blacks are there????</p><p>Anyway, there you have it — a very minor analysis of women’s shoe prices by brands and colors. This was a fun one for me. I learned a lot about colors I never knew existed. I also learned that there are several types of blacks (besides regular black and matte black) and that people actually google “What colors go well with pewter and stucco?”!</p><p>I hope you enjoyed reading this! Do not forget to clap if you did :)</p><p>All the plots were done with <a href="https://plot.ly/pandas/">Plotly</a>, so they are interactive!!!</p><p>For other analysis and interaction with the plots, check the entire rendered notebook <a href="https://nbviewer.jupyter.org/github/Kelechukwu1/Data-Exploration-and-Visualization/blob/master/WomenShoesPrices/Women%20Shoe%20Prices%20Analysis.ipynb">here</a> and <a href="https://github.com/Kelechukwu1/Data-Exploration-and-Visualization/tree/master/WomenShoesPrices">this </a>is a link to the notebook on GitHub. The data set can be found <a href="https://data.world/datafiniti/womens-shoe-prices">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=437aa795c96f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Afterlife: What lies Beyond?]]></title>
            <link>https://medium.com/@Kelechukwu_/the-afterlife-what-lies-beyond-2bed9409695b?source=rss-55112e71dd2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2bed9409695b</guid>
            <category><![CDATA[religion]]></category>
            <category><![CDATA[death]]></category>
            <category><![CDATA[life]]></category>
            <category><![CDATA[afterlife]]></category>
            <category><![CDATA[belief]]></category>
            <dc:creator><![CDATA[Kelechi]]></dc:creator>
            <pubDate>Thu, 03 Jan 2019 13:51:14 GMT</pubDate>
            <atom:updated>2019-09-20T10:00:30.298Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*irajz1DFSl9A9tbeijhuQw.jpeg" /><figcaption>Death ( Yaorusheng/Getty Images)</figcaption></figure><p>“ Death is not extinguishing the light; it is only putting out the lamp because the dawn has come.</p><p>— Rabindranath Tagore”</p><p>One of my recent penchants has been reading about other religions, particularly finding intersections between their beliefs and Christianity. For one, I refuse to believe that there is only one “true religion” and the practitioners of other religions are going to hell.</p><p>I lost a friend last year, and it definitely put things into perspective for a while. I realized that every other thing pales in comparison when death is involved. However, death is constant; we only just further on the queue. Some people, however, yearn for death and would not mind jumping the queue. Almost everyone who believes in a supernatural being also believes in an afterlife that follows death. This afterlife is, supposedly, eternal. The sad part is that we will never find out if such really exists until we die.</p><p>So, what do different religions say about death and an afterlife? In my search, I read some papers and also stumbled upon this wonderful documentary on Netflix called — <a href="https://www.imdb.com/title/tt5242220/">The Story of God</a>. It is a show where Morgan Freeman goes around the world asking religious leaders pertinent questions about God and life.</p><p>In the very first episode, he explored what different religions believe about the afterlife. I’ll do a brief summary of what some religions and science believe.</p><h3><strong>Ancient Egypt</strong></h3><p>Ancient Egypt was one of the first civilized places in the world. It was a largely polytheistic society. There was belief in three major afterlife scenarios — the underworld, eternal life and rebirth/reincarnation.</p><p>Ancient Egyptians believed that the body would be important in the afterlife, hence the reason for mummification. Also, they believed the journey to the afterlife was super long, so they buried the dead with food and drinks to help their journey. Weapons were also seen in many tombs to help the dead fight enemies in their afterlife journey. Other things like sacred spells, clothes, ointments and boats were also present to help with their journey to the afterlife. It is worth noting that it was important for the dead to proceed to eternal life with the gods so they could preserve humanity, particularly ensuring the sun never ceased.</p><h3><strong>Hinduism</strong></h3><p>I was particularly excited about reading this one because I had no previous idea what Hinduism was about.</p><p>Hindus believe that the soul is immutable and can take on different coverings or shells in the form of a body in different cycles of rebirth known as <em>Samsara</em>. The could be human form, animals or other forms of life. The assignment of these bodies depends on the performance or karma of the person in the last cycle of rebirth.</p><p>Hence the soul is constantly reborn in different bodies until it achieves a state called <em>Moksha or Nirvana. Moksha </em>is a state of liberation obtained through a virtuous and moral life, material prosperity and emotional fulfilment <em>(dharma, artha and kama).</em></p><h3>Buddhism</h3><p>The Buddhists maintain the same belief in rebirth, albeit with several differences. There is no permanent soul in Buddhism. Also, the paths for attaining Nirvana are different in both religions.</p><h3>Science</h3><p>There have been numerous attempts to understand the afterlife in science. One that stood out for me was Dr. Sam Parnia, a critical care physician, who has studied over a hundred cardiac arrest survivors — people who have tasted death for a while.</p><p>Sam says a common observation is that many of them claim to have seen a light and felt peace. They claim to have felt themselves leaving their bodies behind in transition to a calm atmosphere. Many others claimed to have seen their dead loved ones welcoming them with open arms.</p><p>I also stumbled upon <a href="https://www.thoughtco.com/visions-at-the-hour-of-death-2594543">this website</a> where people shared similar visions of their dying friends / relatives.</p><p>However, many Near Death Experience (NDE) experts <a href="https://skeptiko.com/sam-parnia-claims-near-death-experience-probably-an-illusion/">have criticized Sam’s methodology.</a> Also Sam has himself said that NDEs may well be an illusion.</p><p>Cyber-consciousness is becoming a common research area amongst neuroscientists. Cyber consciousness is largely defined as “a software system that can persuade observers into thinking it has an internalized sense of who it is, what it is and what its place in the world is”.</p><p>That bit of consciousness is what separates humans from machines and what, supposedly, transcends to the afterlife. This means that if machines can be given consciousness, we could well be on our way to achieving immortality by attempting to transfer the consciousness of a human to a machine.</p><p>In the book, Heavens on Earth by Michael Shermer, several important questions were raised as regards the possibility of transferring consciousness.</p><p>They include — How do we define self-identity? Shall I insist that it is inseparable from my body? If I upload my mind to a computer, how shall I conceive of my original self versus the copy?</p><p>Other scientists like Sean Carroll, a cosmologist and physics professor at the California Institute of Technology, have refuted the possibility of an afterlife.</p><p>According to Carroll, “Claims that some form of consciousness persists after our bodies die and decay into their constituent atoms face one huge, insuperable obstacle: the laws of physics underlying everyday life are completely understood, and there’s no way within those laws to allow for the information stored in our brains to persist after we die.”</p><p>Carroll is of the opinion that for an afterlife to exist, consciousness must be something that is entirely separated from our physical body, and that is impossible.</p><h3>Conclusion</h3><p>I am primarily Christian, so I believe in the afterlife per the Christian doctrine. I think that the afterlife in other religions is very interesting. I believe there are &quot;several truths&quot; and one just has to stick to the truth they are most comfortable with, while — most importantly — respecting the truth of others.</p><p>I look forward to reading about how other beliefs vary across various religions. I also look forward to seeing my friend in the afterlife ☺</p><p>PS — I scoured the internet for afterlife beliefs in African traditional religion, but I couldn’t find anything concrete. I am particularly interested in intersections between African traditional religion and Christianity. African traditional religion has been repackaged to us as black magic, and that shouldn’t be. Any references as regards this will be appreciated.</p><h3>References</h3><p>Guasch-Jané, M., Andrés-Lacueva, C., Jáuregui, O. and Lamuela-Raventós, R. (2006).<em> First evidence of white wine in ancient Egypt from Tutankhamun’s tomb.</em> Journal of Archaeological Science, 33(8), pp.1075–1080.</p><p><em>Burial customs in ancient Egypt: life in death for rich and poor</em><br>W Grajetzki (2003)</p><p><a href="https://m-cacm.acm.org/news/178647-seeking-human-cyber-consciousness/fulltext">https://m-cacm.acm.org/news/178647-seeking-human-cyber-consciousness/fulltext</a></p><ul><li><a href="http://science.sciencemag.org/content/359/6374/398.full">Investigating the afterlife</a></li><li><a href="https://www.express.co.uk/news/science/848991/life-after-death-what-happens-when-you-die-quantum-physics">There is NO life after death: Scientist insists afterlife is IMPOSSIBLE</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2bed9409695b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handling Imbalanced Datasets: Predicting Credit Card Fraud]]></title>
            <link>https://medium.com/coinmonks/handling-imbalanced-datasets-predicting-credit-card-fraud-544f5e74e0fd?source=rss-55112e71dd2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/544f5e74e0fd</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[credit-card-fraud]]></category>
            <category><![CDATA[imbalanced-data]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Kelechi]]></dc:creator>
            <pubDate>Thu, 26 Jul 2018 00:31:39 GMT</pubDate>
            <atom:updated>2019-03-06T07:11:04.935Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*PcYvD4PSsqiDXlD6dMfuJg.jpeg" /><figcaption>Credit Cards (<a href="https://www.google.com.ng/url?sa=i&amp;source=images&amp;cd=&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwjmzI6qnbvcAhUGLBoKHYm7AyEQjhx6BAgBEAM&amp;url=https%3A%2F%2Fwww.finanzen.net%2Fnachricht%2Fprivate-finanzen%2Feuro-am-sonntag-service-grosser-exklusiv-test-das-sind-die-top-kreditkarten-6072848&amp;psig=AOvVaw3mKM2m8d-yTNzTGnt9TiTQ&amp;ust=1532641638127212">source</a>)</figcaption></figure><p>As data scientists, we will come across various types of datasets. One such dataset is an imbalanced data set. This type of dataset always poses a problem for beginner data scientists as most machine learning algorithms are bad at handling it.</p><p><strong>What is an imbalanced dataset?</strong></p><p>An imbalanced dataset is one where the number of observations belonging to one group or class is significantly higher than those belonging to the other classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZeGXHtNu8fu_PswjHivGwg.jpeg" /><figcaption>Imbalance (<a href="https://www.google.com.ng/url?sa=i&amp;source=images&amp;cd=&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwjQja_2p7vcAhUMxoUKHY1kDEoQjhx6BAgBEAM&amp;url=https%3A%2F%2Fmedium.com%2F%40mikeal%2Fcommunity-imbalance-theory-c5f8688ae352&amp;psig=AOvVaw2HPqvgwmquuXbxmYHbori5&amp;ust=1532644524044133">Source</a>)</figcaption></figure><p>This occurs in cases such as credit card fraud detection where there might be only 1000 fraud cases in over a million transactions, representing a meager 0.1% of the dataset. The identification of rare diseases is another possible case of dealing with imbalanced data.</p><p><strong>Challenges of dealing with Imbalanced datasets</strong></p><p>Machine Learning algorithms are very likely to produce faulty classifiers when they are trained with imbalanced datasets. These algorithms tend to show a bias for the majority class, treating the minority class as a noise in the dataset. With many standard classifier algorithms, such as Logistic Regression, Naive Bayes and Decision Trees, there is a likelihood of the wrong classification of the minority class.</p><p>There is also a problem of vanity metrics in measuring the performance of algorithms on imbalanced datasets. If we have an imbalanced dataset containing 1% of a minority class and 99% of the majority class, an algorithm can predict all cases as belonging to the majority class. The accuracy score of this algorithm will yield an accuracy of 99% which seems impressive, but is it really? The minority class is totally ignored in this case and this can prove expensive in some classification problems, such as the case of a credit card fraud, which can cost individuals and businesses lots of money.</p><p><strong>Methods of Handling Imbalanced Datasets</strong></p><p>There are two major methods of handling imbalanced datasets and they are discussed below:</p><p><strong>Oversampling: </strong>This method involves reducing or eliminating the imbalance in the dataset by replicating or creating new observations of the minority class. There are four types of oversampling techniques:</p><ul><li><strong>Random Oversampling</strong>: In this case, new instances of the minority class are created by randomly replicating existing samples in order to increase the minority count in the dataset. This method however can lead to overfitting as it simply replicates the already existing instances of the minority class.</li><li><strong>Cluster-based oversampling</strong>: Here, the K-means algorithm is applied separately to both the majority and minority instances. This helps identify the clusters in the dataset. After the identification, each cluster is oversampled such that all clusters have the same number of observations. Again, there is a risk of overfitting the model with this method.</li><li><strong>Synthetic Oversampling</strong>: This method helps to avoid overfitting. In this method, a small subset of minority is chosen and synthetic examples of this subset are created to balance up the overall dataset. This adds new information to the dataset and increases the overall number of observations.</li><li><strong>Modified Synthetic Oversampling</strong>: This is just like the synthetic oversampling method, however this one makes room for the noise and inherent distributions of the minority class.</li></ul><p><strong>2. Under-sampling: </strong>In this method, the imbalance of the dataset is reduced by focusing on the majority class. One popular type is explained below:</p><ul><li><strong>Random Undersampling</strong>: In this case, existing instances of the majority class are randomly eliminated. This technique is not the best because it can eliminate information or data points that could be useful for the classification algorithm.</li></ul><p><strong>Measuring algorithm performance on an Imbalanced Dataset</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*7_V4pAp6b0mVA0l-_5AJcQ.jpeg" /><figcaption>Performance (<a href="https://www.google.com.ng/url?sa=i&amp;source=images&amp;cd=&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwinttnwqLvcAhVSxxoKHfllCzUQjhx6BAgBEAM&amp;url=https%3A%2F%2Fblog.usejournal.com%2Fswift-performance-tips-55dc5688808b&amp;psig=AOvVaw0xjlu5-xjkrZ9bKbwaM7E9&amp;ust=1532644777416597">Source</a>)</figcaption></figure><p>Since we have established that accuracy is a poor measure of performance on imbalanced datasets, how then do we measure performance? In order to establish this, let us first define some terms:</p><p><strong>False Positive (FP)</strong>: This is used to describe positive predictions that are actually negative in real life. An example will be predicting a credit card transaction is fraudulent when in truth it is not.</p><p><strong>True Positive (TP)</strong>: This is used to describe positive predictions that are actually positive in real life.</p><p><strong>False Negative (FN): </strong>This is used to describe negative predictions that are actually positive in real life. An example will be predicting a credit card transaction is not fraudulent when in truth it is.</p><p><strong>True Negative (TN): </strong>This is used to describe negative predictions that are actually negative in real life.</p><p>Now that we have that out of the way, let us look at possible performance measures.</p><p><strong>Some Measures and indicators of model performance include —</strong></p><p><strong>Precision: </strong>This is an indicator of the number of items correctly identified as positive out of total items identified as positive. Formula is given as: TP/(TP+FP)</p><p><strong>Recall / Sensitivity / True Positive Rate (TPR): </strong>This is an indicator of the number of items correctly identified as positive out of total actual positives. Formula is given as: TP/(TP+FN)</p><p>Precision can be seen as “how useful the results are”, and recall is “how complete the results are”</p><p><strong>Specificity</strong> / <strong>True Negative Rate (TNR)</strong>: This is an indicator of the number of items correctly identified as negative out of total actual negatives. Formula is given as: TN/(TN+FP)</p><p><strong>F1 Score: </strong>This is a performance score that combines both precision and recall. It is a harmonic mean of these two variables. Formula is given as: 2*Precision*Recall/(Precision + Recall)</p><p><strong>Matthew Correlation Coefficient Score: </strong>This is a performance score that takes into account true and false positives, as well as true and false negatives. This score gives a good evaluation for imbalanced dataset. Formula is given as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WATDEJrO-0QQ2EZZBBoh9A.jpeg" /><figcaption>MCC</figcaption></figure><p><strong>Area Under ROC Curve: </strong>An ROC curve (receiver operating characteristic curve) is a graph that shows the performance of a classification algorithm at all classification thresholds. This curve plots TPR vs. FPR.</p><p><strong>Area Under Precision-Recall Curve: </strong>A Precision-Recall curve is graph that shows performance by plotting precision against recall.</p><p><strong>Confusion Matrix: </strong>This is a graphical representation of the TP, FP, FN and TN. A generalized confusion matrix is given below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/424/1*PQmvCX6JVHeQ1RK3nVmK6A.png" /><figcaption>Confusion Matrix</figcaption></figure><p>Generally, the best measures for imbalanced datasets are: Matthew Coefficient Correlation Score, F1 Score and The Area under the Precision-Recall Curve.</p><p>Still, it is important that you understand the business implication of the model when looking to choose a performance evaluation metric. Ideally, there would be trade offs between false positives and false negatives in real life. For instance, if you are classifying against credit card fraud, you may prefer to have a false positive than have a false negative. That is, you would rather predict that a transaction is fraudulent when it actually is not, than predict that a transaction is not fraudulent when it is. Bear in mind that excessive false positive predictions could lead to bad customer experience, so you may have to consider that as well. Also, if you are building a movie recommendation model, for instance, you may prefer to have false negatives than false positives. That is, you would rather tell a person they do not like a movie when they actually do, than tell a person they will like a movie when they do not.</p><p>Essentially, the business implications of these metrics need to be taken into account before settling for one.</p><p><strong>Practical Example: Credit Card Fraud Prediction</strong></p><p>This practical example utilizes an <a href="https://www.kaggle.com/mlg-ulb/creditcardfraud">anonymized credit card transactions dataset.</a></p><p>The ratio of non-fraudulent transactions to fraudulent transactions was a whooping — 99.83% to 0.17%</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*CiCmwPQ6a8to8KdUbj81aw.jpeg" /><figcaption>Imbalance in the dataset</figcaption></figure><p>I proceeded to modelling, selecting Logistic Regression as my algorithm. I trained the algorithm with the unbalanced dataset. Below was my result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*QCD9ieJ0CmiweBIW3cdnpA.png" /><figcaption>Result for imbalanced data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*J_owglnVSrbsWhC0fqgq1A.png" /><figcaption>confusion matrix</figcaption></figure><p>Notice that the accuracy is very high, despite the presence of false positives and false negatives. However, the F1 score and MCC score tell a better story of the actual model performance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*pVq9FfKsyyVroJpPlLWq1A.gif" /><figcaption>Shame (Source- Giphy)</figcaption></figure><p>I then proceeded to balance the dataset.</p><p>I used <a href="https://imbalanced-learn.readthedocs.io/en/stable/generated/imblearn.over_sampling.SMOTE.html">SMOTE (synthetic minority oversampling technique)</a> to balance the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*BdcclZnt5dxHFHPSx-ZQRg.png" /><figcaption>Applying SMOTE algorithm</figcaption></figure><p>I then trained the algorithm with the balanced dataset, tested with the original data and obtained these results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*NaavmkvTyw4Mdv5Zw4nP3g.png" /><figcaption>Smote result</figcaption></figure><p>As we can see, this model is much better than the former one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*SSGjl39_ONrsdMYNlQ7-gA.gif" /><figcaption>Cooool (Souce — Giphy)</figcaption></figure><p>There you have it! I hope you enjoyed reading this half as much as I enjoyed writing it. If you did, please clap for the post and share it. You should also follow me and check out my other posts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=544f5e74e0fd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/handling-imbalanced-datasets-predicting-credit-card-fraud-544f5e74e0fd">Handling Imbalanced Datasets: Predicting Credit Card Fraud</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Ensemble Learning]]></title>
            <link>https://medium.com/@Kelechukwu_/understanding-ensemble-learning-166649c15ac6?source=rss-55112e71dd2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/166649c15ac6</guid>
            <category><![CDATA[ensemble]]></category>
            <category><![CDATA[bagging]]></category>
            <category><![CDATA[boosting]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ensemble-learning]]></category>
            <dc:creator><![CDATA[Kelechi]]></dc:creator>
            <pubDate>Fri, 20 Jul 2018 21:40:41 GMT</pubDate>
            <atom:updated>2019-02-03T19:04:37.432Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*YTHdkJy2p8uPa1B027RkBA.png" /><figcaption>Ensemble Logic (<a href="http://www.simafore.com/blog/bid/109978/Transportation-cost-forecasting-using-two-level-ensemble-models">Source</a>)</figcaption></figure><p>As beginner data scientists, one of the words we hear very often is — ensemble, but what does this really mean? We mostly hear about it from Kaggle competitions, although nobody has cared enough to really explain it to us. In this post, I will try my best to explain ensemble learning to you in very simple terms.</p><p><strong>What is an Ensemble in Machine Learning?</strong></p><p>An ensemble model is a collection of machine learning models that are each trained on a dataset, and then combined by some logic into a single model which is more robust and accurate than each of these individual models. The intuition behind this is that each model follows a different approach or utilizes a different technique, thus providing new information and marginal increases to the performance of the overall model.</p><p>In our daily lives, we create ensembles without even realizing it. Say we want to rate or form an opinion about the recently released Drake Album — Scorpion. We can go to various music websites — say Rollingstone, Metacritic, Pitchfork and All Music. Each of these websites provides a rating of Scorpion, and we can combine these ratings to decide on a personal rating to give the album.</p><p>We can also decide to ask our friends who have listened to the album whether or not it is good. We can ask five friends, and if four of them say we should listen, we can infer that maybe the album is good.</p><p>This is basically what Ensembles are about — combining opinions (or in this case — models)</p><p>Ensemble models are very popular and have been known to be very effective in Kaggle Competitions. They are also a good way to achieve appropriate variance-bias tradeoff.</p><p><strong>Types of Ensemble Models</strong></p><p><strong>1.</strong> <strong>Bagging: </strong>Bagging stands for <strong>B</strong>ootstrap <strong>AGG</strong>regating. As this implies, Bagging combines bootstrapping and aggregating into the formulation of an ensemble. Bootstrapping basically involves random sampling with replacement. Bagging implements learning models on small population sizes or samples, and then aggregates the results from each of these models into one ultimate model. Bagging helps to reduce the variance error in models.</p><p><strong>2.</strong> <strong>Boosting: </strong>This is an iterative approach to combining models. Boosting performs several iterations of training on the dataset and each successive learner improves on the weakness of the previous learner. Thereafter, the boosting technique combines all the individual learners into one single strong learner. Boosting helps to reduce bias error, although it may over fit the training data, leading to a high variance when tested on other datasets.</p><p>3. <strong>Stacking: </strong>This is an ensemble approach that involves using a learner to combine and collect outputs from different individual learners on the same data set. This combination is then presented as the final model.</p><p><strong>4.</strong> <strong>Blending</strong>: This is an ensemble approach that is similar to stacking, but utilizes a validation data set from the training data to make predictions.</p><p><strong>Ensemble Aggregation Techniques</strong></p><p>1. <strong>Voting: </strong>In this technique, which is mostly for classification problems, each prediction by a machine learning model is treated as a vote. The final prediction for each data point is obtained from a combination of all votes. There are two types of voting methods — Hard and Soft:</p><p><strong>a. </strong>In the hard voting method, the mode prediction is the one that is selected by the ensemble. For instance, if there are three classifiers and two states to predict and, for a data point,</p><p>Classifier 1 predicts A</p><p>Classifier 2 predicts A</p><p>and Classifier 3 predicts B</p><p>Then, the output of the ensemble for that data point will be the most popular prediction, which is A.</p><p><strong>b. </strong>In the soft voting method, the ensemble takes into consideration the level of certainty of each model. Using the same example above, assuming for the same data point:</p><p>Classifier 1 predicts A with 55%, leaving B with 45% probability</p><p>Classifier 2 predicts A with 51%, leaving B with 49% probability</p><p>and Classifier 3 predicts B with 90%, leaving A with 10% probability</p><p>Calculating the average of each class predictions, class A yields 38.7%, while class B yields 61.3%. Even though more classifiers predicted class A, the ensemble will output class B because of the high level of certainty of the average prediction. Essentially, Soft voting considers the certainty level of each voter, rather than simply considering the binary choice of each voter.</p><p><strong>2. Averaging: </strong>This is similar to the soft voting approach and can be used for both classification and regression problems. The average of predictions from each regressor is used to make the final prediction. In the case of classification, the average of probabilities as has been shown above is considered. Some classifiers do not output probabilities, such as the SVC. Hence, when using such classifiers, you have to set their Probability parameter to be “True”</p><p><strong>3. Weighted Average: </strong>This is just like the averaging method, except some models are assigned more weight or preference than others. For instance, if you know a model performs well in a particular problem, you will give it more weight than a regular performing model. This also comes into play in real life. If we wanted to predict the outcome of a football game, predictions from some pundits will carry more weight than those from other pundits.</p><p><strong>Popular Examples of Bagging and Boosting Algorithms</strong></p><p><strong>Bagging algorithms:</strong></p><ol><li>Random forest</li></ol><p>2. Bagging Regressor</p><p>3. Bagging Classifier</p><p><strong>Boosting algorithms:</strong></p><ol><li>GBM</li><li>XGB</li><li>CatBoost</li><li>LightGBM</li><li>AdaBoost</li></ol><p><strong>Talk is Cheap; show me the damn Code:</strong></p><p>I have written code examples of each of the ensemble aggregation techniques, and the Bagging Classifier and Regression in <a href="https://github.com/Kelechukwu1/Tutorials/tree/master/Ensemble%20Methods">this notebook</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=166649c15ac6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bias? What Bias?]]></title>
            <link>https://medium.com/@Kelechukwu_/facts-do-not-cease-to-exist-because-they-are-ignored-aldus-hexley-72bf285698ae?source=rss-55112e71dd2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/72bf285698ae</guid>
            <category><![CDATA[psychology]]></category>
            <category><![CDATA[clustering-illusion]]></category>
            <category><![CDATA[confirmation-bias]]></category>
            <dc:creator><![CDATA[Kelechi]]></dc:creator>
            <pubDate>Tue, 17 Jul 2018 21:49:04 GMT</pubDate>
            <atom:updated>2018-07-18T14:08:23.148Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*d4Ui89GFAxPkOhAbnkm8LA.png" /><figcaption>One of my fav emojis</figcaption></figure><p>Just found this in my draft — Written on August 20, 2015 after I read <a href="https://www.amazon.com/Art-Thinking-Clearly-Rolf-Dobelli/dp/0062219693"><em>The Art of Thinking Clearly</em></a><em> </em>by Rolf Dobelli. I did not edit it, just published as I found it. Enjoy! (or not).</p><p><em>“Facts do not cease to exist because they are ignored” </em>— Aldus Hexley</p><p>In our daily activities, we tend to think of things in such a way that they conform to our preexisting notion. This is a very irrational manner of thinking and it forms the basis of the confirmation bias.</p><p><em>“Black Swan logic makes what you don’t know far more relevant than what you do know”</em> — Nassim Taleb</p><p>Nassim Taleb further accentuates this in his book “the black swan”. For many years in the old world, people thought all swans were white. With each white swan they saw, their thoughts were further confirmed (or so they thought). But the sight of the first black swan shattered their supposed knowledge of the color of swans.</p><p>There seems to be a subtle overlap between the confirmation bias and the clustering illusion. The latter is man’s proclivity to search for patterns where none exists. However, both of them have a final goal of confirming our preexisting thoughts.</p><p>Rolf Dobelli sights a very practical example of the clustering illusion in his book, “the art of thinking clearly”. During the second world war, the Germans bombed London using the V1 self-navigating rockets. With every attack, the impact sites were plotted on a map and Londoners thought they had discovered a pattern. They then made theories about which parts of the city were safest. However, after the war, statistical analysis confirmed that the distribution was totally random.</p><p><em>“It is easier to prove something is right than it is to prove the same thing is wrong.”</em> — Some guy on Quora :)</p><p>Now, the confirmation bias and clustering illusion may sound a tad bit simple but their effects are far beyond that. If anything, their effects are quite insidious and only conspicuous in retrospect. However, a major question lingers:</p><p>How does(n’t) our knowledge of confirmation bias affect our confirmation bias and how we attribute events to confirmation bias?</p><p>Well, truth is this is a subject of worry and I don’t think any definite answer can be given to this question.</p><p>Finally, it is an almost Herculean task to rid ourselves of the confirmation and clustering illusion. However, like everything in life, it takes constant practice. So the next time you think you’ve noticed a pattern, try to disprove it. Also, the next time you want to confirm a certain thought, try to disprove it as well. Only when it cannot be disproved can it truly be confirmed. After all, that is what science is all about!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72bf285698ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Classification and Regression Machine Learning Algorithms with Practical Case Studies…]]></title>
            <link>https://medium.com/@Kelechukwu_/understanding-classification-and-regression-machine-learning-algorithms-with-practical-case-studies-d134ae4ba07?source=rss-55112e71dd2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d134ae4ba07</guid>
            <category><![CDATA[regression]]></category>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Kelechi]]></dc:creator>
            <pubDate>Tue, 10 Jul 2018 08:04:10 GMT</pubDate>
            <atom:updated>2018-07-10T08:04:10.750Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding Classification and Regression Machine Learning Algorithms with Practical Case Studies (Part 2)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*QPW907TDq2cNqYe8a5P07w.png" /></figure><p>We have explored classification algorithms with a practical case study in <a href="https://medium.com/@Kelechukwu_/understanding-classification-and-regression-algorithms-with-practical-case-studies-777acfef4de8">part 1</a>. This Part 2 will be focused on regression algorithms. So, let us cut right down to the chase.</p><p><strong>Regression Algorithms</strong></p><p>Regression problems are those that involve the prediction of continuous variables. For example, predicting the weight of students based on given data, predicting the scores of students, predicting house prices, etc. This is unlike classification problems whereby we are bothered with grouping observations.</p><p>Again, there are several algorithms that can be used for regression problems. We will explore them in detail by using a practical case study.</p><p><strong>Case Study: Big Mart Sales Prediction (</strong><a href="https://datahack.analyticsvidhya.com/contest/practice-problem-big-mart-sales-iii/"><strong>Link</strong></a><strong>)</strong></p><p><strong>Problem:</strong></p><p>The data scientists at BigMart have collected 2013 sales data for 1559 products across 10 stores in different cities. Also, certain attributes of each product and store have been defined. The aim is to build a predictive model and find out the sales of each product at a particular store. Using this model, BigMart will try to understand the properties of products and stores which play a key role in increasing sales.</p><p><strong>Approach:</strong></p><p>It was basically the same as the classification problem. I made some hypotheses before starting out. I posited some factors that could influence the item outlet sales and decided to validate or ditch them during my EDA. Also, I decided to understand the importance of feature scaling on various algorithms, so I had two datasets — a scaled one and an unscaled one. Thereafter, I compared different regression algorithms as the evaluation was the RMSE.</p><p><strong>Solution (</strong><a href="https://github.com/Kelechukwu1/Big-Mart-Sales-Prediction_top_three_percent"><strong>Github Link</strong></a><strong>):</strong></p><p>I explored the data extensively. This led to the discrediting of some of my hypotheses. For instance, I posited that items with high visibility should have high outlet sales. However, the opposite was the case. I noticed several other attributes in the data, all of which are comprehensively explained in my notebook.</p><p>I filled in missing variables based on insight from my EDA. I also handled inconsistent entries in the fat content column. I then created some new features — The first was the age of the outlets. (2018 — Establishment year), the second was whether or not the item type is a consumable and the third was whether the item type is a food, drink or non-consumable.</p><p>I then converted the categorical variables to numerical ones. Also, the item visibility column had several zeros, which may have represented missing values. So I replaced with the median of item visibility of similar outlets and item identifier. I then scaled the data for and saved it for later comparison with unscaled one.</p><p>I then proceeded to modelling and evaluation. I used the following algorithms for modelling:</p><p>· <strong>Linear Regression: </strong>This is an algorithm that works by trying to fit a line to your data points. This line is usually the line of best fit such that it has the minimum distance between most, if not all, data points. The higher the distance between the line and the data points, the greater the error. This is a very simple algorithm and works well when variables are linearly related. However, it punishes co-linearity between variables. Linear regression is prone to overfitting and this is why there exists regularization. Linear regression cannot also handle several input features and cannot handle non-linear relationships.</p><p>· <strong>Lasso Regression: </strong>This is an algorithm that is just like the linear regression, but comes regularized. LASSO stands for Least Absolute Shrinkage and Selection Operator. This algorithm punishes the absolute size of coefficients. This means it can offer an automatic selection of feature as some coefficients can be shrunk to zero, meaning it drops such features.</p><p>· <strong>Ridge Regression: </strong>Ridge regression also penalizes coefficients<strong>, </strong>but it does so by penalizing the squared size of these coefficients. Unlike Lasso, ridge actually does not force features to zero.</p><p>· <strong>Gradient Boosting Regressor: </strong>Boosting is an ensemble method that trains several weak learners sequentially. Every successive weak learner focuses on learning from the mistakes of the previous learner. Thereafter, the boosting technique combines all the weak learners into one single strong learner.</p><p>· <strong>Random Forest Regressor: </strong>As described earlier, this algorithm combines several strong decision tree learners by bagging. Bagging is a method where several strong learners are trained in parallel. These learners are then combined and their flaws are smoothened out.</p><p>· <strong>Support Vector Regressor: </strong>As described earlier, this algorithm aims to distinctly separate the input variable space. SVR finds the coefficients that yield the highest separations. The distance between the separation hyperplane and the closest data point is referred to as the margin. The aim is to get the highest margin, which yields the most distinct separation.</p><p>· <strong>K nearest neighbour Regressor: </strong>For a data point to be predicted, this algorithm looks to find the most similar data points or neighbours to that data point and uses to it to form the outcome variable. In this case, it may be the mean output variable. The similarity between data points is usually determined by Euclidian distances or Hamming distances. As a result of this, the scales of features will be strong determinants of these distances.</p><p><strong>Conclusion</strong></p><p>After submitting the solutions to the Analytics Vidhya platform, the following were noticed:</p><p>The worst performing algorithm was the KNN on the unscaled data (remember KNN works well with scaled data cos it is distance dependence). However when used on the scaled data, the KNN algorithm performed well. Reducing the RMSE from 2482 to 1246. The Lasso algorithm also performed better on the scaled data than on the unscaled one. RMSE reduced from 2401 to 1202. Same with Ridge regression, Random Forest, Linear regression and SVR. The decrease in SVR was not as significant as the rest though. RMSE reduced from 1814 to 1757. The best performing algorithm was the GradientBoosting Regressor. On the normal data, it had a score of 1155. On the scaled data, however, it gave an RMSE score of 1153. On the competition leaderboard, I am in position number 540 out of over 16 000 registered competitors (top 3.2%).</p><p>PS: <a href="https://github.com/Kelechukwu1/Big-Mart-Sales-Prediction_top_three_percent">my notebook</a> is very explanatory, check it out.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d134ae4ba07" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Classification and Regression Machine Learning Algorithms with Practical Case Studies…]]></title>
            <link>https://medium.com/@Kelechukwu_/understanding-classification-and-regression-algorithms-with-practical-case-studies-777acfef4de8?source=rss-55112e71dd2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/777acfef4de8</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[regression]]></category>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Kelechi]]></dc:creator>
            <pubDate>Mon, 09 Jul 2018 22:43:26 GMT</pubDate>
            <atom:updated>2019-01-16T07:19:23.856Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding Classification and Regression Machine Learning Algorithms with Practical Case Studies (Part 1)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*QPW907TDq2cNqYe8a5P07w.png" /><figcaption>Algorithm (<a href="https://www.google.com/search?q=algorithm+picture&amp;rlz=1C1CHBD_enNG798NG798&amp;source=lnms&amp;tbm=isch&amp;sa=X&amp;ved=0ahUKEwjQ0oTfjZPcAhVLIcAKHXvsCh8Q_AUICigB&amp;biw=1366&amp;bih=662#imgrc=w9Xt0Gy6pCnnlM:">source</a>)</figcaption></figure><p><strong>Introduction</strong></p><p>There is a lot of buzz around machine learning algorithms these days, and rightly so. Machine learning is arguably the most glorified alongside its fellow new technologies like cloud computing, iOT, AR, VR and Blockchain. In order to harness the full potential of machine learning algorithms, it is important to know the best scenarios and case studies in which they should be applied. I set out to understand these algorithms in detail. I conducted classification and regression tasks, and compared the results obtained by these algorithms. I will be meticulously explaining how I went about this and what I discovered along the way.</p><p><strong>Classification Algorithms</strong></p><p>Classification problem are those that require the prediction of states. Essentially, classification problems require you to predict what group or class or state an entity falls in. For example, prediction of whether or not a credit card transaction is fraudulent one, predicting whether or not a tweet is hate speech, and so on.</p><p>The simplest classification problems have just two classes or are binary classification problems. However, classification problems can have more than two classes and these are often referred to as multi-class classification problems.</p><p>There are several algorithms that can be used for classification problems. We will explore them in detail by using a practical case study.</p><p><strong>Case Study: The Dream House Finance Loan Problem (</strong><a href="https://datahack.analyticsvidhya.com/contest/practice-problem-loan-prediction-iii/"><strong>Link</strong></a><strong>)</strong></p><p><strong>About Company</strong></p><p>Dream Housing Finance Company deals in all home loans. They have presence across all urban, semi urban and rural areas. Customer first apply for home loan after that company validates the customer eligibility for loan.</p><p><strong>Problem</strong></p><p>Company wants to automate the loan eligibility process (real time) based on customer detail provided while filling online application form. These details are Gender, Marital Status, Education, Number of Dependents, Income, Loan Amount, Credit History and others. To automate this process, they have given a problem to identify the customers segments, those are eligible for loan amount so that they can specifically target these customers. Here they have provided a partial data set.</p><p><strong>Approach</strong></p><p>My approach was simple. I sought out to understand the data and put myself in the shoes of the company manager. This way I would be able to think beyond the technical aspects and apply some domain knowledge in the manipulation of my data. I spent quality time exploring my data, cleaning it and creating new features before modelling.</p><p><strong>Solution (</strong><a href="https://github.com/Kelechukwu1/Loan-Status-Prediction-top-4-percent"><strong>Github Link</strong></a><strong>)</strong></p><p>I first detected extreme outliers using the <a href="https://en.wikipedia.org/wiki/Outlier#Tukey&#39;s_fences">Tukey method</a> and dropped them (two in total). There after I performed some exploratory data analysis. I began with describing the statistical properties of the numerical variables in the data set. I observed the presence of some outliers based on these descriptions.</p><p>I then proceeded to perform visualizations. I started with strip plots of the target variable (loan status) against the numerical variables. I made several observations, particularly with the applicant and co-applicant incomes. I then employed the use of hues to visualize three variables at once — two categorical and one numerical. This revealed the variation of loan eligibility status across all numerical variables by gender, etc.</p><p>Next, I used count plots to compare categorical variables. I noticed that applicants with credit histories seemed to have higher chances of obtaining loans when compared to those without. I also noticed observations between other categorical variables, all of which are well explained in my notebook.</p><p>I detected and filled in missing values where appropriate. I then converted the categorical variables to numerical variables since some of our classification algorithms need that. I detected some new outliers and log transformed them.</p><p>I created some new features based on observations from my exploratory data Analysis. I initially created family income which is a summation of applicant and co-applicant income. Thereafter, I created — loan amount/loan amount term, family income/loan amount, family income/loan amount term, applicant income/loan amount, applicant income/loan amount term.</p><p>The first will show how much the person has to release per month to pay up the loan. The second and fourth will allow us know how much of the family’s and person’s monthly income is the loan amount. The third and fifth will let us know how much the family and person have to spend monthly over the course of the loan term. There is no information as regards whether the income is the total income over the loan amount term or yearly, but I assumed the former.</p><p>I then proceeded to modelling where I identified the important features according to the gradient boosting classifier. I used the following algorithms for modelling:</p><p>· <strong>Logistic Regression: </strong>Even though it has the word regression, this is a classification algorithm that works by trying to fit a line to your data points. This algorithm is based on a <a href="https://en.wikipedia.org/wiki/Logistic_function">logistic function</a>. This function makes probability-like predictions between zero and one that determine the class of a data point. Logistic regression is a very simple algorithm and works well when there is a strong linear relationship between variables and the outcome variable. However, co-linearity between input variable affects this model. It is also prone to overfitting and <a href="https://stats.stackexchange.com/questions/83216/intuitive-understanding-of-regularization">regularization</a> is advised.</p><p>· <strong>Linear Discriminant Analysis: </strong>This is an algorithm that is used to classify by making predictions by calculating statistical properties of data points. These statistical properties, usually mean and variance are then used to make predictions. This algorithm assumes a Gaussian distribution for datasets, so it is very sensitive to outliers. It can also be used as a dimension reduction algorithm. LDA is also good with multi-class classification problems. It is advisable to standardize your data and ensure it is normalized.</p><p>· <strong>Gradient Boosting Classifier: </strong>Boosting is an ensemble method that trains several weak learners sequentially. Every successive weak learner focuses on learning from the mistakes of the previous learner. Thereafter, the boosting technique combines all the weak learners into one single strong learner.</p><p>· <strong>Naive Bayes Classifier: </strong>This is a machine learning classification algorithm that assumes independence between input variables. This algorithm, which is based on the <a href="https://en.wikipedia.org/wiki/Bayes%27_theorem">Bayesian theorem</a>, assumes that the presence or outcome of a feature is not based on the presence or outcome of another.</p><p>· <strong>Random Forest Classifier: </strong>This algorithm combines several strong decision tree learners by bagging. Bagging is a method where several strong learners are trained in parallel. These learners are then combined and their flaws are smoothened out.</p><p>· <strong>Support Vector Classifier: </strong>This algorithm aims to distinctly separate the input variable space. SVC finds the coefficients that yield the highest separations. The distance between the separation hyperplane and the closest data point is referred to as the margin. The aim is to get the highest margin, which yields the most distinct separation.</p><p><strong>Conclusion</strong></p><p>Upon submitting to the competition platform, the Linear Discriminant Analysis, Logistic Regression and Gradient Boosting classifiers gave the best results on the test data after being fitted with the normal data with accuracies of over 78%. However, on the pre-processed train data, the Naive Bayes and SVC gave the best accuracies of about 72%. This gives us an idea of what algorithms are affected by outliers the most.</p><p>I also ended up with a peak accuracy of 78.472%, placing me amongst the top 4% out of about 27k registered participants.</p><p>Here is <a href="https://medium.com/@Kelechukwu_/understanding-classification-and-regression-machine-learning-algorithms-with-practical-case-studies-d134ae4ba07">part 2</a> explaining the regression bit.</p><p>PS: the <a href="https://github.com/Kelechukwu1/Loan-Status-Prediction-top-4-percent">notebook</a> in my github is very well explained. Check it out.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=777acfef4de8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Practical Guide To Data Cleaning For Beginners]]></title>
            <link>https://medium.com/coinmonks/a-practical-guide-to-data-cleaning-for-beginners-bd4f45967825?source=rss-55112e71dd2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd4f45967825</guid>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[data-cleaning]]></category>
            <dc:creator><![CDATA[Kelechi]]></dc:creator>
            <pubDate>Sat, 07 Apr 2018 10:41:29 GMT</pubDate>
            <atom:updated>2020-10-16T12:19:14.218Z</atom:updated>
            <content:encoded><![CDATA[<p>As beginner data scientists, we are all so eager to begin making data science models without properly dealing with the data. This is a common pitfall that leads to poor models. In order to improve the quality of your model, data cleaning is required.</p><h4><strong>I am interested, but can you provide a definition for data cleaning?</strong></h4><p>Sure, I got you.</p><p>According to Wikipedia, <strong>Data cleansing</strong> or <strong>data cleaning</strong> is the process of detecting and correcting (or removing) corrupt or inaccurate records from a record set, table, or database and refers to identifying incomplete, incorrect, inaccurate or irrelevant parts of the data and then replacing, modifying, or deleting the dirty or coarse data.</p><p>Scary, right?</p><p>Now, forget that very long sentence. Let me break it down for you in a simple sentence.</p><p>Data cleaning is basically the act of identifying and correcting false, incomplete or irrelevant parts of data.</p><p>Sounds better, yeah?</p><h4><strong>Okay, but what is the importance of this data cleaning?</strong></h4><p>According to an article on <a href="https://www.forbes.com/sites/bernardmarr/2015/09/30/big-data-20-mind-boggling-facts-everyone-must-read/#68e64d9317b1">Forbes</a>, by the year 2020, about 1.7 megabytes of new information will be created every second for every human being on the planet. This means that different types and sources of data will be at play, and that could prove to be messy.</p><p>Yes, there is usually a lot of buzz around the data science algorithms and not data cleaning. This is simply because data cleaning is the least fun part of data science.</p><p>If data science is the sexiest job of the 21st century, then data cleaning is the most unsexy part of data science.</p><p>The importance of data cleaning in training a model cannot be overstated. No matter the algorithm you use — if your data is bad, you will get bad results. Professional data scientists know this and have revealed that data cleaning takes up to 70% of the time spent on a data science project.</p><p>Better and cleaner data outperforms the best algorithms. If you use a very simple algorithm on the cleanest data, you will get very impressive results. However, if you use the best algorithm on messy data, you would most likely not get the desired result.</p><p><em>Essentially, it is garbage in, garbage out.</em></p><h4>Enough of all this! How do I perform this data cleaning thing?</h4><p>Jeez. Chill out! We were just getting to that. Before we get started, it is advised you open the <a href="https://github.com/Kelechukwu1/Tutorials/tree/master/A%20Practical%20Guide%20to%20Data%20Cleaning%20for%20beginners">code examples here</a> — so you can follow along well.</p><p><strong>1.Dealing with Missing Values: </strong>This is perhaps the most common trait of unclean data. These values usually take the form of NaN or None. Missing values can also lead to our models predicting NaN values, which we would not want. So, how do we tackle these missing values?</p><p>The data used in the code example contains information about building permits issued in San Francisco from Jan 1st, 2013 to Feb 25th, 2018.</p><p>After reading in your data, you need to first establish that there are missing values in the dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*AoSW010eJ793PrQNAzt10g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*ZcYxLlamRY0C-51Iu7q7Lw.png" /></figure><p>It is important to also check the percentage of data missing. This will give you an idea of how to handle the missing values. We can also visualize how much data is missing per column.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*afHxH6ekYG7gqPa4QJyvUA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*YuZ4L_anKHRBw-6ye-Bs0g.png" /></figure><p>There are so many missing values!</p><p>Now that we have established that there are missing values in the dataset, how do we handle them?</p><p>In order to handle missing data, it is important to identify the cause of the missing data. This will guide us in deciding on the best way to handle them.</p><p>There are several causes of missing data values. Some values could be missing because they do not exist, others could be missing because of improper collection of data or poor data entry. For example, if someone is single and a question applies to married people, then the question will contain a missing value. In cases like this, it would be wrong to fill in a value for that question.</p><p>In our data, for instance, Street Number Suffix does not always exist, so it would not be ideal to fill it up. However, the missing locations, zipcodes and permit expiration date can be filled up.</p><p>There are several ways to fill up missing values, and we will explore some of them here.</p><p>We can decide to drop the rows or columns with missing values. This is only advised when the percentage of missing values in a row or column is so high that it does not make sense to keep the column or row.</p><p>For instance, the TDIF compliance column and the Voluntary Soft-Story Retrofit have near 100% missing values, so it makes sense to drop them. We can also decide to drop columns where the missing values are at least 60% of the data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*ZeHVAHM1O8zWay8NyrlD3A.png" /></figure><p>The same can also be done for the rows of any data set by just specifying that the axis = 0</p><p>If we are dealing with numerical values, we can decide to fill all null variables with 0. We can also decide to fill in all NA values with the mean of all the values in the column, or the median. All of these decisions depend on the type of data,what you want to accomplish with the data, and the cause of the missing values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*4jC0X8TfzXswgZH8t_TJCQ.png" /></figure><p>As you can see, the missing values have been replaced with 0</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*FKrOhK7beE5zpduHKUik8A.png" /></figure><p>Finally, we can also decide to fill up missing values with whatever value comes directly after it in the same column. We will also specify that any missing value which does not have any value directly under it will be filled with 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*QfgfJ1Y-HQ3WSSO8CpaC7g.png" /></figure><p><strong>2</strong>. <strong>Inconsistent Data Entry: </strong>This occurs when there are different unique values in a column which are meant to be the same. There are also other types of inconsistent data entries, but this will be our focus here. The data setto be used here contains information about Suicide Attacks in Pakistan from 1995 to 2016. As usual, we will first import all relevant libraries and read in our data.</p><p>We will handle the inconsistent entries in the Province column. To check for all unique values, we do this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*qbSoFxG2jua21MBhqSiS2g.png" /></figure><p>We can guess that ‘Balochistan’ are probably meant to be the same ‘Baluchistan’. A simple Google search suggests that we are right. Also, ‘FATA’ and ‘Fata’ are most likely meant to be the same.</p><p>One of the ways to remove data inconsistencies is by removing whitespaces before or after entry names and by converting all cases to lower cases. For white spaces, if we had something like ‘ fata’ and ‘fata ’, they would be considered two unique values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/919/1*JqLPiF-0T_gfSdu6nPk1QQ.png" /></figure><p>Nice, we can see that fata and FATA have been unified</p><p>We still have a problem though. We need to unify ‘balochistan’ and ‘baluchistan’ entries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*_EEhow-OSOJaiSunZdF7qQ.png" /></figure><p>Niceee. Seems like we have solved it all.</p><p>NB: If we have a large number of inconsistent unique entries, we cannot check with our eyes like we just did for the closest matches. We can use the Fuzzy Matching. This helps to identify which strings are most likely to be the same. A package —<a href="https://github.com/seatgeek/fuzzywuzzy"> Fuzzy Wuzzy </a>— does this well. The FuzzyWuzzy package to be used takes in two strings and returns a ratio. The closer the ratio is to 100, the more likely we will unify the strings.</p><p><strong>3. Handling Dates and Times: </strong>We are often faced with dates in our datasets. And, as beginners, this can often prove daunting. It is even worse when there are inconsistent formats of dates. For instance — dd/mm/yy and mm/dd/yy in the same columns. Also, our date values might not be in the right data type, and this will not allow us effectively perform manipulations and get insight from it. Fear not though, as we will solve all of that here.</p><p>As usual, we will first import all relevant libraries and read in our data.</p><p>The data to be used here contains information about a record of the date, time, location, depth, magnitude, and source of every earthquake with a reported magnitude 5.5 or higher since 1965. All compiled by The National Earthquake Information Center (NEIC).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*L-l9pxKVRdOhZ-vxTAUHmA.png" /></figure><p>If we take a look at the Numpy documentation, the datatype O matches with the Object data type, which is not the date time data type</p><p>We proceed to convert our date datatypes to date time data types. We will need to import the datetime package to handle this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*jsymvmVeqcewt4fgkc48og.png" /></figure><p>As we can see, the data type has correctly changed to the datetime data type, and now we can perform various date time manipulations on the column because of its data type.</p><p>If all your dates are in a specific format, you can easily feed in that format into the datetime when converting. However, all our dates are not in a specific format, so we asked the function to automatically infer the format.</p><p>Hence, we need to be sure all our dates converted well since we asked the function to infer the format. A simple mistake in data entry could lead to a wrong inference.</p><p>To do this, we will plot a barchart of the months and ensure that the highest value is 12.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*JtnGLhCuGAm850uVBFg_fg.png" /></figure><p>As you can see, the highest day is 12, so we are good to go.</p><p>We can also do the same for the days of the months. The highest value should be 31, and there should be a dip there since not all days of the month have 31 days.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*GIYxeUlhbGoA8IEd5sTpDA.png" /></figure><p>Nice, our hypothesis is correct. Seems like we got this one right.</p><p><strong>4. Scaling and Normalization: </strong>Let us take them one by one:</p><p>Scaling is important if one wants to specify that a change in one quantity is not equal to another change in another. This is particularly useful if you want to work with algorithms that treat a change in a numerical feature as an equal change in another numerical feature. Scaling ensures that just because some features are big it won’t lead to using them as a main predictor. For instance, if the age and the salary of a person are being used in prediction, some algorithms will pay attention to the salary more because it is bigger. Also, an increase in the age by 1, will be considered similar to an increase in the salary by 1. This does not make sense, so it makes sense to scale your data.</p><p>Normalization basically involves transforming or converting your dataset into a normal distribution. This is useful when you want to use algorithms that work well with normal distributions. Some algorithms like SVM converge far faster on normalized data, so it makes sense to normalize your data to get better results.</p><p>We would normalize a data and visualize it before and after normalization.</p><p>The data to be used here contains information about over 300 000 kickstarter projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*SFP96vnBcFHYRHr0V2tzXQ.png" /></figure><p>Nice, we can see that our data now resembles a normal distribution</p><h4>Conclusion</h4><p>There are several other forms of data cleaning that might need to be done on data. However, this is a good primer for absolute beginners. The need to properly arrange and tidy up your data before the formulation of any model cannot be overstated. I hope this article has helped spark that interest in you! :)</p><p>Very well explained code examples are in this <a href="https://github.com/Kelechukwu1/Tutorials/tree/master/A%20Practical%20Guide%20to%20Data%20Cleaning%20for%20beginners">github repo</a>.</p><p>PS: For further reading on Handling missing data — you can read this <a href="https://medium.com/ibm-data-science-experience/missing-data-conundrum-exploration-and-imputation-techniques-9f40abe0fd87">brilliant article.</a></p><blockquote><a href="https://coincodecap.com/?utm_source=coinmonks">Get Best Software Deals Directly In Your Inbox</a></blockquote><figure><a href="https://coincodecap.com/?utm_source=coinmonks"><img alt="" src="https://cdn-images-1.medium.com/max/584/0*OJ-qb5G6i863msBB.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd4f45967825" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coinmonks/a-practical-guide-to-data-cleaning-for-beginners-bd4f45967825">A Practical Guide To Data Cleaning For Beginners</a> was originally published in <a href="https://medium.com/coinmonks">Coinmonks</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Poetry: Contemplating You]]></title>
            <link>https://medium.com/@Kelechukwu_/poetry-contemplating-you-c829dbccec60?source=rss-55112e71dd2b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c829dbccec60</guid>
            <category><![CDATA[contemplation]]></category>
            <category><![CDATA[love]]></category>
            <category><![CDATA[poetry]]></category>
            <dc:creator><![CDATA[Kelechi]]></dc:creator>
            <pubDate>Wed, 24 Feb 2016 03:22:23 GMT</pubDate>
            <atom:updated>2016-02-24T03:22:23.421Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*PdmLNVy0-cQpYqWJHh9Cxw.jpeg" /></figure><p>your eyes are a kaleidoscope of everything<br>i want to get lost in them<br>piece by piece<br>till i become you</p><p>maybe then i would understand your intricacies<br>maybe then i would fathom your awkwardness<br>contemplating you is like thinking in eight<br>dimensions</p><p>is it the parabolic curve of your lips and how you never stutter?<br>or the wisdom i garner with every word you<br>utter?</p><p>is it the smell of your perfume that always<br>lingers?<br>or the sensation that your touches trigger?</p><p>is it your immaculate smile and how it never<br>fails to dazzle?<br>or how you hold me at ransom without flinching a muscle?</p><p>is it how i’m still addicted to you with every<br>dose?<br>or how your flaws complement you? only heaven knows</p><p>contemplating you is a journey<br>down an undulating road<br>that meanders<br>into oblivion</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c829dbccec60" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>