<?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 Bob Sohval on Medium]]></title>
        <description><![CDATA[Stories by Bob Sohval on Medium]]></description>
        <link>https://medium.com/@bsohval?source=rss-dc94f0b61af0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*xSSrC-uScpoar6VL.jpg</url>
            <title>Stories by Bob Sohval on Medium</title>
            <link>https://medium.com/@bsohval?source=rss-dc94f0b61af0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 01:24:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bsohval/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[Coping with Collinearity]]></title>
            <link>https://techblog.securityscorecard.com/coping-with-collinearity-b16719c62380?source=rss-dc94f0b61af0------2</link>
            <guid isPermaLink="false">https://medium.com/p/b16719c62380</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[col-linearity]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Bob Sohval]]></dc:creator>
            <pubDate>Thu, 12 May 2022 22:37:45 GMT</pubDate>
            <atom:updated>2022-05-12T22:37:45.714Z</atom:updated>
            <content:encoded><![CDATA[<p>A common task in data science is to quantify the dependence of an output variable on one or more input variables. A textbook example is the regression of housing prices to determine their dependence on neighborhood, number of bedrooms, baths, house age, lot size, etc.</p><p>The linear relationship between the output or target variable y and the individual features xi can be expressed as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/251/0*hGTQxIzEOn664qsU" /></figure><p>where xi is the value for feature i (e.g. number of bedrooms) and bi is the weight or importance of that feature. For the housing price example, each house would have a price y and known values for the features xi. Typically the number of records (e.g. houses) exceeds the number of features n.</p><p>The goal of the linear regression is to find the set of weights {b1, b2, … bn} that most accurately predicts the measured values of the target variable y.</p><p>Ordinary least squares regression (OLS) is the most statistically robust and fastest method to solve this type of problem. But what happens if the data suffer from collinearity?</p><h4>What is Collinearity?</h4><blockquote>“<a href="https://en.wikipedia.org/wiki/Multicollinearity">In statistics, multicollinearity (also collinearity) is a phenomenon in which one predictor variable in a multiple regression model can be linearly predicted from the others with a substantial degree of accuracy. In this situation, the coefficient estimates of the multiple regression may change erratically in response to small changes in the model or the data. Multicollinearity does not reduce the predictive power or reliability of the model as a whole, at least within the sample data set; it only affects calculations regarding individual predictors.</a>”</blockquote><p>In effect, data collinearity occurs when two or more of the feature vectors are substantially correlated with each other, that is, the feature vectors are not mutually independent. There are two important takeaways from the description above:</p><ol><li>Collinearity interferes with the extraction of correct weights for individual features.</li><li>Collinearity does not affect the predictive accuracy of the regression model.</li></ol><p>Consider a hypothetical case in which a feature vector x1 is duplicated in the data, producing x1 and x2, and that the correct weight for x1 is 1.0. The regression model could return many equivalent sets of feature weights for x1 and x2, including (1, 0), (0.5, 0.5), (0, 1) or even (-2, 3). These potential outcomes are all mathematically valid, but may be inconsistent with the problem domain, especially, for example, if the weights must be strictly non-negative.</p><p>Techniques such as <a href="https://en.wikipedia.org/wiki/Variance_inflation_factor">Variance Inflation Factor (VIF)</a> are sometimes deployed to identify correlated features and then to remove them from the model one at a time until the residual collinearity drops below an acceptable threshold. However, a shortcoming of this approach is that the removed feature vectors may carry some additional information that could have improved the accuracy of the regression had they remained in the model.</p><p>An often overlooked technique for mitigating the effects of collinearity is regularization of the model. Adding regularization reduces the correlation between feature vectors and can produce a more robust and complete set of feature weights, as described in the example below.</p><p>Analysis of simulated data, consisting of 300 records generated randomly from 20 features with predetermined feature weights (no collinearity — all feature vectors are independent) plus some added noise show a correlation matrix with near-zero off-diagonal elements, as expected. The fitted feature weights determined by OLS (blue) faithfully match the true feature weights (red).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/0*GfYqy94AnPT2iT4B" /></figure><p>A second set of simulated data was prepared in which collinearity was introduced into the first four feature vectors and the last two feature vectors. In this case, we observe significant correlation within these two groups, as evidenced by the substantial off-diagonal elements in the correlation matrix.</p><p>As shown below, the fitted feature weights determined by OLS deviate significantly from the true weights for the features suffering from collinearity. In addition, the uncertainty in the values (error bars) for the collinear features have greatly increased.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/0*W9lfeexCb3HAgsQw" /></figure><p>This example dramatically illustrates the errors that data collinearity among feature vectors can introduce into the fitted feature weights. Note that the fourth fitted weight is approximately 11x greater than the true value, while the first three fitted weights are returned with negative values instead of positive values. The last two feature weights, which also suffer from collinearity, deviate more from the true values than the features without collinearity.</p><h3>Mitigating Collinearity with Regularization</h3><p>If a regression is performed on the same data, but now using L2 (Ridge) regularization, the situation improves significantly:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/0*dgCWqSouWmC-tntf" /></figure><p>Regressing the collinear data using L2 regularization reduces the error bars for the collinear feature weights and also returns values much closer to the true weights compared to OLS without regularization.</p><p>We have demonstrated that L2 regularization can be an effective tool for coping with collinearity. All of the input features may be retained (in contrast with VIF), and the final result is much more accurate than simple OLS.</p><p>Regularization strength is typically controlled by setting a hyperparameter. Finding the appropriate value for the hyperparameter and an explanation of why L2 regularization helps mitigate the effects of collinearity will be the subject of a future blog post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b16719c62380" width="1" height="1" alt=""><hr><p><a href="https://techblog.securityscorecard.com/coping-with-collinearity-b16719c62380">Coping with Collinearity</a> was originally published in <a href="https://techblog.securityscorecard.com/">SecurityScorecard Techblog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>