<?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 Karl Dorsainvil on Medium]]></title>
        <description><![CDATA[Stories by Karl Dorsainvil on Medium]]></description>
        <link>https://medium.com/@kdorsain?source=rss-b400f5348e89------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*zBay7FzlzCM-s9_G</url>
            <title>Stories by Karl Dorsainvil on Medium</title>
            <link>https://medium.com/@kdorsain?source=rss-b400f5348e89------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 18:46:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kdorsain/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[Dealing with Multicollinearity of Features]]></title>
            <link>https://medium.com/@kdorsain/dealing-with-multicollinearity-of-features-2b13bc42fbe1?source=rss-b400f5348e89------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b13bc42fbe1</guid>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Karl Dorsainvil]]></dc:creator>
            <pubDate>Thu, 14 Nov 2019 00:29:56 GMT</pubDate>
            <atom:updated>2019-11-14T00:29:56.550Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is Multicollinearity?</h3><p>When doing regression analysis, there are many factors that negatively affect your predictions such as outliers, duplication of data or extraneous values. However, multicollinearity can also be one these factors. The term multicollinearity(also called collinearity) exists whenever an independent variable (feature) is highly correlated with another independent variable. This may not seem to be an issue at first but in terms of regression analysis, the main goal is to identify relationships between the independent variable and the target variable. Features that are highly correlated can definitely provide some falsities in our outcome. Therefore if a change is made in one predictor then another predictor is affected as well.</p><h3>Identifying Multicollinearity</h3><p>Let’s start by loading the King County house data from Seattle which contains house prices from the 20th trough the 21st century. The full data can found <a href="https://www.kaggle.com/gloriousc/house-sales-regression-in-king-county-with-map/data">here</a> ! For simplicity, only a few features were chosen from this data set.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*rK6Sis58yTPUZI6ErmM25w.png" /></figure><p>One thing to note here, is that the target variable (<strong>price</strong>) was purposefully omitted from the figure above. When trying to identify multicollinearity it is best to do so without the dependent variable. We are only interested in correlation between the independent variables!</p><p>Today, we will be looking at two main methods for identifying multicollinearity between features: <strong>correlation matrix </strong>and <strong>heatmaps.</strong></p><p><strong>Correlation Matrix using Pandas</strong></p><p>The correlation matrix from pandas dataframe permits you to see correlation between independent variables. Let’s apply this to our dataframe called <strong>data </strong>above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*mc0VhRROUxHYFveDbiOloA.png" /></figure><p>At first glance, we can see that the feature names are listed horizontally and vertically. Correlation between the features will take a value of -1 to 1 in which -1 means a negative linear relationship and 1 is a positive linear relationship. It is important to note that features of the same name (feature that meet diagonally above)will always be a 1. For example, bedrooms and bedrooms with have a value of 1.</p><p>Looking into this further, we can see that for example <em>sqft_living vs sqft_above</em> have a .88 relationship and <em>sqft_above vs grade</em> have a .76. This usually means that one of these features’ column may have to be dropped from the dataset entirely to have better results in your linear regression model. At that point, it would be prudent to do some research to decide which of these features is best to remove.</p><p>One question that is usually asked: “<strong><em>What value represents high multicollinearity?</em></strong>” The cutoff value that is mostly used in the data science industry is 0.7 to 0.8. Let’s perform another correlation analysis of our features but this time only selecting values that are greater than 0.75.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*DwdvfqQ4kHclXINnQqLtEg.png" /></figure><p>This returns a boolean matrix in which the values that are greater than 0.75 will be set to true. Let’s proceed with another method called heatmaps!</p><p><strong>Heatmaps using Seaborn</strong></p><p>Heatmaps are another great way to show multicollinearity as it provides better visualization. The colors get darker as collinearity increases. For example, bedrooms vs grade have minimal collinearity(light green)whereas sqft_above vs sqft_living do(dark green).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/621/1*L_4l005TkZAtpn9xcp8dWA.png" /></figure><h3>Conclusion</h3><p>Overall, when performing linear regression it is almost imperative that multicollinearity between features is validated. This can negatively affect the prediction of a model. We have learned two great methods above for identifying collinearity between features, correlation matrix and heatmaps.</p><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b13bc42fbe1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>