<?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 Vignesh S on Medium]]></title>
        <description><![CDATA[Stories by Vignesh S on Medium]]></description>
        <link>https://medium.com/@22vignesh97?source=rss-bf8578732bbb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*7NdLEurcg467ujWMzFOSHg.jpeg</url>
            <title>Stories by Vignesh S on Medium</title>
            <link>https://medium.com/@22vignesh97?source=rss-bf8578732bbb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 16:10:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@22vignesh97/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[SUPERVISED LINEAR REGRESSION USING OLS MODEL]]></title>
            <link>https://22vignesh97.medium.com/supervised-linear-regression-using-ols-model-d2561502343b?source=rss-bf8578732bbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2561502343b</guid>
            <category><![CDATA[linear-regression-python]]></category>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[ordinary-least-square]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Vignesh S]]></dc:creator>
            <pubDate>Thu, 30 Sep 2021 20:22:05 GMT</pubDate>
            <atom:updated>2021-09-30T20:22:05.888Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8j3NcMXMHlBNiD9w.jpeg" /></figure><h3>REGRESSION ANALYSIS</h3><p>Regression analysis is a statistical technique for studying the linear relationships.</p><h4>Purpose of Regression analysis</h4><p>Regression analysis is done for one of two purposes.</p><ol><li><strong>To predict which independent variables have an impact on dependent variable.</strong></li><li><strong>To estimate the effect of some explanatory variable on the dependent variable.</strong></li></ol><h3>LINEAR REGRESSION</h3><p><em>Linear regression is a machine learning algorithm that is used to predict the output (dependent features) continuous values based on the input( independent) features using the linear function y=b1x+b0 where b1is the slope, b0is the intercept x is the independent variables and y is the dependent variables.</em></p><p><strong><em>Simple Linear Regression</em></strong>: y=b0+b1x ( one independent variable)</p><p><strong><em>Multiple Linear Regression </em></strong>: y=b0+b1*x1+b2*x2+…….+bn*xn ( more independent variables) n- number of independent features. x1,x2,x3 -Parameters.</p><p><strong><em>Variance (var(x)):</em></strong></p><p>variance is the average of the squared differences from the mean. It tells how one independent(x) spread of variable with respect to mean.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/0*lbUSlUbnd_nHEUXQ" /><figcaption>Variance</figcaption></figure><p><strong><em>Covariance (Cov(x1,x2)) and correlation(R):</em></strong></p><p>Covariance measures how change in one variable is associated with other variable.</p><p>It gives the together spread of data.(x1 and x2)</p><p>For example: if we want to compare weight of the person is related to age or height we can’t able to compare because it is in units kg/yrs and kg/cm so we need to break the unit so comes concept called <strong>correlation</strong> it scales the unit and break the units and gives linear association between 2 numeric variables. Now we get weight-age is 0.7 and weight-height is 0.88 so we can say weight is highly dependent on height variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/0*IZCHOxVNy__iyXvO.png" /><figcaption>COVARIANCE -TOGETHER SPREAD OF X AND Y</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/0*tCmFUsLk6jjjC6VL.png" /><figcaption>CORRELATION (R): COV(x)/SIGMA (x) IS ZSCALED FORMULA SO IT IS DOING SCALING</figcaption></figure><h4>Linear Regression two methods as shown below:</h4><p>STATSMODELS (<strong><em>ORDINARY LEAST SQUARE</em></strong>) - Using hypothesis test gives output lots of understanding on how parameters related to target.</p><p>SCIKIT LEARN MODEL (<strong><em>SKLEARN</em></strong>) -Gives model accuracy.</p><h3>ORDINARY LEAST SQUARE</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*W4lx-mGAlkUTCbBCn4m7LQ.png" /><figcaption>Simple Linear Regression — one independent and one dependent variable.</figcaption></figure><p><strong>Linear Regression line:</strong></p><p>y=b0+b1*x+ e</p><blockquote>y- set of values taken by dependent variable/Target variable/Response variable</blockquote><blockquote>x- set of values taken by independent variable/predictor variable</blockquote><blockquote>e -Random error component</blockquote><h4>Random error component:</h4><p>Error term also called as <strong><em>Residual</em></strong>, represents the distance of the observed value from the value predicted by the regression line.</p><blockquote>Error term=Actual value — predicted value</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qosmZnR6hz1-7Dwi.jpg" /></figure><p>The linear regression line which explains the trend in the data is the <em>best fit line</em>. <strong><em>Ordinary least square method</em></strong> is used to find the <strong><em>best fit line</em></strong> in the data. Ordinary least squares (<strong>OLS</strong>) is a <em>non-iterative</em> method that fits a model such that the sum-of-squares of differences of observed and predicted values is minimized.</p><h4>OLS OBJECTIVE</h4><p>This method aims at <strong><em>minimizing the sum of squares of the error terms, that is it determines those values of b0 and b1at which error terms are minimum.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*8W8n27Dmm_SVs2smAo9CrQ.png" /><figcaption>BEST FIT LINE</figcaption></figure><h4>INTERPRETATION OF BETA COEFFICIENTS (b0 and b1):</h4><p><strong>b1(Slope)</strong>: It gives the amount of change in response variable per unit change in response variable.</p><p><strong>b0(intercept)</strong>:It is the y intercept which means when x=0 ,y is b0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*Hh4VNpmscj6xnJ16r89ezQ.png" /><figcaption>slope (b1)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/222/1*t3tEK-quanps7oDETUv_PA.png" /><figcaption>Intercept (b0)</figcaption></figure><h4>MEASURES OF VARIATION:</h4><p><strong>SST</strong>: Sum of the squared difference between the observation and its mean.</p><p><strong>SSR</strong>: Sum of the squared difference between the predicted value and mean of the response value.(EXPLAINED VARIATION)</p><p><strong>SSE</strong>: Sum of the squared difference between observed response variable and its predicted value.(UNEXPLAINED VARIATION)</p><p><strong>Rsquared: </strong>Coefficient of Determination.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*ts7ef391pa0yjJO_g08S2g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*TZqb0Nhh8Tf__LjFJQUHww.png" /></figure><p><strong>ASSUMPTIONS OF LINEAR REGRESSION</strong></p><blockquote>Dependent Variable -Numeric</blockquote><blockquote><strong>LINEARIT</strong>Y: Linear relationship between dependent and independent variables</blockquote><blockquote><strong>MULTICOLLINEARITY</strong>: Between independent variables no high correlation.</blockquote><blockquote><strong>AUTOCORRELATION</strong>: Independence of observation should exists</blockquote><blockquote><strong>HOMOSCEDASTIC</strong>: Error terms should be homoscedastic.</blockquote><blockquote><strong>NORMALITY</strong>: Error terms should follow normal distribution.</blockquote><p>After satisfying all the above conditions build an OLS model.</p><p>Lets understand this better looking at this example, I have taken a simple dataset — Advertising data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/265/0*W-DnMjFm51MuqTmg.png" /></figure><h4>#OLS MODEL CODE</h4><p>import statsmodels.api as sm<br>xc=sm.add_constant(x)<br>ols_model=sm.OLS(y,xc)<br>ols=ols_model.fit()<br>ols.summary()</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*cJYUaCCzQ3AxdJyCdOpjBw.png" /></figure><p><strong><em>Pvalue </em></strong><em>is less than and equal to 0.05 then the model is significant with target otherwise not. ( Newspaper pvalue-0.8 not significant with sales so drop the column)</em></p><h4><strong><em>Explainability</em></strong></h4><p><em>Average increase in sales due to TV(0.0458)</em></p><p><em>Sales will happen when no adverting is involved is 2.939(b0) at (x1,x2,x3=0)</em></p><h3><strong>MATH BEHIND OLS</strong></h3><h4>LOSS FUNCTION / COST FUNCTION/ERROR FUNCTION</h4><p><strong><em>Cost function tells us how good the model performs in making predictions for a given set of parameters (m and c)</em></strong></p><p>Loss is the error that occurs between predicting value and actual value.</p><p>STEP 1: ERROR FUNCTION</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*mIvp7XBXeALH-rCKdVQuYg.png" /></figure><p>STEP 2: Differentiate with respect to b0 and b1 and equate to zero.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*7ChFFJAyKflD-hkBbaPRkg.png" /></figure><p>STEP 3: Solving this equation we get the best values of b0 and b1</p><p>STEP 4: Best fit line using OLS.</p><h3><strong>MODEL EVALUATION METRICS</strong></h3><h4>Rsquared and Adjusted Rsquared:</h4><p>Rsquared is coefficient of determination (R2), gives the percentage of variation in the dependent variable explained by the independent variables.</p><p>Taking square root of Rsquared we get correlation(R).</p><p>Rsquared range between o to 1. near 1 is a good model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*nhDHTCs_X82hs0dbHt9xrA.png" /></figure><p>Adjusted Rsquared gives the percentage of variation explained by independent variables that actually affects the dependent variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*S4FTTjb3bbUcNUdiIzk9qA.png" /></figure><p>If a new variable added Rsquared will not see the variable is significant or not with target the value of Rsquared increases so its called statistical fluke. Rsquared is not the proper metric to judge on model rely on adjusted Rsquared also it tells that if a new variable is added if it is not significant the value of adjusted Rsquared decreases then realise the variable has no relation with target.</p><h4><strong>F-STATISTIC</strong></h4><p>It is used to check the significance of the regression model. It is similar to Anova test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*oiTLJpQQRrDwLmNPNn1opQ.png" /></figure><h3><strong>OPTIMIZATION-GRADIENT DESCENT</strong></h3><h4>LOSS FUNCTION / COST FUNCTION/ERROR FUNCTION</h4><p><strong><em>Cost function tells us how good the model performs in making predictions for a given set of parameters (m and c)</em></strong></p><p>Loss is the error that occurs between predicting value and actual value. our objective is to minimize the error by optimizing value of m and c. We will be using <strong><em>Mean squared error </em></strong>to find the loss.</p><h4>MEAN SQUARED FUNCTION</h4><p>Three steps to find the Mean square function.</p><ol><li>Find the difference between actual value and the predicted value.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*F5jamMT-zuE9P2A-in_jbg.png" /></figure><p>2. Square the distance in order to avoid the negative values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/170/1*YJcmV9hESb1GXSnNve1wjA.png" /></figure><p>3.Find the mean of squares for every given value in x.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/239/1*ZDoL-Fhrx1-L--qFTriO_w.png" /></figure><p>MSE:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*Xqbq0JoYn1XrufF0Nc1CLA.png" /></figure><h4>GRADIENT DESCENT ALGORITHM</h4><p>Gradient Descent is used to obtain model parameters (slope-m and intercept- c).Gradient means Slope ,Descent means Moving downwards.</p><p><strong><em>Gradient descent is an iterative optimizing algorithm which finds the parameters( m and c )such that error term( loss function) is minimum.</em></strong></p><p><strong><em>Step size is the learning rate</em></strong>.<strong> </strong>Gradient Descent has a hyper parameter called learning rate . If the learning rate is high it will not reach the goal it will keep oscillating. If value is too small it will take lot of iterations to get the goal. Thus it is important to choose an appropriate learning rate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*0a0_22miaTDBV-j0aPtVhw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*9gp8AzIwR4m2uLBHKxLqcg.png" /></figure><p><strong>STEP 1:</strong>Assume initially random values of m and c, Here m(slope)=0 and intercept(c)=0,Learning rate =0.0001( small) in order to obtain the good accuracy.</p><p><strong>STEP2</strong>: Partial derivative of loss function with respect to m .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*KyFXOkgz81cCPZIYVmy13Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*VqvV3PhtQhqBsNMzkAv03A.png" /></figure><p>Partial derivative of loss function with respect to c.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*mwymP5_0uzh8UTmij9jz-Q.png" /></figure><p><strong>STEP 3:</strong> Update the m and c using the following equations</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/1*eeZW32yNP18JAn8HXvHBxQ.png" /></figure><p>Each update of m and c we can improve the accuracy and reach the goal.</p><p><strong>STEP 4:</strong> Repeat step 2 and step 3 until we get loss function ideally zero.</p><p>I hope you liked this article on linear regression using OLS model ,that you should know as a Data Scientist. Feel free to ask your valuable questions in the comments section below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2561502343b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[STATISTICS FOR DATA SCIENCE]]></title>
            <link>https://22vignesh97.medium.com/statistics-for-data-science-e1327584209a?source=rss-bf8578732bbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/e1327584209a</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Vignesh S]]></dc:creator>
            <pubDate>Thu, 23 Sep 2021 19:41:40 GMT</pubDate>
            <atom:updated>2021-11-25T01:42:40.904Z</atom:updated>
            <content:encoded><![CDATA[<p>Statistics is the discipline that concerns the <strong><em>collection, organization, analysis, interpretation, and presentation of data</em></strong>. Statistics is used for decision making by understanding the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vvhk3zxkLml05Y2pIaKUew.jpeg" /></figure><h3>Types of Statistics:</h3><ol><li>Descriptive statistics - <strong><em>Understand the sample</em></strong></li><li>Inferential statistics - <strong><em>Understand the population</em></strong></li></ol><p>In descriptive statistics no prediction will be there understand the data of current samples (Mean, Median, Mode, IQR, Range).</p><p><strong><em>Descriptive statistics</em></strong> will answer the question to client <strong><em>what happened?</em></strong> by means of EDA.</p><p>After Completing EDA in prediction with the help of model it will answer the question to client <strong><em>what will happen? </em></strong>is called <strong><em>Inferential statistics</em></strong></p><h3><strong>Descriptive Statistics:</strong></h3><h4>1.Measure of central tendency:</h4><p><strong><em>Mean:</em> </strong>It is defined as sum of all observation divide by total number of observation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*PH1bnFCJSHLUKHvD0qvlAg.jpeg" /></figure><p><strong><em>Median: </em></strong>Middle value after sorting the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*_1FtpVCn8CI1uKnL3zDYkw.jpeg" /></figure><p><strong><em>Mode: </em></strong>Values with highest frequency/ most repeated observation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*yYN4_OqGUSfv1nqwJ5DzIQ.jpeg" /><figcaption>Comparison of Mean , Median ,Mode</figcaption></figure><h4>2. Measures of Spread/Dispersion:</h4><p><strong><em>Range: </em></strong>Difference between the Max and Minimum value. <strong>(MAX — MIN)</strong></p><p><strong><em>Variance: </em></strong>Variance is the arithmetic mean of square of deviation taken from mean.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WUZYkhXrDjswbY8FRZaUwg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c7MewPoxYiRLbtfMZ_n9Jg.png" /></figure><p><strong><em>standard deviation: </em></strong>Standard deviation of the variable is square root of variance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*FwQP0FEx2OZWw-SC2G8myQ.png" /></figure><p><strong><em>coefficient of variation or Percent of variation: </em></strong>The coefficient of variation represents the ratio of the standard deviation to the mean.</p><p>For example: If consider the team player selection for IPL match.</p><p>Let player 1 history of score for 5 matches be(100,50,85,63,45) and player 2 score be (75,83,82,78,75) we can see the player 2 will be selected because he is consistent( std-dev) for all matches and also mean score is good. Even though player 1 scored 100 in one match he will not be selected because he is not consistent one match he overperforms and other he underperforms.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/165/1*bXuBwGR-YaiYhBX-RXX6fA.png" /></figure><p><strong><em>IQR-Inter quartile Range =(q3-q1):</em></strong></p><p>Quartiles are the points in the data set that divides the data set into four equal parts. Q1, Q2 and Q3 are the first, second and third quartile of the data set.</p><ul><li>25% of the data points lie below Q1 and 75% lie above it.</li><li>50% of the data points lie below Q2 and 50% lie above it. Q2 is nothing but Median.</li><li>75% of the data points lie below Q3 and 25% lie above it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0MPDTLn8KoLApoFvI0P2vQ.png" /></figure><p><strong><em>Skewness:</em></strong> Measure of symmetric and asymmetric.</p><p>Mean=Median : symmetry ,Mean&gt;Median : Right-skewed , Mean &lt; Median : Left-skewed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*uf7EGHlgfpJ_W4EVRL_qwQ.png" /></figure><p><strong><em>kurtosis: </em></strong>Measure of peakedness.</p><ul><li>Mesokurtic — This is the case when the kurtosis is zero, similar to the normal distributions.</li><li>Leptokurtic — This is when the tail of the distribution is heavy (outlier present) and kurtosis is higher than that of the normal distribution.</li><li>Platykurtic — This is when the tail of the distribution is light( no outlier) and kurtosis is lesser than that of the normal distribution.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*eKwI3HqFrljQeEZYLy4PMQ.png" /></figure><p><strong><em>Covariance and correlation:</em></strong></p><p>Covariance measures how change in one variable is associated with other variable.</p><p>It gives the together spread of data.</p><p>For example: if we want to compare weight of the person is related to age or height we can’t able to compare because it is in units kg/yrs and kg/cm so we need to break the unit so comes concept called <strong>correlation</strong> it scales the unit and break the units and gives linear association between 2 numeric variables. Now we get weight-age is 0.7 and weight-height is 0.88 so we can say weight is highly dependent on height variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mtAwdlLtfHek5IYx3IPuYA.png" /><figcaption>COVARIANCE -TOGETHER SPREAD OF X AND Y</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*vqfx5_fWFVgNVBjUYGmTOQ.png" /><figcaption>CORRELATION: COV(x)/SIGMA (x) IS ZSCALED FORMULA SO IT IS DOING SCALING</figcaption></figure><h3><strong>INFERENTIAL STATISTICS:</strong></h3><p>Inferential statistics main aim is to take sample data from population do some statistical test and come to conclusion of the specific data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/311/1*lSN7dWG8ra_ez3PHc3ViFw.png" /></figure><p>STATISTICAL TESTS :<strong><em>Top Down Approach</em></strong></p><p>1.Start with Hypothesis</p><p>2.Then data satisfies the claim against or favour with the population</p><p>Machine Learning: <strong><em>Bottom up Approach</em></strong></p><ol><li>Starts with data</li><li>Arriving the insights y=f(x) and finding hypothesis.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*MYVfKutnqu8MxjfMurM3pw.png" /></figure><p>Linkedin : <a href="https://www.linkedin.com/in/22vignesh97/">https://www.linkedin.com/in/22vignesh97/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1327584209a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parametric Vs Non parametric model selection for Regression and classification based on Statistical…]]></title>
            <link>https://22vignesh97.medium.com/parametric-vs-non-parametric-model-selection-for-regression-and-classification-based-on-statistical-152fddd4b384?source=rss-bf8578732bbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/152fddd4b384</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[classification]]></category>
            <category><![CDATA[regression]]></category>
            <dc:creator><![CDATA[Vignesh S]]></dc:creator>
            <pubDate>Fri, 20 Aug 2021 10:26:28 GMT</pubDate>
            <atom:updated>2021-08-20T15:17:12.860Z</atom:updated>
            <content:encoded><![CDATA[<h3>Parametric Vs Non parametric model selection for Regression and classification based on Statistical test.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*VF-54nRkdk3QoErnCpFnqA.png" /></figure><h3><strong>PARAMETRIC MODEL</strong></h3><p>In a parametric model, the number of parameters is fixed with respect to the sample size. It must satisfy all the assumptions.</p><p>A learning model that memorizes the data with the help of parameters given (i.e. independent features )is called linear/parametric model.</p><p><strong>Benefits of Parametric Machine Learning Algorithms:</strong></p><ul><li>Explainability is good(Easy to interpret to client or stakeholders).</li><li>Suits for simple data.</li><li>Parametric models are very fast to learn from data.</li></ul><p>A linear regression line has an equation of the form <strong><em>Y = a + bX</em></strong>, where <strong><em>X</em></strong> is the explanatory variable and <strong><em>Y</em></strong> is the dependent variable. The slope of the line is <strong><em>b</em></strong>, and <strong><em>a</em></strong> is the intercept (the value of <strong><em>y</em></strong> when <strong><em>x</em></strong> = 0).<strong>Suppose in linear regression if you have 10 independent variables then the no of parameters is 11 (10 slopes and one intercept).</strong></p><h3><strong>NON PARAMETRIC MODEL</strong></h3><p>Algorithms that do not make strong assumptions about the form of the mapping function are called nonparametric machine learning algorithms. By not making assumptions, they are free to learn any functional form from the training data.</p><p>In a nonparametric model, the (effective) number of parameters can grow with the sample size.</p><p><strong>Benefits of Nonparametric Machine Learning Algorithms:</strong></p><ul><li>Suits for Complex data.</li><li>No assumptions (or weak assumptions) about the underlying function.</li><li>Can result in higher performance models for prediction.</li></ul><h3>Hypothesis Test Generic Conditions:</h3><p>Linearly separable for regression can be found by doing statistics test.</p><p><strong>BASIC CONDITION FOR ALL STATISTICAL TEST:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*sBhOTPYTfmczxkeIaUXkpA.png" /></figure><p><strong><em>Hypothesis test:</em></strong></p><p><strong><em>H0(Null hypothesis): Mean1=Mean2=Mean3 (No Relation)</em></strong></p><p><strong><em>Ha(Alternate Hypothesis): Mean1 != Mean2 != Mean3 ( Relation)</em></strong></p><p><strong>TSTAT </strong>: Test-Statistic tells how far the mean is varying between the groups ( Standard deviation). It talks about the distance between the means whether they are overlapping or not. <strong>T-stat is significant if it is greater than 1.96 for 95% confidence level.</strong></p><p><strong>PVALUE</strong>: P value tells the how much area they are overlapping. <strong>If the p-value is less than or equal to 0.05 then Alternate hypothesis holds good ( significant with target it has relation )</strong> ,if p-value greater than 0.05 then null hypothesis holds good no relation with target.</p><h3><strong>REGRESSION:</strong></h3><p><strong><em>Based on the data that you are working you have to select the model whether we can go by parametric models or by non parametric models.</em></strong></p><p>For the target variable continuous (Regression) check whether the conditions are satisfying before building the model</p><ol><li>Dependent variable must be numeric</li><li>Independent variables does not show multicollinearity</li><li>Linear Relation between dependent and independent variables</li><li>Absence of Autocorrelation</li><li>Error terms must be homoscedastic</li><li>Error terms must follow normal distribution.</li></ol><p><strong>OLS summary </strong>if any of the condition not satisfied (i.e. suppose age is having multicollinearity with target showing pvalue&gt;0.05 we can drop the variable and make the data that satisfy the conditions for building the Linear regression) or if you are not comfortable with drop the age better go for non parametric model i.e. Decision tree regressor,KNN regressor because it has the ability to learn .</p><p>suppose if you keep the age column which is having multicollinearity and build the Linear Regression model then it will lead to overfitting.</p><p>Consider BMI as target and Diabetic case Less,medium,severe to understand the linear and non linear dependency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*QC6A97GfYFm4LQci7B5NIw.png" /><figcaption>Linear dependency, slope increases, pvalue&lt;0.05 in this case. As BMI increases diabetic severity increase</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*hjbFXsb9-88Nu3nXzUDltQ.png" /><figcaption>Even though means are far apart slope is inconsistent linear regression finds difficult to interpret.Non linear dependency pvalue&gt;0.05.</figcaption></figure><p>Parametric model provides the better Explainability about the data, Non Parametric models provides the better accuracy.</p><h3><strong>CLASSIFICATION</strong></h3><p>For the target variable Category (Classification) ,Check the statistical test for parametric models like Logistic regression and Naive Bayes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*Zy-YOxli9YEl02KjNBU-mQ.png" /></figure><p>If the t-static &gt;1.96 and p-value &lt;0.05 satisfies the condition ,i.e. Means are apart, so it is Linearly separable we can built the Parametric model .</p><p>Consider Diabetic case high, medium, severe as target and BMI as independent variable to understand the linear and non linear dependency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*Hoqj2TxUdgkONYmXE69QDA.png" /><figcaption>Linear dependency maintains linear relationship as BMI increases diabetics risk increases. Slope is consistent.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*KgQPUHhXfIKJjZloLQHFzw.png" /><figcaption>It is non maintaining linear relationship slope is inconsistent, Eventhough they are statistically significant.the linear model finds struggle to model the relationship.</figcaption></figure><p>If means are so closer , not linearly separable, overlapping .Built a Non parametric models for classification because it has the ability to learn the overlapping.</p><p><strong><em>Finally it is in the hand of stakeholders if they want to have better Explainability from the data ,go for satisfying the all the assumptions and built a linear model if they focus on accuracy built Non linear model. For non linear model there is no assumptions checking, we can directly build the model.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=152fddd4b384" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TRAIN TEST SPLIT VS CROSS VALIDATON]]></title>
            <link>https://22vignesh97.medium.com/train-test-split-vs-cross-validaton-9a2a8c2bb16b?source=rss-bf8578732bbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a2a8c2bb16b</guid>
            <category><![CDATA[train-test-split]]></category>
            <category><![CDATA[crossvalidation]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Vignesh S]]></dc:creator>
            <pubDate>Sat, 14 Aug 2021 07:24:06 GMT</pubDate>
            <atom:updated>2021-08-14T07:24:06.936Z</atom:updated>
            <content:encoded><![CDATA[<h3>There are various pipelines in Data science projects with machine learning used cases like Data gathering, Feature Engineering, Feature selection, Model creation, Model deployment.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*8YV9-LqgzeIMzL36npT9QQ.jpeg" /></figure><h3>TRAIN TEST SPLIT</h3><p>Before model creation we will be doing Train test split, on the entire data. Suppose if you are having 1000 data points, Assume we are splitting it into train 70% test 30 % or 80% train 20 % test based on the data you have.</p><p>These <strong>70 % train data</strong> and <strong>30% test data</strong> are <strong>randomly selected.</strong></p><p>Random selection is done by <strong>Random_state</strong> variable we can choose random state=10 or 100,but each time if you fix different random state you will get shuffled data points on train and test data.</p><p>Whenever random selection happens our accuracy keeps on fluctuating i.e. for 70% train 30% test the accuracy may end up with 85% and if you change the random state to 80% train 20% test accuracy changes to 87%.</p><h3>DRAWBACK</h3><p>so we cant able to explain the stakeholders the exact accuracy.so in order to prevent this we are using cross validation</p><p>CODE:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*HIy3GpCZd_nJgiU-FbPMGg.png" /></figure><h3>CROSS VALIDATION</h3><p>There are various types of cross validation</p><ol><li>Leave one out cross validation (LOOCV)</li><li>K-Fold cross validation</li><li>Stratified cross validation</li><li>Time series cross validation</li></ol><p>In this we will see Leave one out cross validation and KFold cross validation</p><h3>LEAVE ONE OUT CROSS VALIDATION</h3><p>In leave one out cross validation ,in the name itself we can see we are just leaving one data point for test and considering remaining all for train data.</p><p>For example: If you are considering 1000 data points(rows) and in the first iteration consider one data points as test and remaining 999 data points as train data and keep on doing 1000 iterating changing the test and train data points.</p><p><strong>Note:</strong> LeaveOneOut() is equivalent to KFold(n_splits=n) and LeavePOut(p=1) where n is the number of samples (i.e. 1000)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zj6mOOR6xWNUWgt7kf8B4Q.png" /></figure><h3>DRAWBACK</h3><ol><li>No of iterations is more, computation time is more.</li><li>It will leads to bias error i.e. if a new test data point which is not part of this dataset is given in production phase it will not able to predict accurately since it is not trained on the data point so accuracy will be reduced.</li></ol><h3>KFOLD CROSS VLIDATION</h3><p>In order to prevent the train test split you can use KFold cross validation</p><p>In KFold cross validation if you set n_splits=5 it will split it into 5 iterations or experiments.</p><p>If you have 1000 data points it will split 1000/5=200, considering 200 for test data points and remaining 800 for train data points based on the test it will give accuracy assume 0.85,likewise repeat for remaining 4iterations .so we will end up with 5 different accuracy for various randomly shuffled data points.</p><p>From that we can take mean accuracy and explain the stakeholders model accuracy , we can also able to explain what will be the min and max accuracy the model will predict.</p><p>The purpose of using Random_state in KFOLD is when you use three models with different features(log_reg-x1,x2,x3,KNN-x1,x3,x4,Decision tree-x2,x3,x5) by fixing same random state we can say that the result changes is due to the change of variables or due to change of values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/909/1*4GAxT1wUFbJIxY722UDxvQ.png" /></figure><h3>DRAWBACK</h3><p>For classification consider binary classification 0,1 if test data has all 1 and in train data also has most 1 it will lead to imbalance to overcome this we use stratified cross validation.</p><p>CODE:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*VjfGDra05oIpSPLux2c5Yw.png" /></figure><p>Contact Links:</p><p>Linkedin: <a href="https://www.linkedin.com/in/22vignesh97/">https://www.linkedin.com/in/22vignesh97/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a2a8c2bb16b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Converting Data file to CSV file and read through Jupyter notebook]]></title>
            <link>https://22vignesh97.medium.com/converting-data-file-to-csv-file-and-read-through-jupyter-notebook-b88b516c4c17?source=rss-bf8578732bbb------2</link>
            <guid isPermaLink="false">https://medium.com/p/b88b516c4c17</guid>
            <category><![CDATA[csv-file]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[jupyter-notebook]]></category>
            <dc:creator><![CDATA[Vignesh S]]></dc:creator>
            <pubDate>Sat, 03 Jul 2021 18:42:03 GMT</pubDate>
            <atom:updated>2021-09-24T06:26:28.678Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi Welcome ,This was my first blog, so thanks for medium platform to providing this opportunity. since I was very passionate in learning new technologies and I love to share the stuff which I came across my learning. In this blog I am going to share how to convert the Data File in to the CSV file and read it in Jupiter Notebook.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JafT3gf12CmTQdW8l7zieQ.jpeg" /><figcaption>Data File to CSV file</figcaption></figure><h3><strong>1.Datasets Extraction</strong></h3><p>There are various free sources where we can get data of any domain and infer the business insights. Below I am listing the various useful resource where we can extract the datafiles for our projects.</p><ol><li>Kaggle:<a href="https://www.kaggle.com/tags/web-sites">https://www.kaggle.com/tags/web-sites</a></li><li>UCI Machine Learning: Repository :<a href="https://archive.ics.uci.edu/ml/index.php">https://archive.ics.uci.edu/ml/index.php</a></li><li>Data World:<a href="https://data.world/datasets/website">https://data.world/datasets/website</a></li><li>Government data:<a href="https://data.gov.in/">https://data.gov.in/</a></li></ol><h3><strong>2 .Data file to CSV file through excel</strong></h3><p>Some of the data file you download may not be in the condition where you cannot directly work with platform, it may be unstructured, In order to convert it into better readable form you need to convert it into structured data. Here I will show how we are going to convert the unstructured data file to structured csv file and use it in the Jupyter platform where it is helpful for the data scientist and data analyst to make his/her work simple.</p><p><strong>STEP 1: Download the file from data source to local desktop</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_hKF8guyhooqPuCfJalhkA.png" /><figcaption><strong>Data file</strong></figcaption></figure><p><strong>STEP 2: Convert the Data file to Notepad</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tBSrZTlzkcBnJa_7l0XqZw.jpeg" /><figcaption><strong>Conversion to notepad</strong></figcaption></figure><p><strong>STEP 3: Open the notepad file and copy the content and paste in Excel</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2MUjxbQDTlWiWF-V59GO5A.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*Ao_2wTjKnlIZY1unXvG1AA.jpeg" /><figcaption><strong>Paste the content of notepad to Excel.</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RBSbVnqyewyc1KrtuBc6dw.jpeg" /><figcaption><strong>Click on data in menu bar and click text to columns.</strong></figcaption></figure><p><strong>STEP 4: Change the content to structured format</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*2hGH4dFEe7OLyJzEy4fC9g.jpeg" /><figcaption><strong>Use the delimiter option and change in to relevant columns and rows click next.</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DIYX-m-_MX1hYxFhFw6svg.jpeg" /><figcaption><strong>Changed to relevant rows and columns.</strong></figcaption></figure><p>After modification save the file and convert to comma separated values(csv) and store it in local desktop…</p><h3><strong>Read through Jupyter Notebook without changing anything in excel using python code.</strong></h3><p>open the jupyter notebook and type the following commands to import the csv file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SVWAf9b0S-DWy6_6yHm14g.jpeg" /><figcaption>Import csv file to Jupyter</figcaption></figure><p>Import the basic pandas library to import the datasets</p><h4><strong>import numpy as np</strong></h4><h4><strong>import pandas as pd</strong></h4><p>After import the datasets read the csv file</p><h4>df=pd.read_csv(“car.csv”)</h4><p>Data frame has been created and now we are free to work and infer the insights of the datasets that is imported.</p><p>Explicitly pass header=0 to be able to replace existing names. The header can be a list of integers that specify row locations for a multi-index on the columns e.g. [0,1,3]. Refer:<a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html">https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z9mY_7y-xcjqumom2xuQkw.png" /></figure><p><strong>([“symboling”,”normalized-losses”,”make”,”fuel-type”,”aspiration”, “num-of-doors”,”body-style”,”drive-wheels”,”enginelocation”,“wheelbase”,”length”,”width”,”height”,”curb-weigh”,”engine-type”,“num-of-cylinders”,”engine-size”,”fuel-system”,”bore”,”stroke”,“compression-ratio”,”horsepower”,”peak-rpm”,”city-mpg”,”highway-mpg” “price”],axis=’columns’,inplace=True)</strong></p><h3><strong>Reading the DATA file through Python code is as simple .</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wEjRdTdC6BiosDnuIWN8Pg.png" /></figure><p>If your data is in this format in csv ,you can read the data in notebook by not changing anything in excel using following code,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LzCtytuZwmvM3j8G7sO-sw.png" /></figure><p>To see the code refer the GitHub profile below…</p><p>GitHub profile:<a href="https://github.com/vigneshsathish/Exploratory-Data-Analysis">https://github.com/vigneshsathish/Exploratory-Data-Analysis</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b88b516c4c17" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>