<?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 Femi Ogunbode on Medium]]></title>
        <description><![CDATA[Stories by Femi Ogunbode on Medium]]></description>
        <link>https://medium.com/@femiogunbode?source=rss-40eb8f78b57c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fv5w-H0MFy4R35ppMq4W4w.png</url>
            <title>Stories by Femi Ogunbode on Medium</title>
            <link>https://medium.com/@femiogunbode?source=rss-40eb8f78b57c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 11:55:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@femiogunbode/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[No middle ground]]></title>
            <link>https://femiogunbode.medium.com/no-middle-ground-6675fe702144?source=rss-40eb8f78b57c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6675fe702144</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[credit-risk]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[decision-tree]]></category>
            <dc:creator><![CDATA[Femi Ogunbode]]></dc:creator>
            <pubDate>Wed, 28 Mar 2018 16:53:25 GMT</pubDate>
            <atom:updated>2022-08-14T15:26:23.473Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*YIzIYO2sZ6URXANRSd4tGQ.jpeg" /></figure><p>This entry is to explain the approach I took in solving a prediction problem in a competition I entered last year.</p><p>The competition involved predicting outcome of short term loans (N10,000 -N50,000). The competition was hosted on Kaggle, thanks to Data Science Nigeria and One Finance &amp; Investment Limited.</p><p>I don’t intend on going in-depth into details, but instead I’ll try and highlight the important steps I took in approaching the problem and the results.</p><h3>Data</h3><p>The data to be used in training and testing the model had information about demographics of customers, previous loans taken by customers and current loans. For a complete break down of the data-set and the features, check out the <a href="https://drive.google.com/file/d/0B7k4GI-Y7OsBai1lMmZsU2duYlVVUW1NRW9Cb1JmN0FKMW5v/view?usp=sharing">report</a>.</p><h3><strong>Observation</strong></h3><p>After cleaning the data and carrying out exploratory data analysis, I made a few observations but I’ll be talking about just one important observation that influenced how I approached the modelling phase.</p><p>The amount borrowed by the customers ranges from N10,000 to N50,000. In the plot below it’s evident that most of the loans where N10,000. This observation led me to the <strong>NO MIDDLE GROUND</strong> approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*4cIqvktfV57dohgRhUTolw.png" /></figure><h3><strong>Approach</strong></h3><p>So after observing that majority of the loans where N10,000 I thought It’ll be best to create a separate model for the N10,000 loans and another one for the rest. Now I hoped that splitting the problem and treating as two separate problems, would not only make it easier to understand but also improve accuracy. This approach was inspired by Corne Nagel (Chief Data Scientist at OneFi) while having a quick chat with him during one of the breakfast sessions at the bootcamp. He explained how he sometimes splits models between distinctive groups in some of his experiments, so I decided to give it a shot.</p><h3>Results</h3><p>I used the decision tree algorithm to build the model. While the evaluation metric for the competition was classification accuracy, I’m going to be showing a confusion matrix instead because I believe it gives a true and clear picture of how the model performed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*GtsIkjwQ_cWXQ6uTMBHn7g.png" /><figcaption>N10,000 Model</figcaption></figure><p>The N10,000 model predicted 468 good loans as good, and the misclassified the remaining 59 good loans as bad.<br>While it accurately predicted 85 bad loans as bad, and misclassified the remaining 127 bad loans as good.<br>The success of the model can be measured properly depending on the business problem, what are the tradeoffs for correctly predicting bad loans as bad?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*Jzpk3TvPB9vn3EcIxr_ufw.png" /><figcaption>Others Model ( &gt; N10,000)</figcaption></figure><p>Once again and even better, all good loans were accurately predicted, but the business problem is identifying potential bad loans and it managed to predict 4 bad loans accurately while misclassifying 85 bad loans as good.</p><h3>Conclusion</h3><p>The model created doesn’t seem to have performed well; it almost always fail when it comes to accurately predicting bad loans.<br>This could be because of the class imbalance i.e there are way more instances of good loans than bad loans. This is a problem that stems from the business side — In real life scenarios bad loans are anomalies and don’t happen as frequently as good loans.</p><p>Click <a href="https://drive.google.com/file/d/0B7k4GI-Y7OsBai1lMmZsU2duYlVVUW1NRW9Cb1JmN0FKMW5v/view">here</a> for the full report (more specifics), <a href="http://nbviewer.jupyter.org/github/FemiOG/OneFi-Loan-Risk-Prediction/blob/master/Loan%20Risk%20Model%20Notebook.ipynb">here</a> for my notebook and finally, <a href="https://www.kaggle.com/c/data-science-nigeria-credit-risk-prediction/leaderboard">here</a> for the competition home page.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6675fe702144" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ridge Regression to Predict House Prices]]></title>
            <link>https://femiogunbode.medium.com/using-ridge-regression-to-predict-house-prices-on-kaggle-lessons-learnt-40094ad3bc0f?source=rss-40eb8f78b57c------2</link>
            <guid isPermaLink="false">https://medium.com/p/40094ad3bc0f</guid>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[regression]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[competition]]></category>
            <dc:creator><![CDATA[Femi Ogunbode]]></dc:creator>
            <pubDate>Wed, 16 Aug 2017 09:42:18 GMT</pubDate>
            <atom:updated>2022-01-20T10:45:35.735Z</atom:updated>
            <content:encoded><![CDATA[<p>I challenged myself last month to build a model every month for the rest of the year while covering most machine learning methods such as supervised (Regression and Classification) and unsupervised learning (Clustering and Dimensionality Reduction)</p><h3>Femi Ogunbode on Twitter</h3><p>1 model every month while covering regression, classification, supervised, and unsupervised learning algorithms till the end of the year. 🙏</p><p>So far I think I’m still on track considering I started a Machine Learning Engineer Nanodegree on Udacity leaving me with less time for other things I planned to do but nevertheless, I will try to complete the challenge.</p><p>For the month of July I decided to pick a regression problem on Kaggle, which involves predicting house prices in Ames, Iowa.</p><p>I’m going to pick just 3 new major stuff I finally figured out while building the model.</p><ul><li>Feature Scaling (Standardisation)</li><li>Regularisation</li><li>PCA</li></ul><h3>Feature Scaling (Standardization)</h3><p>Simply put, its scaling features so we have them on the the same scale.</p><p>I struggled to understand the reason behind doing feature scaling. I mean why can’t I just throw in my features of different scales into my model without having to transform them? Here’s why (Shout out to <a href="https://medium.com/u/e0a650030b6">Akinkunle Allen</a> for breaking it down while explaining how SMOTE works)</p><p>Most machine learning algorithms operate in the vector space which might include calculations like euclidean distance between vectors e.g KNN, K-Means, SMOTE.</p><p>Having features on different scales would cause features with high range to bully features with a lower range in the vector space while performing calculations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oCayLp46OYtKDhLB5ui0GA.jpeg" /><figcaption>LotFrontage and LotArea are on different scales.</figcaption></figure><p>I’ll try listing out classes of algorithms that standardization improves it’s performance.</p><ul><li>Algorithms that uses euclidean distance e.g KNN.</li><li>Those that involve learning rates e.g regularization techniques.</li><li>Algorithms that use gradient descent for optimization.</li><li>Principal Component Analysis</li></ul><p>Though I think the 2nd &amp; 3rd are kind of the same.</p><p>I’ll recommend this <a href="http://sebastianraschka.com/Articles/2014_about_feature_scaling.html#about-standardization"><strong>article</strong></a> to better understand feature scaling and when to use it.</p><p>Finally, if I decided to use regularization (which I did) for my model or wanted to use PCA to capture some underlying structure in my features (which I plan on doing) standardization would come in handy.</p><h3>Regularization</h3><p>This is an attempt to prevent overfitting by penalizing the cost function. As more features are added to the dataset the model becomes more complex and overfitting is bound to happen.</p><p>So what regularization does is to introduce a regularization parameter which essentially penalizes the feature with large weights. Hence, for features with large weight the regularisation parameter minimizes it. The intuition is, if all our feature weights are somewhat relatively small, the complexity of our model is reduced.</p><p>The regularization parameter controls the trade-off between the goal of fitting the model well (crux of developing models) and the goal of keeping the parameter small.</p><p>Doing the project I decided to try out different algorithms to see how they compare (just for the fun of it…I knew already that I wanted to use a linear model). So below are the scores from the ‘experiment’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/557/1*Cfs5fyTqbNI1lfftLjyIvQ.jpeg" /><figcaption>Scores from different models</figcaption></figure><p>Obviously my linear models (Linear Regression &amp; Ridge) outperformed others in terms of generalization. But the trade-off between the training set score and cross validation score of the ridge model (which is a regularization option for linear regression models) seems good enough, even slightly better than the linear regression model.</p><p>You can read this <a href="http://www.chioka.in/differences-between-l1-and-l2-as-loss-function-and-regularization/">article</a> to learn about different regularization options and their use cases. Also, <a href="https://medium.com/u/592ce2a67248">Andrew Ng</a> gave a very good introduction in his machine learning coursera course under the section “Regularization” in week 3.</p><h3><strong>PCA</strong></h3><p>Principal component analysis is a dimensionality reduction technique that works by projecting high dimensional data onto a plane of lower dimension while trying to minimizes the projection error</p><p>For example given a 2 dimensional dataset, what PCA does is to try to find directions in the plane that captures most variance in the data points whilst trying to minimize the projection error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*DQT3kLk92nnBYaMZa_cjgw.jpeg" /><figcaption>U1 (Purple line) : 1-dimensional plane that captures the maximum variance . Xn — X’n (Blue line) : Projection Error</figcaption></figure><p>PCA is useful in cases where you have latent features. Let me deviate a bit, latent features are features that capture the same concept in our problem.</p><p>Contextually, in predicting house prices, features like square footage and number of rooms describes a concept (latent feature) like size, also features like neighborhood safety and schools generally describes the latent feature, neighborhood. Applying PCA to this dataset of 4 features reduces it to just 2 essential features which makes it easier to visualize their relationship.</p><p>I’ll not be diving deeper into PCA (though I really want to). I only highlighted it because for my next machine learning project, I will be using PCA to understand the features and see how the number of features can be reduced. And hopefully I get to write an article about what I learnt doing it.</p><p>I made it to the top 23% on the competition <a href="https://www.kaggle.com/c/house-prices-advanced-regression-techniques/leaderboard">leaderboard</a> with my ‘simple’ model and you can check out my <a href="https://github.com/FemiOG/Linear-Regression-Model-For-House-Prices-Ames">notebook</a> for the model.</p><p>I look forward to writing about my experience on the next project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40094ad3bc0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Logistic Regression]]></title>
            <link>https://femiogunbode.medium.com/what-i-learnt-this-week-logistic-regression-9dbfc351b812?source=rss-40eb8f78b57c------2</link>
            <guid isPermaLink="false">https://medium.com/p/9dbfc351b812</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[logistic-regression]]></category>
            <category><![CDATA[udacity]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Femi Ogunbode]]></dc:creator>
            <pubDate>Tue, 01 Aug 2017 11:12:27 GMT</pubDate>
            <atom:updated>2022-01-20T10:46:21.349Z</atom:updated>
            <content:encoded><![CDATA[<p>Ok so I decided to challenge myself to write about machine learning jargon I learnt or finally figured out over the course of my Machine Learning Engineer Nanodegree on Udacity (and hopefully beyond completion).</p><p>This is going to help me understand these topics even better. Also, this is my first attempt at any kind of writing and I hope to keep it short and concise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*VZ2d24UOFylsvSRo4JH_Mw.jpeg" /></figure><p>One of the questions asked during this week’s <a href="https://github.com/FemiOG/finding_donors">project</a> was to explain in layman’s term, how the machine learning algorithm I chose for the project works. The answer I gave was off the top of my head and I did not carry out any research due to my laziness. I was secretly expecting my reviewer to reject the explanation but lo and behold he/she commended it. So I decided to share it with the <em>same aim of explaining it to a non-technical audience </em>with a little more detail.</p><h4>Logistic Regression in layman’s term.</h4><p><strong>Backstory:</strong> Logistic Regression is a machine learning algorithm used for classification i.e (predicting whether something is true or not)</p><p>The Logistic Regression algorithm works by <a href="http://machinelearningmastery.com/logistic-regression-for-machine-learning/">learning</a> weights of each features and a constant term from a training dataset. So that given a new observation it multiplies these weights by the corresponding features of our new observation, adding all the products plus the constant term and fitting the result in a special function (<a href="https://en.wikipedia.org/wiki/Logit">Logit Function</a>) that scales it down to a number between 0 and 1 which can be interpreted as probabilities, with results lesser than 0.5 indicating a prediction of false and results greater than or equals to 0.5 indicating a prediction of true.</p><p><em>Did not understand any of the jargons i just said? Worry not!</em></p><p>To put it into context given a person’s features like age, weight and height we can predict their sex. Logistic Regression learns the numerical weights of each features such as age, weight, height and a constant term from past data of several peoples age, weight ,height and their corresponding sex.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*hsk4sonlH4puVZbX9Lr4Ww.jpeg" /><figcaption><a href="http://www.toshistats.net/101-5-logistic-regression-with-r/">http://www.toshistats.net/101-5-logistic-regression-with-r/</a></figcaption></figure><p>Using this diagram, let’s assume x1, x2 and x3 (Input) to represent the person’s age, weight and height respectively. The labels on each arrows representing the weights of the corresponding feature and the square symbol (whatever the color is) representing our special function. The output y representing the probabilities (between 0 and 1) of this person being either male or female.</p><p>To predict the probabilities of the person being either male or female, the values of each features is multiplied by the corresponding weights. Then all the products are added together with the constant term to get a value. Then this value is passed into a special function that scales it down to a value between 0 and 1, with values lesser than 0.5 indicating that the person is female and values greater than or equals to 0.5 indicating that the person is male.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yPL4KUkDPQP21REwao5YlA.jpeg" /><figcaption>and thanks for reading this boring piece.</figcaption></figure><p>Let me know what you think about this in the response section below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9dbfc351b812" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>