<?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 KuanYao Huang on Medium]]></title>
        <description><![CDATA[Stories by KuanYao Huang on Medium]]></description>
        <link>https://medium.com/@musictenors?source=rss-9967102ae431------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WmubPh0KyzfmUagmgf3MeA.jpeg</url>
            <title>Stories by KuanYao Huang on Medium</title>
            <link>https://medium.com/@musictenors?source=rss-9967102ae431------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 22:20:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@musictenors/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[Create Customer Segmentation Report for Arvato Financial Services]]></title>
            <link>https://medium.com/data-science/udacity-data-scientice-nano-degree-capstone-project-create-customer-segmentation-report-for-852d3e6d3180?source=rss-9967102ae431------2</link>
            <guid isPermaLink="false">https://medium.com/p/852d3e6d3180</guid>
            <category><![CDATA[clustering]]></category>
            <category><![CDATA[segmentation]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[KuanYao Huang]]></dc:creator>
            <pubDate>Fri, 17 May 2019 11:10:54 GMT</pubDate>
            <atom:updated>2019-05-24T13:17:07.554Z</atom:updated>
            <content:encoded><![CDATA[<h4>An Udacity Capstone Project from Data Scientice Nano Degree</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3SQT3Uf1g2uC35xB" /><figcaption>Photo by <a href="https://unsplash.com/@christiannkoepke?utm_source=medium&amp;utm_medium=referral">Christiann Koepke</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3><strong>Project Overview</strong></h3><p>By creating customer segmentation and comparing to general population, one can know which part of the general population are more likely to be customer and which part are not. I analyzed demographics data for customers of a mail-order sales company in Germany, comparing it to demographics information for the general population.</p><p>Firstly, I used different approaches to pre-process the data, and then I used unsupervised learning techniques, PCA (Principle Componets Analysis) and k-NN (k-nearest neighbor algorithm), to perform customer segmentation and to identify the core customer traits of the company.</p><p>Secondly, with demographics information for targets of a marketing campaign for the company, I used different models to predict which individuals are most likely to convert into customers.</p><p>Finally, I also tested the model in competition through kaggle, where the competition is <a href="https://www.kaggle.com/c/udacity-arvato-identify-customers">here</a>, and all the contents discussed is based on the jupyter notebook uploaded to <a href="https://github.com/HuangKY/DSND_Term2_Capstone_Arvato">Github repository here</a>.</p><h3><strong>Problem Statement</strong></h3><p>The goal includes four parts as follows:</p><ol><li>Data pre-processing: clean and re-encode data.</li><li>Segmentation: use unsupervised learning techniques to create clusterings of customer and general population, and then identify the difference.</li><li>Prediction: use the demographic features to predict whether or not a person became a customer after a mailout campaign.</li><li>Use the same algorithm to predict and submit to Kaggle competition to get evaluation.</li></ol><h3>Metrics</h3><p>In the segmentation part, explained variance ratio is be used in the PCA process. Explained variance accounts for the ability to describe the whole feature variance, the more the explained variance, the more import of the component.</p><p>In the supervised model prediction parts, precision is mainly used as main metric.</p><h3>Analysis and Methodology— Data Exploration, Visualization and Preprocessing</h3><p>There are four datasets, all of which have identical demographics features (only part of them are different)</p><ul><li><strong><em>Udacity_AZDIAS_052018.csv</em></strong>: Demographics data for the general population of Germany; 891 211 persons (rows) x 366 features (columns)</li><li><strong><em>Udacity_CUSTOMERS_052018.csv</em></strong>: Demographics data for customers of a mail-order company; 191 652 persons (rows) x 369 features (columns)</li><li><strong><em>Udacity_MAILOUT_052018_TRAIN.csv</em></strong>: Demographics data for individuals who were targets of a marketing campaign; 42 982 persons (rows) x 367 (columns).</li><li><strong><em>Udacity_MAILOUT_052018_TEST.csv</em></strong>: Demographics data for individuals who were targets of a marketing campaign; 42 833 persons (rows) x 366 (columns).</li></ul><p>In addition to the above data, there are two additional meta-data:</p><ul><li><strong><em>DIAS Information Levels — Attributes 2017.xlsx</em></strong>: a top-level list of attributes and descriptions, organized by informational category</li><li><strong><em>DIAS Attributes — Values 2017.xlsx</em></strong>: a detailed mapping of data values for each feature in alphabetical order</li></ul><p>Also, I created a file called <strong><em>DIAS_Attributes_Values_2017_details.csv</em></strong> based on the <strong><em>DIAS Attributes — Values 2017.xlsx</em></strong> file, so that I can map each attribute to its type or missing value coding.</p><h4>Deal with Missing/Unknown Value</h4><p>During the Data pre-processing process, I re-encode the missing or unknown value as Nan to make sure the value are all encoded consistently. For example, the ‘-1’ value means unknown in AGER_TYP attribute, I substitute it with <em>np.nan.</em></p><h4>Evaluate missing data in each attribute</h4><p>In each attribute, the proportion of missing value is calculated. Looking into the distribution of missing ratio, most attribute are below 20%. Therefore, I deleted the outliers based on this criterion. (Fig. 1)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*D9l4DzEQ3AnUMVmYoC0slg.png" /><figcaption>Fig. 1 Distribution of missing ratio for each attribute</figcaption></figure><h4>Evaluate missing data in each row</h4><p>Missing data in each row is also evaluted. It can be seen that most rows have no missing value, so I will drop all the rows that have at least one missing value. (Fig. 2) However, in order to make sure the data I drop have no big inference to the whole data, I will check the distribution for some features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*EfNZudSu-KCHnJf1XVj4fg.png" /><figcaption>Fig. 2 Distribution of missing ratio in each row</figcaption></figure><p>By comparing the distribution of values for at least five attributes between the two subsets: the data that does not include deleted rows and the data that only include the rows deleted, there is no large difference between the two. (Fig. 3) So I will preserve this criterion in dealing with the missing value in rows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*OYW_XaRUEEIfTXC3y_Yg3w.png" /><figcaption>Fig. 3 Comparison of distribution of two data set on specific attributes (see Github for all graphs)</figcaption></figure><h4>Re-Encode and pick up features</h4><p>There are four types of data in the data: <em>ordinal, numeric, categorical and mixed</em>. For ordinal variables, although the values might not be linearly related, I assume the ordinal variables as interval variables here. The remaining categorical and mixed variables will be re-encoded and selected.</p><p>Regarding categorical variables, for instance, the OST_WEST_KZ feature includes values of ‘W’ and ‘O’, which is binary. I re-encode it as 0 and 1 numerical binary variable. On the other hand, the CAMEO_DEUG_2015 feature includes ‘X’ value that is not described in the details documents so I re-encode it as Nan. For the remaining categorical variables, I plotted the correlation graph to understand whether the features that shared common characteristics. (Fig. 4)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*OPIbpL16JQAbZ8lPE7_aSQ.png" /><figcaption>Fig. 4 Correlation heat-map between categorical features</figcaption></figure><p>Based on the graph above, LP_FAMILIE_FEIN and LP_FAMILIE_GROB are highly correlated, and LP_STATUS_FEIN and LP_STATUS_GROB are also highly correlated. Since LP_FAMILIE_FEIN and LP_STATUS_FEIN are too detailed, I dropped those two here. In addition, although CAMEO_DEUG_2015and CAMEO_DEU_2015 are not plotted in the graph above, based on the description file both of them are very similar. So I dropped CAMEO_DEU_2015 to simplify. Finally, there is another feature EINGEFUEGT_AM that is not described in the document, I dropped this one as well. After re-encoding and selecting the categorical variables, I used <em>get_dummies </em>method in Pandas to transform to dummy value.</p><p>In addition to the categorical variables, there are six mixed features as follows:</p><ol><li>CAMEO_INTL_2015</li><li>LP_LEBENSPHASE_FEIN</li><li>LP_LEBENSPHASE_GROB</li><li>PLZ8_BAUMAX</li><li>PRAEGENDE_JUGENDJAHRE</li><li>WOHNLAGE</li></ol><p>By looking into CAMEO_INTL_2015 attribute, it seemed the attribute can be separated into two interval variables: one is related to wealth and the other one is related to lifestage, so I used map method to re-encode that feature. Regarding LP_LEBENSPHASE_FEIN and LP_LEBENSPHASE_GROB, since both of them describe the life stage of a person which shares similar traits to CAMEO_INTL_2015, I dropped the two attributes here. On the other hand, the PLZ8_BAUMAX and WOHNLAGE attributes can be regarded as interval variables to some extent, I preserved them here. Finally, looking in to PRAEGENDE_JUGENDJAHRE feature, it looks it can also be separated into two parts: decades and movement. Therefore I created two functions to process this variable.</p><p>After all the pre-processing and re-encoding process, the <em>Udacity_AZDIAS_052018.csv </em>is cleaned and transformed to pandas daframe object <em>azdias_informative_dummy.</em> I also create a function <em>clean_data</em> that includes all the process mentioned above, so that for each demographic data, the cleaning process is assured and remain the same.</p><p>Finally, some features got Nans during the re-encoding process, so I used <em>Imputer</em> to subsitute<em> with means</em>.Then I used <em>StandardScaler</em> to scale all the features. To have a check for the final output, I have count the number of Nans (missing ratio) in each attribute. (Fig. 5)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*cL81xP75bwDgCD7A5LDVdQ.png" /><figcaption>Fig 5. The missing ratio in each attribute (parial)</figcaption></figure><h4>Implementation and Refinement</h4><p><strong>Customer Segmentation Report Part</strong></p><p>From almost 425 features, I conducted PCA to extract import features of the general population. Knowing the main explained variance for each attribute, I decided to use first 6 components in that after 6th componets, the accumulated variance increases slowly. (Fig. 6 and Fig. 7)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*KAs9jrxWbTAXycdBfdRbaA.png" /><figcaption>Fig. 6 (Top): Explained variance across different PCA components. (Bottom): Accumulated</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*OuRghnld4Rzt1_T18qglXg.png" /><figcaption>Fig. 7 Accumulated explained variance for top 100 PCA components</figcaption></figure><p>After selecting the main PCA componets, I used KMeans method to apply clustering. In order to decide how many clusters I should use, I investigate the number of clusterings to the KMeans score. It is showed that when the number of clusterings increases to about 30, the error (score) gets low enough and does not change rapidly. Therefore, I chose 30 as the number of clusterings. (Fig. 8)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*h9CADgdxdRZ1WHktEZJF5g.png" /><figcaption>Fig. 8 The change of score (error) to k (number of clusterings)</figcaption></figure><p>All the process and methods used above are also applied to customer data. Therefore, I can get the clusterings labels for both general population data and customer data.(Fig. 9) By plotting the distribution of the clusterings, I got the results of difference across the two datasets. (Fig. 10)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*0M7A7jWUcb8PddA0kASesg.png" /><figcaption>Fig. 9 The distribution of the clusterings across two populations</figcaption></figure><p>Here in the table where gp_portion means the proportion of of the clusterings in general population and cs_portion means the proportion of of the clustering in customer population showed that the difference between customers and general population is largest in clusters 21 and 28, and lowest in clusters 6 and 20.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*K2VLQUmSvVwP7JCjTI2Lmg.png" /><figcaption>Fig. 10 The difference of clustering distribution in the two datasets</figcaption></figure><p><strong>Supervised Learning Model Part</strong></p><p>In the supervised learning model part, since the data shares the same demographic features from the general population, all the pre-processing is the same as in the customer segmentation parts. However, in order to assure the cleaned columns are the same and all the rows are preserved, the clean_data function is revised to <em>clean_data_preserve_row</em>. After the preprocessing process, I used the same algorithm in the segmentation report part to get the PCA values and clusterings.</p><p>The independent variables are the original cleaned features, the 6 PCA components and the clustering label. The dependent variable is the RESPONSE column in the dataset. In order to predict the the RESPONSE value, which is 0 or 1 binary value, I used three models: logistic regression, random forest and k-NN to predict. GridSearch is also conducted to get the best parameters.</p><h3>Results</h3><h4>Interpretation, Model Evaluation and Validation</h4><p><strong>Customer Segmentation Report Part</strong></p><p>Firstly, I will discuss the 6 PCA components, and then I will use the clustering results above to understand the difference between general population and the customers.</p><p>For each PCA components, I showed the top feature details in order to get know to the characteristics. (Fig. 11 and Fig. 12) The first column shows the importance for each feature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*BV_FLYs1q32MRq4RyuAxYg.png" /><figcaption>Fig. 11 The details of PCA components 1 to 3</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*P7lKbDkzxcOSGnQk1CZP8g.png" /><figcaption>Fig. 12 The details of PCA components 4 to 6</figcaption></figure><p>Here is the summary based on the details of each component. For convenience, I will name each component and explain in behind.</p><p><strong><em>PCA component 1</em></strong> : <strong><em>Rich People Index. </em></strong>Due to low mobility (moving patterns), high share of 1–2 family houses in the PLZ8, high share of cars per household, lots of buildings in the microcell and high financial interest. It might be some people who care about financial news or products, and living in a busy city area and tend to live alone or live with partner only.</p><p><strong><em>PCA component 2: Young and Wandering Index. </em></strong>The person’s birth is mainly in 90s with digital media, not a money saver, has high online affinity, not a financial investor, and not traditional minded.</p><p><strong><em>PCA compoent 3: Car Brand Mania Index.</em></strong> Due to high share of BMW &amp; Mercedes Benz, upper class cars or sportscars, and high share of top German manufacturer (Mercedes, BMW).</p><p><strong><em>PCA compoent 4: Online Shopper Index.</em></strong> Due to high transaction activity, high transaction activity MAIL-ORDER, high density of inhabitants per square kilometer, and large number of 6–10 family houses.</p><p><strong><em>PCA component 5: Car Life Index.</em></strong> Due to high share of cars with an engine power between 61 and 120 KW, high share of cars with no preowner, large number of cars with 5 seats, high share of Asian Manufacturers, and high share of newbuilt cars</p><p><strong><em>PCA compoent 6: Anti-society Index.</em></strong> Due to low dreamily affinity, low familiar minded, low cultural and social minded, and not religious.</p><p>In addition to the PCA components, I also compared the difference between the general population and customers. As mentioned in the previous section, I got the results below from Fig. 9 and Fig. 10.</p><ul><li>General population that are <strong><em>more</em></strong> likely to be part of the mail-order company’s main customer: cluster 21 and 28</li><li>General population that are <strong><em>less</em></strong> likely to be part of the mail-order company’s main customer: cluster 6 and 20</li></ul><p>Looking into each clusters, here is the characteristic for each (take the criterion of absolute value of 3 for convenience):</p><ul><li>cluster 21: PCA component 2 (<em>Young and Wandering Index</em>) is negatively related.</li><li>cluster 28: PCA component 4 (<em>Online Shopper Index</em>) is positively related.</li><li>cluster 6: PCA component 1 (<em>Rich People Index</em>) and 3 (<em>Car Brand Mania Index</em>) are negatively related while PCA component 5 (<em>Car Life Index</em>) is positively related</li><li>cluster 20: PCA component 1 (<em>Rich People Index</em>) is negatively related while 6 (<em>Anti-society Index</em>) are positively related</li></ul><p>Combining all the information above, here is the summary.</p><ul><li>The population who tend to be customer: The people who may be adults and usually shop online.</li><li>The population who might not be customer: The people who are not rich, nor focusing on the brand of cars. However, they tend to use cars often. Some of them might have some anti-society characteristics.</li></ul><p>To sum up, the target of the campaign should focus on the users who are not young and shops online often. On the other hand, for those who are very rich or interested to cars a lot or have anti-society traits, there might be no need to send the campaign to them.</p><p><strong>Supervised Learning Model Part</strong></p><p>Data was separated into training data and test data. However, the results were not good. For the three models (logistic regression, random forest and k-NN), none of them has good precision. I will discuss it in the next justification part.</p><h4>Justification</h4><p><strong>Supervised Learning Model Part</strong></p><p>Because the origin data is unbalanced (most RESPONSE is 0, value 1 is below 1 %), I have tried the following parts to solve the issue:</p><ol><li>Use GridSearch method.</li><li>Set ‘class_weight’ parameter.</li><li>Set the stratify parameter in train_test_split process.</li><li>Try more than 6 PCA components to 20 PCA components.</li></ol><p>However, none of them increased the precision. I will leave this part in the improvement section in the end.</p><p>Also, I have upload the prediction from the test data to kaggle. As mentioned, the performance of the model is not good, so the score is also bad. (Fig. 13)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NkTvrXtIPmoEFuhd8D8hyA.png" /><figcaption>Fig. 13 The submission to kaggle</figcaption></figure><h3><strong>Conclusion</strong></h3><h4>Reflection</h4><p>In the Segmentation part, I have performed data pre-processing and used PCA method combined with k-NN to get the clusterings of different population. The difference was discussed and I have known that which population might be potential customers and which population might not. With understanding the difference, a company can be much more focus on their target, and then increase conversion rate or lower down their marketing cost. The impact is large.</p><p>In the supervised learning part, however, the performance of models were not good. It might be resulted from the biased data distribution where most value of dependent variable are 0. Further investigation is needed.</p><h4>Improvement</h4><p>In order to increase the performance of the supervised learning model, the following parts might be conducted.</p><ol><li>The methods that deal with unbalanced data: under-sampling or over- sampling.</li><li>Increase PCA components.</li><li>Use only the PCA components as independent variables.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=852d3e6d3180" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/udacity-data-scientice-nano-degree-capstone-project-create-customer-segmentation-report-for-852d3e6d3180">Create Customer Segmentation Report for Arvato Financial Services</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What affects house price ?]]></title>
            <link>https://medium.com/@musictenors/what-affects-house-price-e6c073eed87f?source=rss-9967102ae431------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6c073eed87f</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[storytelling]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[KuanYao Huang]]></dc:creator>
            <pubDate>Wed, 06 Feb 2019 22:41:50 GMT</pubDate>
            <atom:updated>2019-05-18T02:44:04.451Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KQQbu_1LaDJemqKF" /><figcaption>Photo by <a href="https://unsplash.com/@jesseroberts?utm_source=medium&amp;utm_medium=referral">Jesse Roberts</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What affects house price : An analysis of home price factors.</h3><p>In the modern world, most people begin to search for a house when they graduate from school or begin their new career. Renting a house is an option that most people choose at first. However, as rent increases or when acquiring a more stable life, buying a house might be another option that people think about. Nevertheless, the amount of money one needs to prepare is quite different between renting a house and buying a house. It is better to have pre-knowledge to get the picture of the house market if considering to buy a house.</p><p>Regarding the factors of house price, one can find different datasets from various open source site. Kaggle, favored by lots of data analyst, is one of the options that offers plenty of dataset and data analysis competitions. I used the dataset <strong><em>&quot;House Sales in King County, USA&quot;</em></strong> from kaggle, where you can find it <a href="https://www.kaggle.com/harlfoxem/housesalesprediction">here</a>, to conduct the analysis. This dataset offers 19 house features including the price and the id columns, along with 21613 observations.</p><p>When it comes to buying a house, one may come out with lots of ideas that matter, such as the trend of the price, the characteristics of an expensive/cheap area, the square foot of the lot, etc. In order to dig dip into the house price, I separated the analysis into three parts, including:</p><ol><li>Is the house price increasing ?</li><li>What factors correlate with the house price mostly?</li><li>Is it possible to tag a house as “cheap” or “expensive” ?</li></ol><h3>Part 1: Is the house price increasing ?</h3><p>Briefly speaking, I would like to understand the trend of the house price at first. I have looked into the daily trend and monthly trend. Although the average of daily house price varies dramatically, it seems that there is no obvious trend there. Furthermore, by looking at the monthly average house price, no large change of the average price discovered. It can then be concluded that the house price is not increasing nor decreasing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9jJLyNsAg3e3d2yCzcqiqA.png" /><figcaption>Figure 1: Daily Average House Price</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vxgUTWOrxQFAN4Q-fhD9cg.png" /><figcaption>Figure 2: Monthly House Price (Box Plot)</figcaption></figure><p>One might have a question that it is difficult to say a house price is increasing nor decreasing since there are some other factors affecting the price. However, generally speaking, there is no obvious trend of house price as time goes by, and the other factors that affect house price will be discussed in part2.</p><h3>Part 2: What factors correlate with the house price mostly?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QSIRuYAhPxOZneZH" /><figcaption>Photo by <a href="https://unsplash.com/@jbrinkhorst?utm_source=medium&amp;utm_medium=referral">Jonathan Brinkhorst</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>When it comes to house price, what factors would come to your mind ? The square foot of a house ? The number of the bedrooms ? Or the location of a house ? There are quantity of factors that may affect the price of a house. The dataset from kaggle offers 19 features for each house, including the factors mentioned earlier and some other variables.</p><p>Firstly, I am interested in the correlation between house price and the other factors. I believed that focusing on the factors that change with the house price can one get more understanding of the whole picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*spCYE56oAfIiXRvWm4VuBQ.png" /><figcaption>Figure 3: The Correlation Between all the Factors (Heat Map)</figcaption></figure><p>The above graph is the correlation of all the factors in the heap map format. The lighter the color the more strong positive correlation between the factors. In contrast, the darker the color, the more negative correlation between the variables. If you focus on the price row, you can see that there are 5 factors that strongly correlated with house price, which are the &quot;sqft_living&quot;, &quot;sqft_above&quot;,&quot;sqft_living15&quot;, &quot;grade&quot; and &quot;bathrooms&quot;. By reading the description from <a href="https://www.kaggle.com/harlfoxem/housesalesprediction">kaggle</a>, the 5 factors can be illustrated as <strong><em>the square footage of the home, the overall grade giving to the house unit, and the number of bathrooms, which highly correlated with house price positively</em></strong>.</p><p>Looking into the correlation results above, it may be questioned that as the size of the house increases, the number of bathrooms might also increase to some extent. This can be confirmed from the above heat map. <strong><em>Therefore the main factors can then be simplified as the size of the house and the overall grade of it.</em></strong></p><p>The correlation is the first step of understanding the factors. However, one might be curious about that what factors contribute to house price most ? The correlation offers a brief look of the the factors but it still has limitations. It cannot get further understandings of the impact of each factor. In order to clarify this, I used two models, linear regression model and random forest regression model, to have a deeper look of the factors.</p><p>The results from each model are a little bit different. R-squared, the ability that a model can correctly predict, is used to evaluate the performance of the two models. Linear regression model has <strong><em>70.8% r-squared value</em></strong> while the random forest regression model has <strong><em>87.6% r-squared value</em></strong>.</p><p>Here I would also like to show the importance of the factors that each model has. The larger the coefficient, the higher importance of a factor that contribute to the change of the price.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*65WcdoUAYzM_PX4OhFpF1Q.png" /><figcaption>Figure 4: The Coefficients (Importance) of the Factors Based on Linear Regression Model</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*UWhbu4P3_kxKduHB3_zBYg.png" /><figcaption>Figure 5 : The Coefficients (Importance) of the Factors Based on Random Forest Regression Model</figcaption></figure><p>Both the models have similar results of importance of the factors. The size of a house (sqft_above, sqft_basement) and the location of a house (lat) are top main factors in both model.</p><p>To sum up in this section, through the correlation analysis and the regression modeling, there are five important factors from the results.</p><blockquote>1. sqft_above: square footage of house apart from basement</blockquote><blockquote>2. sqft_basement: square footage of the basement</blockquote><blockquote>3. lat: Latitude coordinate</blockquote><blockquote>4. waterfront: House which has a view to a waterfront</blockquote><blockquote>5. grade: overall grade given to the housing unit, based on King County grading system</blockquote><p><strong><em>Factor 1 and 2 (</em></strong>square footage<strong><em>)</em></strong>: It can be illustrated that the larger the size of a house, the more expensive of the price. This is quite intuitive since the more space one can use, the more money one needs to pay.</p><p><strong><em>Factor 3 (latitude): </em></strong>The latitude factor is quite interesting. The northern the area, the higher the house price. This should have further analysis to understand the geographic effect in King Country to the price.</p><p><strong><em>Factor 4 (waterfront): </em></strong>Surprisingly, waterfront is also another important factor. it can be said that the surrounding environment has an impact to the price, and people care about the waterfront view. For me, it is indeed comfortable to have a broad view from a house instead of a crowded street view or a high-buildings scene. And it is good to refresh my mind through walking along the waterside. Probably these are the possible reasons why the waterfront is an important factor.</p><p><strong><em>Factor 5 (grade):</em></strong> The grade of a house also matters. The grade shows an evaluation of a house based on house environment, infrastructure and safety. Obviously these reasons are important and people consider about it when buying a house.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3YNHHAavy-c6nfqm" /><figcaption>Photo by <a href="https://unsplash.com/@blankerwahnsinn?utm_source=medium&amp;utm_medium=referral">Fabian Blank</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Part 3: Is it possible to tag a house as “cheap” or “expensive” ?</h3><p>By using the model in part2, I can then predict the price for each house. I have used the predicted price and the actual price to get the price difference. After normalization of the price difference, I tagged the houses based on the price that is far from the average (3 deviations from 0).</p><p>The details how I tagged the houses is as follows. I tagged the houses as <strong><em>&quot;cheap&quot;</em></strong> if the predicted price is much higher than the actual price, while the houses are tagged as <strong><em>&quot;expensive&quot;</em></strong> if the predicted price is much lower than the actual price. The other houses are tagged as <strong><em>&quot;normal&quot;</em></strong>. Apart from the normal houses, there are <strong><em>1.6%</em></strong> of the cheap and expensive houses.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TGiKQwfE2rDcWGJysd-ucQ.png" /><figcaption>Figure 6: The Distribution of the Price Difference</figcaption></figure><p>Looking into the &quot;expensive&quot; and &quot;cheap&quot; houses, there are interesting findings: <strong><em>Most the expensive houses are located in zipcode 98004 while most the cheap houses are located in zipcode 98040. </em></strong>From google map, I can map the zipcode to the actual area visually.</p><blockquote><strong><em>zipcode 98004 (more expensive houses):</em></strong></blockquote><blockquote><a href="https://www.google.com/maps/place/%E3%82%A2%E3%83%A1%E3%83%AA%E3%82%AB%E5%90%88%E8%A1%86%E5%9B%BD+%E3%80%9298004+%E3%83%AF%E3%82%B7%E3%83%B3%E3%83%88%E3%83%B3%E5%B7%9E+%E3%83%99%E3%83%AB%E3%83%93%E3%83%A5%E3%83%BC/@47.5931424,-122.256935,12.22z/data=!4m5!3m4!1s0x54906c86648f1ab3:0x70905fed96b53f84!8m2!3d47.6264794!4d-122.2051488">Bellevue</a>, King County, Washington, United States</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4h6zapDrebybdl9M3GIchw.png" /><figcaption>Figure 7: Z<em>ipcode 98004, Bellevue, more Expensive Houses </em>(Google Map)</figcaption></figure><blockquote><strong><em>zipcode 98040 (more cheap houses):</em></strong></blockquote><blockquote><a href="https://www.google.com/maps/place/%E3%82%A2%E3%83%A1%E3%83%AA%E3%82%AB%E5%90%88%E8%A1%86%E5%9B%BD+%E3%80%9298040+%E3%83%AF%E3%82%B7%E3%83%B3%E3%83%88%E3%83%B3%E5%B7%9E+%E3%83%9E%E3%83%BC%E3%82%B5%E3%83%BC%E3%82%A2%E3%82%A4%E3%83%A9%E3%83%B3%E3%83%89/@47.5620701,-122.2798637,12.34z/data=!4m5!3m4!1s0x5490696298e6a771:0xeb4ecf2eb8a4edca!8m2!3d47.5824227!4d-122.2331227">Mercer Island</a>, King County, Washington, United States</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DzhoIun8mdBkO3kB6MfsmQ.png" /><figcaption>Figure 8: Z<em>ipcode 98040, Mercer Island, more Cheap Houses</em> (Google Map)</figcaption></figure><p>Although it is necessary to do more analysis to this geographic factor, I would like to have some brief understanding firstly of the two region. Based on the information from the <a href="http://www.visitbellevuewashington.com/about-bellevue/transportation/buses/">Bellevue official website</a>, there are metro, sound transit, and bus in Bellevue. In contrast, Mercer Island has only <a href="https://mymercerisland.net/getting-around-mercer-island-commuting-public-transportation-tips/">bus system</a>. <strong><em>Probably due to the convenience of transportation</em></strong>, Bellevue is much more popular than Mercer Island, so there are more expensive houses in Bellevue and more cheap houses in Mercer Island.</p><h3>Conclusion</h3><p>Based on the analysis of the house prices in in King County, I had the following findings:</p><ol><li>The house price in King County <strong><em>is not increasing nor decreasing</em></strong> during 2014 to 2015.</li><li>The important factors that affect house price are: <strong><em>(i) the square footage of a house, (ii) the location (latitude), (iii) the existence of a waterfront, (iv) the grade of a house </em></strong>based on King County grading system.</li><li>It is possible to tag a house as cheap or expensive using the model constructed. Furthermore, the area that has more expensive or more cheap houses can be specified. <strong><em>Bellevue has more expensive houses while Mercer Island has more cheap houses. </em></strong>It you have tight budget limit, you may consider Mercer Island at first.</li></ol><p>The findings are a first step to investigate the story behind the house price in King County. Further studies are required to have a more detailed picture of the house price.</p><p>To see more details of this analysis, please refer to my Github account <a href="https://github.com/HuangKY/king_country_house_sales">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6c073eed87f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>