<?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 AshirbadPradhan on Medium]]></title>
        <description><![CDATA[Stories by AshirbadPradhan on Medium]]></description>
        <link>https://medium.com/@ashirbadpradhan8115?source=rss-f6dd1946d20b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*T9MoJZ_b-5QGNAhJ</url>
            <title>Stories by AshirbadPradhan on Medium</title>
            <link>https://medium.com/@ashirbadpradhan8115?source=rss-f6dd1946d20b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 03:31:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ashirbadpradhan8115/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[Feature Scaling Technique:]]></title>
            <link>https://medium.com/@ashirbadpradhan8115/feature-scaling-technique-ada4d77aef21?source=rss-f6dd1946d20b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ada4d77aef21</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-modeling]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[feature-scaling]]></category>
            <dc:creator><![CDATA[AshirbadPradhan]]></dc:creator>
            <pubDate>Thu, 18 Jan 2024 06:54:38 GMT</pubDate>
            <atom:updated>2024-01-18T06:54:38.807Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, we will understand feature scaling technique in depth.</p><p><strong>Feature scaling</strong> is a preprocessing steps in machine learning that involves transforming features to a similar scaling. One key aspect of feature engineering is scaling which involves transforming the data to make it more suitable for modeling.</p><p>This techniques can help to improve model performance, reduce the impact of outliers, and ensure that the data is on the same scale.</p><p><strong>Feature scaling</strong> becomes necessary when datasets containing features that have different ranges, units of measurement, or orders of magnitude. In such cases, the variation in feature values can lead to biased model performance or difficulties during the machine learning process.</p><p>For an instance , Suppose we have a dataset which contains different columns have different units like one column can be weights in kg ,one may be age in year and income in rupees, where weight ranges from [1–110] ,age ranges from [20–60] and income ranges from [25000–100000]. If we feed this data to our model, it will consider income has highest weightage and it may influence more about the income column. So to overcome this type of problem we use feature scaling where we can bring down the data into same scale.</p><p><strong><em>TYPES:</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/829/1*3-I6bUKy2M0LCJJUF37AsA.png" /></figure><p><strong>1)Standard Scaler:</strong></p><ul><li>This technique scale the data to have a mean of zero and standard deviation of one. This is also known as Standardization.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*TiGQ8-nQuONQlpdGrtHnmQ.png" /></figure><ul><li>It is appropriate when data approximately follows a Gaussian Distribution or bell-shaped curve.</li><li>It is less sensitive to outliers</li><li>It changes the shape of original distribution.</li><li>It preserves the relationship between the data points.</li></ul><p><strong>2)Min-max Scaler:</strong></p><ul><li>This technique scales the data in range between zero and one. This is also known as Normalization.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*I-Pujc_o2NRyY9vzN1c6xA.png" /></figure><ul><li>It is useful when the distribution of data is unknown or not gaussian distribution.</li><li>It is sensitive to the outliers.</li><li>It retain the shape of original distribution.</li><li>It may not preserve the relationship between the data points.</li></ul><p>However, at the end of the day, the choice of using <em>normalization</em> or <em>standardization</em> will depend on your problem and the machine learning algorithm you are using. There is no hard and fast rule to tell you when to normalize or standardize your data. You can always start by fitting your model to raw, normalized, and standardized data and comparing the performance for the best results.</p><p><strong>3)Robust Scaler:</strong></p><ul><li>The Robust scaler scales the data based on percentiles and is robust to outliers. It subtracts the median and divides by the interquartile range.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*Gu93l4agZhrgjRIvIkJzKQ.png" /></figure><ul><li>This Scaler removes the median and scales the data according to the quantile range. The IQR is the range between the 1st quartile (25th quantile i.e. Q1) and the 3rd quartile (75th quantile i.e. Q3).</li><li>Since it uses the interquartile range, it absorbs the effects of outliers while scaling. The interquartile range (Q3 — Q1) has half the data point. If you have outliers that might affect your results or statistics and don’t want to remove them, Robust scaler is the best choice.</li></ul><p><strong>4)Max-absolute Scaler:</strong></p><ul><li>The Max-absolute scaler scales the data to the range [-1, 1] based on the maximum absolute value in each feature.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*2JIvzfm1Cv_ibm4c-Z0-Mg.png" /></figure><p>In nutshell, Standardization is not suitable for data that have outliers. It adjusts the mean to 0.Robust scaler is more suitable for data that have outliers. Min-max scaler is is not suitable for data that have outliers. It adjusts the data between 0 and 1. Max-absolute scaler is not suitable for data that have outliers. It adjusts the data between -1 and 1.</p><h4><strong>Scaling the features is important for several Reasons:</strong></h4><p>Some machine learning algorithms are sensitive to feature scaling, while others are virtually invariant.</p><ol><li><strong>Gradient Descent Based Algorithms: </strong>Machine learning algorithms like linear regression , logistic regression, neural network, PCA (principal component analysis), etc., that use gradient descent as an optimization technique require data to be scaled. <em>“Having features on a similar scale can help the gradient descent converge more quickly towards the minima”.</em></li><li><strong>Distance Based Algorithms: </strong>Distance algorithms like KNN, K-mean Clustering, and SVM(support vector machines) are most affected by the range of features. This is because, behind the scenes, they are using distances between data points to determine their similarity.</li><li><strong>Tree Based Algorithms: </strong>Tree based algorithms on the other hand, are fairly insensitive to the scale of the features. A decision tree only splits a node based on a single feature. The decision tree splits a node on a feature that increases the homogeneity of the node. Other features do not influence this split on a feature. So, the remaining features have virtually no effect on the split. This is what makes them invariant to the scale of the features.</li></ol><p>Hope you like it, fellas!</p><p>Thanks for reading. See you again with another blog ,take care guys.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ada4d77aef21" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hyperparameter Tuning| Machine Learning.]]></title>
            <link>https://medium.com/@ashirbadpradhan8115/hyperparameter-tuning-machine-learning-6508a0cd2368?source=rss-f6dd1946d20b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6508a0cd2368</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-ana-analytics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data-analyst]]></category>
            <dc:creator><![CDATA[AshirbadPradhan]]></dc:creator>
            <pubDate>Wed, 23 Aug 2023 14:23:03 GMT</pubDate>
            <atom:updated>2023-08-23T14:23:03.651Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog ,we will understand hyperparameter tuning in depth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*sK2bPeahQ3tcENLUNf603A.png" /></figure><h4><strong>Parameter</strong></h4><ul><li>In machine learning, a parameter refers to a configuration variable that is used by an algorithm to make predictions or learn patterns from data. These parameters are typically learned or estimated from the training data during the model training process.</li><li>There are two types of parameters in machine learning:</li></ul><p>a)Model parameters.</p><p>b)Model Hyperparameters.</p><h4><strong>a)Model Parameters (</strong>Internal Parameters<strong>)</strong></h4><p>1) They can be directly trained from data.</p><p>2)Model parameters are learned during training when we optimize a loss function using method like gradient descent. ( optimization refers to determining best parameters for a model, such that the loss function of the model decreases, as a result of which the model can predict more accurately).</p><p>3)The model parameters specify how to transform the input data into the desired output.</p><p>4) Model parameters are the properties of training data that will learn on its own during training by the machine learning model.</p><p>5)Learning during training process.</p><p>Model parameters are weights , Bias .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*QHAH_FP5L2EudB0vznST7w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*eRqtnWb6MRPnA22BIekSEw.png" /></figure><h4><strong>b)Model hyperparameters (</strong>External Parameters<strong>)</strong></h4><p>1) They can’t be directly trained from the data. ( means its value can not be estimated from the data).</p><p>2)There is no way to calculate or update hyperparameter to reduce the loss in order to find the optimal model architecture.</p><p>3)The hyperparameter define how our machine learning model is actually structure.</p><p>4)We generally perform experiments to find which value works best.</p><p>5)A hyperparameter is a parameters whose value is used to control the learning process.</p><p>6)It used in process to help estimate model parameters.</p><p>7)They are actually fixed before the training process begins.</p><h4>Hyperparameters</h4><p>Hyperparameters is a parameters whose value is set before learning process begins.</p><p><strong><em>Model hyperparameters are</em></strong></p><p>i ) Learning Rate.</p><p>ii)Lambda in Ridge and Lasso Regularization.</p><p>iii)Cross validation.</p><p>iv)n_ estimators.</p><p><strong>i )Learning Rate.</strong></p><p>•It is used in the gradient descent to find the global minimum of a function.</p><p>(Gradient Descent- Gradient descent is an iterative optimization algorithm to find the global minimum of function. Here this function is the loss function.)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*16uR2JPzCtu2qSCGPe7kbw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*Mzyir6wRt5tbg36SRtS7ww.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/278/1*v-kA0vmcMQLKp4Y4n0KhCw.jpeg" /><figcaption>Gradient Descent in 3D</figcaption></figure><p><strong>ii)Lambda in Ridge and Lasso Regularization.</strong></p><ul><li>Before Understanding Ridge(L2) and Lasso(L1) regularization we need to first understand</li></ul><p>a) <em>linear Regression</em>- this is nothing but tries to find the best fit line ,that minimizes the residuals , which gives the result of generalized model.</p><p>b)<em>Bias and Variance</em>- we use bias term for training and variance for testing result.</p><ul><li>If model perform good in both training and testing dataset then it is called as Low Bias and Low Variance [Generalized Model].</li><li>If my model perform worst in both training and testing dataset, which is giving high error we call this as high bias and high variance [Underfitting condition].</li><li>If my model performs good in Training dataset and performs badly in the testing dataset, we call this as low bias &amp; high variance [Overfitting condition].</li><li>To overcome this overfitting condition and make model to generalized regularization technique came into picture. So ridge and lasso are the regularization technique that deals with overfitting and when dataset is large. This technique involves adding a penalties to the cost function.</li><li>This penalty is nothing but the lambda i.e. hyperparameter. we use set of lambda values because we don’t the penalty value and test ,which hyperparameter gives the best accuracy for both training and testing dataset.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*xbvSu3tddUNQ6GgAEDqMZw.png" /><figcaption><strong>Bias -Variance tradeoff</strong></figcaption></figure><h4>iii)Cross Validation (cv)</h4><p>Cross-validation is a technique that involves partitioning a dataset into subsets, training the model on some subsets, and evaluating its performance on the remaining subset.</p><ul><li>The main goal of cross-validation is to estimate how well a trained model will perform on unseen data. It helps to detect issues such as overfitting or underfitting and provides a more robust evaluation of the model’s performance.</li></ul><p><strong><em>Types of cross validation are</em></strong></p><ol><li>Leave one out cross validation</li><li>Holdout cross validation</li><li>k-fold cross validation</li><li>Stratified k-fold cross validation</li><li>Time series cross validation</li></ol><h4>iv) n_ estimators</h4><p>Number of tress you want build for model .</p><h3><strong><em>Hyperparameter tuning</em></strong></h3><ul><li>Hyperparameter tuning is a process of finding the hyperparameter values of a learning algorithm that produce the best model.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*0nU5GCvUVXkqV43DZWU1pw.png" /></figure><ul><li>The outcome of hyperparameters tuning is the best hyperparameters setting and the outcome of model training is the best model parameters settings.</li><li>Machine learning model can have many hyperparameter and finding the best combination of parameters can be treated as a search problem.</li><li>we can’t know the best value for a model hyperparameter on a given problem. So we can search the best value by trial and error.</li></ul><p>Types of Hyperparameter tuning method</p><p><em>a)GridSearchCV</em></p><p><em>b)RandomisedSearchCV</em></p><h4><strong>a)GridSearchCV</strong></h4><ul><li>In grid search approach machine learning model is evaluated for a range of hyperparameters values.</li><li>It is called as grid search because it search for the best set of hyperparameters from a grid of hyperparameter values.</li><li>It try all combination.</li><li>It is an exhaustive searching through a manually specified subset of hyperparameter space of learning algorithm.</li><li>With grid search technique , we simply build a model for each possible combination of all of hyperparameters values provided , evaluating each model and selecting architecture which produce the best result.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*qWvR_3bD7w6r7ey23bPcUg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/727/1*XPvxCbaj7zntL0STo6DcJA.png" /></figure><p><strong><em>Disadvantages</em></strong></p><p>It will go through all the intermediate combination of hyperparameters which makes grid search computationally very expensive.(means take a lot of time)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*zPaMAxLtluI23lZclAziMw.png" /><figcaption>code for ridsearchcv</figcaption></figure><h4>b)RandomisedSearchCV</h4><ul><li>Instead of searching over the entire grid, random search only evaluates a random sample of points on the grid based on random state and give the best estimators .</li><li>This makes random search a lot cheaper than grid search.</li></ul><p><strong><em>Disadvantages</em></strong></p><ul><li>It doesn’t use information from prior experiments to select the next set.</li><li>It is very difficult to predict the next set(means which set of hyperparameters give best result ) for experiment.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*0ZpNXGnYpaRT2OsEOYvwGw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BtQWad18MtPPq_pa61muTg.png" /><figcaption>code for RandomsiedsearchCv</figcaption></figure><h4><strong>CONCLUSION:</strong></h4><p>In summary, hyperparameters are the parameters that you set before training a model, and hypertuning parameter is the process of finding the best values for those hyperparameters to optimize the model’s performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6508a0cd2368" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decision Tree ID3 Algorithm |Machine Learning]]></title>
            <link>https://medium.com/@ashirbadpradhan8115/decision-tree-id3-algorithm-machine-learning-4120d8ba013b?source=rss-f6dd1946d20b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4120d8ba013b</guid>
            <category><![CDATA[data-analyst]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-scientist]]></category>
            <category><![CDATA[decision-tree]]></category>
            <dc:creator><![CDATA[AshirbadPradhan]]></dc:creator>
            <pubDate>Sun, 11 Jun 2023 09:48:10 GMT</pubDate>
            <atom:updated>2023-06-11T09:48:10.406Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog ,we understand Decision Tree ID3 algorithm in details with example sample dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1sqy1OThlBiGFQr6numvxA.jpeg" /></figure><h3><strong>Decision Tree</strong></h3><p>A Decision Tree is a supervised Machine learning algorithms used for both regression and classification problem statement. It uses the tree representation to solve a problem in which each node represents an attribute, each link represents a decision rule and each leaf represents an outcome( categorical or continuous value).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*1_I2S5xiW49_A0kP7mgQDQ.png" /></figure><h3>Decision Tree Terminologies</h3><p><strong>Root Node</strong>- It is the topmost node in the tree, which represent the complete dataset. Also we can say it is the starting point of the decision-making process.</p><p><strong>Decision/Internal Node- </strong>Decision nodes are nothing but the result in the splitting of data into multiple data segments and main goal is to have the children nodes with maximum homogeneity or purity( means all of the same kind).</p><p><strong>Leaf/Terminal Node</strong>- This node represent the data section having highest homogeneity (means all of the same kind).</p><p><strong>Entropy</strong>-It is used for checking the impurity or uncertainty present in the data. Entropy is used to evaluate the quality of a split. When entropy is zero the sample is completely homogeneous, meaning that each instance belongs to the same class and entropy is one when the sample is equally divided between different classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*iztrAcaoyhM9cfjnszk-sw.png" /></figure><p>Formula of Entropy -</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/1*c61IrcyJOAgKqINAYsP5RQ.png" /></figure><p><strong>Information Gain</strong>- Information gain indicates how much information a particular feature/ variable give us about the final outcome.</p><p>Formula of information gain-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HSh5x1n-evMPSXo7Ac1Y8w.png" /></figure><h3>ID3 [Iterative Dichotomiser3]</h3><p>(It is the most popular algorithms used to constructing trees.)</p><p>ID3 stands for Iterative Dichotomizer3 and is named such because the algorithm iteratively(repeatedly) dichotomizes(divides) features into two or more groups at each step.ID3 is an algorithm invented by Ross Quinlan used to generate a decision tree from a dataset and is the most popular algorithms used to constructing trees.</p><p>ID3 is the core algorithm for building a decision tree .It employs a top-down greedy search through the space of all possible branches with no backtracking. This algorithm uses information gain and entropy to construct a classification decision tree.</p><h3>Characteristics of ID3 Algorithm</h3><p>Major Characteristics of the ID3 Algorithm are listed below:</p><ul><li>ID3 can overfit the training data (to avoid overfitting, smaller decision trees should be preferred over larger ones).</li><li>This algorithm usually produces small trees, but it does not always produce the smallest possible tree.</li><li>ID3 is harder to use on continuous data (if the values of any given attribute is continuous, then there are many more places to split the data on this attribute, and searching for the best value to split by can be time-consuming).</li></ul><h3>Advantages and Disadvantages of ID3 Algorithm</h3><h4>Advantages</h4><ul><li>Inexpensive to construct</li><li>Extremely fast at classifying unknown records Easy to interpret for small-sized trees.</li><li>Robust to noise (especially when methods to avoid over-fitting are employed).</li><li>Can easily handle redundant or irrelevant attributes (unless the attributes are interacting).</li></ul><h4>Disadvantages</h4><ul><li>The space of possible decision trees is exponentially large. Greedy approaches are often unable to find the best tree.</li><li>Does not take into account interactions between attributes.</li><li>Each decision boundary involves only a single attribute.</li></ul><h4><strong>Steps to making Decision Tree</strong></h4><p>a) Take the Entire dataset as an input.</p><p>b) Calculate the Entropy of the target variable, As well as the predictor attributes</p><p>c) Calculate the information gain of all attributes.</p><p>d) Choose the attribute with the highest information gain as the Root Node</p><p>e) Repeat the same procedure on every branch until the decision node of each branch is finalized.</p><h3>Example-</h3><p>Forecast whether the match will be played or not according to the weather condition. Here we can see the table-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*lkGNUgIfJErU-u-6LlDfVA.png" /></figure><p>First we are going to calculate the entropy for “Decision” attribute which is a target variable and also calculate the entropy for independent attributes like “Outlook”, “Temp.” , “Humidity” , “Wind” .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*kjo5IoQZ3cEiLum4P-ToAQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cAFgoiv2UByOUUOqFm9fdA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*o2ID3ihlyOZ4fUMOAyf8iA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PfFQRhfn-x1qRFkFTj0tBw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OAEckDbj5Fu1nzyzqkWUNQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wGgjeNErU7eiAIhcA-WJew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O_k3NkGkdQfNRudIe5Uceg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*5Xo7ylQRrdDdtGQhZt5n5g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*FDc-8RwOjHpiXc1i5YLjMg.png" /></figure><p>Repeat the same procedure on every branch until the decision node of each branch is finalized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*xU7uee3AoFV_lRAeektgrw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*b6fJsU5i94qkXLMqveG-6w.png" /></figure><p>Outlook=Sunny and temp=Hot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/675/1*J_yMtfSvz9-5sB0QEOy4Jw.png" /></figure><p>Outlook=Sunny and temp=Mild</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*I0dxkkfgTBTgxR_4eTjtyw.png" /></figure><p>Outlook=Sunny and Temp=Cool</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*rbvmIxdlzoNjXyqXeF9Qow.png" /></figure><p>Outlook=Sunny |Humidity=High</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*_lhszfcB-PZ62wU16nUNYg.png" /></figure><p>Outlook=Sunny | Humidity=Normal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*trU-g7Af7E4-6dUwZSdusA.png" /></figure><p>Outlook=Strong | Wind=Strong</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*ClnCvOztr5bDnSB-_ZV6TQ.png" /></figure><p>Outlook=Sunny | Wind=Weak</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*BtaqG_DYTwcrYi1AUxs74Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_GulK9_EHWP14GbBK7Gp7g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*5cG0h0CdIUfDsRc9cmxgxw.png" /></figure><p>Here decision will always be yes if outlook were overcast. So no need of calculating entropy and information gain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*Q3dBVAP4hFKQm_fxgWqP1g.png" /></figure><p>Outlook=Rain | Temp=Mild</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*51pcMe0YNT-4OS1AyojbXg.png" /></figure><p>Outlook=Rain |Temp=Cool</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*_JEo7TT--KB2yhFx-QnGuw.png" /></figure><p>Outlook=Rain | Humidity=High</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*JdJ8AxlolB5vFlfxXIDZ3w.png" /></figure><p>Outlook=Rain | Humidity=Normal</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*6doq1t1uX0p1k2So3vVYog.png" /></figure><p>Outlook=Rain | Wind=Strong</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*8nyb2aenIE_IPHcclQS4EQ.png" /></figure><p>Outlook=Rain | Wind=Weak</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*YYo65QBlzF3JIb3iX8cZKQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0l7boxmDMrJq-QUU7lsnmQ.png" /></figure><p>Here we can see that information gain is high for (Outlook=Rain | Wind) , so it will be the decision node after Rain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*JPDa9vne771YWQftzKiPSw.png" /></figure><p>Decision Tree construction is over. Here we learned that how a decision tree is created in backend using this algorithm.</p><h3>Conclusion</h3><p>We covered the process of the ID3 algorithm in detail and saw how easy it was to create a Decision Tree using this algorithm by using only two metrics i.e. Entropy and Information Gain.</p><p>Hope you liked it , fellas !</p><p>Thanks for reading .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4120d8ba013b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple Linear Regression.]]></title>
            <link>https://medium.com/@ashirbadpradhan8115/simple-linear-regression-16a9dfa49b91?source=rss-f6dd1946d20b------2</link>
            <guid isPermaLink="false">https://medium.com/p/16a9dfa49b91</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[data-scientist]]></category>
            <dc:creator><![CDATA[AshirbadPradhan]]></dc:creator>
            <pubDate>Fri, 19 May 2023 15:33:49 GMT</pubDate>
            <atom:updated>2023-05-19T15:33:49.957Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*4D1-hf7ujkk4q3Szf8jepg.png" /></figure><p>Simple linear regression is used to estimate the relationship between two quantitative variables(i.e. Independent variable and dependent variable). It is a Supervised Machine Learning Algorithm to predict the continuous variable based on the certain features that we have (so we use linear regression if the target variable is continuous). If we take a unidimensional case for instance, where Y is dependent on specific value of X. Linear regression tries to find Best fit line, that passes through all the points that we have as closely as possible and the way it does is by trying to minimize the residuals of the points from the line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*eRqtnWb6MRPnA22BIekSEw.png" /><figcaption>Linear Regression</figcaption></figure><h3>How to perform a simple linear regression</h3><p><strong>Simple linear regression formula.</strong></p><p>The formula for a simple linear regression is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/143/0*dawNHH4EZ9wP_fUR.png" /></figure><ul><li><strong>y</strong> is the predicted value of the dependent variable (<strong>y</strong>) for any given value of the independent variable (<strong>x</strong>).</li><li><strong>B0</strong> is the <strong>intercept</strong>, the predicted value of <strong>y</strong> when the <strong>x</strong> is 0.</li><li><strong>B1</strong> is the regression coefficient — how much we expect <strong>y</strong> to change as <strong>x</strong> increases.</li><li><strong>x</strong> is the independent variable ( the variable we expect is influencing <strong>y</strong>).</li><li><strong>e</strong> is the <strong>error</strong> of the estimate, or how much variation there is in our estimate of the regression coefficient.</li></ul><p>Linear regression finds the line of best fit line through your data by searching for the regression coefficient (B1) that minimizes the total error (e) of the model.</p><h3>Linear Regression Line</h3><p>A linear line showing the relationship between the dependent and independent variables is called a <strong>regression line</strong>. A regression line can show two types of relationship:</p><ul><li><strong>Positive Linear Relationship:</strong><br>If the dependent variable increases on the Y-axis and independent variable increases on X-axis, then such a relationship is termed as a Positive linear relationship.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/328/1*DAIc65UlCnoham68Eynmjg.png" /></figure><ul><li><strong>Negative Linear Relationship:</strong><br>If the dependent variable decreases on the Y-axis and independent variable increases on the X-axis, then such a relationship is called a negative linear relationship.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*M5ZOAVsceiXWrFsepw0zbA.png" /></figure><h3>Finding the best fit line:</h3><p>When working with linear regression, our main goal is to find the best fit line that means the error between predicted values and actual values should be minimized. The best fit line will have the least error. (<strong>OLS-Ordinary Least Squares</strong> method is used to find out the best fit line or linear regression line by minimizing sum of squared difference between actual values and predicted values)</p><p>The different values for weights or the coefficient of lines (a0, a1) gives a different line of regression, so we need to calculate the best values for a0 and a1 to find the best fit line, so to calculate this we use cost function.</p><h3>Cost function:</h3><ul><li>The different values for weights or coefficient of lines (a0, a1) gives the different line of regression, and the cost function is used to estimate the values of the coefficient for the best fit line.</li><li>Cost function optimizes the regression coefficients or weights. It measures how a linear regression model is performing.</li><li>We can use the cost function to find the accuracy of the <strong>mapping function</strong>, which maps the input variable to the output variable. This mapping function is also known as <strong>Hypothesis function</strong>.</li></ul><p>For Linear Regression, we use the <strong>Mean Squared Error (MSE)</strong> cost function, which is the average of squared error occurred between the predicted values and actual values. It can be written as:</p><p>For the above linear equation, MSE can be calculated as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*FdjeXUPzBV7l0sbFT7cxXw.png" /></figure><p><strong>Where,</strong></p><p>n=Total number of observation<br>Yi = Actual value<br>Yi^=(a1xi+a0)= Predicted value.</p><p><strong>Residuals:</strong> The distance between the actual value and predicted values is called residual. If the observed points are far from the regression line, then the residual will be high, and so cost function will high. If the scatter points are close to the regression line, then the residual will be small and hence the cost function.</p><h3><strong>Gradient Descent:</strong></h3><ul><li>Gradient descent is used to minimize the MSE by calculating the gradient of the cost function.</li><li>A regression model uses gradient descent to update the coefficients of the line by reducing the cost function.</li><li>It is done by a random selection of values of coefficient and then iteratively update the values to reach the minimum cost function.</li></ul><h3>Model Performance:</h3><p>The Goodness of fit determines how the line of regression fits the set of observations. The process of finding the best model out of various models is called <strong>optimization</strong>. It can be achieved by below method:</p><p><strong>1. R-squared method:</strong></p><ul><li>R-squared is a statistical method that determines the goodness of fit.</li><li>It measures the strength of the relationship between the dependent and independent variables on a scale of 0–100%.</li><li>The high value of R-square determines the less difference between the predicted values and actual values and hence represents a good model.</li><li>It is also called a <strong>coefficient of determination,</strong> or <strong>coefficient of multiple determination</strong> for multiple regression.</li><li>It can be calculated from the below formula:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/331/1*YdUcelAC-XXy4CBkuxJJHQ.png" /></figure><p>where;</p><p>SSR=Sum of squared regression. SSE=Sum of squared error. SST=Sum of squared total.</p><p>The main problem with R-Squared is that it will always remains the same or increases as we are adding more independent variable, Therefore to overcome this problem.</p><p>An <strong>Adjusted R-Squared </strong>came into picture by penalizing those adding independent variable that do not improve your existing model. It can be calculated from below formula:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*_igiB_HiOfoMp3KZC5QZ0w.jpeg" /></figure><h3><strong>Assumptions Of Linear Regression Algorithm.</strong></h3><p>There are five most important assumptions of linear regression algorithm.</p><ol><li>Linearity:- There should be Linear Relationship between the Features &amp; Target Variable.</li><li>Homoscedasticity:- The size of the error in our prediction doesn’t change significantly across the values of the independent variable.</li><li>Multi-collinearity:- There should be no multicollinearity between the features.</li><li>Independence:- Observations are Independence of each other.</li><li>Normality:- The data follows a Normal Distribution.</li></ol><h3><strong>Example: </strong>Predicting the impact of advertising on sales with Simple linear regression.</h3><p>Taking example of Advertisement and sales data. Using Python.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*a3tPopD636RWtyp7HYAJyg.png" /></figure><p><strong>Problem Statements: </strong>Whether the given data model is a good model or not.</p><ol><li><strong>Importing The Libraries:</strong></li></ol><p>Importing pandas library for data manipulation and data analysis. Importing matplotlib and seaborn library for data visualization and importing filter warnings for remove the warnings.</p><pre>import pandas as pd<br>import matplotlib.pyplot as plt<br>import seaborn as sns<br>from warnings import filterwarnings<br>filterwarnings(&#39;ignore&#39;)</pre><p><strong>2.Read the file:</strong></p><p>If the file is in csv then use pandas library to read the file and create a data set name data.</p><pre>data=pd.read_csv(&quot;slr.csv&quot;)<br>data</pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/324/1*fmr2BhoiiVqVvdmKRYQ3Jg.png" /></figure><p><strong>3.Draw scatterplot:</strong></p><p>The <strong>scatter</strong> () method in the <strong>matplotlib</strong> library is used to draw a <strong>scatter plot</strong>. <strong>Scatter plots</strong> are widely used to represent relation among variables and how change in one affects the other.</p><pre># lets print the scatter plot<br>plt.scatter(data.Advt,data.Sales)<br>plt.xlabel(&#39;Advt&#39;)<br>plt.ylabel(&#39;Sales&#39;)<br>plt.show()</pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*iJhSwKlX-5BkD1hohW8P1A.png" /></figure><p>It indicates that as advertisement is increasing then sales are also increasing.</p><p><strong>4. Check for correlation matrix:</strong></p><p>Seaborn is used to plot heatmap of a given data to show the correlation matrix .It indicates how one variable is correlate with other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*LQ1vioxN-bVyRA4RM_Ik_w.png" /></figure><p><strong>5. Now find the mean:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ir3inpqWzpmo_qQTAktRow.png" /></figure><p><strong>6.Now find the co-efficient:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kDl_ZIF-mB64khiyOvMOfA.png" /></figure><p><strong>7.Find the intercept:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9IMwh2yjfHxgVq9v9nOWXA.png" /></figure><p><strong>8.Now Find the predicted values:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZtydmxjUnKrX4eNpkq7lPA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ER3sHbKUFoQiS4Z7rIb7g.png" /></figure><p><strong>9.Plot best fit line:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*_Ej9oKISDN0I0c_0xzl7QA.png" /></figure><p>It shows positive linear relationship between advertisement and sales and blue shows the best fit line( where sum of squared difference between actual point and predicted point is minimum).</p><p><strong>10. Find Residuals:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ejM9MipoeiU1WnhNzf-RUw.png" /></figure><p><strong>11.Find SST, SSR, SSE :</strong></p><p>SST=Sum of squared total. SSR=Sum of squared regression. SSE=Sum of squared error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ytK0rXtj4tZx2i3UqU9Hg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p99Zsnbr9vrgstwcx6A7CA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h7mAYKcW7n4SUsc2LNKWlw.png" /></figure><p><strong>12. Find R-squared and Adjusted R-squared:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RMpR8hGH143DrWBFrPYlmw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZtbWeUzR3oMpAYhlwANoPw.png" /></figure><p><strong>Conclusion:</strong></p><p>Here we got <strong>R-squared value=90%</strong> ,that’s indicating goodness of fit. The model is a good model (we have <strong>relevant predictors</strong> in the model). There is no need of taking the adjusted R-squared value because the data doesn’t have the multi-collinearity (because there is only one independent variable present in the given data).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16a9dfa49b91" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>