<?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 Harshamokhasi on Medium]]></title>
        <description><![CDATA[Stories by Harshamokhasi on Medium]]></description>
        <link>https://medium.com/@harshamokhasi07?source=rss-7ca5e980a485------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*WpImywooVx1NXHWm</url>
            <title>Stories by Harshamokhasi on Medium</title>
            <link>https://medium.com/@harshamokhasi07?source=rss-7ca5e980a485------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 01:33:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@harshamokhasi07/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[Types and Importance of Feature Selection in Machine Learning]]></title>
            <link>https://medium.com/@harshamokhasi07/types-and-importance-of-feature-selection-in-machine-learning-2612b0844b6a?source=rss-7ca5e980a485------2</link>
            <guid isPermaLink="false">https://medium.com/p/2612b0844b6a</guid>
            <dc:creator><![CDATA[Harshamokhasi]]></dc:creator>
            <pubDate>Sun, 19 Feb 2023 13:52:33 GMT</pubDate>
            <atom:updated>2023-02-19T14:30:02.241Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*poSn4wLA48-xIVnKDKLZvw.png" /><figcaption>Source: Maxim Popov/Dreamstime.com</figcaption></figure><p>In the beginning, I used to believe that machine learning is going to be all about algorithms, knowing which one to apply when to apply, and what will be my model accuracy. When I contracted close by, I realized that was not the case.</p><p>In this article, I will focus on one of the critical parts of getting your models right — feature selection. I will discuss in detail why feature selection plays a vital role in creating an effective predictive model.</p><h3><strong>Table of Contents</strong></h3><ol><li>What is feature selection?</li><li>What is the importance of Feature Selection in machine learning?</li><li>What are the techniques for feature selection?</li><li>Different types of feature selection.</li></ol><h3>1. Feature selection in machine learning:</h3><p>Feature Selection is the method of reducing the input variable to your model by using only relevant data and eliminating noise in data. The goal of feature selection is to improve the performance of the model by reducing the number of input features while maintaining or even increasing the accuracy of the model.</p><h3>2. Importance of Feature Selection in Machine Learning:</h3><p>I was always wondering, can’t we just input the raw data straight into the model, can’t we just train the model with the raw data, can’t we achieve the objective by fitting the model with the raw data. In the world of machine learning, there is only one simple rule “<strong>Garbage In Garbage Out</strong>”. By the way, this garbage is dataset noise. When there is an overabundance of features, this is significant. The problem with the raw data if we train our model the output will be very low efficiency. The need for feature selection arises because a large number of input features can lead to overfitting, where the model learns the noise in the data rather than the underlying pattern.</p><p>Feature selection is a crucial step in the machine learning process as it has several important benefits:</p><p>· <strong>Reduces Overfitting:</strong> When a model is trained on a large number of features, it becomes more prone to overfitting, where the model learns the noise in the data rather than the underlying patterns. By selecting only, the most relevant features, the model can avoid overfitting and produce more accurate predictions.</p><p>· <strong>Improves Model Interpretability:</strong> A model with many features can be difficult to understand and interpret. Feature selection helps to simplify the model by retaining only the most meaningful features, making it easier to understand the relationship between the features and the target variable.</p><p>· <strong>Increases Training Speed:</strong> Training a machine learning model on a large number of features can be computationally expensive and time-consuming. By reducing the number of features, the training time can be reduced, allowing the model to be trained and tested more quickly.</p><p>· <strong>Improves Generalization Performance:</strong> A model that is trained on only the most relevant features is more likely to generalize well to new, unseen data, compared to a model that is trained on a large number of features, including many that are not relevant.</p><h3>3. Feature Selection Techniques:</h3><p>Feature selection methods can be broadly classified into three categories: filter methods, wrapper methods, and embedded methods.</p><p>Filter methods (ANOVA, Pearson Correlation, Variance thresholding, Information gain), Wrapper techniques (forward, backward, and stepwise selection), and embedding methods are three categories of supervised methods (Lasso, Ridge, Tree based).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*bz4jCirT6wJrWnI9i-iDUg.png" /><figcaption>Feature Selection Techniques</figcaption></figure><h3>3.1 Filter Methods:</h3><p>Filter methods evaluate the importance of features based on their statistical properties or correlation with the target variable, and select the top-ranked features. In most cases, filter methods are utilized as a pre-processing step. The main key advantage of the filter method is it involves selecting the most important features from a dataset based on their statistical properties, rather than on how well they contribute to a model’s performance.</p><p>The following are some typical Filter methods are as follows:</p><p>· Correlation</p><p>· Variance Threshold</p><p>· Chi-Square test</p><p>· ANOVA</p><p>· Information Gain</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*eA-SGrIuWLeqBDOPoLTl8A.png" /><figcaption>The flow of the Filter Method</figcaption></figure><p><strong>3.1.1 Correlation:</strong></p><p>Pearson’s correlation is a statistical measure of the strength and direction of the linear relationship between two variables. In machine learning, Pearson’s correlation can be used as a feature selection method to identify and select the most relevant features for a given predictive modeling task.</p><p>Specifically, Pearson’s correlation can be used to identify features that are highly correlated with the target variable, as well as to identify features that are highly correlated with each other. Highly correlated features may contain redundant information, and keeping all of them in a model can lead to overfitting and reduced performance. Therefore, selecting the most relevant features based on their correlation with the target variable can help to improve the predictive performance of a machine learning model.</p><p>Alternatively, a more sophisticated approach, such as principal component analysis (PCA), can be used to identify a smaller set of uncorrelated features that capture most of the variation in the data.</p><p><strong>3.1.2 Variance threshold:</strong></p><p>It involves selecting features based on the variance of their values. The basic idea is to remove features that have very low variance, as they are likely to be uninformative or redundant.</p><p>By removing low-variance features, the variance thresholds can help to reduce the dimensionality of the dataset and improve the efficiency and accuracy of machine learning models. This is particularly useful when dealing with high-dimensional datasets where the number of features is much larger than the number of samples. Removing low-variance features can also help to reduce overfitting, as it can eliminate noise and uninformative signals in the dataset. However, it’s important to note that the variance threshold is a relatively simple and crude feature selection technique, and may not always result in optimal feature subsets. Other more sophisticated methods, such as Lasso regularization, may be more effective in certain cases.</p><p><strong>3.1.3 Information Gain:</strong></p><p>It measures the reduction in entropy of the target variable that results from splitting the data based on a particular feature. Entropy is a measure of the uncertainty or randomness in the target variable. By splitting the data based on a feature, we can reduce the entropy of the target variable, which means that the feature provides useful information for predicting the target variable. The higher the information gain, the more useful the feature is for predicting the target variable.</p><p>During feature selection, the algorithm selects the features with the highest information gain, which means they provide the most useful information for predicting the target variable.</p><p><strong>3.1.4 Chi-square Test:</strong></p><p>The chi-square test is a statistical test used to determine the independence of two categorical variables. In the context of feature selection in machine learning, the chi-square test can be used to evaluate the relationship between a feature and the target variable.</p><p>Specifically, the chi-square test can be used to measure the significance of the association between a categorical feature and the categorical target variable. It does this by comparing the observed frequencies of a particular feature with the expected frequencies that would be observed if the feature and the target variable were independent.</p><p><strong>3.1.5 ANOVA:</strong></p><p>It is a method for identifying important features that can be used for prediction in machine learning. It measures the statistical significance of each feature in explaining the variation in the target variable, allowing you to select the most relevant features for your model. The ANOVA test calculates a p-value for each feature, which indicates the probability that the variation in the target variable can be explained by chance. If the p-value is less than a predefined significance level, typically 0.05, then the feature is considered to be statistically significant and can be selected as a relevant feature for prediction.</p><h3>3.2 Wrapper Method:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*05fX8ubBtcH3Wh2C7qIi2g.png" /><figcaption>The flow of the Wrapper Method</figcaption></figure><p>This technique uses a predictive model to evaluate the performance of subsets of features. In this method, a set of features is selected and a model is trained on this subset. The model is then used to make predictions on a validation set, and the performance of the model is evaluated using a performance metric, such as accuracy or mean squared error.</p><p>The feature selection process is then repeated for all possible combinations of features, and the subset of features that produces the best model performance is selected. This method is called a “wrapper” because it wraps the feature selection process around the training of a predictive model.</p><p>Wrapper methods are computationally intensive because they involve training a model for every possible subset of features. However, they can be effective in identifying the most relevant features for a specific predictive model, and they can handle complex interactions between features that may not be apparent from the simple correlation analysis.</p><p>Commonly used wrapper methods are often employed and include forward feature selection, backward feature deletion, and recursive feature elimination.</p><h4>3.2.1 Forward Selection:</h4><p>In forward selection, the feature selection process begins with an empty set of features and sequentially adds one feature at a time to the subset based on its contribution to the model’s performance.</p><p>The algorithm starts by training a model using only one feature, then iteratively adds the next feature to the subset that provides the best improvement in model performance. This process continues until no further improvement can be achieved by adding more features.</p><p>One advantage of forward selection is that it can be computationally efficient, especially when the number of features is relatively small. However, it may not always find the optimal feature subset, and it can be sensitive to the order in which the features are added.</p><h4><strong>3.2.2 Backward Elimination:</strong></h4><p>The goal of this technique is to eliminate unnecessary features in a dataset to improve the accuracy of a model.</p><p>In backward elimination, the process starts with a model that includes all the available features. The model is then trained on the dataset, and the feature with the highest p-value is identified. The p-value measures the significance of a feature in predicting the target variable. If the p-value is above a certain threshold (e.g., 0.05), the feature is considered non-significant and is removed from the model.</p><p>After removing the non-significant feature, the model is retrained on the remaining features, and the process is repeated. The iteration continues until all non-significant features are removed, or a predefined number of features is reached.</p><h4><strong>3.2.3 Bi-directional elimination (Step-wise Selection):</strong></h4><p>In this method in the wrapper, the method uses a combination of forward selection and backward elimination approaches. The algorithm starts with an empty set of features and performs forward selection, where it adds one feature at a time to the feature set, and evaluates the performance of the selected subset using a chosen performance metric. Then, it performs backward elimination, where it removes one feature at a time from the selected feature set and again evaluates the performance of the reduced subset using the same performance metric.</p><p>This process of forward selection and backward elimination continues until no more features can be added or removed without decreasing the performance of the subset. The result is a subset of features that provides the best performance according to the chosen performance metric.</p><h3>3.3 Embedded Methods:</h3><p>Filter and wrapper techniques’ advantages are combined in embedded methods. It is put into practice by algorithms with built-in feature selection techniques.</p><p>In this technique which integrates the feature selection process into the model training process, feature selection is done as a part of the model training process itself.</p><p>Embedded methods are commonly used in machine learning algorithms that have a built-in mechanism for feature selection, such as regularization methods like Lasso and Ridge regression. These methods work by adding a penalty term to the objective function of the model, which encourages the model to select only the most important features.</p><p>Embedded methods are generally faster and more efficient than wrapper methods that require training the model multiple times for different subsets of features. Additionally, embedded methods can prevent overfitting by selecting only the most relevant features, which can improve the generalization performance of the model.</p><p>Some popular examples of embedded feature selection methods are:</p><p><strong>3.3.1</strong> <strong>Lasso regression:</strong></p><p>Lasso regression is a linear regression technique that is commonly used for feature selection in machine learning. It works by introducing a penalty term (L1 penalty) to the standard linear regression cost function, which encourages the model to produce coefficients with smaller absolute values. Penalizes the sum of the absolute values of the coefficients, which tends to shrink less important features to zero and effectively remove them from the model.</p><p>Lasso regression is particularly useful when dealing with high-dimensional data, where the number of features is large relative to the number of observations. In this case, it can be difficult to identify which features are most relevant for making accurate predictions, and lasso regression can help by identifying a subset of the most important features.</p><p><strong>3.3.2</strong> <strong>Ridge regression:</strong></p><p>Ridge regression is not primarily designed for feature selection; it can help with feature selection in some cases. By penalizing the magnitude of the regression coefficients, ridge regression can reduce the impact of features that are less important in predicting the target variable. This can help to identify the most relevant features and exclude those that are not useful.</p><p>However, it is important to note that ridge regression does not perform explicit feature selection by setting some coefficients to zero. Instead, it shrinks the coefficients towards zero, allowing all features to contribute to the model to some extent.</p><p><strong>3.3.3</strong> <strong>Elastic Net regression:</strong></p><p>Combines L1 and L2 regularization, which allows it to handle situations where some groups of features are highly correlated. In comparison to Lasso regression, which tends to select only one feature among highly correlated features, Elastic Net regression can select multiple correlated features. Additionally, it can handle situations where there are more predictors than observations.</p><p><strong>3.3.4</strong> <strong>Decision tree-based methods:</strong></p><p>Yes, decision tree-based methods like Random Forest and Gradient Boosting can be used for feature selection. In fact, one of the main advantages of these methods is that they automatically rank the importance of each feature in the dataset, allowing us to identify which features are most relevant for predicting the target variable.</p><p>Random Forest and Gradient Boosting are ensemble learning methods that combine multiple decision trees to improve the accuracy of predictions. In Random Forest, a set of decision trees are built independently on random subsets of the data, and the final prediction is obtained by aggregating the predictions of all the trees. In Gradient Boosting, decision trees are built sequentially, with each tree trying to correct the errors of the previous tree.</p><p>Therefore, these methods can be used not only for prediction but also for feature selection, by ranking the importance of features and selecting the ones that are most relevant to the task at hand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*6M9_ESCMA0AlaA-k-hRbCg.png" /><figcaption>Created using word cloud(text mining)</figcaption></figure><h3>4. References:</h3><p>· <strong>Title:</strong> How Does Feature Selection Benefit Machine Learning Tasks?</p><p>· <strong>Title:</strong> <a href="http://www.analyticsvidhya.com/">www.analyticsvidhya.com</a> › blog › 2016Feature Selection Methods | Machine Learning — AnalyticsVidhya.</p><p>· <strong>Title:</strong> Dimensionality Reduction — Feature Selection … — Gayathri siva</p><p>· <strong>Title:</strong> Variance Threshold — PHP-ML — Read the Docs</p><p>· <a href="https://amzn.to/3b2LHTL">Applied Predictive Modelling</a>, 2013 — Page 488.</p><p>· Richard G. Baraniuk “Compressive Sensing”, IEEE Signal Processing Magazine [120] July 2007</p><p>· <strong>Title:</strong> Feature Selection Techniques in Machine Learning — Javatpoint</p><p>· Scikit learn documentation,(<a href="https://scikit-learn.org/stable/modules/feature_selection.html">https://scikit-learn.org/stable/modules/feature_selection.html</a>).</p><p>· <strong>Title:</strong> Getting Data ready for modelling: Feature engineering</p><p>· Ferri et al, <a href="https://citeseerx.ist.psu.edu/doc_view/pid/5fedabbb3957bbb442802e012d829ee0629a01b6">Comparative study of techniques for large-scale feature selection</a>.</p><p>· A comprehensive guide to Feature Selection using Wrapper methods in Python.(<a href="https://www.analyticsvidhya.com/blog/2020/10/a-comprehensive-guide-to-feature-selection-using-wrapper-methods-in-python/">https://www.analyticsvidhya.com/blog/2020/10/a-comprehensive-guide-to-feature-selection-using-wrapper-methods-in-python/</a>).</p><p>· <strong>Title:</strong> towardsdatascience.com › getting-data-ready-forGetting Data ready for modelling: Feature engineering</p><p>· <strong>Title: </strong>Feature selection -(<a href="https://en.wikipedia.org/wiki/Feature_selection#Embedded_method">https://en.wikipedia.org/wiki/Feature_selection#Embedded_method</a>).</p><p>· <strong>Image Source:</strong> Maxim Popov/Dreamstime.com</p><p>(techopedia: <a href="https://www.techopedia.com/sre-vs-devops-whats-the-difference/2/33629)">https://www.techopedia.com/sre-vs-devops-whats-the-difference/2/33629)</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*5qhOVeCol8krFzyQpgKUQA.png" /></figure><p><strong>Harsha Mokhasi</strong></p><p><a href="https://www.linkedin.com/school/rvcengineering/?trk=public_profile-settings_topcard-school">RV College Of Engineering</a></p><p>Bengaluru, Karnataka, India</p><p>LinkedIn: <a href="http://www.linkedin.com/in/harsha-mokhasi-data-analyst">www.linkedin.com/in/harsha-mokhasi-data-analyst</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2612b0844b6a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>