<?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 Marcos Juncken on Medium]]></title>
        <description><![CDATA[Stories by Marcos Juncken on Medium]]></description>
        <link>https://medium.com/@juncken-marcos?source=rss-3737a2eb59f4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*XGVYMkKbjMEHI12AZeLlsA.png</url>
            <title>Stories by Marcos Juncken on Medium</title>
            <link>https://medium.com/@juncken-marcos?source=rss-3737a2eb59f4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 17:27:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@juncken-marcos/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[How can we predict house prices with Machine Learning?]]></title>
            <link>https://juncken-marcos.medium.com/how-can-we-predict-house-prices-with-machine-learning-f26b9432a7aa?source=rss-3737a2eb59f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f26b9432a7aa</guid>
            <category><![CDATA[predictions]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[real-state]]></category>
            <dc:creator><![CDATA[Marcos Juncken]]></dc:creator>
            <pubDate>Thu, 17 Dec 2020 20:00:36 GMT</pubDate>
            <atom:updated>2020-12-17T23:02:12.597Z</atom:updated>
            <content:encoded><![CDATA[<p>Using Python to understand which variables affect the house rent and sales price in São Paulo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iu8kSsHLsPoiRq8ikkJSwQ.jpeg" /><figcaption><strong>Photo by </strong><a href="https://www.pexels.com/@kaiquestr?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Kaique Rocha</a><strong> from </strong><a href="https://www.pexels.com/photo/sky-people-street-taking-photo-97906/?utm_content=attributionCopyText&amp;utm_medium=referral&amp;utm_source=pexels">Pexels</a></figcaption></figure><p><strong>Hello World!</strong> I&#39;m learning more about data science and how we can predict values based on other variables. Since I work in a Real State Startup — <a href="https://loft.com.br/">Loft</a> — I tried to apply some of the concepts and processes in data science to answer some interesting questions about this market!</p><p>The first question that I thought about is the main subject of this article — <strong>how to predict house prices?</strong> Is that possible using the concepts that I&#39;ve already learned?</p><p>But following this question, <strong>which variables impact more in rent and in sales?</strong> Because probably they are different since the people that choose between these 2 different types of negotiation have different needs.</p><p>It&#39;s common sense that the region where is the property located affects the price — so, this is our third question, <strong>where in São Paulo is cheaper and where is more expensive?</strong></p><p>So, these are our 3 questions to answer:</p><ol><li><strong>How can we get at least 90% accuracy to predict property price?</strong></li><li><strong>Rent vs Sale: what is the difference between variables correlation with the price?</strong></li><li><strong>What neighborhoods in São Paulo have the highest squared meter price? And the lowest?</strong></li></ol><p>And to answer those questions we need a good database, surfing in our World Wide Web, I founded this <a href="https://www.kaggle.com/argonalyst/sao-paulo-real-estate-sale-rent-april-2019"><strong>São Paulo properties database</strong></a> on Kaggle that was very useful to me! And was great because São Paulo is the city I live and work in. 😀</p><p>But before exploring the questions I will show some challenges that we had on the dataset.</p><p><strong>*This project is available on </strong><a href="https://github.com/marcosjuncken/PredictHousePrices"><strong>GitHub here</strong></a><strong>.</strong></p><h3>Preparing the Data</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/0*_9g73cBX3Y8ftWwi" /><figcaption>Random image from Word Wide Web</figcaption></figure><p>Before trying to analyze the data, I needed to check if everything there was making sense. And I saw three main things that were very important to fix before answering our questions.</p><p>To accomplish that I need to use the knowledge that <strong>Yoda’s Jedi Master</strong> taught me.</p><p>First I understood if we had values for all lines of the dataset and a sample of this data. Until here everything was looking good. But when I checked the types of values, I saw that Elevator, Furnished, Swimming Pool, and New were classified as integers instead of boolean — and all of these values were 0 or 1.</p><p>The second problem that I founded was when I check the value counts for Latitude and Longitude. A lot of them were 0?!? I&#39;m not the smartest person on geography, <strong>but I know that São Paulo is not located in the Gulf of Guinea</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*54ShcdrOeW8PUHV0.png" /><figcaption>Latitude 0 and Longitude 0</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mqXcIJq_3YgeEZv-EJhOkw.png" /></figure><p>So after that, I plot the 13640 lines of data that we have on the dataset and I faced this image.</p><p>Didn&#39;t look so good, maybe this is wrong. MAYBE.</p><p>So I searched for the maximum latitude and longitude for São Paulo and <strong>replaced all the values that were out of São Paulo with the values mean</strong> (excluding the out of location values, of course).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wa8KqV-MBCcdQAPIeF2cUA.png" /></figure><p>And the new plot was making a lot of sense now! After this part, I just created 2 other datasets to separate properties for sale and for rent, because the price between them is very different.</p><p>That was very helpful to answer our 3 questions later!</p><h3>1 — <strong>How can we get at least 90% accuracy to predict property price?</strong></h3><p>The only way that I learned to predict values was with the<strong> Linear Regression Model</strong>. Before trying this model, I created a dummy variable for each categorical values in our dataset. Remembering that now we have 3 datasets:</p><ul><li>df = all properties</li><li>df_rent = properties for rent</li><li>df_sale = properties for sale</li></ul><p>But unfortunately, the results were not satisfactory:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AtZwaysQEle2W0bRoZy7XQ.png" /></figure><p>So I needed to surf again on our <strong>World Wide Web</strong> and I find the <strong>Gradient Boost Model </strong>— for more information check this article.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xTgSRJkPnBkgNA_PdDA7Cw.png" /></figure><p>And now we achieved our objective, <strong>we have an accuracy score of 0.93</strong> — at the data frame that has both for sales and for rental properties.</p><p>This is great, and Gradient Boost can understand a lot better than Linear Regression the number of features that have an impact on the price and that the features have a correlation between than.</p><h3>2 — What neighborhoods in São Paulo have the highest squared meter price? And the lowest?</h3><p>To prepare the answer to this question we need to understand that the price for itself doesn&#39;t mean a lot comparing different regions. <strong>The squared meter is a variable that can explain better</strong> the differences in property valuation between neighborhoods.</p><p>So let&#39;s begin to analyze the neighborhoods with the <strong>highest square meter</strong> price in properties for sale and for rental:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*_kSFAbULDiFEe04DI_sNGQ.png" /><figcaption>Properties For Rental</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*3L8Y--RqhCOueJMcYAaccg.png" /><figcaption>Properties For Sale</figcaption></figure><p>Here we can already see the differences:</p><ul><li>We have 9 districts that are in both lists: Iguatemi, Vila Olimpia, Itaim Bibi, Brooklin, Pinheiros, Vila Madalena, Moema, Campo Belo and Jardim Paulista.</li><li>Alto de Pinheiros is just in the 10 highest Squared Meter Price for sale.</li><li>Consolação is just in the 10 highest Squared Meter Price for rent.</li></ul><p>And the <strong>lowest squared meter price</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*jioRi1s_t43M6sKp59dinA.png" /><figcaption>Properties For Rental</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*fPlC3DOY-bDkoxKvSI4cew.png" /><figcaption>Properties For Sale</figcaption></figure><p>Let’s understand this data:</p><ul><li>We have 5 districts that are in both lists: Grajaú, Artur Alvim, Itaim Paulista, Lajeado and Guaianazes.</li><li>Capão Redondo, Medeiros, Itaquera, São Rafael and Cidade Tiradents are just in the 10 lowest Squared Meter Price for sale.</li><li>Ponte Rasa, Jardim Helena, Jaçanã, José Bonifácio and Jardim São Luis are just in the 10 lowest Squared Meter Price for rent.</li></ul><h3>3— Rent vs Sale: what is the difference between variables correlation with the price?</h3><p>Now let’s see which variables impact more in price! First I will show the heatmap indicating the <strong>correlation of the variables with the price</strong> of the properties for rental and for sale.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TQ5PbxRC2q0cWqc0m1j30A.png" /><figcaption>Properties For Rental</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SVxcS2ZEfSB5pWVrQlo7TA.png" /><figcaption>Properties For Sale</figcaption></figure><p>At those heatmaps, we can see some difference.</p><p>Let’s begin with variables that impact more when the apartment is for sale:</p><ul><li>Size, number of rooms, toilets, and parking spots.</li></ul><p>And the variables that impact more when the apartment is for rent:</p><ul><li>The condo price and if the apartment is furnished.</li></ul><p>Bringing that to reality makes sense because the variables with a bigger correlation in the properties for sale are more about long-term characteristics and in the properties for rent is more about short-term characteristics.</p><p>Another way to understand that is to<strong> measure the coefficient weights in a Linear Regression model </strong>that we tried before:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/343/1*v0hQPkoSkDvky-uZh0LD_A.png" /><figcaption>Properties For Rent</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*bXCJMMmgeaAanAzo34KEgg.png" /><figcaption>Properties For Sale</figcaption></figure><p>In this case, we can understand that <strong>Geographic Location is the more important characteristic to define the price</strong>, which is very true. We can see this difference when we analyzed the Districts with the highest and lowest squared meter price.</p><ul><li>Suites and Furnished have a bigger impact on price when we look at the properties for sale.</li><li>New and Toilets have a bigger impact on price when we look at the properties for rent.</li></ul><p><strong>Thanks for reading!</strong> Feedbacks are very welcomed! 😃</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f26b9432a7aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>