<?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 Ifeoma Veronica Nwabufo on Medium]]></title>
        <description><![CDATA[Stories by Ifeoma Veronica Nwabufo on Medium]]></description>
        <link>https://medium.com/@ifysuccessvera?source=rss-3714aab440ec------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*rxVz-Pau1oNGExh_b6ihng.png</url>
            <title>Stories by Ifeoma Veronica Nwabufo on Medium</title>
            <link>https://medium.com/@ifysuccessvera?source=rss-3714aab440ec------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 11:29:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ifysuccessvera/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[Probably Approximately Correct (PAC) Learning Framework in Plain English]]></title>
            <link>https://ifysuccessvera.medium.com/probably-approximate-correct-pac-learning-framework-in-plain-english-738b78c6e82?source=rss-3714aab440ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/738b78c6e82</guid>
            <dc:creator><![CDATA[Ifeoma Veronica Nwabufo]]></dc:creator>
            <pubDate>Fri, 29 Aug 2025 17:08:18 GMT</pubDate>
            <atom:updated>2025-08-29T17:17:18.572Z</atom:updated>
            <content:encoded><![CDATA[<p>PAC means Probably Approximately Correct. The PAC learning framework is a computational learning framework introduced by Leslie Valiant in 1984 to formalize what it means to “learn”. This learning framework requires that, with high probability, a learning algorithm makes small errors.</p><p>In machine learning, we talk a lot about what it means to say that a machine has <em>learned</em>. But what does it really mean when you say that a machine has <em>learned </em>in the PAC framework?</p><p>According to Valiant (2013), <em>learning</em> is the ability to <em>generalize</em>.</p><p>But what does it mean to <em>generalize</em>?</p><p>Think about how you learned to read in English. You were taught two-lettered words, then three, then four, and so on. Maybe you were also taught phonetics. But I am very sure that you were not taught all the three-lettered words or all four-lettered words in the English dictionary nor were you taught all the words in the English dictionary. Somehow, you were able to pronounce new words you came across. Almost certainly, you made some mistakes in your pronunciation, but almost surely, all the words you know now are not words that you were taught consciously.</p><p>How were you able to do that? Why were you able to do that?</p><p>I think a neurologist may be able to give an in-depth explanation of the <em>hows</em> and the <em>whys</em> 😊.</p><p>However, this capability of being able to read out new words even when you had not seen them previously is what is referred to as <em>generalization</em>.</p><p>We want a learning machine to have this special capability possessed by humans. We want this machine to see only a few examples and be able to pronounce a new word.</p><p>Just like humans, we do not require that the machine be correct all the time. We just want the machine to be correct <strong>most</strong> of the time.</p><h3><strong>Key Assumptions of PAC Learning</strong></h3><ol><li>Same distribution assumption</li><li>Regularity/bounded complexity</li></ol><h4>Same distribution assumption</h4><p>In the PAC learning paradigm, we also have the requirement that any new example shown to the learning machine must not be different from the example from which it was shown previously. This means that training and testing examples come from the same distribution. In statistics, it is referred to as being independently and identically distributed (iid).</p><p>Coming back to our analogy, it means that if the machine has learned words in English, it shouldn’t be expected to pronounce words in French or any other language. Think about it: do you require that a ‘master’ in English must be a master in French? I wouldn’t. I know you wouldn’t too. This requirement means that we want the examples and the new words to come from the same distribution. Valiant (2013) refers to it as <em>The Invariance Assumption</em>.</p><h4>Regularity/bounded complexity</h4><p>The second assumption is that the data has patterns which can make generalization possible. That is, we require that there exist some regularities in the examples given to the learning machine.</p><p>Think about this: how do we pronounce a new word or even a long word? We just think about a similar word we had come across and try to pronounce this new word the same way. How about a long word? We break down the word syllable by syllable, right? We were able to pronounce these words because of the regularities that exist in the English Language. Valiant (2013) refers to it as <em>The Learnable Regularity Assumption</em>.</p><p>Hence, we make the above assumptions about the examples given to the learning machine. We assume that the examples are invariant and regular.</p><h4>A tiny bit of math</h4><p>Bringing all the above points together, we can define what it means to be PAC-learnable. A learning algorithm should:</p><ol><li><strong>Probably</strong>: be right at least 1 — $\delta$ times</li><li><strong>Approximately</strong>: have error within $\epsilon$</li><li><strong>Correct</strong>: have low error, given that the above assumptions are true.</li></ol><p>If you enjoyed reading this, follow me for more :)</p><h3>References</h3><ol><li>Valiant, L. Probably Approximately Correct: Nature’s Algorithms for Learning and Prospering in a Complex World. Basic Books, 2013.</li><li>Valiant, L. G. A Theory of the Learnable. Communications of the ACM, 27(11):1134–1142, 1984.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=738b78c6e82" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unsupervised Visualization Of Images Using t-SimCNE]]></title>
            <link>https://ifysuccessvera.medium.com/unsupervised-visualization-of-images-using-t-simcne-23a9ad15f0?source=rss-3714aab440ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/23a9ad15f0</guid>
            <dc:creator><![CDATA[Ifeoma Veronica Nwabufo]]></dc:creator>
            <pubDate>Fri, 23 Jun 2023 13:08:43 GMT</pubDate>
            <atom:updated>2024-05-05T11:36:31.386Z</atom:updated>
            <content:encoded><![CDATA[<p>It is said that a picture is worth a thousand words. A picture can convey information more quickly and even more retainable information. However, a major obstacle faced in Data Science is the multidimensionality of data which makes data difficult to visualize in high dimensions; hence impedes a meaningful understanding of the structure of data.</p><p>Several methods exist that can be used to reduce the dimensions of data so that the information about the structure of the data is understood. The classic is probably Principal Component Analysis (I have written a blog post about it which can be found <a href="https://ifysuccessvera.medium.com/principal-component-analysis-pca-mathematical-overview-with-implementation-on-python-40accf47ad48">here</a>). There are also methods such as Uniform Manifold Approximation and Projection (<a href="https://arxiv.org/pdf/1802.03426.pdf">UMAP</a>) and t-Distributed Stochastic Neighbor Embedding (t-SNE). Today, I’d write about t-SimCNE which is a method I’ve been experimenting with over a couple of months. It is a method by Böhm et al (2023) and the paper can be found <a href="https://arxiv.org/pdf/2210.09879.pdf">here</a>.</p><h3><em>t-SimCNE</em></h3><p>t-SimCNE is a visualization method based on <em>contrastive learning</em> and t-SNE. The <em>t</em> is the <em>student t-distribution</em>, <em>Sim</em> is gotten from <em>SimCLR</em> and <em>CNE</em> stands for <em>Contrastive Neighbour Embedding</em>.</p><p>Briefly, contrastive learning is a self-supervised technique of learning. The main ingredient is that this method seeks to train a neural network to learn to distinguish images without the use of labels by maximizing the similarity between the positive pairs of an object (gotten through augmentations) while pushing negative examples apart. If you want to read more about contrastive learning, check out this blog <a href="https://www.v7labs.com/blog/contrastive-learning-guide#:~:text=Contrastive%20Learning%20is%20a%20technique,a%20data%20class%20from%20another.">post</a>.</p><p>Now, how does t-SimCNE bring all these methods together, and is it better than them?</p><h3><strong>TRAINING</strong></h3><p>There are broadly two <em>spaces </em>in t-SimCNE. There are 3 training chambers. In the first training chamber, there is a ResNet backbone (or any suitable backbone) that produces a 512-dimensional representation output from a given input. There is then a multilayer perceptron (MLP) (fully-connected projection head) comprising a single hidden layer with 1024 neurons, a ReLU activation, and an output layer of 128 units. They make up the first chamber of training (referred to as <em>pre-training — </em>this stage of getting representations from self-supervision is usually referred to as pre-training in self-supervised learning). In the original literature, this is trained for 1000 epochs.</p><p>T-SimCNE aims to reduce the 128D layer output to 2D. They do this by randomly initializing a 2D output layer. This 2D initialization follows a normal distribution. Then they swap the 128D output in the first training chamber with the initialized 2D weights. Next, the entire network except the last 2D output layer is frozen. Only the 2D output layer is fine-tuned for 50 epochs in order to ensure alignment with the previous parts of the network. That forms the second training chamber.</p><p>Lastly, the entire network is unfrozen and fine-tuned for 450 epochs, forming the 3rd training chamber. Thus, the total number of epochs trained is 1500.</p><p>Wait! We know that while training a network, the goal is to optimize some loss function. Next, we go into the loss function.</p><h3>LOSS FUNCTION</h3><p>Remember that t-SimCNE is an extension of SimCLR. In SimCLR, the authors use the <a href="https://paperswithcode.com/method/nt-xent"><em>NT-Xent loss</em></a><em> </em>(also referred to as InfoNCE loss)<em>. </em>In t-SimCNE, the authors replace the NT-Xent loss with the <em>t-SimCNE loss </em>which is characterized by the use of the Euclidean metric to compute the similarity between points as opposed to the cosine metric used in SimCLR<em>. </em>Then, just like t-SNE, they use the Cauchy (t-distribution) kernel to transform the Euclidean distance into a similarity function. Hence, given two points zᵢ and zⱼ, the Euclidean distance dᵢⱼbetween them is given by dᵢⱼ= ‖zᵢ — zⱼ‖ with its associated Cauchy similarity as 1/(1 + d²ᵢⱼ). Then the t-SimCNE loss (referred also as the Euclidean loss in their paper) is defined as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*YhFXF_WionHxZAjuMufXeQ.gif" /><figcaption>t-SimCNE Loss</figcaption></figure><p>In their work, they found out that using this Euclidean loss function in the first two training chambers gave lower loss values and better visually appealing clusters as opposed to the use of the SimCLR loss in the first training chamber followed by the Euclidean loss.</p><h3>RESULTS</h3><p>t-SimCNE has produced incredible results as observed in the results and produces better clusters in a 2D visualization than SimCLR. For self-supervised tasks like SimCLR and t-SimCNE, the quality of the 2D embedding is accessed via classification accuracy. It is also helpful to visualize the embeddings. t-SimCNE gives visually appealing embeddings better than t-SNE or its counterparts.</p><p>Below are the images from the embeddings produced in the CIFAR-10 and CIFAR-100 datasets. Interestingly, t-SimCNE was able to discover cluster subgroups in CIFAR-100 (You can look at the paper and find the classification results).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EzYjOZrD-PijtMdwKvkTCQ.png" /><figcaption>t-SimCNE Visualization for CIFAR-10 from Böhm et al (2023)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RPnZazu1-WHYiCYKzA453w.png" /><figcaption>t-SimCNE Visualization for CIFAR-100 Böhm et al (2023)</figcaption></figure><p>Have any questions? Don’t hesitate to ask!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23a9ad15f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Structures 102: Operations on Data Structures]]></title>
            <link>https://ifysuccessvera.medium.com/data-structures-102-operations-on-data-structures-2849ca1e096f?source=rss-3714aab440ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/2849ca1e096f</guid>
            <dc:creator><![CDATA[Ifeoma Veronica Nwabufo]]></dc:creator>
            <pubDate>Tue, 13 Sep 2022 08:07:15 GMT</pubDate>
            <atom:updated>2022-09-13T08:07:15.658Z</atom:updated>
            <content:encoded><![CDATA[<p>In the last <a href="https://ifysuccessvera.medium.com/data-structures-101-introduction-to-data-structures-and-algorithms-c71c625fd4c7">post</a>, we looked at what data structures are and the types of data structures that we have. I talked a bit about the space and time complexity of a data structure. In order to be able to fully analyze the space and/or time complexity of a data structure, we have to fully understand the operations which can be performed by using a particular data structure. This is what this post is all about.</p><p><strong>Operations on Data Structures</strong></p><p>Several operations can be carried out on a given data structure. These involve:</p><ol><li>Creation: this is the initial step that involves defining the data structure.</li><li>Insertion: this is the addition of new members to a data structure.</li><li>Traversal: this is <strong>visiting all</strong> the elements in a data structure.</li><li>Searching: this involves looking for element(s) in a data structure. This is different from traversal as you may not visit all the elements in your data structure.</li><li>Deletion: this is the complete removal of a data structure.</li><li>Updation: this is modifying the data structure after its creation. The elements of some data structures can be updated while some can’t. The data structures that can be updated are known as being mutable. In Python, lists, sets, and dictionaries can be updated while tuples cannot.</li><li>Sorting: this is the arrangement of items in a data structure in a particular order.</li><li>Merging: this involves bringing together two or more different data structures and making them one.</li></ol><p>Loved this tutorial? Clap and share!</p><p>What next would you want me to write about?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2849ca1e096f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Setup Virtual Environment in Windows Command Prompt]]></title>
            <link>https://ifysuccessvera.medium.com/how-to-setup-virtual-environment-in-windows-command-prompt-5ff9cf9dd3c3?source=rss-3714aab440ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ff9cf9dd3c3</guid>
            <dc:creator><![CDATA[Ifeoma Veronica Nwabufo]]></dc:creator>
            <pubDate>Sat, 03 Sep 2022 23:16:53 GMT</pubDate>
            <atom:updated>2023-04-27T13:38:55.524Z</atom:updated>
            <content:encoded><![CDATA[<p>A virtual environment is a way of managing packages and versions in python during development.</p><p>This isolates the packages used for a particular project so does not meddle with packages installed globally. More so, it is helpful when you want to pass on projects to others. So, if someone wants to work on a project you are working on, the person can take a list of all the packages you used in your project and installs them quickly.</p><h3>How to Setup Virtual Environment in Windows Command Prompt</h3><p>In the Windows command prompt, we can install and use virtual a virtual environment by doing the following:</p><ol><li>If you have not installed the virtual environment, install virtual environment by:</li></ol><pre>pip install virtualenv</pre><p>2. To create a virtual environment, do:</p><pre>python -m virtualenv nameofenv</pre><p>Hence, if I want to name my virtual environment <strong><em>env</em></strong>, then I would do:</p><pre>python -m virtualenv env</pre><p>So in the above code, the name of the virtual environment is <strong><em>env</em></strong>. You can name it any name you wish.</p><p>3. You then need to activate your virtual environment. You do this by:</p><pre>nameofenv\Scripts\activate</pre><p>Since the name of my virtual environment is <strong><em>env</em></strong>, I would do:</p><pre>env\Scripts\activate</pre><p>Note that for linux-based terminals, you would rather do:</p><pre>source nameofenv/bin/activate</pre><p>You would know that you have activated the virtual environment if you find the name of your environment at the beginning of the path description in your command prompt.</p><p>If you want to deactivate your virtual environment, do:</p><pre>deactivate</pre><p>When you activate a new virtual environment, you would see that all the other packages you had previously on your computer are not there. You can check the packages and versions in your environment by doing:</p><pre>pip list</pre><p>The above lists all the packages you have and their versions. Most likely, you would find only pip, setuptools, and wheel when you first run the command. See below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/1*crvCx67ZTCWI_-urLVYqew.png" /><figcaption>Checking packages after activating a new virtual environment</figcaption></figure><p>You can now install packages and use <em>pip list</em> to check that they are installed.</p><p>So, suppose I install pandas as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*A5044GTgTLCMOgqhKo0qYQ.jpeg" /></figure><p>The above has installed pandas. Notice, that it has also installed some other dependencies. I can now check the list of my packages to see if pandas has been installed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*MkOouurU5xx7Dck4IqOmTQ.jpeg" /><figcaption>Updated pip list</figcaption></figure><p>Suppose you want to pass a copy of all the packages and their versions, you can save them in a <em>requirements.txt</em> file by doing the following:</p><pre>pip freeze &gt; requirements.txt</pre><p>The above creates a requirements.txt file in your working directory.</p><p>The packages from the requirements.txt file can be installed later by doing:</p><pre>pip install -r requirements.txt</pre><p>I hope you are now able to install and activate a virtual environment.</p><p>Have questions? Do not hesitate to ask!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ff9cf9dd3c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Structures 101: Introduction to Data Structures and Algorithms]]></title>
            <link>https://ifysuccessvera.medium.com/data-structures-101-introduction-to-data-structures-and-algorithms-c71c625fd4c7?source=rss-3714aab440ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/c71c625fd4c7</guid>
            <dc:creator><![CDATA[Ifeoma Veronica Nwabufo]]></dc:creator>
            <pubDate>Sun, 19 Jun 2022 10:39:48 GMT</pubDate>
            <atom:updated>2022-06-19T10:42:28.288Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are on this page, you probably wonder what data structures and algorithms mean. So leggo!</p><p>Let’s start by defining what data structures are.</p><blockquote>Data structures refer to the way we organize and store data so that it can be accessed, manipulated or used efficiently when we need them.</blockquote><p><strong>Divisions of Data Structures</strong></p><p>Data structures are broadly divided into two [1]:</p><ol><li>Linear data structure</li><li>Non-linear data structures</li></ol><p>We explain the above as follows:</p><ol><li>Linear data structures are data structures in which the data elements are arranged in a sequential manner. Examples of linear data structures are arrays, stacks, queues, linked lists, etc.</li><li>Non-linear data structures have their elements arranged in a non-linear manner, that is, they are not arranged sequentially. Examples of non-linear data structures are graphs, trees, heaps, hash tables, etc.</li></ol><p>It is important to have a good knowledge of the various data structures as that would inform you about the right type of data structure to use for a given task. Using the right type of data structure is a way of optimizing space and time for a task.</p><p>Now, let’s go to algorithms.</p><p>What is an algorithm?</p><blockquote>An algorithm is a step by step procedure of solving a problem.</blockquote><p>Hence, an algorithm does not refer to a specific programming language. It can, however, be expressed as pseudocode or a flowchart [2] for solving a problem.</p><p>It is often the case that data structures and algorithms go together. That is, we often do not talk about data structures without talking about the algorithms and vice versa. This is because if you know the right tool to use for a task (the data structure), it is equally important to know how to write an algorithm that would optimize for that data structure!</p><p>Loved this tutorial? Clap and share!</p><p><strong>References</strong></p><p>[1] Data Structure and Types. (2022). Retrieved 19 June 2022, from <a href="https://www.programiz.com/dsa/data-structure-types">https://www.programiz.com/dsa/data-structure-types</a></p><p>[2] Introduction to Data Structures and Algorithms | Studytonight. (2022). Retrieved 19 June 2022, from <a href="https://www.studytonight.com/data-structures/introduction-to-data-structures">https://www.studytonight.com/data-structures/introduction-to-data-structures</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c71c625fd4c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Naive Bayes Classifier]]></title>
            <link>https://ifysuccessvera.medium.com/naive-bayes-classifier-ebd3ef77d091?source=rss-3714aab440ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebd3ef77d091</guid>
            <dc:creator><![CDATA[Ifeoma Veronica Nwabufo]]></dc:creator>
            <pubDate>Sun, 15 May 2022 21:43:23 GMT</pubDate>
            <atom:updated>2024-01-21T10:41:47.402Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a type classifier that is mostly used as a baseline for text classification. The classifier uses the Bayes Theorem, hence it is a probabilistic model. It is called Naive Bayes because the order of words in a sentence does not impact the result of the classifier. For example the sentences:</p><blockquote><strong>The boy is kind, not so?</strong></blockquote><p>and</p><blockquote><strong>The boy is not so kind?</strong></blockquote><p>are considered the same by Naive Bayes. But we know that the first sentence is not the same as the second sentence! This property of the Naive Bayes model is called the independence property of Naive Bayes.</p><p>Though Naive Bayes does not consider the order of words, it considers the multiplicities of the words in a sentence. For example:</p><blockquote><strong>what a great day</strong></blockquote><p>is not the same as</p><blockquote><strong>what a great great day.</strong></blockquote><p>Now, let us look at Bayes Theorem.</p><h3><strong>Bayes Theorem</strong></h3><p>Let A and B be events. Then we define the following conditional probabilities:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*_XmXP4iNZZggeUDh9FpSLQ.gif" /><figcaption>Conditional Probabilities for events A and B</figcaption></figure><p>Note: <em>P(A∩B)</em> is called the joint probability of <em>A</em> and <em>B.</em></p><p>Since equations (1) and (2) have common numerators <em>(P(A∩B))</em>, we can put them together and have:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*LEV2nwOu1oPCOt3Nx-ousw.gif" /><figcaption>Bayes Theorem</figcaption></figure><p>Equation (3) is Bayes Theorem where,</p><p><strong><em>P(A)</em></strong> is the <strong>prior probability </strong>—<strong> </strong>probability before carrying out a test;</p><p><strong><em>P(B)</em> </strong>is the <strong>marginal probability — </strong>the<strong> </strong>probability of the evidence;</p><p><strong><em>P(B|A)</em></strong> is the <strong>likelihood</strong> of <em>B</em> given <em>A</em> — the probability of the evidence given that the probability of A is true; and</p><p><strong><em>P(A|B)</em></strong> is the <strong>posterior probability — </strong>the probability of A after the evidence has been seen.</p><p>In the Naive Bayes text classification problem, we are interested in finding the probability of a label given the words. Hence we can rewrite equation (3) in terms of label and the words:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*VfKuN6H-1WsX2a07HnlGrg.gif" /><figcaption>Bayes Theorem in terms of label and words</figcaption></figure><p>Simplifying further, we have:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*wh1gK83CejOSxQkGVS6X_A.gif" /></figure><h3>Naive Bayes Classifier</h3><p>We want the model to be easy to estimate so from equation (5), we make a <strong>naive</strong> <strong>assumption</strong> that the probability of a word given a class <strong>is independent</strong> of previous words and then we have:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*lmX6fAIY22nkX5kZmEITZA.gif" /><figcaption>Naive assumption that gives the Naive Bayes theorem</figcaption></figure><p>This assumption is what makes us call the model naive as we know that this assumption is not true in many cases because the probability of one word given a class may be dependent on the probability of another word given that class.</p><h3>Simple Example</h3><p>Suppose we have 5 sentences from a movie review as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*G9o-QgRQPmT2JCTuxtfnPQ.png" /><figcaption>Table 1: Movie reviews</figcaption></figure><p>And we want to predict the review of a new sentence:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/548/1*doVTo0_5-2exp9nJ6rkIaw.png" /><figcaption>Table 2: New Review to Predict</figcaption></figure><p>We can construct a table to summarize the reviews from Table 1 as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i03XjqBYWaaz57FmoI0vBg.png" /><figcaption>Table 3: Summary of Movies Review Table</figcaption></figure><p>And calculate the most probable review as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/1*UNzpjrbNPq7FZHRddGtArw.gif" /></figure><p>From the above, we see that the review with more probability is the <strong>positive</strong> <strong>review</strong>.</p><p>The above tutorial is inspired by the NLP courses taught at the African Masters in Machine Intelligence programme by Armand Joulin and Edouard Grave of Facebook AI Research.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebd3ef77d091" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Upload Files to Colab from Kaggle without Downloading into your Local Drive]]></title>
            <link>https://ifysuccessvera.medium.com/how-to-upload-files-to-colab-from-kaggle-without-downloading-into-your-local-drive-cf45b046374d?source=rss-3714aab440ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf45b046374d</guid>
            <dc:creator><![CDATA[Ifeoma Veronica Nwabufo]]></dc:creator>
            <pubDate>Wed, 10 Nov 2021 16:19:06 GMT</pubDate>
            <atom:updated>2021-11-10T16:19:06.423Z</atom:updated>
            <content:encoded><![CDATA[<p>This tutorial will guide you on how you can upload files to colab from Kaggle without downloading them into your local drive.</p><p>To perform this task you have to use Kaggle’s API.</p><ol><li>Go to your Kaggle profile and click on your avatar. You would find it at the top right-hand side of your screen.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*6ijqvqnu5vJBVZ7PnbJWiw.jpeg" /><figcaption>avatar</figcaption></figure><p>2. Click <strong>Account</strong></p><p>3. Scroll downwards. Under the API option, click on <strong>Create New API Token </strong>to generate an API token - this is a json file that stores your username and key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*D7yHjMKyy0tM82AKn9ntcQ.jpeg" /></figure><p><em>A json file will be downloaded. The file contains your credentials.</em></p><p>4.<em> </em>You may need to install kaggle. Open your colab notebook and type !<em>pip install kaggle.</em> Sometimes, you may get an error when you want to download some files so you may need to use the second command to upgrade.</p><pre>!pip install kaggle</pre><pre>!pip install --upgrade --force-reinstall --no-deps kaggle</pre><p>5. Create a folder named <strong>kaggle</strong> in your root directory and store the credentials with the following code:</p><pre>!mkdir ~/.kaggle</pre><p>6. Upload your kaggle credentials into colab.</p><pre>from google.colab import files</pre><pre>uploaded = files.upload()</pre><p>7. Next copy the json file credentials into the <em>kaggle</em> folder you created in step 5by copying the paths.</p><pre>!cp /json_path /kaggle_path</pre><p>You should have something like this:</p><pre>!cp /content/kaggle.json ~/.kaggle/kaggle.json</pre><p>8. Set up your environment so that Kaggle can interact with your operating system.</p><pre>import os<br>os.environ[&quot;KAGGLE_CONFIG_&quot;] =&#39;json_path&#39;</pre><p>You should have something like this:</p><pre>import os</pre><pre>os.environ[&quot;KAGGLE_CONFIG_&quot;] =&#39;/content/kaggle.json&#39;</pre><p>9. Go to <a href="https://www.kaggle.com/datasets">kaggle</a> and get the name of the dataset. You can search for a list of all the datasets with that name.</p><pre>!kaggle datasets list -s &quot;name_of_dataset&quot;</pre><p>For example, if I want to download the iris dataset from kaggle, I would do this:</p><pre>!kaggle datasets list -s &quot;iris&quot;</pre><p>The above gives you a list with references, titles, and other information of datasets that are similar to the name of the dataset you entered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S-ZGJDnVHJ2F3Uiu9sL12A.jpeg" /></figure><p>Copy the ref of your desired dataset then download the datasets by using the following code:</p><pre>!kaggle datasets download -d &quot;paste-the-copied-ref-here&quot;</pre><p>Example:</p><pre>!kaggle datasets download -d &quot;uciml/iris&quot;</pre><p>Or you can simply write the path of the file provided by kaggle. You should find it under the files’ section on the <strong><em>Data</em></strong><em> </em>page.</p><p><strong>Note: If the dataset is from a competition, you may need to join the competition else you would get a <em>403 Forbidden</em> error.</strong></p><p>10. Now you have a zipped file and you can unzip it using the code below:</p><pre>import zipfile</pre><pre>!unzip &quot;your_zipped_file_path_here&quot; -d data/</pre><p>Do leave a comment if you found this interesting. If you have questions, please leave them in the comments’ section.</p><p>You can follow me on Twitter at <a href="https://twitter.com/iamdataqueen_">@iamdataqueen_</a> and LinkedIn <a href="https://ifysuccessvera.medium.com/www.linkedin.com/in/ifeoma-veronica-nwabufo">Ifeoma Veronica Nwabufo</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf45b046374d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Principal Component Analysis (PCA): Mathematical Overview with Implementation on Python]]></title>
            <link>https://ifysuccessvera.medium.com/principal-component-analysis-pca-mathematical-overview-with-implementation-on-python-40accf47ad48?source=rss-3714aab440ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/40accf47ad48</guid>
            <dc:creator><![CDATA[Ifeoma Veronica Nwabufo]]></dc:creator>
            <pubDate>Sat, 30 Oct 2021 17:12:55 GMT</pubDate>
            <atom:updated>2023-02-20T00:08:44.710Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What is Principal Component Analysis?</strong></p><p>Principal Component Analysis is a dimension reduction tool that tries to find a representation of data in a dimension lower than the dimension of the original data such that much information is still retained.</p><p>Here, we try to capture the maximum amount of variance in the data in a lower dimension. It is a linear transformation that chooses a new coordinate system for the data set such that the greatest variance by any projection of the dataset comes to lie on the first axis (then called the first principal component), the second greatest variance on the second axis, and so on.</p><p>Mathematically, it is simply a change-of-basis operation. The mathematical question posed is: Given a data matrix X, in a basis, say x, can we obtain another basis y that is a linear combination of the original basis and that re-expresses the data optimally? To achieve this, we seek uncorrelated variables such that each of these variables represents unique information that describes the data.</p><p><strong>2. Principal Component Analysis: Mathematical View</strong></p><p><strong>2.1</strong> <strong>Assumptions</strong></p><p>We assume that the data follow a statistical distribution.</p><p><strong>2.2 Obtaining the PCA Step by Step</strong></p><p>We consider an <em>n x p </em>matrix <strong>X </strong>with rows <em>x₁, x₂, . . . , xₙ </em>where each <em>xᵢ </em>is an individual from a measurement with each <em>pᵢ </em>of <strong>X </strong>corresponding to variables.</p><p>For this tutorial, we use the iris dataset which you can download here: <a href="https://www.kaggle.com/uciml/iris">https://www.kaggle.com/uciml/iris</a></p><pre>#importing libraries</pre><pre>import numpy as np</pre><pre>import pandas as pd</pre><pre>import seaborn as sns</pre><pre>import matplotlib.pyplot as plt</pre><ol><li><strong>Reading the Data</strong></li></ol><pre>X=pd.read_csv(&#39;Iris.csv&#39;)</pre><p><strong>2. Normalization</strong></p><p>In this step, we subtract the mean X̄ of X from X and divide by the standard deviation σ to ensure that the variables contribute equally to the analysis and are not drawn by large values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/96/0*fT1eP6j8gjRoNO3o" /></figure><pre>X_scaled=(X - X.mean())/X.std()</pre><p><strong>3. The Covariance Matrix</strong></p><p>We move on then to compute the covariance matrix C. This is a square positive semi-definite matrix that would allow us to obtain positive eigenvalues.</p><p>Hence, the covariance matrix C from is defined as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/123/0*WxhvXVxHnpDdipzH" /></figure><pre>covariance_mat=X_scaled.corr()</pre><p>which is a square symmetric <em>p x p</em> matrix where each diagonal element of C represents the variance of a variable with itself while the off-diagonal elements are covariances between variables.</p><p><strong>4. Compute the eigenvalues and eigenvectors to determine the principal components using Singular Value Decomposition.</strong></p><p>So, from the covariance matrix, we perform SVD to obtain the eigenvalues and eigenvectors as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/97/0*g6dKrtzbBr75vRN5" /></figure><pre>import numpy as np</pre><pre>eigen_vectors, eigen_values, eigen_vectors_inv=np.linalg.svd(covariance_mat)</pre><p>where V is a matrix of eigenvectors with V⁻¹ its inverse and a diagonal matrix A whose diagonals are eigenvalues. These eigenvalues represent the amount of variance present while the eigenvectors give the direction of the features which are now uncorrelated.</p><p>Hence, we can now arrange the eigenvectors in descending order by using the eigenvalues.</p><pre>order = eigen_values.argsort()[::-1]</pre><pre>eig_values = eigen_values[order]</pre><pre>eig_vectors = eigen_vectors[order]</pre><p>It is important to take the number of components with high variance. Hence, we compute the amount of variance contributed by each eigenvalue.</p><pre>row = [&quot;Component &quot; + str(i+1) for i in range(len(eigen_values))]</pre><pre>col = [&quot;std deviation&quot;,&quot;variance(%)&quot;,&quot;cumulative variance(%)&quot;]</pre><pre>total_variance = sum(eigen_values)</pre><pre>variance_table = pd.DataFrame([[i**0.5,np.round(i*100 /total_variance,2), np.round(j*100/total_variance,2)] for i,j in zip(eigen_values,np.cumsum(eigen_values))],columns= col,index = row)</pre><pre>variance_table</pre><p><strong>5. Change-of-Basis (Projection into a New Dimension)</strong></p><p>We then move on to obtain a new matrix which is a linear combination of the old matrix X and the eigenvectors V.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/70/0*5geO1gn-Df5NSGTn" /></figure><pre>n_components = 2</pre><pre>eigenvector_subset = eig_vectors[0:n_components]</pre><pre>X_prime = np.dot(X_scaled,eigenvector_subset)</pre><p>which is an <em>n x p</em> matrix.</p><p>For the full implementation on python, check out the notebook on GitHub <a href="https://github.com/Success-Vera/PCA-Maths-and-Python">here</a></p><p>Do leave a comment if you found this interesting. If you have questions, please leave them in the comments section.</p><p>You can follow me on Twitter <a href="https://twitter.com/ifeoma_nwabufo">@ifeoma_nwabufo</a> and on LinkedIn <a href="https://medium.com/www.linkedin.com/in/ifeoma-veronica-nwabufo">Ifeoma Veronica Nwabufo</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40accf47ad48" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Artificial Intelligence, Machine Learning Roadmap: How do I Learn Machine Learning?]]></title>
            <link>https://ifysuccessvera.medium.com/the-artificial-intelligence-machine-learning-roadmap-how-do-i-learn-machine-learning-fc8c171075d1?source=rss-3714aab440ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc8c171075d1</guid>
            <dc:creator><![CDATA[Ifeoma Veronica Nwabufo]]></dc:creator>
            <pubDate>Sun, 18 Jul 2021 22:17:05 GMT</pubDate>
            <atom:updated>2021-07-18T22:17:05.085Z</atom:updated>
            <content:encoded><![CDATA[<p>Letters to Enthusiast</p><h3><strong>Dear Enthusiast,</strong></h3><p>If you are reading this letter, then you must have heard so much about Artificial Intelligence and Machine Learning. You must be asking the same question I was asking months ago, “…but how do I learn Machine Learning?”</p><p>In this article, I present to you clear guidelines on how to transition into this field. But there is only one rule in this game:</p><p><strong>Rule number one:</strong></p><blockquote><strong>Enjoy yourself at this step!</strong></blockquote><p>Surprised? Yeah that’s the rule. You must enjoy yourself at <strong>this step. </strong>At every step, you have to enjoy it.</p><p>If you are ready to keep to the rule, then let’s dive in.</p><p>Excited?</p><p>I am!</p><h4><strong>Step 1: Make up your mind</strong></h4><p>This is the first and most important step.</p><p>Heads-up…</p><p>You might feel overwhelmed at some point but if your mind is made up, you’d be able to go through and put all necessary efforts to move to the next step.</p><p><strong><em>Remember the rule.</em></strong></p><h4>Step 2: Learn Python</h4><p>In case you have forgotten, the rule says: <strong><em>Enjoy yourself at this step!</em></strong></p><p>Python is a programming language that is easy to learn. Writing lines of codes is like giving directions to someone.</p><p>If you have never written a single line of code before, that’s fine. There is always a first time!</p><p>There are excellent resources out there that can help you from articles to videos. It depends on how you like to learn.</p><h4>But how do I know what to learn?</h4><p>You really need a structured course so that you don’t move randomly.</p><p>Check out <a href="https://www.youtube.com/watch?v=rfscVS0vtbw">freeCodeCamp</a> or <a href="https://www.youtube.com/watch?v=_uQrJ0TkZlc">Programming with Mosh</a> if you like videos.</p><p>If you like to read, you can learn from the python documentation <a href="https://docs.python.org/3/tutorial/introduction.html">here</a>.</p><p>PS: that’s how I learnt as well.</p><p>DataCamp, tutorialspoint, medium, etc, also have great resources.</p><p><strong>Disclaimer</strong>: Don’t expect to learn everything before you move on to step three. Once you can read a line of code and have a fair idea of what it does, you can move on to step three.</p><p>Really, if you devote time, after some weeks of learning python, you are ready to dive into step three.</p><p>Not to forget…</p><p>It would be very helpful to try your hands on coding projects and give yourself some challenging tasks on <a href="https://www.hackerrank.com/domains/python">hackerrank</a>, <a href="https://leetcode.com/explore/">leetcode</a> or similar sites.</p><h4>Step 3: Start Machine Learning right away!</h4><p><strong><em>Remember the rule!</em></strong></p><p>Yes, you heard me right. Start right away. There is no need to waste any time. You might have heard that you need math, but math can wait. If you can use a calculator, then you are fine.</p><p>As you begin this step, don’t think you would understand everything right away. Just learn the basics. As you progress, there woud be those <em>aha</em> moments when what you had learnt in the past comes to the surface and then you immediately understand it.</p><p><strong><em>Again, you need guidance. You need a structured course!</em></strong></p><p>Kaggle has an excellent resource. You can access it <a href="https://www.kaggle.com/learn/intro-to-machine-learning">here</a>. Once you are done with the introduction, you could level up to the intermediary level.</p><p>If you like videos, you can check up Coursera, Udemy, Udacity. They also have excellent, well structured courses on the introduction to Machine Learning. Personally, I learnt so much from Coursera, specifically Andrew Ng’s videos. But if you don’t have access to them, you can always learn on YouTube. Edureka, Programming with Mosh, have structured courses. Simply go on YouTube and dive right in.</p><p>I’m sure you’d feel great when you successfully run a project from start to finish. That’s how I also felt the first time. I was so excited!</p><p>I’d also encourage you to participate in Machine Learning competitions. They will help you in no small way. If you feel that you know nothing, welcome on board! I also felt that way. Should I tell you my little secret?</p><p><em>Bring your ears closer so that I can whisper. This is only beween you and I, promise? I trust you’d tell no one… not even Mama.</em></p><p>In a hushed voice…</p><p>I registered for my first competition with a name no one can trace to me!</p><p>Yeah, it was that bad. I felt I knew nothing and didn’t want everyone to know about it.</p><p>But you know what?</p><p>Things are very different now.</p><p>Again, don’t sweat it if you find yourself forgetting what you’ve learnt before or having to check up other people’s codes. Everybody faced the same problem. But if you remain consistent at learning, you’d find yourself writing your own codes!</p><p><strong>Step 4: Learn some statistical and linear algebra basics</strong></p><p>Now, you really must <strong><em>remember the rule</em></strong>. <strong><em>Enjoy this step</em></strong>!</p><p>Yeah. Some people would say this should be step three. Really, if you can, carry on with step three and four concurrently. But if you’re like me, you are very curious so you start machine learning before going into any stats or algebra.</p><p>For algebra, I absolutely love <a href="https://www.youtube.com/watch?v=LHsPJ2bQX1U&amp;list=PLl-gb0E4MII03hiCrZa7YqxUMEeEPmZqK">Kimberly Brehm</a>. I was glued to her channel when I was learning algebra. She also has videos on statistics.</p><p>My stats favourite is <a href="https://www.youtube.com/c/zedstatistics/playlists">Justin Zeltzer</a>. He is excellent at giving intuitions. From probability to regression, you will have all you need.</p><p>Remember that there are also structured courses on Coursera, Udemy, Udacity on both statistics and linear algebra.</p><h4><strong>Step 5: Explore!</strong></h4><p>If you have followed through steps one to four, then you are set for exploration.</p><p>The ideas coming to your head aren’t crazy. If you can think it, there is a high chance it can be done.</p><p>Let’s call it a day today.</p><p>See you soon…</p><p><strong><em>Your favourite ML blogger,</em></strong></p><p><strong><em>Success Vera</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc8c171075d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Letter to Math Teachers]]></title>
            <link>https://ifysuccessvera.medium.com/a-letter-to-math-teachers-852063beb863?source=rss-3714aab440ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/852063beb863</guid>
            <dc:creator><![CDATA[Ifeoma Veronica Nwabufo]]></dc:creator>
            <pubDate>Tue, 02 Feb 2021 15:14:21 GMT</pubDate>
            <atom:updated>2022-10-16T18:36:25.097Z</atom:updated>
            <content:encoded><![CDATA[<p>Dear Math Teacher,</p><p><strong>Helping Students Love Mathematics</strong></p><p>As a mathematician, it is worrisome to me that students are afraid of mathematics. And I am not completely out of those in that category. That’s why I decided to write to all math teachers all over the globe, of which I am part…</p><p>In elementary school, you hear many pupils say that their favorite subject is mathematics. Then that number decreases when they get to high school. Then even more in the university. <strong>I think that the methodology of teaching math is what is responsible for these trends.</strong></p><p>Consider, for example, elementary school. The children are taught addition by counting sweets, which is what’s important to them. I think that’s what makes the whole subject interesting. The child thinks: “I can know how many sweets I have always if I just know how to count!” They have a motivation. So they love math and then learn it easily.</p><p>Then later, they go to high school and it is interesting until they see a lot of geometry and calculus. Then, they just say, “You know what, I have done a lot of mathematics already. Let’s stop here.”</p><p>P.S: I must actually say personally that high school math was very interesting to me.</p><p>Those who were bold enough to study math in university then come across giant lemmas and theories that they are supposed to understand and know why it works and sometimes, it doesn’t just make sense. They hear the teacher saying, “This is a beautiful proof.” And the student many times can’t see any beauty.</p><p><strong>What are my proposed solutions?</strong></p><ol><li><strong><em>Start the course with a motivation.</em></strong> Tell them what they will be able to do by the end of the class. As much as possible, make it interesting.</li><li><strong><em>Give an intuition of the topic.</em></strong> Before all the equations are written on the board, give an intuition of the topic. Let them see it without the ‘equation lens’.</li><li><strong><em>See how to bring real-life applications to what you teach.</em></strong> I understand that some concepts are really abstract, especially in college. But try to see if there are real-life applications to them.</li><li><strong><em>Give as many in-class quizzes as possible</em></strong>. And give the solutions too after they are done. It helps to build confidence.</li><li>As much as possible,<strong><em> encourage the students</em></strong> by telling them that they are doing well and can do better.</li><li>There is something I call ‘The Compound Effect of Mathematics’. Many concepts in math have their applications in later classes.<strong><em> Please, try to finish the syllabus</em></strong> so that they can be well prepared for the later classes.</li><li>This is the last and probably the most important. <strong><em>Explain the math concepts like you were talking to your five-year-old sibling.</em></strong></li></ol><p>I strongly believe in the simplicity of life. And I think that we as math teachers should help keep it that way. Let’s make life simple.</p><p>I hope that this letter finds relevance and helps us to be better math teachers in whatever capacity we teach.</p><p>Ifeoma Veronica Nwabufo</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=852063beb863" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>