<?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 Ifuwelemuel on Medium]]></title>
        <description><![CDATA[Stories by Ifuwelemuel on Medium]]></description>
        <link>https://medium.com/@ifuwelemuel123?source=rss-e34a9d1ccbcd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*zJcfejuL3Mj65wVY</url>
            <title>Stories by Ifuwelemuel on Medium</title>
            <link>https://medium.com/@ifuwelemuel123?source=rss-e34a9d1ccbcd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 09:06:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ifuwelemuel123/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[Detecting patterns with Unsupervised learning (GMM)]]></title>
            <link>https://medium.com/@ifuwelemuel123/detecting-patterns-with-unsupervised-learning-gmm-4a22e6f28f8e?source=rss-e34a9d1ccbcd------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a22e6f28f8e</guid>
            <category><![CDATA[unsupervised-learning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[clustering]]></category>
            <category><![CDATA[gaussian-mixture-model]]></category>
            <dc:creator><![CDATA[Ifuwelemuel]]></dc:creator>
            <pubDate>Sun, 10 Mar 2024 20:24:45 GMT</pubDate>
            <atom:updated>2024-03-10T20:24:45.997Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*OmQVDFZ60J4K_ZJG5QNGNQ.png" /></figure><p>Hey everyone,</p><p>I have an interesting one for you this week, sorry about last week, I was distracted from achieving consistency. Inspite of this, I promise to continue posting every week; and carrying you along the way.</p><p>All that said,</p><p>We are back!</p><p>I’m sure some of us have heard of unsupervised learning algorithms.</p><p>Well! if you haven’t, that’s alright I was once there.</p><p>For starters, <strong>unsupervised learning algorithms </strong>are used for pattern recognition. In the real world, data isn’t always labeled, as seen in the previous week&#39;s project; where we dealt with <strong>supervised learning</strong>. This week, we want our model to extract insights and patterns from the data without human supervision.</p><p>With this in mind, the possibilities are endless.</p><h3><strong>Introduction</strong></h3><p>Without going too deep into the math, Gaussian mixture models (GMM) are probabilistic models that are used to model real-world data sets. GMMs are Gaussian distribution generalizations that may be used to describe any data set, that can be clustered into multiple Gaussian distributions. The Gaussian mixture model is a probabilistic model in which all data points are assumed to be created by a mixture of Gaussian distributions with unknown parameters. Clustering, or grouping a set of data points into clusters, may be accomplished using a Gaussian mixture model.</p><p>Hence, for better understanding, each data point is assigned to a cluster by a probability distribution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*4gcRouXWJD2buXRg" /><figcaption><a href="https://vitalflux.com/gaussian-mixture-models-what-are-they-when-to-use/">https://vitalflux.com/gaussian-mixture-models-what-are-they-when-to-use/</a></figcaption></figure><h3><strong>Building a classifier based on Gaussian Mixture Models</strong></h3><p>Create a new Python file and import the following packages:</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>import matplotlib as mpl<br>from sklearn import datasets<br>from sklearn.model_selection import StratifiedKFold<br>from sklearn.mixture import GaussianMixture<br>from matplotlib import patches</pre><p>We are using the iris dataset available in scikit-learn for analysis:</p><pre># Load the iris dataset<br>iris = datasets.load_iris()<br></pre><p>Split dataset into training and testing (80/20 split)</p><pre># Break up the dataset into non-overlapping training (75%) and<br># testing (25%) sets.<br>skf = StratifiedKFold(n_splits=4)</pre><p>Extract the training data</p><pre># Only take the first fold.<br>train_index, test_index = next(iter(skf.split(iris.data, iris.target)))<br><br>X_train = iris.data[train_index]<br>y_train = iris.target[train_index]<br>X_test = iris.data[test_index]<br>y_test = iris.target[test_index]<br><br># Extract the number of classes<br>n_classes = len(np.unique(y_train))</pre><p>Build the model</p><pre>classifier = GaussianMixture(n_components=n_classes,<br>                    covariance_type=&#39;full&#39;, n_init=20)</pre><p>Initialize the means and train the classifier:</p><pre><br># Initialize the GMM means<br>classifier.means_init = np.array([X_train[y_train == i].mean(axis=0)for i in range(n_classes)])<br><br># Train the other parameters using the EM algorithm.<br>classifier.fit(X_train)</pre><p>plot the output</p><pre><br>plt.figure()<br>colors = &#39;bgr&#39;<br><br>for i, color in enumerate(colors):<br>    # Extract eigenvalues and eigenvectors<br>    eigenvalues, eigenvectors = np.linalg.eigh(classifier.covariances_[i][:2, :2])<br><br>    # Normalize the first eigenvector<br>    norm_vec = eigenvectors[0] / np.linalg.norm(eigenvectors[0])<br><br>    # Extract the angle of tilt<br>    angle = np.arctan2(norm_vec[1], norm_vec[0])<br>    angle = 180 * angle / np.pi <br><br>    # Scaling factor to magnify the ellipses<br>    # (random value chosen to suit our needs)<br>    scaling_factor = 8<br>    eigenvalues *= scaling_factor <br><br>    # Draw the ellipse<br>    ellipse = patches.Ellipse(classifier.means_[i, :2], <br>            eigenvalues[0], eigenvalues[1], 180 + angle, <br>            color=color)<br>    axis_handle = plt.subplot(1, 1, 1)<br>    ellipse.set_clip_box(axis_handle.bbox)<br>    ellipse.set_alpha(0.6)<br>    axis_handle.add_artist(ellipse)<br><br># Plot the data <br>colors = &#39;bgr&#39;<br>for i, color in enumerate(colors):<br>    cur_data = iris.data[iris.target == i]<br>    plt.scatter(cur_data[:,0], cur_data[:,1], marker=&#39;o&#39;, <br>            facecolors=&#39;none&#39;, edgecolors=&#39;black&#39;, s=40, <br>            label=iris.target_names[i])<br><br>    test_data = X_test[y_test == i]<br>    plt.scatter(test_data[:,0], test_data[:,1], marker=&#39;s&#39;, <br>            facecolors=&#39;black&#39;, edgecolors=&#39;black&#39;, s=40, <br>            label=iris.target_names[i])<br><br>plt.xticks(())<br>plt.yticks(())<br><br><br>plt.legend(loc=&#39;lower right&#39;, prop=dict(size=12))<br><br><br>plt.show() <br><br>y_train_pred = classifier.predict(X_train)<br>train_accuracy = np.mean(y_train_pred.ravel() == y_train.ravel()) * 100<br>print( &#39;Train accuracy: %.1f&#39; % train_accuracy, )<br><br>y_test_pred = classifier.predict(X_test)<br><br>test_accuracy = np.mean(y_test_pred.ravel() == y_test.ravel()) * 100 <br>print( &#39;Test accuracy: %.1f&#39; % test_accuracy,)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OmQVDFZ60J4K_ZJG5QNGNQ.png" /></figure><h3>Conclusion</h3><p>We were able to show the GMM’s ability to classify features of the iris dataset.</p><p>The visualization of higher-dimensional data was proving very difficult to demonstrate. I’m not completely sure, but you can show the representation by plotting the combination of all the features.</p><p>Although it is not incorrect, its accuracy is very high, proving its ability with the test data.</p><p>Remember this life na one.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a22e6f28f8e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Predicting traffic using Extremely Random Forest regressor]]></title>
            <link>https://medium.com/@ifuwelemuel123/predicting-traffic-using-extremely-random-forest-regressor-97b9475dd2d9?source=rss-e34a9d1ccbcd------2</link>
            <guid isPermaLink="false">https://medium.com/p/97b9475dd2d9</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[storytelling]]></category>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[random-forest]]></category>
            <dc:creator><![CDATA[Ifuwelemuel]]></dc:creator>
            <pubDate>Sun, 25 Feb 2024 19:37:43 GMT</pubDate>
            <atom:updated>2024-02-25T19:37:43.424Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Sk2bnog-6NBY8cx3" /></figure><p>Hey Everyone,</p><p>Our project for this week is an extreme random forest. It was a little bit cumbersome, though because I definitely did not understand it at the time, but it was worth it.</p><p>My girlfriend works at a marketing agency. I could see how she would spend long hours of the day looking for the best influencers for a campaign, then go back and calculate their return on investment in percentage of each influencer.</p><p>I found this very archaic, and I love her, so I decided to help her out.</p><p>As of this point, I had identified my problem statement, did a little research on its feasibility, and found a paper from the KTH Royal Institute of Technology.</p><p>Shocker…</p><p>I did not have enough data to continue that project, hence the reason I used a free traffic data.</p><p>I will do my best to try and complete this project by the end of the month.</p><p><strong>Introduction</strong></p><p>Extreme random forest [ERF] is a type of classification model where the model tries to predict the correct label of the input data. The classification model like every other model must be trained, And this training is based on the training data. It is tested using “test data” and its performance is evaluated based on new data.</p><p>I banked on the model’s ability to handle complex datasets and deliver accurate predictions, keeping in mind; that it is a supervised learning algorithm.</p><p>Well, let’s see how it goes.</p><h3>What are Random Forests and Extremely Random Forests?</h3><p>I’m not going to lie I was initially confused, I knew about the <strong>random forest</strong> but an <strong>extreme random forest</strong> was new to me. Below is a brief description of the two;</p><p>A <strong>Random Forest </strong>builds multiple decision trees over bootstrapped subsets of the data while <strong>Extremely random forests </strong>build multiple decision trees over the entire dataset. In addition, RF chooses the best node to split on while ERF randomizes the node split.</p><p>Essentially Extreme random forest is just a bigger Random forest algorithm, some texts may call it an extra random forest.</p><h3>How does the ERF algorithm work?</h3><p>Random Forest works in two phases. The first is to create the random forest by combining “decision trees, and the second is to make predictions for each tree created in the first phase.</p><p>The working process can be explained in the below steps and diagram:</p><p><strong>Step 1:</strong> Select random “K” data points from the training set.</p><p><strong>Step 2:</strong> Build the decision trees associated with the selected data points (subsets).</p><p><strong>Step 3:</strong> Choose the number N for the decision trees that you want to build.</p><p><strong>Step 4:</strong> Repeat Steps 1 &amp; 2.</p><p><strong>Step 5:</strong> For new data points, find the predictions of each decision tree, and assign the new data points to the category that wins the majority votes.</p><p>The algorithm can be better understood by the below example:</p><p><strong>Example:</strong> Suppose there is a dataset that contains multiple fruit images. So, this dataset is given to the Random forest classifier. The dataset is divided into subsets and given to each decision tree. During the training phase, each decision tree produces a prediction result, and when a new data point occurs, then based on the majority of results, the Random Forest classifier predicts the final decision. Consider the below image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*5ehTZGfZEdrhP_Xx" /></figure><p><a href="https://www.javatpoint.com/machine-learning-random-forest-algorithm">https://www.javatpoint.com/machine-learning-random-forest-algorithm</a></p><h3>Task description</h3><p>This dataset consists of data that counts the number of vehicles passing by on the road during baseball games played at Los Angeles Dodgers Stadium. To make the data readily available for analysis, we need to pre-process it. The pre-processed data is in the file <em>traffic_data.txt</em>. In this file, each line contains comma-separated strings. Let’s take the first line as an example:</p><p><em>Tuesday,00:00, San Francisco, no,3</em></p><p>Day of the week, time of the day, opponent team, binary value indicating whether or not a baseball game is currently going on (yes/no), number of vehicles passing by.</p><p>We are trying to predict the number of vehicles going by using the given information. Since the output variable is continuous-valued, we need to build a regressor that can predict the output. We will be using Extremely Random Forests to build this regressor. Let’s go ahead and see how to do that.</p><p>We would then create a new Python file and import the following packages:</p><pre>import numpy as np<br>import matplotlib.pyplot as plt<br>from sklearn.metrics import classification_report, mean_absolute_error<br>from sklearn.model_selection import cross_validate<br>from sklearn.ensemble import ExtraTreesRegressor<br>from sklearn.metrics import classification_report<br>from sklearn.model_selection import train_test_split<br>from sklearn.preprocessing import LabelEncoder</pre><p>We would then load the data in the file traffic_data.txt:</p><pre># Load input data<br>input_file = &#39;/Users/mac/Documents/LIFE/ICT/ML/chapter /traffic_data.txt&#39;<br>data = []<br>with open(input_file, &#39;r&#39;) as f:<br>for line in f.readlines():<br>items = line[:-1].split(&#39;,&#39;)<br>data.append(items)<br>data = np.array(data)</pre><p>We need to encode the non-numerical features in the data. We also need to ensure that we don’t encode numerical features. Each feature that needs to be encoded needs to have a separate label encoder. We need to keep track of these encoders because we will need them when we want to compute the output for an unknown data point. Let’s create those label encoders:</p><pre># Convert string data to numerical data<br>label_encoder = []<br>X_encoded = np.empty(data.shape)<br>for i, item in enumerate(data[0]):<br>if item.isdigit():<br>X_encoded[:, i] = data[:, i]<br>else:<br>label_encoder.append(LabelEncoder())<br>X_encoded[:, i] = label_encoder[-1].fit_transform(data[:, i])<br>X = X_encoded[:, :-1].astype(int)<br>y = X_encoded[:, -1].astype(int)</pre><p>Split the data into training and testing datasets:</p><pre># Split data into training and testing datasets<br>X_train, X_test, y_train, y_test = cross_validation.train_test_split(<br>X, y, test_size=0.25, random_state=5)</pre><p>Train an extremely Random Forests regressor:</p><pre># Split data into training and testing datasets<br>X_train, X_test, y_train, y_test = cross_validation.train_test_split(<br>X, y, test_size=0.25, random_state=5)</pre><p>Compute the performance of the regressor on testing data:</p><pre># Extremely Random Forests regressor<br>params = {&#39;n_estimators&#39;: 100, &#39;max_depth&#39;: 4, &#39;random_state&#39;: 0}<br>regressor = ExtraTreesRegressor(**params)<br>regressor.fit(X_train, y_train)</pre><p>Let’s see how to compute the output for an unknown data point. We will be using those label encoders to convert non-numerical features into numerical values:</p><pre># Compute the regressor performance on test data<br>y_pred = regressor.predict(X_test)<br>print(&quot;Mean absolute error:&quot;, round(mean_absolute_error(y_test, y_pred),2))</pre><p>Predict the output:</p><pre># Testing encoding on single data instance<br>test_datapoint = [&#39;Saturday&#39;, &#39;10:20&#39;, &#39;Atlanta&#39;, &#39;no&#39;]<br>test_datapoint_encoded = [-1] * len(test_datapoint)<br>count = 0<br>for i, item in enumerate(test_datapoint):<br>if item.isdigit():<br>test_datapoint_encoded[i] = int(test_datapoint[i])<br>else:<br>test_datapoint_encoded[i] = int(label_encoder[count].transform(np.array([test_datapoint[i]])))<br>count = count + 1<br>test_datapoint_encoded = np.array(test_datapoint_encoded)<br># Predict the output for the test datapoint<br>print(&quot;Predicted traffic:&quot;, int(regressor.predict([test_datapoint_encoded])[0]))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/0*nYLieZCFg4Q9Yo6K" /></figure><h3>Conclusion</h3><p>We were able to successfully predict traffic using an <strong>extremely random forest regressor</strong>. And hopefully, by next week, we will be able to go forward with our original plan for this week.</p><p>Remember this life na one.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97b9475dd2d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ground Zero, Episode 1]]></title>
            <link>https://medium.com/@ifuwelemuel123/ground-zero-episode-1-2ba6de1fe788?source=rss-e34a9d1ccbcd------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ba6de1fe788</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[africa]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[careers]]></category>
            <category><![CDATA[journaling]]></category>
            <dc:creator><![CDATA[Ifuwelemuel]]></dc:creator>
            <pubDate>Sun, 18 Feb 2024 16:00:43 GMT</pubDate>
            <atom:updated>2024-02-18T16:00:43.245Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3C4DYlsUON4SEnHo" /></figure><p>EVERY GREAT STORY STARTS FROM THE BEGINNING RIGHT?</p><p><em>Well, here’s my beginning...</em></p><p>In 2019, I heard about the capabilities of machine learning/artificial intelligence (AI) in a class lecture. As a Nigerian student just trying to survive college, I didn’t care for it, really.</p><p>All I wanted was to trade forex and hoped that by the near future, I would buy my mother a pink Porsche.</p><p>Fast forward to 2024, and I have low-key been moving in circles while nursing this burning desire to stand out in whatever and wherever I find myself.</p><p>The reshaping of my mindset is now long overdue. I’m ready to step out of the rat race, ready for financial freedom, and ready for a life of purpose by God’s grace.</p><p>Recently, I decided to share my journey. We are going to go back to the basics, avoiding all the hype and “cringe AI news.”</p><p>The goal is to “practice the effectiveness of artificial intelligence in Nigeria.” I know it sounds like big terms, but what I am saying is to understand how practical AI in Nigeria would be for real-life scenarios. Also, because I have a budding interest in entrepreneurship, we would scope our experience to the business landscape and how it can be applied in this sector.</p><blockquote>Highlights of week 0</blockquote><p>A wise man once said, “A journey of a thousand miles begins with a single step.”</p><p>I’m sure I have taken a few steps, but maybe not in the right direction. The silver lining? I gained some new knowledge from this.</p><p><strong><em>Deep work is required for extensive research.</em></strong></p><h4>Conclusion</h4><p>As you join me in my journey of mastery and discovery of the thoughts and principles on this blog, I hope it will also spark in you the same curiosity and motivation.</p><p>Remember this life na one</p><p><strong>Disclaimer:</strong> This post is purely an expression of my personal views, experiences, and opinions. It does not represent advice in any way (no go use am plan your life). I’ve also used AI and ML interchangeably. I apologize in advance to anyone this might offend.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ba6de1fe788" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>