<?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 Zeros &amp; Ones! on Medium]]></title>
        <description><![CDATA[Stories by Zeros &amp; Ones! on Medium]]></description>
        <link>https://medium.com/@swarnpriyaswarn?source=rss-5088565aa9f1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Kt2aILGEPm1wrPspQbhHgQ.jpeg</url>
            <title>Stories by Zeros &amp;amp; Ones! on Medium</title>
            <link>https://medium.com/@swarnpriyaswarn?source=rss-5088565aa9f1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 23:36:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@swarnpriyaswarn/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[Why Naïve-Bayes Theorem is best for Text Analysis?]]></title>
            <link>https://medium.com/@swarnpriyaswarn/why-na%C3%AFve-bayes-theorem-is-best-for-text-analysis-f1a15b0c6056?source=rss-5088565aa9f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1a15b0c6056</guid>
            <category><![CDATA[naive-bayes]]></category>
            <category><![CDATA[text-analytics]]></category>
            <dc:creator><![CDATA[Zeros & Ones!]]></dc:creator>
            <pubDate>Wed, 19 Jul 2023 04:03:47 GMT</pubDate>
            <atom:updated>2023-07-19T04:03:47.684Z</atom:updated>
            <content:encoded><![CDATA[<p>Well, well, this is one question which lingered in my mind for a very very long time. Lets get cracking:</p><p>Among the various algorithms available, Naïve Bayes has proven to be a popular and effective choice for text analysis tasks. Why?</p><p>Few Advantages:</p><ol><li><strong>Simple </strong>: Naïve Bayes is a simple algorithm and has faster training and prediction times compared to more complex algorithms, making it highly efficient for large-scale text analysis tasks.</li><li><strong>Effective Handling of High-Dimensional Data</strong>: Text analysis often involves working with high-dimensional data, where each word or term in a document can be considered as a feature. Naive Bayes is well-suited to handle such data due to its ability to work with a large number of features efficiently. The algorithm calculates the probability of a class given the presence of a particular feature independently for each feature, which allows it to handle high-dimensional data with relative ease.</li><li><strong>Interpretability and Explainability</strong>: Another advantage of Naïve Bayes is its interpretability and explainability. The algorithm provides straightforward probabilistic outputs, allowing users to understand and interpret the results easily.</li><li><strong>BEST REASON: </strong>Naïve Bayes runs on the basic fundament that we find out probability of a event based on the another which has already occurred…meaning if we take example of spam and ham, we train the model that given that “Congratulation, Bank, Details, like words” the mails were marked as spam. So, you see…given that one kind of word is present in the mail, mail is going to be labelled as spam or ham.</li></ol><p>It is the simplest way I could put in. Hope this helps.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1a15b0c6056" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Probability!!!]]></title>
            <link>https://medium.com/@swarnpriyaswarn/probability-983f918de36b?source=rss-5088565aa9f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/983f918de36b</guid>
            <category><![CDATA[probability]]></category>
            <category><![CDATA[bayes-theorem]]></category>
            <category><![CDATA[terminology]]></category>
            <dc:creator><![CDATA[Zeros & Ones!]]></dc:creator>
            <pubDate>Thu, 16 Mar 2023 10:47:58 GMT</pubDate>
            <atom:updated>2023-03-16T10:47:58.218Z</atom:updated>
            <content:encoded><![CDATA[<p>Couldn’t help starting this blog with the below quote:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*mDuJiOtd77ed_4RR.jpg" /><figcaption>Photo Credit : Google Mata Ji</figcaption></figure><p>So, what’s the probability of anything? It’s simple. Tell me all the possible occurrences of anything — the answer lies there! And that’s it!!</p><p>Lets learn the probability language:</p><p><em>Event</em> — A favorable outcome which we want, like flipping of head or tail.</p><p><em>Probability </em>— Likelihood of an event = no. of favorable outcome/no. of total possible outcome</p><p><em>Random</em> — Not in a synchronized manner</p><p><em>Sample </em>— Event</p><p><em>Population</em> — All possible occurrences — Also known as Sample Space</p><p><em>Union, Intersection and Complement </em>::</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/306/1*Kttj0lU145C7rTXHZMNAQQ.png" /></figure><p><em>Independent Event: </em>Any event occurs without any pre-notion. Like flipping a coin or throwing a dice to get a 6.</p><p><em>Dependent Event: </em>When an event is dependent on something..for example Going to the market if it is sunny, playing out if it doesn’t rain. Getting a blue ball after a red one…and so on. Where one event should occur, so that other occurs.</p><p><em>Conditional Probability: </em>P(A|B) =Probability of event(A given B) = P(A ∩ B)/ P(B)</p><blockquote><strong>MOST IMPORTANT CONCEPT: BAYES Theorem:</strong></blockquote><p>This is the basis one of the important machine learning algorithm — Naïve Bayes Theorem.</p><p>Formulae for Bayes Theorem :</p><p>P(A|B) = (P(B|A) * P(A)) / P(B)</p><p>P(A|B) is called Posterior — likelihood of A given B</p><p>P(B|A) — likelihood of B given A</p><p>P(A) in the numerator — Prior (Probability without any condition)</p><p>P(B) in the denominator is called Evidence/Marginal.</p><p>Question on Bayes Theorem:</p><p>If there are three machines A,B,C. Total 1000 items are produced. Three machines production percentage and error percentage is given.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/302/1*y2VTygI4forrufyQ9HhRxQ.png" /></figure><p>As we know that there are 1000 items, we can calculate the production amount and the related error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*12as8_mDyzSCWA5BKQktGw.png" /></figure><p>So, till here we know these information. With this we know, how much defective items are being produced by the three machines. But if we have to find out the probability of defective piece being is from the machine C.</p><p>Solution:</p><p>P(C|D) = (P(D|C) *P(C)) /P(D)</p><p>P(D|C) = Probability of defective given machine C, we know = 0.01</p><p>P(C) = Probability of production of machine C = 0.5</p><p>P(D) = Probability of Defective piece = P(A)*P(D|A) + P(B)*P(D|B) +P(C)*P(D|C) = 0.2*0.05 + 0.3*0.03 + 0.5*0.01 = 0.024</p><p>Putting all in the formulae = (0.01*0.5)/0.024 = 0.208</p><p>Probably you all will understand, or not!! Happy Learning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=983f918de36b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The “*” Patterns Programs!]]></title>
            <link>https://medium.com/@swarnpriyaswarn/the-patterns-programs-85b3ac93c302?source=rss-5088565aa9f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/85b3ac93c302</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[patterns]]></category>
            <dc:creator><![CDATA[Zeros & Ones!]]></dc:creator>
            <pubDate>Tue, 07 Mar 2023 00:20:04 GMT</pubDate>
            <atom:updated>2023-03-07T00:20:04.322Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>Question 1. The * pattern which we want is as below:</strong></blockquote><pre>*<br>**<br>***<br>****</pre><p>Solution: The code for the same is:</p><pre>for i in range(1,5):<br>    for j in range(1,5):<br>        if i &gt;= j:<br>            print(&quot;*&quot;,end=&quot;&quot;)<br>    print()</pre><p>Explanation: We are taking i and j range 1 to 5, we can also take it from 0 to 4. (1,2,3,4 or 0,1,2,3 will be executed respectively).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kILRvH9IEB-ImrFZXG2kNw.jpeg" /></figure><p>when i = 1, j prints * once, at position 1</p><p>when i =2, j prints * twice, at position 1 and 2</p><p>when i =3, j prints * thrice, at position 1,2 and 3</p><p>when i =4, j prints * four times, at position 1,2, 3 and 4</p><p>It is very simple, j prints * as i number time and at positions less than i.</p><p>Therefore, if i ≥ j : the loop will print *.</p><blockquote><strong>Question 2. The * pattern which we want is as below:</strong></blockquote><pre>   *<br>  **<br> ***<br>****</pre><p>Solution : The code for the same is:</p><pre>for i in range(1,5):<br>    for j in range(1,5):<br>        if j &gt;= 5- i:<br>            print(&quot;*&quot;,end=&quot;&quot;)<br>        else:<br>           print(&quot; &quot;,end=&quot;&quot;)<br>    print()</pre><p>Explanation: We are taking i and j range 1 to 5, we can also take it from 0 to 4. (1,2,3,4 or 0,1,2,3 will be executed respectively).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*plt7WiJljYGxwN7AoG8DIQ.jpeg" /></figure><p>As per the logic,</p><p>i = 1, j should print ___* :: if j ≥ 5-i, print(“*”) else print(“ “) :::</p><p>(short execution: : when i = 1: for j = 1 to 5,</p><p>1≥ 5–1(4) , _</p><p>2 ≥ 5–1(4), __</p><p>3 ≥ 5–1(4)___</p><p>4≥ 5–1(4)___*)</p><p>i = 2, j should print __**</p><p>(short execution: : when i = 2: for j = 1 to 5,</p><p>1≥ 5–2(3) , _</p><p>2 ≥ 5–2(3), __</p><p>3 ≥ 5–2(3)__*</p><p>4≥ 5–2(3)__**)</p><p>i = 3, j should print _***</p><p>(short execution: : when i = 3: for j = 1 to 5,</p><p>1≥ 5–3(2) , _</p><p>2 ≥ 5–3(2), _*</p><p>3 ≥ 5–3(2)_**</p><p>4≥ 5–3(2)@_***)</p><p>i = 4, j should print ****</p><p>(short execution: : when i = 4: for j = 1 to 5,</p><p>1≥ 5–4(1) , *</p><p>2 ≥ 5–4(1), **</p><p>3 ≥ 5–4(1)***</p><p>4≥ 5–4(1)@****)</p><blockquote><strong>Question 3. The * pattern which we want is as below:</strong></blockquote><pre>****<br>*** <br>**  <br>*</pre><p>Solution: The code for the same is:</p><pre>for i in range(1,5):<br>    for j in range(1,5):<br>        if j&lt;= 5-i:<br>            print(&quot;*&quot;,end=&quot;&quot;)<br>        else:<br>            print(&quot; &quot;,end=&quot;&quot;)<br>    print()</pre><p>Explanation: We are taking i and j range 1 to 5, we can also take it from 0 to 4. (1,2,3,4 or 0,1,2,3 will be executed respectively).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QeF3opV7ej3mTm4Um1wStw.jpeg" /></figure><blockquote><strong>Question 4. The * pattern which we want is as below:</strong></blockquote><pre>****<br> ***<br>  **<br>   *</pre><p>Solution: The code for the same is:</p><pre>for i in range(1,5):<br>    for j in range(1,5):<br>        if j &gt;= i:<br>            print(&quot;*&quot;,end=&quot;&quot;)<br>        else:<br>            print(&quot; &quot;,end=&quot;&quot;)<br>    print()</pre><p>Explanation: We are taking i and j range 1 to 5, we can also take it from 0 to 4. (1,2,3,4 or 0,1,2,3 will be executed respectively).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3p6bcEWkbjS1uFmBZOmtQA.jpeg" /></figure><blockquote><strong>Question 5. The * pattern which we want is as below:</strong></blockquote><pre>    *   <br>   ***  <br>  ***** <br> *******</pre><p>Solution: The code for the same is:</p><pre>import numpy as np<br><br>num1 = [1,2,3,4,5,6,7,8]<br>hld=int(np.median(num1))<br># print(hld)<br><br>for i in range(4):<br>    for j in range(len(num1)):<br>         if j &gt; hld - i and j &lt; hld + i:<br>            print(&quot;*&quot;,end=&quot;&quot;)<br>        else:<br>            print(&quot; &quot;,end=&quot;&quot;)<br>            <br>    print()</pre><p>Explanation: Here, a library is used — NumPy for finding out the middle point of the given array.</p><p>Once we know the middle point, we know the * sign should be in a triangular way, 1 increasing on each side of the middle point. So, we print the *, for the following condition :</p><p>j &gt; hld — i and j &lt; hld + i:</p><p>for i = 1, hld = 4:</p><p>j=1:: 1&gt;3 and 1&lt; 5, so printing _ at position 1 (Condition1 False so Execute Else)</p><p>j=2:: 2&gt;3 and 2&lt; 5, so printing __ at position 2 (Condition1 False so Execute Else)</p><p>j=3:: 3&gt;3 and 3&lt; 5, so printing ___ at position 3 (Condition1 False so Execute Else)</p><p>j=4:: 4&gt;3 and 4&lt;5, so printing ___* at position 4 (Condition1 True and condition 2 True so Execute if)</p><p>j=5:: 5&gt;3 and 5&lt; 5, so printing ___*_ at position 5 (Condition1 True and condition 2 False so Execute else)</p><p>j=6:: 6&gt;3 and 6&lt;5, so printing ___*__ at position 6 (Condition1 True and condition 2 False so Execute else)</p><p>j=7:: 7&gt;3 and 7&lt;5, so printing ___*___ at position 7 (Condition1 True and condition 2 False so Execute else)</p><p>and so on.</p><blockquote><strong>Question 6. The * pattern which we want is as below:</strong></blockquote><pre> *******<br>  ***** <br>   ***  <br>    * </pre><p>Solution: The code for the same is:</p><pre>import numpy as np<br><br>num1 = [1,2,3,4,5,6,7,8]<br>hld=int(np.median(num1))<br># print(hld)<br>m = 3<br><br>for i in range(4):<br>    for j in range(len(num1)):<br>        if j &gt;= hld - m and j &lt;= hld + m:<br>            print(&quot;*&quot;,end=&quot;&quot;)<br>        else:<br>            print(&quot; &quot;,end=&quot;&quot;)<br>    m =m- 1   <br>    print()</pre><p>Explanation: Here, a library is used — NumPy for finding out the middle point of the given array.</p><p>Once we get the middle value, a bit of hard coding is done. Have taken m =3 and will be decreasing it by 1 as we go, cause we wanted entire row to be printed in the first row and further it should decrease. Also, there are only 4 rows we want. By the time it comes to 4th row, m’s value will become 0.</p><p>More explanation:</p><p>for i = 1, hld = 4, m=3 : for different values of j : j &gt;= hld — m and j &lt;= hld +m:</p><p>j = 1: 1 ≥1 and 1≤7, printing * at position 1 (both conditions are true)</p><p>j = 2: 2≥1 and 2≤7, printing ** at position 2 (both conditions are true)</p><p>j = 3: 3≥1 and 3≤7, printing *** at position 3 (both conditions are true)</p><p>j = 4: 4≥1 and 4≤7, printing **** at position 4 (both conditions are true)</p><p>j = 5: 5≥1 and 5≤7, printing ***** at position 5 (both conditions are true)</p><p>j = 6: 6≥1 and 6≤7, printing ****** at position 6 (both conditions are true)</p><p>j = 7: 7≥1 and 7≤7, printing ******* at position 7 (both conditions are true)</p><p>When we go further, one of the condition will become false and _ will be printed.</p><blockquote><strong>Question 7. The * pattern which we want is as below:</strong></blockquote><pre>*******<br>*** ***<br>**   **<br>*     *</pre><p>Solution: The code for the same is:</p><pre>for i in range(1,5):<br>    for j in range(1,8):<br>        if j &lt;= 5 - i or j&gt;= 3 + i:<br>            print(&quot;*&quot;,end=&quot;&quot;)<br>        else:<br>            print(&quot; &quot;,end=&quot;&quot;)<br>    print()</pre><p>Explanation: Tried to generalize this code, but had to hard code it…If any one can help me to generalize, it would be great. Nevertheless, this code works perfectly fine.</p><blockquote><strong>Question 8. The * pattern which we want is as below:</strong></blockquote><pre>1<br>12<br>123<br>1234</pre><p>Solution: The code for the same is:</p><pre>for i in range(2,6):<br>    for j in range(1,i):<br>        print(j,end=&quot;&quot;)<br>        <br>    print()</pre><p>This is a easy one.</p><blockquote><strong>Question 8. The * pattern which we want is as below:</strong></blockquote><pre>1<br>12<br>123<br>1234</pre><p>Solution: The code for the same is:</p><pre>for i in range(2,6):<br>    for j in range(1,i):<br>        print(j,end=&quot;&quot;)<br>        <br>    print()</pre><p>This is a easy one.</p><blockquote><strong>Question 8. The pattern which we want is as below:</strong></blockquote><pre>1<br>12<br>123<br>1234</pre><p>Solution: The code for the same is:</p><pre>for i in range(2,6):<br>    for j in range(1,i):<br>        print(j,end=&quot;&quot;)<br>        <br>    print()</pre><p>This is a easy one.</p><blockquote><strong>Question 9. The pattern which we want is as below:</strong></blockquote><pre>54321<br>4321<br>321<br>21<br>1</pre><p>Solution: The code for the same is:</p><pre>for i in range(1,6):<br>    for j in range(1,6):<br>        if j&lt;=6-i:<br>            print(7-j-i,end=&quot;&quot;)<br>    print()<br>    m = n-1</pre><p>This one is also quiet simple.</p><p>Hope it is easy for all!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85b3ac93c302" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[fit(), transform(), fit_transform(), predict() —The codes which does it all!!!]]></title>
            <link>https://medium.com/@swarnpriyaswarn/fit-transform-fit-transform-predict-the-codes-which-does-it-all-c1f4cc24a4da?source=rss-5088565aa9f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1f4cc24a4da</guid>
            <category><![CDATA[standard-deviation]]></category>
            <category><![CDATA[standardization]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[fit-transform]]></category>
            <category><![CDATA[mean]]></category>
            <dc:creator><![CDATA[Zeros & Ones!]]></dc:creator>
            <pubDate>Mon, 06 Mar 2023 00:21:09 GMT</pubDate>
            <atom:updated>2023-03-06T00:21:09.092Z</atom:updated>
            <content:encoded><![CDATA[<p>It may look very simple 2–3 lines codes which we have to use while we scale the data and when we run the model. But what does it do?</p><p>Well, some says easy way is — mug it up!! Afterall same sequence of codes are used in every project! But what if you get stuck…you forget the codes…some errors comes and you don’t know how to handle it or even why is it showing up?</p><p>Easy way is to understand it…..and you will never forget!</p><p>To start with this concept →</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xYe5ksN_h4kUjwDve9p42w.jpeg" /></figure><p>First and foremost it is important to understand that the raw data goes as input to two places — — to EDA and for the pre-processing data.</p><p>Another important thing is — Exploratory Data Analysis or EDA is an independent step. We do it for better understanding of the data. It’s output can explain us many hidden dependencies and relations. But the output doesn’t go anywhere. It is not related to any other process although it does explains a lot of thing.</p><p>While, raw data goes as input to data-preprocessing. The processed data goes as input in the model-training part.</p><blockquote><strong>Pre-Processing </strong>→ Transformation of data happens here. Few examples of pre-processing are:</blockquote><ul><li>Standard Scalar — This is the preprocessing technique where the data is processed or (as spoken in machine learning language) feature is scaled. What does that mean? Simple — it makes the mean = 0 and standard deviation = 1. It standardize the data using the z-test formulae = (x — mu)/std_dev</li><li>MinMax Scalar</li><li>PCA</li></ul><blockquote><strong>Model Training → </strong>Model Training is various algorithms which we apply on various pre-processed datasets. There are many algorithms which are used. Few examples are:</blockquote><ul><li>Random Forest</li><li>Decision Tree</li><li>Logistic Regression</li><li>Linear Regression</li><li>Adaboost</li><li>Clustering and many more.</li></ul><p>Having said and done with this much understanding, where does the fit() and all those codes comes in picture?</p><p>Here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rLLk89qWU8ZaWrC9aDJOEQ.jpeg" /></figure><p>Continuation of the above figure, giving you the overview of fit, transform and fit_transform.</p><p>(Predict is a simple code with simple explanation which we will study at the end.)</p><blockquote><strong>Pre-Processing — Use of fit(), transform() and fit_transform()</strong></blockquote><ul><li><strong>fit() — Use of this code:</strong></li></ul><pre>from sklearn.preprocessing import StandardScaler<br>scaler = StandardScaler()  #created an object of StandardScalar<br><br>-----------------------------------------------------------<br><br>df1[&#39;INCOME&#39;] = scaler.fit(df1[[&quot;INCOME&quot;]])  ## called the function of<br>#fit.</pre><p>Now, what does this fit() command does?</p><p>It basically calculates various parameters like — mean and standard deviation. These are stored in other variables internally. No other calculations takes place here.</p><ul><li><strong>transform() — Use of the code:</strong></li></ul><pre>from sklearn.preprocessing import StandardScaler<br>scaler = StandardScaler()  #created an object of StandardScalar<br><br>-----------------------------------------------------------<br><br>df1[&#39;INCOME&#39;] = scaler.fit(df1[[&quot;INCOME&quot;]])#called the function of fit.<br>df1[&#39;INCOME&#39;] = scaler.transform(df1[[&#39;INCOME&#39;]])#called the function of transform</pre><p>Now, what does this transform() command does?</p><p>This is the part where the calculation takes place. The z-score formulae is applied = (x-mu)/std_dev …this formulae is applied for all the observations/rows of that feature/column. All the observations starts ranging from -3 to +3. Standardization happens.</p><ul><li><strong>fit_transform() — Use of the code:</strong></li></ul><pre>from sklearn.preprocessing import StandardScaler<br>scaler = StandardScaler() #created an object of StandardScalar<br><br>---------------------------------------<br><br>df1[&#39;INCOME&#39;] = scaler.fit_transform(df1[[&#39;INCOME&#39;]])<br>#called the function of fit_transform</pre><p>Now, what does this transform() command does?</p><p>It does both. It calculates various parameters like — mean and standard deviation and at the same time, standardizes the observations. So, it is like 2 thongs takes place together.</p><p>Just for showing an example of how data looks before fit_transform() and after applying it:</p><pre>from sklearn.preprocessing import StandardScaler<br>scaler = StandardScaler()<br><br><br>df1[&#39;INCOME&#39;]<br><br>#OUTPUT<br>0      125301.242500<br>1       50815.445310<br>2       62977.824160<br>3       77099.966240<br>4      126887.768340<br>           ...      <br>298     15251.524730<br>299     18408.395450<br>300     40171.535635<br>301     40171.535635<br>302         0.000000<br>Name: INCOME, Length: 289, dtype: float64<br><br><br>df1[&#39;INCOME&#39;] = scaler.fit_transform(df1[[&quot;INCOME&quot;]])<br>df1[&quot;INCOME&quot;]<br><br>#OUTPUT<br>0      2.344391<br>1      0.139393<br>2      0.499435<br>3      0.917492<br>4      2.391357<br>         ...   <br>298   -0.913403<br>299   -0.819951<br>300   -0.175698<br>301   -0.175698<br>302   -1.364893<br>Name: INCOME, Length: 289, dtype: float64</pre><blockquote><strong>Model_Training — Use of fit(), transform()</strong></blockquote><p>Now we see that fit() and transform() both happens in the training data, why only transform happens in the testing data. Why?</p><p>It is very interesting to note : fit() calculates the mean and standard deviation using the trainging data. Based on these parameters, further standardization is done. Model is formed.</p><p><strong>So, when we get the testing data, again mean and standard deviation is NOT calculated.</strong> The same mean and standard deviation calculated for training data is used. <strong>This saves the model from the problem of overfitting also.</strong> And that is what we do right…even in decision tree…we create a tree using the training data and the same tree then predicts the target/output/result of the testing data. The same way, mean and standard deviation is known and just the observation values are transformed.</p><p>Very important thing to note is, when we use decision tree or random forest model, then we don’t do the fit_transform process. Then why do we need the same for regression?</p><p>Very simple explanation: Let me consider these two columns of age and salary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/193/0*oGq0sAtftmxdYn3U.png" /></figure><p>Now, even if we try to plot a graph, we can plot the graph like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/0*zIt0JUSFmkv-P6CA.png" /></figure><p>Age will become most insginificant factor. There may be other features like distance from office to home, or appraisal result or like. In front of salary, all will be like a flat line. All parameters will be insignificant.</p><p>So, this is the main reason we do standardization. This is how the same graph will look after the features are standardized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/0*gm6c8xPWgvpjv2K_.png" /></figure><p>Much better right. Age also shows some significant movement along with the salary.</p><p>Detailed explanation of standardizationa dn normalization in another blog, leaving the like for reference:</p><p><a href="https://medium.com/@swarnpriyaswarn/feature-scaling-4th-step-of-pre-processing-data-abff3a6f12d1">https://medium.com/@swarnpriyaswarn/feature-scaling-4th-step-of-pre-processing-data-abff3a6f12d1</a></p><p>Happy Learning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1f4cc24a4da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tricky Interview Questions!!]]></title>
            <link>https://medium.com/@swarnpriyaswarn/tricky-interview-questions-81b6471bd3ce?source=rss-5088565aa9f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/81b6471bd3ce</guid>
            <category><![CDATA[tricky-questions]]></category>
            <category><![CDATA[probability]]></category>
            <category><![CDATA[interview]]></category>
            <dc:creator><![CDATA[Zeros & Ones!]]></dc:creator>
            <pubDate>Tue, 28 Feb 2023 13:35:07 GMT</pubDate>
            <atom:updated>2023-02-28T13:35:44.436Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>Question 1. </strong>We have to make a password with 5 characters or numbers. Two situations are there with repetition and without repetition. How many passwords can be formed in both cases?</blockquote><p>Answer :</p><p>There are:</p><p>a-z characters — 26</p><p>A-Z characters — 26</p><p>0–9 Numbers — 10</p><p>In total = 26+26+10 = 62</p><p>Situation 1 : Without repetition:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*mjnR-2WpQitFuAtc14J04A.png" /></figure><p>So, total number of password that can be created is = 62*61*60*59*58</p><p>Situation 2: With Repetition:</p><p>That’s simple now. Right. All the 5 will have 62 options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*ZSYRJ4tfMkT-c8VlMcjPVw.png" /></figure><p>So, number of password that we can get is = 62⁵</p><p>That’s a lot!!!</p><blockquote><strong>Question</strong> 2: Arati has 2 kids. I is girl. What is the probability that 2nd is also a girl?</blockquote><p>This question is also tricky but very simple.</p><p>If anyone has 2 kids, what are the options for elder and younger siblings?</p><p>Girl Girl</p><p>Girl Boy</p><p>Boy Girl</p><p>Boy Boy</p><p>But according to this question, Boy Boy option is complete no — no.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/209/1*Uq7jwJvYZhE6DnCl96hgPQ.png" /></figure><p>So, we have three options. Now, it is not defined if the child who is girl is elder one or younger one, so we will not consider that also.</p><p>So, probability of have another girl = 1/3</p><p>Simple! Isn’t it!!</p><p>Will keep updating this list of questions. But posting these two for now, it may help someone crack their interview!! Happy Learning!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81b6471bd3ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stats — A Brief Introduction]]></title>
            <link>https://medium.com/@swarnpriyaswarn/stats-a-brief-introduction-3b82598d2455?source=rss-5088565aa9f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b82598d2455</guid>
            <category><![CDATA[inferential-statistics]]></category>
            <category><![CDATA[stats]]></category>
            <category><![CDATA[kurtosis-and-skewness]]></category>
            <category><![CDATA[descriptive-statistics]]></category>
            <category><![CDATA[normal-distribution]]></category>
            <dc:creator><![CDATA[Zeros & Ones!]]></dc:creator>
            <pubDate>Tue, 28 Feb 2023 13:01:39 GMT</pubDate>
            <atom:updated>2023-02-28T13:01:39.862Z</atom:updated>
            <content:encoded><![CDATA[<h3>Stats — A Brief Introduction</h3><p>Stats stats stats!!</p><p>The pillar of machine learning. The heart and soul of machine learning. The whole essence of machine learning.</p><p>Without stats, understanding machine learning is not possible. So, a bit of statistics!!!</p><p>Many people feel stats is Maths…well its not!! It is much more than that.</p><p>We don’t need literature, rather it is the stats that makes the numbers tell the whole story. Its’ quiet interesting.</p><p>The process of statistical interpretation is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1015/1*LD8drtBB11Ch8RvnNVu97Q.png" /></figure><p>Data is nothing but collection of different information. Organizing, analyzing and interpreting the data is the main part of stats.</p><p>Lets get going:</p><p>There are two types of statistics —</p><ul><li><strong>Descriptive Statistics:</strong> The Data or Collection Data are described in a summarized manner. There are two parts included in this descriptive statistics :</li></ul><ol><li>Measure of Central Tendency: where we get the mean, median and mode.</li><li>Measure of Dispersion: where we get the Q1, Q3, IQR, Range, Outliers, standard deviation information.</li></ol><ul><li><strong>Inferential Statistics: </strong>Here, as the name states, we infer from the the descriptive kind. There are many many ways in which we infer. Few of them are:</li></ul><ol><li>Hypothesis testing</li><li>Anova, Manova</li><li>t-test, z-test, chi-square test et all!</li></ol><p>This list is lonnnnnnnggggggg. Let’s take it slow!!! ;-\</p><p>Let’s understand a few basic concepts of statistics! Also, very important is to understand or rather learn these terminologies which are used very frequently in statistics. In short, to understand stats, we need to learn its language. Get set and Gooooooooooooooo!</p><blockquote>Lets talk more about the data:</blockquote><p>Data can be:</p><ul><li><strong>Structured or Unstructured :</strong>: Structured data have defined rows(observations) and columns(features). While unstructured data is like e-mails, photos, videos, satellite images etc.</li><li><strong>Cross-Sectional :</strong>: Which means that if we collect information of one thing, we get many other different information along with that. For example, if we get a list of movies released in 2023, we will also get the details of all the actors, all the producers, all the songs, the genre of the movies, and many other information related to the movies.</li><li><strong>Time Series data</strong> :: Just one features information is collected over time. Like 2020 to 2023 sales of a particular smart phones. So, how much sale happened of a particular smartphone will be displayed and we can analyze whether there is a increase or decrease in the sales.</li><li><strong>Panel data: </strong>Like how panel interviews happen, many interviews figure out if the candidate is worth the job or not. Same way, many information is required to understand just one parameter. Like to analyze the GDP of a country we need to have information of private and public consumption, government outlays, investments, additions to private inventories, paid-in construction costs and the list goes on and on.</li></ul><blockquote>Diving a bit deeper:</blockquote><p>Now that we collected the data, there would be different features/columns. Each features/column would of certain type. Right!!</p><p>There are 4 different types of variables…or we can say 4 different ways the features/columns can depict. They are:</p><ul><li><strong>Nominal Data : </strong>This is the categorical variables or qualitative data. Don’t stress about the jargons. Basically this means that this data-type is basically where no calculation can happen, no order can be assigned. It is just qualitative data. For example : Gender — Male or female. Now, there are no rankings which are based on either gender or YES/NO. You can’t give more preference to any. It is a equal-weighted option. This is what nominal data is!!!</li><li><strong>Ordinal Data: </strong>This is also kind of qualitative data but a certain order is maintained here. Like rank in the class according to the grades. Or any kind of ratings etc..</li><li><strong>Interval Data:</strong> There is a threshold value and based on that we divide the data into intervals. For example: if temp &gt; 30 deg C, it is hot, else its cold.</li><li><strong>Ratio Data: </strong>This is pure numerical data. You can do complete calculations here.</li></ul><blockquote>Few other concepts.</blockquote><ul><li><strong>Population and Samples:: </strong>Lets take a example to understand these two words. So, let the population be your housing society. You want to measure average height of the adults staying in that housing society(I really don’t know why you want to check that…hahaha). Anyhow, so you can’t know on each door to find out height of the adults. Possible problems may be — people not being cooperative, few people may be on some vacation or people are away to office/market/movie when you knock their door and so on. So, what is the way out. Out of 100 families staying in a housing society, we could only get a data of 40 people.</li></ul><p>Population — 100</p><p>Sample — 40</p><p>The only thing we need to be sure about is, that the sample should be taken in such a way that it is a true representation of the population.</p><p>(If we eat one mango out of the box full of mangoes, we are kind of sure how rest of them are going to taste right!! So, that one mango is true representation of the box-full of mangoes.)</p><ul><li><strong>Normal or Gaussian Distribution:</strong> We know about normal curve…the one which looks like a bell. Well, that looks like a bell because of one very important thing — Mean = Median = Mode. It is simple curve.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*3ZS4Wmjj8fzqhywkk7pgiw.png" /></figure><p>Standard deviation = (Variance)¹/2 -It is one of the measures of dispersion.</p><p>As the image shows, and as we know Mean = Median = Mode, we see a perfect symmetrical curve.</p><p>Mean + 1unit of std dev, we cover 68% of data.</p><p>Mean + 2 units of std dev, we cover 95% of data and</p><p>Mean +3 Units of std dev, we cover 99.7% of data.</p><p>These three points/percentage need to be remembered. This happens only when the data is normally distributed or has a gaussian distribution.</p><ul><li><strong>Skewness —</strong> Skewness in itself means, distortion or asymmetry. Here also, it means that the graph is either too much in the right side or to the left side.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*T8OlbXggc0QGtQFvQCYwqw.png" /></figure><p>For both the skewed graphs, mode the is highest point.</p><p>Negatively Skewed Graph :- will have a tail running to the left.</p><p>Positively Skewed Graph :- will have a tail running to the right.</p><p>Like shown in above image.</p><ul><li>Kurtosis: This is another fancy word. Nothing to be scared of this. There may be data which forms a graph like these — Leptokurtic, Mesokurtic and Platykurtic.</li></ul><p>The funda is very simple — in the normal or gaussian graph, we saw that 68% of data lies within 1 unit of std-dev range, 95% data in 2 times std-dev range and 99.7% data in 3 times std-dev range.</p><p>It doesn’t happen in the kurtosis graphs. Now hoeever the name be difficult this is what it means.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*WM7iKodhrxGkjmBQTZliCg.png" /></figure><p>Leptokurtic is very lean and thin graph. We can see the comparison with the normal graph. No way it will hold 68% of data in 1std-dev range. While Mesokurtic is a bit smaller and flatter and Platykurtic is like very flat plane. The funda remains the same.</p><p>So, that’s just the start of stats. Just a few terms that we will get to hear/use and apply in machine learning.</p><p>Happy Learning!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/0*6rcVkPm0BgV-h0IY" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b82598d2455" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handling Imbalance Dataset — 5th Step of Pre-Processing Data!]]></title>
            <link>https://medium.com/@swarnpriyaswarn/handling-imbalance-dataset-5th-step-of-pre-processing-data-525c2375c29c?source=rss-5088565aa9f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/525c2375c29c</guid>
            <category><![CDATA[imbalance-dataset]]></category>
            <category><![CDATA[pre-processing]]></category>
            <category><![CDATA[oversampling]]></category>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[undersampling]]></category>
            <dc:creator><![CDATA[Zeros & Ones!]]></dc:creator>
            <pubDate>Mon, 27 Feb 2023 10:45:08 GMT</pubDate>
            <atom:updated>2023-02-27T10:45:08.395Z</atom:updated>
            <content:encoded><![CDATA[<h3>Handling Imbalance Dataset — 5th Step of Pre-Processing Data!</h3><p>This step is not mandatory for all the machine learning problems. This is very important for CLASSIFCATION PROBLEMS ONLY.</p><p>Now, to start with, what is imbalance dataset?</p><p>We get a dataset with target column. There are 1000 observations(rows). But out of 1000 observation 888 are Yes/True/Positive and only remaining 112 is No/False/Negative.</p><p>It is called imbalanced dataset.</p><p>There are many ways to handle imbalanced dataset. Mentioning here a few:</p><ol><li><strong>Under — Sampling</strong> : What we do here is, say we have 112 observations of No/False/Negative. We will randomly select 112 observations from the Yes/True/Positive. So, we reduce the number of observations and balance the dataset.</li><li><strong>Over — Sampling </strong>: What we do here is…like we reduced the number of observations in under — sampling, we increase the number of observations in over — sampling. We will take all the 888 Yes/True/Positive observations and will take 112 samples and randomly repeat the observations to match 888 number and that is how we do over — sampling.</li></ol><p>There are many other ways also. These two are simple and mostly used.</p><p>Sweet and small blog.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=525c2375c29c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Feature Scaling — 4th Step of Pre-Processing Data!]]></title>
            <link>https://medium.com/@swarnpriyaswarn/feature-scaling-4th-step-of-pre-processing-data-abff3a6f12d1?source=rss-5088565aa9f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/abff3a6f12d1</guid>
            <category><![CDATA[pre-processing]]></category>
            <category><![CDATA[standardization]]></category>
            <category><![CDATA[normalization]]></category>
            <dc:creator><![CDATA[Zeros & Ones!]]></dc:creator>
            <pubDate>Mon, 27 Feb 2023 10:21:42 GMT</pubDate>
            <atom:updated>2023-02-27T10:21:42.980Z</atom:updated>
            <content:encoded><![CDATA[<h3>Feature Scaling — 4th Step of Pre-Processing Data!</h3><p>Before we understand what feature scaling is lets see an example:</p><p>So, we have the following data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/193/1*5k4-J_C40bIb_tj52xSzgA.png" /></figure><p>Now, if we want to see how this two variables are moving, we can make a line chart. Right!! We know that age is increasing and with that, some where the salary is increasing and at other ages, it is decreasing. Let me draw a simple line chart in excel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*xDtqXryfnCSM0vfKWYLf0Q.png" /></figure><p>Now now, the values of salary is soooo big that the age looks like a flat line — a constant line at 0. This can’t be so. If I have to interpret whether age has any impact on the salary, I would interpret it as NO. NONE. According to me, age is not important and is insignificant for the study.</p><p>Imagine if there are other variables like distance from office to home or work-life satisfaction level, the graph would given more constant or straight lines and just one correctly moving graph of the salary.</p><p>All my interpretation may be wrong. And to tackle this issue, we use feature scaling. It is very important to scale the data. Or one feature will outshine and will affect the analysis of the data.</p><p>What are ways of feature scaling:</p><ul><li>Normalization</li><li>Standardization</li></ul><blockquote><strong>Normalization</strong></blockquote><p>This is a process of feature scaling when the data doesn’t have any outlier. The formulae for finding the normalized value is::</p><p>= (Actual Value — Minimum Value)/(Maximum Value — Minimum Value)</p><p>One important thing to note here is that the normalized data ranges from <strong>0 to 1.</strong></p><p>Now, let me normalize the age and salary and build the graph:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*N1jAwl1r0hDmxyp2dJdOUQ.png" /></figure><p>We see that even though salary value was very large, the values of age is also equally considered. We see both the variables moving ahead.</p><blockquote><strong>Standardization</strong></blockquote><p>This is a process of feature scaling when the data has outliers. The formulae for finding the standardized value is::</p><p>= (Actual Value — Mean)/ Standard Deviation</p><p>One important thing to note here is that the standardized data ranges from <strong>— 3 to 3.</strong></p><p>Now, let me standardize the age and salary and build the graph:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/1*lQwl2l17sR-ZkUjPvaK5cA.png" /></figure><p>The difference between raw data and normalized/standardized data is very clear. It is mandatory to scale the data when we are doing regression problems.</p><p>Data used for the above graph:::</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*VaWnkggqwjZBhU462aDmnQ.png" /></figure><p>Do try it yourself, its thrilling to see why we need to do feature scaling and how it affects the interpretation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abff3a6f12d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Outlier — 3rd Step of Pre-Processing Data!]]></title>
            <link>https://medium.com/@swarnpriyaswarn/outlier-3rd-step-of-pre-processing-data-ef39cac8a19c?source=rss-5088565aa9f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef39cac8a19c</guid>
            <category><![CDATA[pre-processing]]></category>
            <category><![CDATA[iqr]]></category>
            <category><![CDATA[quartile]]></category>
            <category><![CDATA[outliers]]></category>
            <dc:creator><![CDATA[Zeros & Ones!]]></dc:creator>
            <pubDate>Mon, 27 Feb 2023 05:29:43 GMT</pubDate>
            <atom:updated>2023-02-27T05:29:43.615Z</atom:updated>
            <content:encoded><![CDATA[<h3>Outlier — 3rd Step of Pre-Processing Data!</h3><p>Question 1 . What is an outlier?</p><p>To know what outliers are, we need to know what box plot is!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*_yOgDJMAMwK8h0q3H82TAg.png" /></figure><p>So, there is a box, although, there is not animal, but we also have some whiskers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/0*s6cxQQTOJX1A3e5F.jpg" /><figcaption>Image Credit : Google Images (Mr. Whiskers!!!)</figcaption></figure><p>Well, none in the box though!! But you see these whiskers….the same are attached to the box, on both sides.</p><p>At the left end of the whiskers (the line attached to the box to the left end) is the minimum value or lowest value. While the other side, at the right end marks the maximum value.</p><p><strong>Range = Max Value — Min Value</strong></p><p>Point to note here is that the min and max value is not what is in the list, rather we calculate the min and max values.</p><p>Max Value = Q1 + 1.5*IQR (This gives the position)</p><p>Min Value = Q3 + 1.5*IQR (This gives the position)</p><p>Median = The central Value(where list has odd number of variables) OR Average of middle two values(where list has even numbers of variable)</p><p>Lower Quartile = Q1</p><p>Upper Quartile = Q3</p><p>First of all — What is quartile?</p><p>Quartile is — Quarter!! 4 parts.</p><p>So, like:</p><p><em>Percentile = (n+1)/100</em></p><p><em>Docile = (n+1)/10</em></p><p><em>Quartile = (n+1)/4</em></p><p>Therefore:</p><p>First Quartile, Q1 = (n+1)/4</p><p>Second Quartile, Q2 = 2 * ((n+1)/4) = (n+1)/2 = This is nothing but the median</p><p>Third Quartile, Q3 = 3 * ((n+1)/4)</p><p>Fourth Quartile, Q4 = 4 * ((n+1)/4) = (n+1) = This is nothing but the maximum value.</p><p>Inter-Quartile Range = IQR = Q3 — Q1</p><p>This entire approach of range, quartiles and Inter-Quartile range is called — Measure of Dispersement.</p><p>(There is also measure of central tendency where we calculate the mean, median and mode.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*N7JhTy0jzsSJCcZvKarHwg.png" /></figure><p>Example:</p><p>Data = 2,4,5,7,8,9,11,13,14,16,17</p><p>Q1 = (11+1)/4 = 12/4 = Value at( 3rd Position) :: ( We take this value as the position number)</p><p>So, the value at 3rd position is = 5</p><p>Therefore, Q1 = 5</p><p>Q3 = 3(11+1)/4 = 12*3/4 = Value at (9th Position) = 14</p><p>IQR = Q3-Q1 = 14–5 = 11</p><p>Putting all values to find out the outliers:</p><ul><li>+ve Outlier Value = Q3 + 1.5*IQR = 14 + (1.5*11) =14 + 16.5 = 30.5</li><li>-ve Outlier Value = Q1–1.5*IQR = 5 — (1.5 * 11) = 5–16.5 = -11.5</li></ul><p>So, any value which is more than 30.5 are positive outliers and any value which is less than -11.5 are the negative outliers.</p><p>Considering another example, in which a outlier is there.</p><p>Data = 1,5,7,9,11,13,15,17,19,5000</p><p>Q1 = (10+1)/4 == 2.75 (Index Number) = (2 +0.75)(Index Number) = 5 + 2*0.75 = 5+1.5 = 6.5</p><p>Q3 = 3*(10+1)/4 = 33/4 = 8.25(Index Number) = (8 + 0.25)(Index Number) = 17+2*0.25 = 17 + 0.5 = 17.5</p><p>IQR = Q3- Q1 = 17.5–6.5 = 11</p><ul><li>+ve Outlier = Q3 + 1.5*IQR = 17.5 + (1.5*11) = 17.5 + 16.5 = 34</li><li>-ve Outlier = Q1–1.5 * IQR = 6.5 — (1.5*11) = 6.5 -16.5 = — 10</li></ul><p>So, any number more than 34, will be a positive outlier. Any number less than — 10 will be a negative outlier.</p><p>We can see in the dataset, 5000 &gt; 34, hence 5000 is an outlier!</p><p>Question 2 . How outlier effects ?</p><p>Data = 1,5,7,9,11,13,15,17,19,5000</p><p>Lets see the graph:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*7ZrVk8F1pv6TwPtv0C2Tmw.png" /></figure><p>We can see the graph how outlier is affecting the graph. The whole scenario is changed, if we remove/condition the outlier. And this is why it is very important to handle the outliers.</p><p>Question 3) How outliers remove outliers?</p><p>There are various ways to remove outliers. Few of them are:</p><ol><li>Remove Outlier — this is one way, as in above example, we see that 5000 looked very odd. We could easily remove 5000. BUT THIS IS ONLY DONE WHEN THE BUSINESS HAS AGREED.</li><li>Transform it :</li></ol><ul><li>Log Transformation : log(5000) = 15.3 …. which looks very reasonable.</li><li>Sqrt Transformation : (5000)¹/2 = 70.71 … better than 5000</li><li>Cube Root Transformation: (5000)^1/3 = 17.09 ….much better than 5000</li></ul><p>3. Regularization : Dictionary meaning, to make things or to regularize things which follows the respective rules. In machine learning, there are many ways to do regularization. Few are:</p><ul><li>Lasso Regularization</li><li>Ridge Regularization</li><li>Elastic Net Regression</li></ul><p>Outlier treatment is NOT a mandatory step. If we are doing standardization, outliers are automatically handled by that step. But knowing what outlier is, how to figure out what the outliers value could be, ways to remove outliers and what to fill in place of outlier — ALL IS MANDATORY.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef39cac8a19c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Encoding — 2nd Step of Pre-Processing Data!]]></title>
            <link>https://medium.com/@swarnpriyaswarn/encoding-2nd-step-of-pre-processing-data-2d439b26a4fe?source=rss-5088565aa9f1------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d439b26a4fe</guid>
            <category><![CDATA[encoding]]></category>
            <category><![CDATA[label-encoding]]></category>
            <category><![CDATA[one-hot-encoding]]></category>
            <category><![CDATA[pre-processing]]></category>
            <category><![CDATA[multicollinearity]]></category>
            <dc:creator><![CDATA[Zeros & Ones!]]></dc:creator>
            <pubDate>Fri, 24 Feb 2023 14:25:56 GMT</pubDate>
            <atom:updated>2023-02-24T14:25:56.510Z</atom:updated>
            <content:encoded><![CDATA[<h3>Encoding — 2nd Step of Pre-Processing Data!</h3><p>Encoding is very interesting concept. If you ask google, something like this will come up — <strong>the process of putting a sequence of characters (letters, numbers, punctuation, and certain symbols) into a specialized format for efficient transmission or storage</strong>.</p><p>Well, we all know the literal meaning of encoding. But when we are dealing with machine earning, why we we need encoding at all?</p><p>The answer to this actually another question :</p><p>What is the datatype of the column/feature?</p><p>Well, if the <strong>datatype is categorical, only then we need to do encoding.</strong> Reason being that we can’t do any numerical analysis on the categorical data. For me, the best reason is it saves you from lots of spelling mistakes and less of writing :/</p><p>Jokes apart, it is a mandatory step for pre-processing of the data. So, let’s see the ways of encoding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/877/1*371XP749N8saZUeGnVrGaQ.png" /></figure><ol><li>Label Encoder: Coverts characters to numbers.</li></ol><p>For example: lets assume there are 5 different cities and we need to use the label encoder to do the encoding. Below is an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/254/1*SJXAUfbMq_r156a9n_lU_g.png" /></figure><p>So, here according to the alphabetical order, we do the encoding. So, B for Bangalore is encoded as 0 and C Chennai is encoded as 1 and so on.</p><p>(In case we have two different cities name starting with same alphabet, we code like how we see the dictionary. According to the next alphabet and so on. )</p><p>Point to remember is : The numbers are not significance. It is just a label. 0,1 or 5 doesn’t signifies and rank or order. They all are equal and just a label.</p><p>2. One-Hot Encoding</p><p>Here, all the variables are converted into rows and all different variables gets a binary value. This overcomes the problem of assigning weightage to the numbers by machines or by humans.</p><p>Let’s see an example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*shmAMOdM8PlJPb7buwymTQ.png" /></figure><p>We can do the one-hot encoding using the label-encoder classification or even without it. If we are using the label encoder, we need to do it first followed by the one-hot encoding.</p><p>So, here in the example, we see how we have 5 different columns and each column represent a city. City0 — Bangalore (Label Encoding — 0) gets a 1 for Bangalore and 0 for others. Similarly, for City4 — Pune (Label Encoding — 4) gets a 1 for Pune and 0 for others.</p><p>We see all the city0 to city4 — encoding holds only binary numbers 0 or 1.</p><p>3. Dummy Variable: Process of Dummy variable encoding is same as the one-hot encoding, only difference being that number of columns in dummy variable encoding is (n-1) (considering there are n columns).</p><p>So, any one of the columns can be dropped in case of dummy variable. Dropping the City4.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*6zJ_caMRShnOWYbAqE0fRg.png" /></figure><p>We drop one of the columns, to avoid the problem of multicollinearity. This is a very simple concpet:</p><p>See the following are the given information:</p><p>Cities present : <strong>Delhi — Mumbai — Pune — Chennai — Bangalore</strong></p><p>City0 = Bangalore</p><p>City1 : Chennai</p><p>City2 : Delhi</p><p>City3: Mumbai</p><p>So, if the city without any value, can be concluded to be Pune; there are only 5 options right. If 4 cities label we know, 5th one we can guess. Right!!</p><p>This much for now!!!</p><p>Happy Learning!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d439b26a4fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>