<?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 Harun Erbay on Medium]]></title>
        <description><![CDATA[Stories by Harun Erbay on Medium]]></description>
        <link>https://medium.com/@harunerbay?source=rss-21cf1d9acabb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Harun Erbay on Medium</title>
            <link>https://medium.com/@harunerbay?source=rss-21cf1d9acabb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 01:03:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@harunerbay/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[House Prices Prediction using Regression Model and Web Scraping]]></title>
            <link>https://medium.com/i%CC%87stanbuldatascienceacademy/house-prices-prediction-using-regression-model-and-web-scraping-8791199635b6?source=rss-21cf1d9acabb------2</link>
            <guid isPermaLink="false">https://medium.com/p/8791199635b6</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[web-scraping]]></category>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[projects]]></category>
            <dc:creator><![CDATA[Harun Erbay]]></dc:creator>
            <pubDate>Sun, 26 Dec 2021 13:44:32 GMT</pubDate>
            <atom:updated>2021-12-27T12:00:37.269Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*c77VqhDKQZK5Wt3f" /></figure><h3>Introduction</h3><p>The second project of the Data Science Bootcamp, organized in partnership with <a href="https://www.linkedin.com/school/istanbul-data-science-academy/"><strong>Istanbul Data Science Academy</strong></a> and <a href="https://www.linkedin.com/company/hepsiburada/"><strong>Hepsiburada</strong></a><strong>,</strong> has been successfully completed. In this project, we made a house price prediction model using Machine Learning which houses for sale in Kadikoy, Istanbul. We got the data from <a href="https://www.zingat.com/"><strong>this site</strong></a> for web scraping.</p><h3>Problem Statement</h3><p>The goal of project is to help us understand the relationship between house features and how these variables are used to predict house price.</p><h3>Objective</h3><ul><li><strong>Web scraping</strong> using Python BeautifulSoup</li><li><strong>Predict</strong> the house price</li></ul><h3>Methodology</h3><ul><li>Data Collection with Web Scraping</li><li>Data Cleaning and Reorganizing</li><li>Exploratory Data Analysis (EDA)</li><li>Linear Regression</li><li>Conclusions</li></ul><h3>1. Data Collection with Web Scraping</h3><h4>Step 1 :</h4><p>Our first step is to import the libraries that might be required to build our model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ba8f440d04f573a489e4d8e5e6559cab/href">https://medium.com/media/ba8f440d04f573a489e4d8e5e6559cab/href</a></iframe><h4>Step 2 :</h4><p>Using this function , we can get html code of given url to function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/84ba633c0ecf8c321996d0e706d95fdf/href">https://medium.com/media/84ba633c0ecf8c321996d0e706d95fdf/href</a></iframe><h4>Step 3 :</h4><p>Then, we need a function like below to reach all pages.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16b2b3b0351340c3cbcdc063fd4de403/href">https://medium.com/media/16b2b3b0351340c3cbcdc063fd4de403/href</a></iframe><h4>Step 4 :</h4><p>In the next step, we needed all links on all pages to access the house postings.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/808aec922001de89bb065e9fde191f1b/href">https://medium.com/media/808aec922001de89bb065e9fde191f1b/href</a></iframe><h4>Step 5 :</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/833/1*MDQ2rS0hBoPH4IDb-5eSoQ.png" /></figure><p>Finally, we pulled the features that we will load into the columns from the page and created our data frame.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8f39bfdd801969b3c23c1ecad56f9148/href">https://medium.com/media/8f39bfdd801969b3c23c1ecad56f9148/href</a></iframe><pre>df.to_csv(&quot;zingat_house_price_prediction.csv&quot;, encoding=&quot;ANSI&quot;)</pre><h3>2. Data Cleaning and Reorganizing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5JNzHPaBAf-AL6uSlkbWWw.png" /><figcaption>Info about data</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-CKI-_KrwGPteuX7XPqSsg.png" /><figcaption>Number of null values in the data</figcaption></figure><p>We have some problems about data set. We need to deal with these before we get to the regression part. So we use the median function to fill in the null values and convert the columns of object type to integer type. We dropped the “ODA-SALON SAYISI” column for better machine learning. We created new columns by applying <strong>get_dummies</strong> to the “MAHALLE” column.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QZaUwPhseqWLELjNqFfCKg.png" /><figcaption>Median function for null values</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p91te-HVCayuRJohYTh4zQ.png" /><figcaption>Object types to integer types</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rQS25CuH7logigkn3LvWJQ.png" /><figcaption>Applying get_dummies</figcaption></figure><h3>3. Exploratory Data Analysis</h3><p>After data cleaning and reorganizing target variable’s distribution as follows;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u8DYpbcGrQz4kcHeMWKbHA.png" /><figcaption>House prices distribution</figcaption></figure><p>We grouped some features to build a better machine learning model and visualized these. You can find detailed codes <a href="https://github.com/harunerbay/House-Price-Predict"><strong>here</strong></a>.</p><ul><li>1.Top 10 neighborhoods with the highest average house prices.</li><li>2.Distribution of the number of rooms and halls.</li><li>3.Distribution of the number of bathrooms.</li><li>4.Correlation matrix of house features</li><li>5.Correlation matrix of the neighborhood where the house is located</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MqQMpZhLgXMOlJi60gCoUg.png" /><figcaption>Figure 1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WpRs-C8StphbYPwmwRMSsg.png" /><figcaption>Figure 2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sWUSWdrxMJByp9--XK5XcA.png" /><figcaption>Figure 3</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3lHzdXyLlL5QtFcQ0uKMBQ.png" /><figcaption>Figure 4</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*InrEN7YW6pRMyMh9vTIxKg.png" /><figcaption>Figure 5</figcaption></figure><pre>sns.pairplot(DF, aspect=1.5)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NFb9HkyLg2llomayn59aZA.png" /></figure><h3>4. Linear Regression</h3><p>First of all, we need to import all the packages we are sure to use.</p><pre>from sklearn.linear_model import LinearRegression<br>from sklearn.linear_model import RidgeCV<br>import statsmodels.api as sm<br>import statsmodels.formula.api as smf<br>from sklearn.model_selection import train_test_split<br>from pandas import Series, DataFrame<br>from sklearn.preprocessing import StandardScaler<br>from sklearn.linear_model import Ridge<br>from sklearn.linear_model import Lasso</pre><p>We used the dataset which we applied get_dummies (new_df). After, we split the data and categorize which columns are feature variables and which are target variables. The size of testing data is 20%.We used R2-Score and MSE as evaluation metrics in model prediction and made it for train-validation-test.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/957f02d41302abc1d24142e9f760f64b/href">https://medium.com/media/957f02d41302abc1d24142e9f760f64b/href</a></iframe><pre>MSE Value:  FİYAT    5.757277e+12<br>dtype: float64 <br><br>R^2 Score Value (Test):  0.5801046663202142 <br><br>R^2 Score Value (Validation):  0.5690857021978828</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c25e7e05dd230314c62a97e78b72dd48/href">https://medium.com/media/c25e7e05dd230314c62a97e78b72dd48/href</a></iframe><pre>MSE Value:  FİYAT    6.274632e+12<br>dtype: float64 <br><br>R^2 Score Value (Test):  0.5438016679245479 <br><br>R^2 Score Value (Validation):  0.5303632838955692</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c10af2cac159be142505e3c34b57679/href">https://medium.com/media/9c10af2cac159be142505e3c34b57679/href</a></iframe><pre>R^2 Score Value (Test):  0.5793058427962506 <br><br>R^2 Score Value (Validation):  0.563142565405035</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3a87618536e33c000fa941794ad68c58/href">https://medium.com/media/3a87618536e33c000fa941794ad68c58/href</a></iframe><pre>R^2 Score Value (Test):  0.5837754090161392 <br><br>R^2 Score Value (Validation):  0.5620382643849704</pre><h3>5. Conclusions</h3><p>According to analysis, the features that most positively affect the price of a house in Kadıkoy are;</p><ul><li>The <strong>square meter</strong> of the house.</li><li><strong>Number of rooms and living rooms</strong> of the house</li><li>The house is located in <strong>Caddebostan</strong> or <strong>Fenerbahce</strong>.</li><li>The best regression method are shown <strong>Linear Regression</strong> and <strong>Lasso Regression</strong>.</li></ul><p>What can we do to improve the prediction model?</p><ul><li>Scanning the house data in <strong>larger area</strong>.</li><li>Working with <strong>more features</strong>.</li><li>Doing more extensive <strong>feature engineering</strong> on features.</li></ul><p>Thank you for reading and taking the time to read my article.You can visit my <a href="https://www.linkedin.com/in/harunerbay/">LinkedIn</a> and <a href="https://github.com/harunerbay?tab=repositories">Github</a> accounts for more detailed information.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8791199635b6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/i%CC%87stanbuldatascienceacademy/house-prices-prediction-using-regression-model-and-web-scraping-8791199635b6">House Prices Prediction using Regression Model and Web Scraping</a> was originally published in <a href="https://medium.com/i%CC%87stanbuldatascienceacademy">İstanbul Data Science Academy</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>