<?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 Adrian Kay on Medium]]></title>
        <description><![CDATA[Stories by Adrian Kay on Medium]]></description>
        <link>https://medium.com/@adrianhkay?source=rss-b3c66d797744------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*H83HTAsmQxMJsBwyCwDw3Q.jpeg</url>
            <title>Stories by Adrian Kay on Medium</title>
            <link>https://medium.com/@adrianhkay?source=rss-b3c66d797744------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 03:56:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adrianhkay/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[Extract information from news articles by using Web-scraping and NLP]]></title>
            <link>https://medium.com/@adrianhkay/extract-information-from-news-articles-by-using-web-scraping-and-nlp-7c9cacbae75?source=rss-b3c66d797744------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c9cacbae75</guid>
            <category><![CDATA[news-articles]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[real-estate]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Adrian Kay]]></dc:creator>
            <pubDate>Tue, 19 Nov 2019 20:00:09 GMT</pubDate>
            <atom:updated>2019-11-19T20:00:09.320Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VBr6dtHeMHprF9Rq" /><figcaption>Photo by <a href="https://unsplash.com/@hannahmgibbs?utm_source=medium&amp;utm_medium=referral">Hannah Gibbs</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>An alternative way to verify your findings from your algorithm and machine learning models could be from the news articles and what better way to do if the results have been vetted and verified by a journalist.</p><p>This article would mainly focus on New York City’s commercial real estate space and information that we would be extracting from these news articles would be their addresses and the overall status of the property(ies). The process is broken down into three stages:</p><ol><li>Web-Scraping — Scrapy</li><li>NLP ( Natural Language Processing) — Natural Language Toolkit (NLTK)</li><li>Utilizing third-party APIs — ZoLa NYC’s Zoning &amp; Land Use Map API</li></ol><h3>Web-Scraping</h3><p>Web-scraping is a very powerful tool to extract information if there are not available. For this exercise, Python <a href="https://scrapy.org/">Scarpy </a>would be used as the website sites itself are not coded javascript nor AJAX. The targeted news websites would be as follows:</p><ol><li><a href="https://therealdeal.com/">The Real Deal</a></li><li><a href="https://newyorkyimby.com/">New York Yimby</a></li><li><a href="https://nypost.com/">New York Post</a></li><li><a href="https://commercialobserver.com/">Commercial Observer</a></li><li><a href="https://www.brownstoner.com/">Brownstoner</a></li></ol><p>Most of these websites are fairly easy to scrape since the site structure is based on page numbers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/997/1*IqSF_XtJkcPYk3VKDOOzKA.png" /></figure><h4>Stage 1 &amp; 2</h4><p>After understanding the site structure and knowing the maximum pages for a certain category, generate a list of URLs to scrape. The next stage is to extract all links “&lt;href&gt;” for each article and loop stage 3.</p><pre># Sample Residential Real Estate List<br>resi_urls = [&#39;<a href="https://therealdeal.com/category/residential-real-estate/page/%7B%7D/&#39;.format(i)">https://therealdeal.com/category/residential-real-estate/page/{}/&#39;.format(i)</a> for i in range(1,270)]</pre><pre>#Sample xPath extraction from html<br>article_urls = response.xpath(&#39;//*[<a href="http://twitter.com/class">@class</a>=&quot;entry-title entry-summary&quot;]/a[1]/@href&#39;).extract()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WO614sjS4wcYne6PQK_CnA.png" /><figcaption>Sample page of an article in TRD, highlighted are fields to be extracted</figcaption></figure><h4>Stage 3 &amp; 4</h4><p>Once the article is loaded, the title, second title, date published, content and tags are all extracted and stored.<br><strong><em>Lesson learned</em></strong><em>:</em> <em>When paragraph text contents hyperlink a single XPath expression would not include the hyperlink text. An “OR (|)” condition at the XPath expression is needed to include </em>all text.</p><pre># Sample code if content contants tags<br>content =&#39;&#39;.join(response.xpath(&#39;//*[@class=&quot;post-content-box&quot;]/p/text() | //p/a/text()&#39;).extract())</pre><h3>NLP ( Natural Language Processing) with NLTK</h3><p>This section would lay out the steps necessary to build a name entity recognizer with <a href="https://www.nltk.org/">NLTK </a>to identify the addresses, locations, or organizations associated with the article.</p><p>After transforming all scraped news articles to a clean database. The next step is to pre-process the text data.</p><ol><li>Remove all stop words</li><li>Word tokenization</li><li>Part-of-speech tagging (POS tagging)</li></ol><pre>nltk.download()<br>from nltk.corpus import stopwords<br>stop = stopwords.words(&#39;english&#39;)</pre><pre>def nltk_process(document):<br>    document = “ “.join([i for i in document.split() if i not in stop])<br>    sentences = nltk.sent_tokenize(document)<br>    sentences = [nltk.word_tokenize(sent) for sent in sentences]<br>    sentences = [nltk.pos_tag(sent) for sent in sentences]<br>    return sentence</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*_2D2539dgnijMulQwnwmxg.png" /></figure><p>4. Pattern recognition<br>Most addresses in the news articles are normally structured as follows:</p><blockquote>205 Fifth Avenue<br>123 Stone Street<br>35th West 5th Avenue</blockquote><p>Note that it doesn’t necessarily have the traditional structure as standard addresses, which increases the complexity of the regular expression patterns. The pattern below should be available to capture the majority of addresses in the US. <a href="https://pythonprogramming.net/part-of-speech-tagging-nltk-tutorial/">Link to POS tags list</a></p><pre># Sample pattern for addresses<br>ADDRESS: {&lt;JJ.?|CD.?&gt;+&lt;CD.?|JJ.?|NNP.?&gt;+&lt;CD|NNP&gt;+}</pre><p>5. Chunking<br>Chunking is a process where the predefined pattern is parsed through the sentences and outputs a label that contains the pattern.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*CX3F3z4fhcO6f2E9R-_uig.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*f9HlDGBQe4vxePBShnBr7A.png" /></figure><h3>Utilizing third-party APIs</h3><p>To take these parsed addresses to the next level and add a geospatial component to it, an API would be used. Since these articles mainly focused on New York City and only<a href="https://zola.planning.nyc.gov/about"> NYC’s Zoning &amp; Land Use Map website</a> contains a hidden API in its search box. Therefore, it would be possible to piggyback this API by using the python package <em>request</em> to help extract the full address and coordinates for further analysis of our platform. In this case, the address and Brough, Block and Lot (BBL) are extracted</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*XXeKLsAwodzkMU6O4UvUTQ.png" /><figcaption>Example output from ZoLa’s API. (Note Lat/Long is also available)</figcaption></figure><pre>import urllib.parse<br>import requests</pre><pre>def address_api(address):<br>    if address == &#39; &#39;:<br>        return None , None<br>    address = urllib.parse.quote(address.encode(&#39;utf-8&#39;))<br>    url = &quot;<a href="https://search-api.planninglabs.nyc/search?helpers[]=geosearch&amp;helpers[]=bbl&amp;helpers[]=neighborhood&amp;helpers[]=zoning-district&amp;helpers[]=zoning-map-amendment&amp;helpers[]=special-purpose-district&amp;helpers[]=commercial-overlay&amp;q={">https://search-api.planninglabs.nyc/search?helpers[]=geosearch&amp;helpers[]=bbl&amp;helpers[]=neighborhood&amp;helpers[]=zoning-district&amp;helpers[]=zoning-map-amendment&amp;helpers[]=special-purpose-district&amp;helpers[]=commercial-overlay&amp;q={</a>}&quot;.format(address)<br>    try: <br>        r = requests.get(url)<br>        if (r.status_code == 200):<br>            if (&#39;json&#39; in r.headers.get(&#39;Content-Type&#39;))&amp; len(r.json()) &gt; 0:<br>                json = r.json()<br>        #         json = list(chain(*json))<br>                addresses = list(map(lambda x: x[&#39;label&#39;] if x[&#39;type&#39;] == &#39;lot&#39; else None ,json))<br>                bbl = list(map(lambda x: x[&#39;bbl&#39;] if x[&#39;type&#39;] == &#39;lot&#39; else None,json))<br>                return addresses, bbl<br>            else:<br>                return None, None<br>        else:<br>            return None, None<br>    except:<br>        return None, None</pre><h3>Future works</h3><p>There is an endless possibility in used NLTK, for example, auto-tagging, translations services, sentence summarization, etc. the list goes on. Also, with larger files with Big Data, Hadoop and Apache Spark would also be needed to speed the process.</p><p>Link to <a href="https://github.com/akay126/NYCCRE_news">GitHub</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c9cacbae75" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Predict House Prices with Advance Regression]]></title>
            <link>https://medium.com/@adrianhkay/predict-house-prices-with-advance-regression-b4bc7bc2f13b?source=rss-b3c66d797744------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4bc7bc2f13b</guid>
            <category><![CDATA[regression]]></category>
            <category><![CDATA[housing-prices]]></category>
            <category><![CDATA[ensemble-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[real-estate]]></category>
            <dc:creator><![CDATA[Adrian Kay]]></dc:creator>
            <pubDate>Wed, 23 Oct 2019 20:32:29 GMT</pubDate>
            <atom:updated>2019-10-23T20:32:29.954Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lFVDlNxCstWL11Ei" /><figcaption>Photo by <a href="https://unsplash.com/@seanpollock?utm_source=medium&amp;utm_medium=referral">Sean Pollock</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Every day we hear about how Machine Learning (ML) is transforming our daily lives, from social media, finance, healthcare, and now real estate. Real Estate Technology “RealTech” has always been behind in many ways throughout the world, but companies like <a href="https://www.zillow.com/">Zillow</a> &amp; <a href="https://cadre.com/">CADRE</a> are taking the lead in real estate analytics.</p><h3>“Guess” what the market is saying</h3><p><a href="https://www.kaggle.com/">Kaggle</a> has always been the place for data scientists to flex their muscles and share ideas. The <a href="https://www.kaggle.com/c/house-prices-advanced-regression-techniques/overview">Ames Housing datase</a>t, compiled by Dean De Cock for data science education, would a perfect place to practice the skills of a data scientist and see how high up the leaderboard you get. Breakdown of skills that would be touched in this article:</p><ul><li>Exploratory Data Analysis</li><li>Data Transformation</li><li>Feature engineering</li><li>Advanced regression models</li><li>Stacking and ensembling models</li></ul><p>The goal is to accurately predict the <strong>sales price </strong>from the test data set provided.</p><h3>Exploratory Data Analysis (EDA)</h3><p>Understanding the variables that are correlated to each other is helpful at the beginning. As it is easier to visualize which variables are essential.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*gjTbECg_lHpfs5WyMDhrZQ.png" /><figcaption>Correlation matrix for all numerical variables</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*B2vZwCdLGRsxgNnoUEU3mQ.png" /><figcaption>Correlation matric for the top 10 most correlated variables to Sales Price</figcaption></figure><p>In the next step, we need to look at the pair plots to identify trends, distributions, and outliers within the data to get a better understanding of how each variable is effecting others and in what way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6gY7fwbFqt4bCY6g8WubdA.png" /><figcaption>Pair plots with the most correlated variables</figcaption></figure><h4>Let’s take a closer look</h4><p>Take <em>gross living area </em>(GrLivArea) and Overall Quality against s<em>als price (SalePrice), </em>for example.<em> </em>There is a clear upward trend against sale prices and can also identify outliers off to the right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*fSpeMauOMtfdL4GKWaYrBw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*Lfta2IAqOHai1-mOTZ_j2g.png" /><figcaption>Scatter Plot between SalePrice and Gross Area (<strong>left</strong>) and Boxplot between Sale Price and Overall Quality (<strong>right</strong>)</figcaption></figure><h3>Data Transformation</h3><h4>Missingness of data</h4><p>Treating missingness of data seems easier than it sounds. Still, in this case, most of the missingness is due to it being with “No Alley” or “No Fireplace,” and only a small portion of the data are actually missing data. Traditionally, before imputation, you would need to know why is data missing, and here are three main types <strong>Missing at Random (MAR)</strong>, <strong>Missing Completely at Random (MCAR), </strong>and <strong>Missing not at Random (MNAR). </strong>In this case, it would be treated as MCAR and impute values based on it’s median or mode depending on the variable; other methods such as <strong>kNN </strong>are also used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*S6JUXFZxJf-ktlkdhUaoHg.png" /><figcaption>Graphs showing the percentage of missing values</figcaption></figure><h4>Skewness and Box-Cox transformation</h4><p>Having a look at the skewness and kurtosis values of each numerical variable can help us understand whether the data is normally distributed or skewed towards the left or right.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*lrhwPLnSazHQcKodh7Gi-A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/428/1*aXVanOVxbXh5D76Uj0iBwQ.png" /><figcaption><strong>Before </strong>log- transformation of the sale price</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*FLWy1IIPk4lyXJKNTX0SWA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*CPvyNduMC_vMuua338pekw.png" /><figcaption><strong>After </strong>log- transformation of the sale price</figcaption></figure><h3>Featuring Engineering</h3><h4>1. Creating new Features</h4><p>From creating new features to removing existing ones. We have to take a deeper dive into each variable; the goal here is to add more context and increase the predictive power of the machine learning algorithms by applying domain knowledge.<br>In this case, new features such as:</p><ul><li>Total Gross Area</li><li>Total Bathroom Area</li><li>Total Porch Area</li><li>Split time to quarters</li><li>Has pool/ 2nd Floor/ Garage / Basement / Fireplace</li></ul><p>These newly created features enhance the ML model and decrease the root mean square error (RMSE)</p><h4>2. Dropping Features</h4><p>Features that are dropped in the exercise are features that are either not relevant to the sale price or features that have 99% the same value.</p><ul><li>id — House ID</li><li>Street — Name of the street (noted might be useful in Manhattan)</li><li>Utilities — 99% same value</li><li>PoolQC — Too much missingness over &lt;40%</li></ul><h4>Sidebar with time-series data</h4><p>It is noted that this exercise is not focused on time-series, and predictions on the test set are within the range of the training set. However, we can see that commercial real estate markets are rarely linear and are cyclical. Still, it is important to note that tradition cross-validation techniques (e.g.kfold) would not work with time-series data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*10SPbAv-kDYfduad3XbZgA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*vFbNPF23FVvD8gN6NRJNRA.png" /></figure><h3>Machine Learning Modeling</h3><p>There are different machine learning algorithm, and different algorithms have its pros and cons</p><h4>Linear models</h4><ul><li>Lasso Regression, L1 — Reduces beta to zero</li><li>Ridge Regression, L2 — Reduces betas very close to zero</li><li>ElasticNet Regression — Combination fo L1 and L2</li></ul><p>The regularized linear models reduces the significates of the independent variable. However, this leads to high bias but significantly reduces the variance. Also known as the bias-variance tradeoff.</p><h4>Non-Linear Models</h4><ul><li>Random Forest — “vanilla” bagging algorithm</li><li>XGBoosting — Extreme Gradient Boosting</li><li>LightGBM — Light Gradient Boosting</li></ul><p>Random Forest, XGBoosting, and LightGBM above are different ensemble learning models, and the aim is to train a large number of low-accuracy models and combining weaker models to obtain a high-accuracy meta-model.</p><h4>Models Stacking</h4><p>Similar to the non-linear models above, stacking models or model ensembling is a method where weaker models are “stacked” on top of each other, resulting in a meta-model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hNvDOOEfuJMg8roxCtac6w.jpeg" /><figcaption>Stacking models from <a href="https://www.kaggle.com/getting-started/18153#post103381">Faron</a></figcaption></figure><h3>Results</h3><p>The accuracy of the models is tested against root mean squared error, RMSE between the test set data and the test data from Kaggle.</p><p>After testing out all six linear and non-linear models, the stacked meta-model had the lowest RMSE. The stacked model is a combination of Elastic Net, Gradient Boosting, Ridge Regression and finally used the Lasso for the out of fold prediction as a new meta-feature for the final model.<br>The RMSE score from the test set was 0.11608 and end up on the top 11% (529/4846) from the leaderboard.</p><h3>Additional Work</h3><p>Tuning hyperparameters<br>Additional feature engineering</p><p><a href="https://github.com/akay126/house-prices-advanced/blob/master/Kaggle%20House%20Prices.ipynb">GitHub </a>Code</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4bc7bc2f13b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Visualize Housing Market with R shiny with web scrapped data]]></title>
            <link>https://medium.com/@adrianhkay/visualize-housing-market-with-r-shiny-with-web-scrapped-data-82e5a72b7c3a?source=rss-b3c66d797744------2</link>
            <guid isPermaLink="false">https://medium.com/p/82e5a72b7c3a</guid>
            <category><![CDATA[web-scraping]]></category>
            <category><![CDATA[housing]]></category>
            <category><![CDATA[hong-kong]]></category>
            <category><![CDATA[real-estate]]></category>
            <dc:creator><![CDATA[Adrian Kay]]></dc:creator>
            <pubDate>Wed, 04 Sep 2019 04:29:03 GMT</pubDate>
            <atom:updated>2019-11-27T18:13:05.875Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RRsUY_oJn5cx4Pm9" /><figcaption>Photo by <a href="https://unsplash.com/@smnzhu?utm_source=medium&amp;utm_medium=referral">Simon Zhu</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Visualize Housing Market with R shiny and Mapbpox with web scraped data</h3><h3>Introduction</h3><p>The housing market in Hong Kong has always been one of the most analyzed and discussed markets in the world, for its high prices and small living spaces. In addition, housing reform has yet to succeed in controlling the sky-high prices for almost 10 years. The result is where millennials in Hong Kong have no choice but to live in unbearable conditions or illegal living spaces.</p><blockquote><em>“Hong Kong is the city most at risk of a property bubble,</em></blockquote><blockquote><em>according to a ranking from UBS Group AG.” — </em><a href="https://www.bloomberg.com/news/articles/2018-09-28/the-cities-around-the-world-most-at-risk-of-property-bubbles"><em>Bloomberg</em></a></blockquote><p><em>“World’s Priciest Home Market Pushes Millennials Beyond the Law” — </em><a href="https://www.bloomberg.com/news/articles/2018-08-26/world-s-priciest-home-market-pushes-millennials-beyond-the-law"><em>Bloomberg</em></a></p><h4>Aim</h4><p>The goal of this <strong>two-week project</strong> was to web-scrap data from real estate websites and develop an <strong>interactive dashboard application</strong> to visualize the housing market using interactive maps and graphs to better understand the problems facing the people of Hong Kong.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1g5leNd_pano-lWU8XLwTw.png" /><figcaption>3D map showing the property age of Hong Kong</figcaption></figure><p><a href="https://api.mapbox.com/styles/v1/berncool/cjndkardf1ikx2rnw9n8i7inj.html?fresh=true&amp;title=true&amp;access_token=pk.eyJ1IjoiYmVybmNvb2wiLCJhIjoiY2oyMzh1emZtMDB0MjM3cWltZGx6cmk0ciJ9.Q6kd7Y7rxkX43cWlZlB2bQ#14.71/22.31253/114.17777/-37.8/60">Scrapy Project - Property Age</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9ENT90LW7mfC6fST0IHzhg.png" /></figure><p>Link to<a href="https://ahkay.shinyapps.io/hk_housing/"> Hong Kong Housing Visualisation by Adrian Kay</a></p><h3>How is it done?</h3><p>On top of normal charts and graphs, housing market data could be interpreted Geo-Spatially. Combining <strong>Geo-Spatial data</strong> with other forms of data (e.g. house properties/price/engineering geology/government zoning) could be a very powerful analytical tool to identify visually unforeseen patterns and make help you make better decisions on what to invest. <strong>Geo-Spatial</strong> <strong>data</strong> can be in the form of a GEOJSON or spatial polygon data frame (shp) and other forms of data can be data from a website or open data from government bodies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*0fwuCCCHrbZJQlvWXGqmDA.jpeg" /></figure><h4>Web-scraping</h4><p>Since data from the Hong Kong housing market is not openly shared nor easily downloaded, the only method to do it freely is by web-scraping data from <a href="http://www1.centadata.com/ephome.aspx">real estate</a> and some <a href="https://data.gov.hk/en/">government websites</a>. <strong>Rvest</strong> is an R package that uses R to web-scrap data from websites and could be housed in the R environment where data pre-processing with <strong>dplyr</strong>/<strong>tidyr</strong> and analysis could be pipelined into one smooth process, provide quick insight about the scraped data.</p><h4>R &amp; R Shiny</h4><p><a href="http://shiny.rstudio.com/">R Shiny</a> is an open-source R package that provides an elegant and powerful web framework for building web applications using R. Shiny helps you turn your analyses into interactive web applications without requiring HTML, CSS, or JavaScript knowledge.</p><p><strong>Leaflet</strong> is a Geo-Spatial package in R that could quickly render maps on a district scale, but not on a street-level scale due to R’s <strong>memory hungry</strong> nature. The advantage is that it could be integrated with R shiny (a web-based interactive dashboard app) and could easily communicate ideas and information to the clients on the web.</p><p>Furthermore, <strong>ggplot</strong>/ <strong>ploty</strong>/<strong>googlevis</strong> could also be integrated into R shiny and give the user real-time information and data analytics at a tabular/ graphical level.</p><h3>Web-Scraping with R</h3><p>Results collected from the web-scraping exercise included the follows parameters of each individual flat that is listed on the site. A total of over <strong>2 million lastest transactions </strong>of flats and houses were recorded</p><ol><li>Region</li><li>District</li><li>Block</li><li>Phase</li><li>Tower</li><li>Flat/Floor</li><li>Saleable Area</li><li>Gross Area</li><li>Price Sold</li><li>Year Sold</li></ol><h3>R Shiny</h3><p>Link to<a href="https://ahkay.shinyapps.io/hk_housing/"> Hong Kong Housing Visualisation by Adrian Kay</a></p><p>Using an interactive dashboard layout with R Shiny allows users to navigate through different windows and tabs easily. Here are some snapshots through all the features on the R Shiny application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*0pP1V4xPZ1oeLmPmzULT-g.png" /><figcaption>Figure 4: Average Age of housing from different districts in Hong Kong</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*pAbjt1qC8-HyDW7irsu1Cw.png" /><figcaption>Figure 5: Height Relationship against Price per SQRT setting could be changed by the user for different analytics proposes.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*HLxiz0Nb_ZUz4_AUZ8sMUg.png" /><figcaption>Figure 6: Average Price per SQRT against Age of buildings</figcaption></figure><p>What are the limitations?</p><h4>Why R Shiny isn’ t the best language to use for this type of analysis?</h4><p>As you may have known R is a memory-intensive programming language and the free version of <strong>R shiny</strong> has its limitation to 500MBs of memory and limited hours. Which if this were been deployed on a large scale, it would have been slow and unreliable.</p><h4>How to improve the speed and efficiency of large-scale deployment?</h4><p>Python</p><p>Using Python would be ideal and on my next project, I would discuss the benefits of using Python <a href="https://scrapy.org/">Scrapy</a> to web-scrap at a large scale and how to pre-process the web-scraped data with <strong>Numpy</strong> and <strong>Pandas</strong>.</p><p>Mapbox and Carto</p><p>Using third-party programs such as <a href="https://www.mapbox.com/"><strong>mapbox</strong> </a>or <a href="https://carto.com/"><strong>carto</strong> </a>would better suited for large-scale development since these platforms are designed for large-scale data sets and can be integrated into any HTML script with an access token.</p><h4>References</h4><p>Link to<a href="https://ahkay.shinyapps.io/hk_housing/"> Hong Kong Housing Visualisation by Adrian Kay</a></p><p>Link to <a href="http://www1.centadata.com/ephome.aspx">CentaData</a></p><p>Link to <a href="https://data.gov.hk/">DATA.GOV.HK</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82e5a72b7c3a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>