<?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 Maaz_Bin_Asad on Medium]]></title>
        <description><![CDATA[Stories by Maaz_Bin_Asad on Medium]]></description>
        <link>https://medium.com/@maazbinasad29?source=rss-f454a7df6f40------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ltLg5gNIccnNSp73</url>
            <title>Stories by Maaz_Bin_Asad on Medium</title>
            <link>https://medium.com/@maazbinasad29?source=rss-f454a7df6f40------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 04:57:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@maazbinasad29/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[A brief insight into conditional probability]]></title>
            <link>https://maazbinasad29.medium.com/a-brief-insight-into-conditional-probability-74d78dbfdc2e?source=rss-f454a7df6f40------2</link>
            <guid isPermaLink="false">https://medium.com/p/74d78dbfdc2e</guid>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[probability]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Maaz_Bin_Asad]]></dc:creator>
            <pubDate>Wed, 03 Feb 2021 15:10:02 GMT</pubDate>
            <atom:updated>2021-02-03T15:10:02.925Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Before you go further</strong></p><p>Event in probability is just a non-deterministic output of some random experiment. Tossing a coin is a random experiment whose output is an event and it cannot be determined before tossing it. Therefore, it is a non-deterministic machine experiment. Generating a random number using a code in computer is deterministic because it uses some algorithm behind curtains whose output can be determined using certain practices. Tossing a coin never uses an algorithm behind it. You just flip it and get output.</p><p><strong>Dependent and Independent events</strong></p><p>Output of a dependent event depend on some other event. For instance, if a bag contains 5 black balls and 5 red balls, you pick any ball from the bag. Next time when you pick some ball from the bag, it will depend on previous event because the probability of second time ‘picking a ball’ is depending on previous event that too was ‘picking a ball’ . In other words, the probability of second time ‘picking a ball’ is changed due to first event. Independent events can be tossing a coin two times. The output in both experiments won’t depend on each other. In other words, probability in second event won’t change due to previous one.</p><p><strong>Conditional</strong> <strong>Probability</strong></p><p>Suppose we have two events A and B. Then, the probability of both events happening at the same time is given by — P(A and B).</p><p>For independent events, P(A and B)= P(A)*P(B) — (i)</p><p>Suppose, A and B are dependent events now . The probability of one of them will now be depending on other event. More formally, the probability of one of them will change depending on other, as discussed previously. The equation (i) now becomes P(A and B)=P(A)*P(B|A) which means probability of event B will change in our case due to event A. The symbol ‘|’ just denotes that probability of event B is not the same now, it has changed due to event A. Note that we could also write probability of event A depending on event B. They both mean the same. Previous equation can also be written as P(B|A)=P(A and B)/P(A). This is the formula for conditional probability of event B, given that A has already been occurred. The Venn diagram below shows the concept more clearly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9fLG13bo-_empxadNAE5VA.jpeg" /></figure><p>The extension of conditional probability is the Bayes theorem that is one of the strongest algorithms in modern era. It can be applied in classification models like Email spam detection, Twitter sentiment classification and medical domain using Machine Learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74d78dbfdc2e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Assertions in programming]]></title>
            <link>https://maazbinasad29.medium.com/assertions-in-programming-2d2c139fc88c?source=rss-f454a7df6f40------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d2c139fc88c</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[secure-coding]]></category>
            <category><![CDATA[assertions]]></category>
            <dc:creator><![CDATA[Maaz_Bin_Asad]]></dc:creator>
            <pubDate>Sun, 13 Dec 2020 19:44:19 GMT</pubDate>
            <atom:updated>2020-12-13T19:51:26.449Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong></p><p>Managing your software is always more important than developing it. This requires following thousands of coding standards and handling hundreds of vulnerabilities and edge cases. One of the features of programming languages that helps you in your software development lifecycle is assertions. Assertions are logical functions to check whether particular requirement is met before code runs further. If that condition is not met, the program terminates and gives assertion error and doesn’t run further lines of code.</p><p><strong>Let’s dive more into it</strong></p><p>You wrote a code and assign a variable, let’s say <em>x</em> as 5. After few lines of random coding, if value of <em>x</em> somehow changes due to some wrong mathematical calculations, this can create problems further.</p><p>Suppose you have some potentially dangerous code starting from next line and if that code gets a value of <em>x</em> other than 5, your application will eventually get destroyed. To tackle this, just check if <em>x </em>actually contains 5 before moving on to that dangerous code.</p><blockquote>Assertions are this much easy</blockquote><p>Use following syntax in C++ to check above logic — assert(<em>x==5);</em></p><p>If above function is correct, code goes further pretty fine, else it stops right here and throws assertion error.</p><p><strong>Why don’t use Exception handling instead of assertions</strong></p><p>Exception handling is not preferred for checking logical correctness of statements. For instance, while receiving data from an API in your software, you can apply exception handling to <strong><em>try </em></strong>something if data is received, <strong><em>except </em></strong>do other thing, while assertion would check if some object contains the value, that further code asks for.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d2c139fc88c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Statistical Mathematics for dimensionality reduction in data science.]]></title>
            <link>https://maazbinasad29.medium.com/statistical-mathematics-for-dimensionality-reduction-in-data-science-92985148a2e4?source=rss-f454a7df6f40------2</link>
            <guid isPermaLink="false">https://medium.com/p/92985148a2e4</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[math]]></category>
            <dc:creator><![CDATA[Maaz_Bin_Asad]]></dc:creator>
            <pubDate>Thu, 12 Nov 2020 17:14:00 GMT</pubDate>
            <atom:updated>2020-11-12T17:17:28.687Z</atom:updated>
            <content:encoded><![CDATA[<h4>What I will discuss:</h4><ul><li>What is feature engineering and dimensionality reduction</li><li>Variance and Central Tendency (Mean)</li><li>Covariance</li><li>How can you use this in Machine Learning</li><li>Conclusion</li></ul><h4>Feature Engineering and dimensionality reduction</h4><p>Feature engineering is probably one of the most crucial step that you need to take before processing the input matrices of features in Machine Learning model. Feature engineering aims at figuring out the relations and properties of different random variables or features in dataset. Random variable is simply the set of outcomes of non-deterministic machine or random experiment(like throwing a dice). This can likely help us in removing the features that do not contribute in target variable. This is also called dimensionality reduction. Dimensionality reduction is a must skill to have for data science and machine learning. It also reduces time and space complexity of algorithms by considerable amount.</p><figure><img alt="The cylinder is converted from 3-D to 2-D removing one dimension and further" src="https://cdn-images-1.medium.com/max/541/1*PVbqfXzLPZVuaCDyozr14w.jpeg" /><figcaption>Cylinder is converted from 3-D to 2-D and then further.</figcaption></figure><p>Dimensionality reduction is categorized as — supervised and unsupervised. I will be putting light on supervised technique here. Unsupervised technique consists of algorithms like Principal Component Analysis (PCA) and Singular Value Decomposition(SVD) that I will discuss in upcoming blog.</p><h4>Variance and Central tendencies</h4><p>Central tendency is the typical value of some probability distribution that attempts to describe the data in a single value. They are mean, median and mode. Most common central tendency is a familiar term mean. Mean or average is the sum of all values in given data divided by the number of data points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*oR8qxUxwvPGaAyMPFYeBew.gif" /></figure><p>One common data distribution is gaussian distribution (or normal distribution) that I take as an example here. Gaussian distribution makes a bell-shaped curve when probability density vs data points graph is plotted. The central line is the mean.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*AYsUOvPkgxe3j1tEj2lQbg.gif" /></figure><p>Variance is simply the average of squared differences from mean. We take square so that negatives are not cancelled by positives. This simply means — on an average, how far data is spread from mean value. The mathematical representation of sample variance is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*qHbfszLNxUvjt-Ze9L9g3Q.png" /><figcaption>Sum of square of differences divided by number of points</figcaption></figure><h4>Covariance</h4><p>Like variance, covariance is also the measure of how far data is distributed, but takes two variables into consideration. The formula remains same and just one of the ‘x’ in squared term is changed to ‘y’ because here we have two random variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*lDxMik8iwQvsEQLG1-9-KA.png" /></figure><p>We can notice here that if (‘<em>x</em>’-x) is positive and (‘y’-y) is negative, the random variables are inversely proportional to each other. Therefore, they have negative covariance. If both are positive, one increases with another and covariance is positive. At last, if any of them is zero means one has no effect while other is increasing or decreasing. This implies no relation between two random variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/170/1*vy99qs9uhpQWuHisoIoL4Q.png" /><figcaption>Three cases of covariance</figcaption></figure><p>The covariance method is also available in Python Numpy library that takes two random variables as argument and gives result.</p><h4>How to use this in Machine Learning.</h4><p>The covariance can be found out between target variable and any other random variable or feature by several python methods and libraries (Matplotlib, Numpy..). The variables that have covariance very close to zero can be removed from dataset because they do not have an impact on target variable. For example, when you are predicting whether a customer will buy some product or not, we can drop customer ID. Note that two variables that are linearly dependent on each other can also create problems. It is always good to drop one of them. For example, meter and feet are linearly dependent and means same thing which is distance. We can drop one of them.</p><h4>Conclusion</h4><p>Dimensionality reduction simply means reducing the number of features that can create problems for our model. For this, you need to do some statistical Maths and make your model run efficiently. Other techniques for dimensionality reduction are yet to come.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=92985148a2e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Norms in Linear Algebra]]></title>
            <link>https://maazbinasad29.medium.com/norms-in-linear-algebra-6d6b7adc4643?source=rss-f454a7df6f40------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d6b7adc4643</guid>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[linear-algebra]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Maaz_Bin_Asad]]></dc:creator>
            <pubDate>Fri, 24 Jul 2020 15:32:09 GMT</pubDate>
            <atom:updated>2020-07-24T15:36:31.809Z</atom:updated>
            <content:encoded><![CDATA[<p>There exist hundreds of applications where you need to find the length or magnitude of a certain vector whether it being a school physics problem statement, a real life scenario or even the Machine Learning itself. Magnitude of vectors have solved many problems, especially in Machine Learning that have helped advance the development of models. I will discuss one such application in this article itself, which is <a href="https://en.wikipedia.org/wiki/Regularization_(mathematics)#:~:text=In%20mathematics%2C%20statistics%2C%20and%20computer,problem%20or%20to%20prevent%20overfitting.">regularization</a>. Let’s dive into the norms of vectors.</p><h3>Introduction</h3><p>Norm is nothing but the magnitude or length of a vector in a vector space. A vector can be represented in a space similar to this figure</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/267/1*VCh-zoFxRUMUxitL8UNbSA.png" /><figcaption>The black arrow represents the vector which has some length</figcaption></figure><p>This vector has some length in a vector space. Suppose, we say that the length of this vector is 5 units. Likewise, we say that the norm of this vector is 5 units</p><h3>How to find norm of a vector</h3><p>In this section, I will introduce three methods to find norm of a vector. Yes! the one you might have studied in your school textbooks is not only the one.</p><h4>L1 Norm</h4><p>The first is the L1 norm of a vector that is found by <a href="https://xlinux.nist.gov/dads/HTML/manhattanDistance.html#:~:text=Definition%3A%20The%20distance%20between%20two,y1%20%2D%20y2%7C.&amp;text=Lm%20distance.">Manhattan distance</a> of vector from the origin of vector space. The geometry that uses Manhattan distance for finding distances between points is Taxicab geometry. Let’s find a norm of a vector that is v = [ 1 2 3 ]. This vector can also be represented as i+2j+3k, where i,j,k are unit vectors along three axes in space. Mathematical representation of L1 norm is ||v||1. The norm of this vector is given by sum of absolute values of each scalars which are 1,2 and 3 in our case. Mathematically, ||v||1 = |1| + |2| + |3| which gives 6. Notice that this is nothing but Manhattan distance from origin if we represent scalars as |1–0| + |2–0| + |3–0|. L1 norm can be added to loss functions in Machine Learning to apply L1 regularization to prevent over fitting in models. The mathematical equation to add L1 norm to loss function being</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*5yoeLSZ1JhNXNM_GWcqxGA.png" /><figcaption>We are just adding L1 norm to squared loss function</figcaption></figure><h4>L2 Norm</h4><p>Now comes the L2 norm. This is one of the most commonly used method to find norms of vectors. Taking same example, let our vector be [ 1 2 3 ]. The L2 norm of this vector is represented by ||v||2 that equates to sqrt(1²+2²+3²) that results in something like 3.74. Of course, the magnitude has changed in this method but it still represents norm. In this case, we calculate Euclidean distance from origin. For intuition, I am representing the equation as sqrt((1–0)²+(2–0)²+(3–0)²). This statement might look familiar now. Regularization technique can be applied with this norm as well</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*qjg75H_U2Qt23isP2L6lYA.png" /><figcaption>Again, just adding L2 norm to squared loss function</figcaption></figure><h4>The value of norms cannot be negative right! (unless there is some relativity theory that refutes this point)</h4><h4>Vector Max Norm</h4><p>Third one is the vector max norm that states that maximum of the given scalars (taking their absolute values) is the norm itself. In our previous case, it’s 3 right! For example, in a vector, v1=[ 1 -4 2 ], it is 4.</p><h4>Conclusion</h4><p>If you are asked to find norms of the vectors, just ask the questioner to specify the method from above three and implement the algorithm to find it. You will find nothing but the length of that particular vector in vector space.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d6b7adc4643" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Object Oriented Programming | Set 1 (Introduction)]]></title>
            <link>https://maazbinasad29.medium.com/object-oriented-programming-set-1-introduction-26fc7ef69e89?source=rss-f454a7df6f40------2</link>
            <guid isPermaLink="false">https://medium.com/p/26fc7ef69e89</guid>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Maaz_Bin_Asad]]></dc:creator>
            <pubDate>Sat, 20 Jun 2020 10:17:39 GMT</pubDate>
            <atom:updated>2020-06-20T10:17:39.921Z</atom:updated>
            <content:encoded><![CDATA[<p>Object oriented programming or so called oops, is a paradigm of programming languages that deals with objects being created under particular class consisting of some functions or methods that can be performed for every object passed into class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*IRhWSTRy_1WZ1tJLuZNf4w.gif" /></figure><p>I know this was a bit technical explanation though of this concept. Let’s dive into what actually they mean, when they say “<strong>oops</strong>”. Let’s say, you got a pressure gauge to measure tyre pressure of an Audi car. You note down the pressure, you bring another pressure gauge, you measure the pressure of Lamborghini this time and bring a new gauge for next cars and so forth. Yes ! It sounds stupid to me also. Even if it’s feasible for some Bill Gates kind of person, still; managing your work is more important than completing it with makeshift. So, it’s pretty obvious that a person should use same pressure gauge for different cars he operate on. Okay ! Enough of practical example. Let’s relate it with programmable oops now. Your car is the class, object is your Audi, Lamborghini, etc. and that pressure gauge is your method or function of that class. Now, for running a particular method on any object you just need to call that particular method for that object. Whenever you are in need to run a method on particular object, you can just enclose it inside a class an enjoy running it on million different objects belonging to same class. The work just got easy right !</p><p>The sample code snippets of C++ and python respectively, for above concepts being</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*7DE1mGdCKFLbVuGHKRuaaw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/1*WaNjAOrAF3jIHqpqAhE2JQ.jpeg" /></figure><h3>Abstraction</h3><p>As discussed earlier, you needed a pressure gauge to measure the pressure of respective objects right ? Moreover, you were able to measure the pressure without knowledge of working principle behind this gauge. The laws used for measuring the pressure were hidden from you and still, the instrument worked pretty fine. This hiding of working algorithms behind some method and allowing you to only access that particular method is what we call abstraction. Taking an example from python, you must have probably used a method in Python called ‘.<strong>sort()</strong>’. This method sorts the given list for you. However, you were using this method without even knowing what sorting algorithm could have been doing this task for you. This is abstraction for you !</p><h3><strong>Encapsulation</strong></h3><p>The principle used inside pressure gauge is analogous to the algorithm written in .sort() method discussed earlier.<br>&quot;<strong>The Bourdon pressure gauge uses the principle that a flattened tube tends to straighten or regain its circular form in cross-section when pressurized. ... Differential pressure can be measured by gauges containing two different Bourdon tubes, with connecting linkages.</strong>&quot; <br>The above definition is what I found from Google. This working principal written in the method that we access from the object is enclosed in a class. By the way, the algorithm used in .sort() method in Python is TimSort and many of you use this method without needing the knowledge of TimSort algorithm. This is encapsulation for you !</p><p>Below is the pictorial explaination for abstraction and encapsulation for ya !</p><p>You use your touch screen mobile phones without needing the knowledge of touch sensors and capacitors that actually do this task for you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*KWOpptqMT188x1ogacxplQ.jpeg" /></figure><h3><strong>Conclusion</strong></h3><p>The object oriented programming does make operations easier and understandable and for obvious reasons, find it’s applications in wide variety of development. Besides, it helps open source developers as well, because of the readability of the code and less effort to alter and create big things.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26fc7ef69e89" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Matrix | The Vector of Intelligence]]></title>
            <link>https://maazbinasad29.medium.com/matrix-the-vector-of-intelligence-7305430b9602?source=rss-f454a7df6f40------2</link>
            <guid isPermaLink="false">https://medium.com/p/7305430b9602</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[mathematics]]></category>
            <dc:creator><![CDATA[Maaz_Bin_Asad]]></dc:creator>
            <pubDate>Mon, 18 May 2020 09:21:55 GMT</pubDate>
            <atom:updated>2020-05-18T09:35:41.775Z</atom:updated>
            <content:encoded><![CDATA[<p>When we hear the word &#39;matrix&#39; , it pretty much draws an intuition of a rectangular array of numbers or that’s what the books call it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*B1rwVx7d1pYujTgPqHVq3g.png" /></figure><p>When studying the chapter of Matrix in school mathematics, who might have guessed that this rectangular representation of numbers is what AI is hunting for. For better intuition of how a matrix deals with Machine Learning, let’s say you have &#39;m&#39; number of features of an object that you want your Machine Learning algorithm to look, for classifying that object as either &#39;A&#39; or &#39;B’. If we represent these features as a column vector, then we say that this vector is one - dimensional column matrix containing features that will classify our model into either of above mentioned categories. Now, can we classify an unknown object into a category by looking at just one feature example? The concept is pretty straight forward here. We need, maybe thousands of similar features that identify the object as either being &#39;A&#39; or &#39;B’. Let’s extend the number of columns to &#39;n’ each containing the features of object. Now, we have a data matrix, say &#39;A’, of order m x n having each column as a feature vector and rows as the training examples.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*QpMkmnPmYtETTOp6jINykg.png" /></figure><p>For instance, take a shallow neural network having only one hidden layer as our classifier and the hidden layer comprises of four neurons. One of the feature columns, say ‘x’, containing x1,x2,x3 .. upto xm is picked from the matrix and we initialize a radom matrix &#39;w&#39; of order 4 x m which is called the weight matrix. The dot product of weight matrix and the column vector is added to another randomly initialized matrix &#39;b&#39; known as bias. Note that the dimensions of‘b’ are (4,1) because the resultant matrix of dot product of w(4,m) and x(m,1) has the dimensions (4,1). The resultant matrix, say &#39;a’, is passed into an activation function (preferably sigmoid function in case of a shallow network) that maps each element of matrix to the function. The sigmoid function binds every element within the range [0,1]. Notice that there does not exist any vertical asymptote of this function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/257/1*gYcX1-5yXWQaf5oM18kQlg.png" /></figure><p>The work we did so far looks pretty much like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*jd3T-pRar3-e3j7H_jluxg.jpeg" /></figure><p>The same procedure is repeated in the next layer of the network that finally classifies the features into one of the classes. The output can be processed with softmax function which distributes the outputs on the basis of probabilities. The mean absolute error is calculated in prediction and then the backpropagation algorithm comes into play to make the neural network learn.</p><h3><strong>Conclusion</strong></h3><p>It seems that the definition &#39;rectangular representation&#39; holds good in Machine Learning as well. The matrix is one of the most important concept required in the field of linear algebra that contributes towards Machine Learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7305430b9602" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>