<?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 Henry Dashwood on Medium]]></title>
        <description><![CDATA[Stories by Henry Dashwood on Medium]]></description>
        <link>https://medium.com/@henrydashwood?source=rss-ed747f9bdc88------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*E2OGtmMxclRKTnoM.</url>
            <title>Stories by Henry Dashwood on Medium</title>
            <link>https://medium.com/@henrydashwood?source=rss-ed747f9bdc88------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 08:44:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@henrydashwood/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[Fine-tuning BART for Abstractive Text Summarisation with fastai2]]></title>
            <link>https://medium.com/curation-corporation/fine-tuning-bart-for-abstractive-text-summarisation-with-fastai2-d7a2ad676a13?source=rss-ed747f9bdc88------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7a2ad676a13</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[fastai]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[summarization]]></category>
            <dc:creator><![CDATA[Henry Dashwood]]></dc:creator>
            <pubDate>Tue, 24 Mar 2020 21:26:17 GMT</pubDate>
            <atom:updated>2020-03-24T21:26:17.540Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NFQxmm9aqu1vmSR73hJOIA.jpeg" /></figure><p>This post is also available as a <a href="https://github.com/CurationCorp/curation-corpus/blob/master/examples/bart/finetuning-bart.ipynb">notebook</a>. The data we are using is our recently open-sourced <a href="https://medium.com/curation-corporation/teaching-an-ai-to-abstract-a-new-dataset-for-abstractive-auto-summarisation-5227f546caa8">Curation Corpus</a>.</p><p>A great thing about working in NLP at the moment is being able to park a hard problem for a few weeks and discovering the community making massive amounts of progress on your behalf. I used to be overwhelmed by the challenge of just training a summarisation model to generate plausible looking text without burning through tonnes of cash on GPUs. Then <a href="https://render.githubusercontent.com/finetuning-bertsumextabs">BertExtAbs</a> came along and solved that problem. Unfortunately, it still gernerated incoherent sentences sometimes and had a habit of confusing entities in an article. You certainly couldn’t trust it to convey the facts of an article reliably.</p><p>Enter BART (Bidirectional and Auto-Regressive Transformers). Here we have a model that generates staggeringly good summaries and has a wonderful implementation from <a href="https://github.com/huggingface/transformers/tree/master/examples/summarization/bart">Sam Shleifer at HuggingFace</a>. It’s still a work in progress, but after digging around in the Transformers pull requests and with help from <a href="https://github.com/morganmcg1/fasthugs">Morgan McGuire’s FastHugs notebook</a> I have put together this notebook for fine-tuning BART and generating summaries. Feedback welcome!</p><p>I should mention that this a big model requiring big inputs. For fine-tuning I’ve been able to get a batch size of 4 and a maximum sequence length of 512 on an AWS P3.2xlarge (~£4 an hour). There is ongoing work to reduce the memory requirements at HuggingFace and I’ll update this accordingly.</p><p>We begin with a bunch of imports and an args object for storing variables we will need. We’ll be fine-tuning the model on the Curation Corpus of abstractive text summaries. We load it into a dataframe using Pandas. For more information about how to access this dataset for your own purposes please see our <a href="https://medium.com/curation-corporation/teaching-an-ai-to-abstract-a-new-dataset-for-abstractive-auto-summarisation-5227f546caa8">article introducing the dataset</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/27469f58f299a68857a2297e4493f0d5/href">https://medium.com/media/27469f58f299a68857a2297e4493f0d5/href</a></iframe><p>To pass our data to the model in our fastai2 learner object we need a dataloader. To create a dataloader we need a Datasets object, batch size, and device type. To create a Datasets object, we have to pass a few things:<br>- Our raw data which in our case is a Pandas dataframe<br>- A list of transforms. Or to be more precise a list containing the list of transforms to perform on our inputs and a list of transforms to perform on our desired outputs. I’ve defined a transform below that encodes the text using the BART tokenizer. Mostly it will be the encodes class method that gets called by fastai2. However the decodes method can also be useful if you want to reverse the process.<br>- We will also split our data into training and validation datasets here, using fastai2’s RandomSplitter class.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc48ce979f56e2c8e2cad14d98337ef6/href">https://medium.com/media/cc48ce979f56e2c8e2cad14d98337ef6/href</a></iframe><p>I’m still exploring whether it is necessary to pass any of the masks and other ids manually or if it is handled for us. Any advice here would be much appreciated!</p><p>This function lets us choose between loading the model architecture with Facebook’s pre-trained weights, the model architecture with our own weights stored locally, or the model architecture with no pre-training at all.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0ec7d7151663b4ab561de3ba3da8cd34/href">https://medium.com/media/0ec7d7151663b4ab561de3ba3da8cd34/href</a></iframe><p>The model will return a lot of different things, but we only want the weights to calculate the loss when training, so we will wrap the model in this class to control what gets passed to the loss function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/69433d5df8480e601f86ccb47a1d091f/href">https://medium.com/media/69433d5df8480e601f86ccb47a1d091f/href</a></iframe><p>You can think of seq2seq tasks as a series of attempts to categorise which word should come next. Cross entropy loss is a pretty good loss function for this use case. We want to normalise it by how many non padding words are in each sequence.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ff85ed022dfe4156f0dee2cf3548f4c/href">https://medium.com/media/9ff85ed022dfe4156f0dee2cf3548f4c/href</a></iframe><p>When fine-tuning the model we will start by just training the top linear layer, then the decoder, and then the encoder (though I’ll leave the latter as it is). fastai2 provides an easy way to split the model up into groups with frozen or unfrozen parameters.</p><p>I’ve been experimenting with half precision training. In theory this will save a lot of memory. However, I find my loss quickly becomes a bunch of nans. This may be an issue with HuggingFace’s implementation or it may be an issue with my code. I’ll update if I work out how to get fp16 working. Do let me know if you have any ideas!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5998666558286148119e9bd75abbe1cc/href">https://medium.com/media/5998666558286148119e9bd75abbe1cc/href</a></iframe><p>The following code for generating the summaries comes from <a href="https://github.com/huggingface/transformers/blob/master/examples/summarization/bart/evaluate_cnn.py">Sam Shleifer’s example in the Transformers repository</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cfae6deda3feea9b232a4a5977fefb25/href">https://medium.com/media/cfae6deda3feea9b232a4a5977fefb25/href</a></iframe><pre>A nonprofit, award-winning news organization has built a tool to collect information and data on political ads that are being targeted to users of the social media giant. ProPublica&#39;s tool is a simple, free browser plugin on a Firefox or Google Chrome web browser, that Facebook users can opt into and report political advertisements they see on the site. Those advertisements will then be collected in a public database to track and analyze advertisements on Facebook.<br>***************<br>Gov. Brian Sandoval of Nevada said he had “great concerns” with the legislation. Gov. Scott Walker of Wisconsin suggested that Congress consider a better-funded version of the measure. Governor Phil Scott of Vermont said the bill could cripple the health care system in Vermont.<br>***************<br>Facebook is looking to recruit news publishers for daily and weekly shows for Facebook Watch. The company is proposing budgets that range from $5 million to $10 million annually for daily news programming. For weekly shows, Facebook is willing to pay around $1 million to$2 million, according to two news publishing execs who have been briefed by Facebook.<br>***************<br>China banned plastic waste imports in 2017. Japan&#39;s recyclers have scrambled to get their hands on the around 600,000 tons of bottles that Japanese discard each year. Most Japanese plastic bottles end up as plastic flake, which is spun into fiber used for making clothing and furniture.<br>***************<br>Common Desk, headquartered in Dallas, is expanding outside of the North Texas region. Link Coworking, which opened in 2010, was one of the first co-working, shared office spaces in the Capitol City.Common Desk’s Nick Clark said that the company had been interested in infiltrating Austin for a few years.<br>***************<br>Jean-Charles Tschudin, Non-Executive Director, acquired 250,000 ordinary shares of 1p each. He is interested in 3,250,117 Ordinary Shares, 0.65% of the issued share capital of the Company. Sinclair has an established sales and marketing presence in the leading EU markets and Brazil, and a network of international distributors.<br>***************<br>Star of the South wind farm could include 250 turbines. Its proposed site is between 10 kilometres and 25 kilometres from Port Albert. If considered feasible, the wind farm is slated to provide “full power’ by 2027. The region was hit hard by the closure of the Hazelwood power plant in 2017.<br>***************<br>BNP Paribas Asset Management said it would sell all positions in companies operating in the tobacco sector by the end of 2018. This is the second big European fund manager in less than a week to distance itself from investing in tobacco stocks, citing concerns about public health and the &quot;substantial&quot; associated economic cost.</pre><p>We are really excited to see how people use this resource. We will be updating you on the progress of our abstractive summarisation over the coming year, and making more datasets available to the community. We hope others will build on our work as we have built on that of others.</p><p>We’re particularly interested in exploring alternative evaluation metrics, ensuring factual accuracy and pushing forward auto-summarisation as a key pillar of our offering: if that sounds interesting to you, <a href="/service/mailto:cto@curationcorp.com"><strong><em>we’re hiring</em></strong></a><em>.</em></p><p>If you’re interested in commercial use or access to the wider catalogue of Curation data, including a larger set of over 150,000 professionally-written abstracts and a scalable, on-demand content abstraction API (driven by humans or AI), please <a href="/service/mailto:cto@curationcorp.com"><strong><em>get in touch</em></strong></a><strong><em>.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7a2ad676a13" width="1" height="1" alt=""><hr><p><a href="https://medium.com/curation-corporation/fine-tuning-bart-for-abstractive-text-summarisation-with-fastai2-d7a2ad676a13">Fine-tuning BART for Abstractive Text Summarisation with fastai2</a> was originally published in <a href="https://medium.com/curation-corporation">Curation Corporation</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fine-tuning Bert for Abstractive Summarisation with the Curation Dataset]]></title>
            <link>https://medium.com/curation-corporation/fine-tuning-bert-for-abstractive-summarisation-with-the-curation-dataset-79ea4b40a923?source=rss-ed747f9bdc88------2</link>
            <guid isPermaLink="false">https://medium.com/p/79ea4b40a923</guid>
            <dc:creator><![CDATA[Henry Dashwood]]></dc:creator>
            <pubDate>Tue, 24 Mar 2020 19:55:39 GMT</pubDate>
            <atom:updated>2020-04-16T11:09:12.256Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kq62gQvtjLbzNlmKP4yBiA.png" /></figure><p>In this blog we will show how to to fine-tune the BertSum model presented by Yang Liu and Mirella Lapata in their paper <a href="https://arxiv.org/pdf/1908.08345.pdf">Text Summarization with Pretrained Encoders</a>. We will be making use of the <a href="https://github.com/huggingface/transformers/tree/master/examples/summarization">partial reimplementation of their code in the HuggingFace transformers repository</a>. This blog is the tl;dr. For an in depth explanation of all these gists, I have written a line by line guide in <a href="https://github.com/CurationCorp/curation-corpus/blob/master/examples/bertextabs/finetune_bertabs_walkthrough.ipynb">this notebook</a>.</p><h4>1: Import dependencies and define arguments</h4><p>These will be useful later on.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c3d966181342dd94dc4c7c9659d458c/href">https://medium.com/media/5c3d966181342dd94dc4c7c9659d458c/href</a></iframe><h4>2. Construct the dataset</h4><p>You’ll notice we support a couple of formats. Feather formatted data should be faster to load but the CSV format is more common.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6f7f85b982c1549122824656d50395d2/href">https://medium.com/media/6f7f85b982c1549122824656d50395d2/href</a></iframe><h4>3. Encode data for the model</h4><p>We need to encode the data in a way that BertSum. The function that does this is known as a collation function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/36f10a71225d5aecffbe8bc460034991/href">https://medium.com/media/36f10a71225d5aecffbe8bc460034991/href</a></iframe><h4>4. Create a loss function (and optional metrics)</h4><p>Developing the best loss function for a task like abstractive summarisation can be a major undertaking. We will adapt the <a href="https://youtu.be/vnOpEwmtFJ8?t=1112">label smoothing cross entropy loss </a>described by Jeremy Howard. <a href="https://youtu.be/IfsjMg4fLWQ?t=1633"><em>seq2seq</em> accuracy</a> is a metric Rachel Thomas uses in the <a href="https://www.fast.ai/2019/07/08/fastai-nlp/">Fastai NLP</a> course.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/84dd9c0d6ea96230fb6eeaf23858c4ac/href">https://medium.com/media/84dd9c0d6ea96230fb6eeaf23858c4ac/href</a></iframe><h4>5. Load everything in</h4><p>Now we will load in the pre-trained model and its weights, define the BOS and EOS symbols in our vocabulary, and load the dataset.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b8e07b02e23d7221fa1429723e763bb/href">https://medium.com/media/5b8e07b02e23d7221fa1429723e763bb/href</a></iframe><h4>6. Train</h4><p>We combine the data and model together to create a <a href="https://docs.fast.ai/basic_train.html#Learner">Fastai Learner object</a>. We train the decoder with one cycle scheduling. Then we unfreeze all the layers and train the whole model. We save the raw Pytorch weights from the epoch with the best validation loss at the end.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b2b04319b9a64f643675d8d561632399/href">https://medium.com/media/b2b04319b9a64f643675d8d561632399/href</a></iframe><h4>7. Generate summaries</h4><p>For generating summaries, we make use of an NMT model. The function below loads in data, sends it though that model and formats the summary at the end. The code underneath is an example of how to generate summaries from your own articles. Save them as .txt files in <em>stories_folder before </em>running the inference code. If you want to evaluate model performance on the test set, pass <em>test_ds</em> to the function instead.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bca5367f3ad393d86197840de2d4b63b/href">https://medium.com/media/bca5367f3ad393d86197840de2d4b63b/href</a></iframe><h4>8. Get excited about the future</h4><p>We are really excited to see how people use this resource. We will be updating you on the progress of our abstractive summarisation over the coming year, and making more datasets available to the community. We hope others will build on our work as we have built on that of others.</p><p>We’re particularly interested in exploring alternative evaluation metrics, ensuring factual accuracy and pushing forward auto-summarisation as a key pillar of our offering: if that sounds interesting to you, <a href="/service/mailto:cto@curationcorp.com"><strong><em>we’re hiring</em></strong></a><em>.</em></p><p>If you’re interested in commercial use or access to the wider catalogue of Curation data, including a larger set of over 150,000 professionally-written abstracts and a scalable, on-demand content abstraction API (driven by humans or AI), please <a href="/service/mailto:cto@curationcorp.com"><strong><em>get in touch</em></strong></a><strong><em>.</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79ea4b40a923" width="1" height="1" alt=""><hr><p><a href="https://medium.com/curation-corporation/fine-tuning-bert-for-abstractive-summarisation-with-the-curation-dataset-79ea4b40a923">Fine-tuning Bert for Abstractive Summarisation with the Curation Dataset</a> was originally published in <a href="https://medium.com/curation-corporation">Curation Corporation</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Teaching an AI to abstract: A new dataset for abstractive auto-summarisation]]></title>
            <link>https://medium.com/curation-corporation/teaching-an-ai-to-abstract-a-new-dataset-for-abstractive-auto-summarisation-5227f546caa8?source=rss-ed747f9bdc88------2</link>
            <guid isPermaLink="false">https://medium.com/p/5227f546caa8</guid>
            <category><![CDATA[summarization]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Henry Dashwood]]></dc:creator>
            <pubDate>Mon, 23 Mar 2020 14:59:24 GMT</pubDate>
            <atom:updated>2020-04-01T15:30:04.757Z</atom:updated>
            <content:encoded><![CDATA[<h3>Teaching an AI to summarise news articles: A new dataset for abstractive summarisation</h3><h4>We are open-sourcing <strong>40,000 professionally-written summaries of news articles. </strong>Instructions for how to access the dataset can be found in our <a href="https://github.com/CurationCorp/curation-corpus">Github repository</a>, along with <a href="https://github.com/CurationCorp/curation-corpus/tree/master/examples">examples</a> of us using the dataset for fine-tuning.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0mP_MXDg_RUfwXBgTM_1pA.png" /></figure><h4><strong>Background</strong></h4><blockquote>Automatic text summarisation is one of those research topics that has been around since the early days of computational linguistics and is still receiving a lot of interest from the research community, as it is far from being considered a solved problem. <br>― <strong><em>Constantin Orasan </em></strong>Automatic summarisation: 25 years On <em>(</em><a href="https://doi.org/10.1017/S1351324919000524"><em>doi:10.1017/S1351324919000524</em></a><em>)</em></blockquote><p>Getting a computer to summarise a long document is a problem that dates back to the earliest days of Natural Language Processing (NLP), with statistical attempts in the late 1950s, the empiricist approaches of the 70s, machine learning techniques in the 90s, finally leading to the increasingly popular deep learning methods being used at the moment.</p><p>Broadly speaking, there are two computational approaches to the problem: <strong>extractive </strong>and <strong>abstractive</strong>. The former takes a document[s] and, using an algorithm, <em>extracts</em> what it deems the most relevant sections to produce a summary, without modifying the wording of the original.</p><p>In contrast, abstractive summarisation, takes the input document and tries to write a coherent, plausible and factually correct summary.</p><p>Abstractive summarisation is one of the hardest problems in natural language processing. An ideal summariser would not only be able to generate coherent text, it would also understand which information can be lifted directly from the source text, and which parts can be paraphrased. State-of-the-art (SOTA) models therefore don’t rely exclusively on translating between the input document and summary, but incorporate copy mechanisms and extractive summarisation tasks in training.</p><h4>Corpora</h4><p>There are practical difficulties with building abstractive summarisation models as well. One is the sheer volume of information that has to be processed. Many NLP tasks work on the sentence or paragraph level. But for summarisation, an entire document is<em> de rigueur.</em> Such large input sizes force us to limit our batch sizes and can make training tedious and expensive.</p><p>There are relatively few datasets for abstractive summarisation, let alone good ones, and fewer still are publicly available. When training models for translation between languages we can draw on sources like books or the proceedings of the European parliament. For summarisation though, there has not been much impetus for people to make significant numbers of high quality abstractive summaries available for public consumption, particularly given the expense that goes into producing them.</p><p>Historically, datasets have been generated using clever hacks. For instance, we might use the sections of a Wikipedia article below the table of contents as our input, and the section above as our target output. Even the most popular dataset for abstractive summarisation, the <a href="https://github.com/abisee/cnn-dailymail"><em>CNN/Daily Mail </em>dataset</a>, is only able to use the subtitles of its articles for a target output. Further still, the text found in these implied summaries may often be noisy due to scraping inaccuracies, around 0.5% of the CNN/Daily Mail dataset has been found to have such errors, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*vlKFI6RBp0e84xEIENwCpw.png" /><figcaption>(<a href="https://www.aclweb.org/anthology/D19-1051.pdf">Kryscinski et al. 2019</a>)</figcaption></figure><h4><strong>Curation Dataset</strong></h4><p>For the last five years at Curation, we have been working to provide companies with the information that they most need to see. We keep abreast of the latest news developments across a range of industries and as part of this service we have a team of professional abstractors writing summaries of news articles.</p><p>We are<strong> open sourcing 40,000 human-written abstracts of news articles</strong> and links to the sources under a Creative Commons license for NLP researchers and data scientists to explore and build on.</p><p>We believe (and our clients seem to agree) these summaries are of an excellent quality, and we’re excited to see how the NLP community can utilise them. Although we cannot include the original article body, we are also releasing a script alongside the that can download and parse the sources for personal use.</p><p>What do we mean by excellent quality? As the <a href="https://github.com/abisee/cnn-dailymail"><em>CNN/Daily Mail</em> corpus</a>’ targets are the subtitles of various news articles, they often assume that the reader has already seen the piece’s headline. This means that taken in isolation the subtitles can feel like they are missing their first sentence. In our experiments we have found that <a href="https://github.com/nlpyang/BertSum">state-of-the-art approaches</a> replicate this in their predictions.</p><p>In contrast, Curation’s abstracts are specifically written by <strong>professional copywriters </strong>to stand alone <em>a priori </em>as an intelligible piece of content in their own right. Our writing team conform to a comprehensive internal <strong>style-guide</strong> and each piece is proofed twice by our editorial and content curation teams to ensure <strong>factual</strong> and <strong>stylistic accuracy</strong>. Our abstracts are on average 40 words longer than other publicly available datasets and are designed to maximise information density whilst still being a joy to read.</p><p>Want to try it out and see for yourself? <a href="https://github.com/CurationCorp/curation-corpus"><strong><em>Click here</em></strong></a> to download the <strong>Curation Abstracts Dataset.</strong></p><figure><img alt="Comparison of summarisation datasets" src="https://cdn-images-1.medium.com/max/1024/1*b7jGsUoFJelyBKY-DX9spA.png" /><figcaption>Comparison of summarisation datasets (based on <a href="https://arxiv.org/pdf/1908.08345.pdf">Yang et al. 2019</a>)</figcaption></figure><h4>Example of summaries in the dataset</h4><pre>Animals must be stunned prior to being killed in order for halal and kosher meat to be marketed with the official European Union (EU) organic label, the European Court of Justice has ruled. The judges argued that organic labelling reflects the highest animal welfare standards, and that stunning is integral to these as it significantly reduces suffering. The UK’s Food Standards Agency estimates that 88% of animals killed under halal methods are stunned. However, a minority of halal – and all kosher – meat is produced without stunning. The case was brought by a French animal welfare association in 2012.<br><strong>*******<br></strong>Researchers in Canada have developed an innovative solar cell which uses bacteria to convert light into energy. The team at the University of British Columbia developed a way of genetically engineering E.coli to produce large amounts of lycopene, a natural dye which bacteria use for photosynthesis. By coating the bacteria with a semiconducting substance and incorporating it into a battery cell, they were able to achieve a current density of 0.686 milliamps per square centimetre, which they say is the highest yet achieved by a biogenic solar cell.<br><strong>*******<br></strong>Southeast Asia is unprepared for the rapidly-rising threat of extremist attacks, warns think tank The Institute for Policy Analysis of Conflict (IPAC). It suggests the main danger is in the southern Philippines, where a few Islamic extremist groups have sworn allegiance to ISIS; the groups have links to other parts of the region, particularly Malaysia and Indonesia. ISIS has also endorsed a Philippines-based militant leader for Southeast Asia and widened its &quot;extremist recruitment pool&quot; in the region, opening up channels for international funding and communication. IPAC says as ISIS loses territory in Syria and Iraq, it raises the risk of revenge attacks in Southeast Asia.</pre><h4>Examples of fine-tuning</h4><p>Alongside the dataset, we are releasing some blogs in the forms of Medium posts and Jupyter notebooks for you to build your own abstractive summariser. They can be found in the <a href="https://github.com/CurationCorp/curation-corpus/tree/master/examples">examples section of the dataset’s repository on Github</a>. We will add to and improve them over time. We would also love to receive feedback on what’s there!</p><h4>Limitations of Evaluation Metrics</h4><p>It is worth briefly mentioning the limitations of current methods of evaluating models for abstractive text summarisation. Since using humans to evaluate summaries is expensive, attempts have been made to create automatic metrics that require no human input, but nevertheless provide some valuable insight into the quality of a machine summary. Some of the most popular measures are provided by the ROUGE package (<a href="https://www.aclweb.org/anthology/W04-1013.pdf">Lin 2004</a>).</p><p>Given that ROUGE scores (in addition to other metrics such as BLEU) are based on n-gram overlap between ‘gold’ reference summaries and machine generated ones, such scores are limited in their ability to measure semantic overlap if extensive paraphrasing has been used. An abstractive summary that captures the salient points of a document could therefore achieve a very low ROUGE score if the phrasing in the reference summary is substantially different. In addition to this, ROUGE scores have been shown to correlate weakly with human judgement for both abstractive and extractive summarisation tasks (<a href="https://www.aclweb.org/anthology/D19-1051.pdf">Kryscinski et al. 2019</a>). For these reasons it is worth taking such measures with a pinch of salt.</p><p>For example, calculating ROUGE on our human summaries (which we hold to be the gold standard), we get a <a href="https://en.wikipedia.org/wiki/ROUGE_(metric)">ROUGE-L</a> score of just 32.86, compared to 40 for the <a href="https://github.com/sebastianruder/NLP-progress/blob/master/english/summarization.md">current state-of-the-art</a> abstractive summariser.</p><p>Anecdotally, we believe some SOTA models are over-optimised for ROUGE scores; when evaluating abstractive models, we have found they tend to be perversely incentivised to perform extractively. We are actively investigating other evaluation metrics, such as (<a href="http://www.cs.umd.edu/~snover/pub/amta06/ter_amta.pdf">TER/hTER</a>) which consider the human edits necessary to reach a coherent, factually correct abstract.</p><h4><strong>The Future</strong></h4><p>We are really excited to see how people use this resource. We will be updating you on the progress of our abstractive summariser over the coming year, and making more datasets available to the community. We hope others will build on our work as we have built on that of others.</p><p>We’re particularly interested in exploring alternative evaluation metrics, ensuring factual accuracy and pushing forward auto-summarisation as a key pillar of our offering: if that sounds interesting to you, <a href="/service/mailto:cto@curationcorp.com"><strong><em>we’re hiring</em></strong></a><em>.</em></p><p>If you’re interested in commercial use or access to the wider catalogue of Curation data, including a larger set of over 150,000 professionally-written abstracts and a scalable, on-demand content abstraction API (driven by humans or AI), please <a href="/service/mailto:cto@curationcorp.com"><strong><em>get in touch</em></strong></a><strong><em>.</em></strong></p><p><em>Henry Dashwood — Machine Learning Engineer, Curation<br>Tom Jennings — CTO, Curation</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*al7h-YtmWgNUT_GxV5UgcA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5227f546caa8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/curation-corporation/teaching-an-ai-to-abstract-a-new-dataset-for-abstractive-auto-summarisation-5227f546caa8">Teaching an AI to abstract: A new dataset for abstractive auto-summarisation</a> was originally published in <a href="https://medium.com/curation-corporation">Curation Corporation</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Dog Detector and Breed Classifier]]></title>
            <link>https://medium.com/data-science/a-dog-detector-and-breed-classifier-4feb99e1f852?source=rss-ed747f9bdc88------2</link>
            <guid isPermaLink="false">https://medium.com/p/4feb99e1f852</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[image-recognition]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Henry Dashwood]]></dc:creator>
            <pubDate>Wed, 30 Jan 2019 04:07:13 GMT</pubDate>
            <atom:updated>2019-01-31T15:29:03.012Z</atom:updated>
            <content:encoded><![CDATA[<p>In a field like physics, things keep getting harder, to the point that it’s very difficult to understand what’s going on at the cutting edge unless it’s in highly simplified terms. In computer science though, and artificial intelligence in particular, knowledge built up slowly over 70+ years by people all over the world is still very intuitive. In fact, thanks to high level programming languages, frameworks, and a community that values sharing knowledge in easily accessible formats, it’s getting easier to enter the field!</p><p>In this blog post we will do something that was impossible a decade ago but which students like myself can now pull off in a few lines of Python; build a system that can identify whether a person or dog is in a photo and tell us what breed it is (or most resembles!).</p><p>You can find the code at my <a href="https://github.com/HenryDashwood/dog_breed_classifier">Github</a>.</p><h3>Detecting People and Dogs</h3><p>There are several ways to solve image classification problems. In this blog post we will be using convolutional neural networks for determining the dog breed. Before that though we will using the <a href="https://www.cs.cmu.edu/~efros/courses/LBMV07/Papers/viola-cvpr-01.pdf">Viola-Jones haar cascade classifier method</a> to detect if the photo contains a human face.</p><p>CNNs get the most attention nowadays but you will have definitely seen the Viola-Jones method before. It’s what draws boxes around faces whenever you open your camera. <a href="https://www.youtube.com/watch?v=uEJ71VlUmMQ">A great video explainer by the University of Nottingham’s Mike Pound can be watched here</a>. Briefly, we work out which filters are best at discriminating between faces and non faces. The best filter is applied to each region of the image. If a region passes it gets tested on the next filter. This is repeated for about 6000 other filters and if a region passes them all we conclude that it contains a face.</p><p>There is lots of other stuff in the paper. For instance, the authors developed a simple yet clever way to efficiently calculate the pixel value of a region in the image. All we need to do though is download these pretrained filters from a library called <a href="https://opencv.org/">OpenCV</a> and run our photo through them.</p><pre>import cv2</pre><pre>def face_detector(img_path):<br>    img = cv2.imread(img_path)<br>    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)<br>    faces = face_cascade.detectMultiScale(gray)<br>    return len(faces) &gt; 0</pre><p>And just like that it counts up how many human faces are in the image!</p><p>Unfortunately, the good people at OpenCV have not built us some nice haar filters for dogs. Instead we will use <a href="http://www.image-net.org/">ImageNet</a>, a dataset of 14 million images labelled into 20,000 categories. It’s been one of the leading computer vision benchmarks over the last decade. We will be using a smaller version of ImageNet with 1000 categories of which categories 151–268 are dog breeds.</p><p>We can use a pretrained CNN called Resnet which we will download from Keras’s website (more on Keras in a bit).</p><pre>from keras.applications.resnet50 import ResNet50</pre><pre>ResNet50_model_ = ResNet50(weights=&#39;imagenet&#39;)</pre><p>We need to do a little bit of preprocessing so that the model can make a prediction about our images:</p><pre>from keras.preprocessing import image             <br>from tqdm import tqdm</pre><pre>def path_to_tensor(img_path):<br>    img = image.load_img(img_path, target_size=(224, 224))<br>    x = image.img_to_array(img)<br>    return np.expand_dims(x, axis=0)</pre><pre>def paths_to_tensor(img_paths):<br>    list_of_tensors = [path_to_tensor(img_path) for img_path in tqdm(img_paths)]<br>    return np.vstack(list_of_tensors)</pre><p>And now we can see if the prediction made by the model matches one of the dog breed categories:</p><pre>from keras.applications.resnet50 import preprocess_input, decode_predictions</pre><pre>def ResNet50_predict_labels(img_path):<br>    img = preprocess_input(path_to_tensor(img_path))<br>    return np.argmax(ResNet50_model_.predict(img))</pre><pre>def dog_detector(img_path):<br>    prediction = ResNet50_predict_labels(img_path)<br>    return ((prediction &lt;= 268) &amp; (prediction &gt;= 151))</pre><p>At the end of all that, when I tested the detectors on 100 sample images, the face and dog detectors didn’t have any false negatives. The dog detector didn’t have any false positives either!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/1*cLTjcSXqx2GFFWebr3stbw.png" /><figcaption>Our human face detector results</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/327/1*4SOLnFwPfy-x0kJ50RcnqA.png" /><figcaption>Our dog detector results</figcaption></figure><h4>Determining the Dog Breed</h4><p>So we can say that there is some sort of dog, or person, in the picture. But I could have done that. Could I tell the difference between 117 different breeds though, probably not. Let’s see if we can tell the difference with machine learning.</p><p>It’s time to crack out the Keras library. Frameworks like Tensorflow, Pytorch, Theano, or CNTK perform machine learning operations for us. Keras is a library that sits on top of some of these and so we can write our code in a more concise and readable way.</p><p>Here is how we define our CNN in Keras:</p><pre>model = Sequential()</pre><pre>model.add(Conv2D(32, (3, 3), input_shape = (224, 224, 3), use_bias=False))<br>model.add(BatchNormalization())<br>model.add(Activation(&#39;relu&#39;))<br>model.add(MaxPooling2D(pool_size = (2,2)))<br>model.add(Dropout(0.2))</pre><pre>model.add(Conv2D(64, (2,2), use_bias=False))<br>model.add(BatchNormalization())<br>model.add(Activation(&#39;relu&#39;))<br>model.add(MaxPooling2D(pool_size = (2,2)))<br>model.add(Dropout(0.2))</pre><pre>model.add(Conv2D(128, (2,2), use_bias=False))<br>model.add(BatchNormalization())<br>model.add(Activation(&#39;relu&#39;))<br>model.add(MaxPooling2D(pool_size=(2,2)))<br>model.add(Dropout(0.2))</pre><pre>model.add(Flatten())</pre><pre>model.add(Dense(512, use_bias=False))<br>model.add(BatchNormalization())<br>model.add(Activation(&#39;relu&#39;))<br>model.add(Dropout(0.2))</pre><pre>model.add(Dense(256, use_bias=False))<br>model.add(BatchNormalization())<br>model.add(Activation(&#39;relu&#39;))<br>model.add(Dropout(0.2))</pre><pre>model.add(Dense(len(dog_names), activation=&#39;softmax&#39;))</pre><pre>model.summary()</pre><p>What’s going on here? We have 3 convolutional layers followed by 3 fully connected layers. This final layer has a softmax activation function which means our output will be the a probability distribution with 1000 values, one for each possible result in the ImageNet-1000 database we are using.</p><p>We will define our optimizer and loss function next. There are a lot of terms in these lines so I’ll try to unpack them.</p><ul><li><em>SGD</em> or stochastic gradient descent is is best likened to rolling down a mountain. If you find a way down, keep going. If not, try a different direction. Remember in multidimensional maths land there are many more than just 3 dimensions to choose from. You’ll know when you reach a local minimum in a certain direction because the gradient of the curve you are on will get smaller. This all handled for us under the hood.</li><li><em>lr</em> is our learning rate. How much should we change the model given a new piece of information? Small rates mean slow training but big rates mean we might jump over the best solution to the other side of the valley. The best solution is to use…</li><li><em>decay</em> means we start off with a big learning rate and decrease with each epoch as we near the bottom of the mountain/valley.</li><li><em>clipnorm</em> is used to clip gradients so that they don’t become absurdly large or shallow which would make it hard to do gradient descent. <em>clipnorm</em> clips the value if this happens but also scales the gradients so we aren’t clipping some and not others</li><li><em>nesterov</em> momentum is when we calculate the gradient having looked ahead a step. It helps us train a bit faster.</li><li><em>categorical_crossentropy</em> is the loss function. It means we are judging the performance of the model, and the extent to which we need to adjust it, on how much new information we receive after we check our results. If I am sure I’ve seen a golden retriever and I’m right, not much new information has been created. If I was unsure then some has been created. And if I was sure it wasn’t a golden retriever but it was, lots of information has been created.</li><li><em>accuracy</em> is the metric we will monitor. It does what it says on the tin. It <em>calculates the mean accuracy rate across all predictions for multiclass classification problems</em>. In other words what fraction of dogs were correctly classified.</li></ul><pre>sgd = SGD(lr=0.01, clipnorm=1, decay=1e-6, <br>          momentum = 0.9, nesterov=True)</pre><pre>model.compile(optimizer=sgd, loss=&#39;categorical_crossentropy&#39;,   <br>              metrics=[&#39;accuracy&#39;])</pre><p>And then we are good to train!</p><pre>checkpointer = ModelCheckpoint(     <br>             filepath=&#39;saved_models/weights.best.from_scratch.hdf5&#39;, <br>             verbose=1, save_best_only=True)</pre><pre>model.fit(train_tensors, train_targets, <br>          validation_data=(valid_tensors, valid_targets), epochs=5,   <br>          batch_size=20, callbacks=[checkpointer], verbose=1)</pre><p>If we run it for 6 epochs this is what happens:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*fDk1NrMmUH_8D2hhs90lMQ.png" /><figcaption>The training and validation losses as our model trained</figcaption></figure><p>The training loss improves as we train but the validation loss looks like it is about to flatten out. This means our model would start to overfit if we trained it for much longer.</p><p>On the test set the model correctly predicted the breeds of 3.7% of the dogs it saw. This is about 4 times better than random guessing but leaves quite a bit of room for improvement.</p><h4>Transfer Learning</h4><p>Enter transfer learning. We can take a pretrained model, like we did with our detector and add our own layers to the end of it to make predictions for us. The model we will use is Resnet50 and has been trained by researchers at Microsoft on bigger machines and for more time than I have access to.</p><p>We can download the weights, store them locally and then unpack the features like so:</p><pre>bottleneck_features = np.load(<br>                           &#39;bottleneck_features/DogResnet50Data.npz&#39;<br>                           )<br>train_Resnet50 = bottleneck_features[&#39;train&#39;]<br>valid_Resnet50 = bottleneck_features[&#39;valid&#39;]<br>test_Resnet50 = bottleneck_features[&#39;test&#39;]</pre><p>It’s very easy with Keras to take Resnet50 and add our own layers to the end of it. Once again, we want our output to be a distribution each breed’s probability</p><pre>Resnet50_model = Sequential()<br>Resnet50_model.add(<br>        GlobalAveragePooling2D(input_shape=train_Resnet50.shape[1:])<br>        )<br>Resnet50_model.add(Dense(133, activation=&#39;softmax&#39;))</pre><p>After that it’s just the same as before</p><pre>Resnet50_model.compile(<br>                       loss=&#39;categorical_crossentropy&#39;, <br>                       optimizer=sgd, <br>                       metrics=[&#39;accuracy&#39;]<br>                      )</pre><pre>checkpointer = ModelCheckpoint(<br>                 filepath=&#39;saved_models/weights.best.Resnet50.hdf5&#39;, <br>                 verbose=1, <br>                 save_best_only=True<br>                 )</pre><pre>resnet50_hist = Resnet50_model.fit(<br>                    train_Resnet50, <br>                    train_targets, <br>                    validation_data=(valid_Resnet50, valid_targets),<br>                    epochs=20, <br>                    batch_size=56, <br>                    callbacks=[checkpointer],    <br>                    verbose=1<br>                    )</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*KPiUmQEPHntKbt0AtWN5kQ.png" /></figure><p>How good is this model? Well, on the test set it correctly predicts 84% of the breeds! That’s way more than even my dog mad family and I would get.</p><h4>Trying it out</h4><p>Combining our human and dog detectors with the breed predictor, let’s try this out on some photos.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*I5Xgfs50BTX8-wbBH-Z_HA.png" /><figcaption>Correct! Not even the Barbour jacket confuses it</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*-vEZoRhUNgvRnDGeC19SbQ.png" /><figcaption>Correct! Ironically, my it’s my dog who is overfitting in this photo (those ducks are plastic!)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*ce-zHHHp-Pb7N4e1w2eCrQ.png" /><figcaption>Wrong, this is actually a Border Collie.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*jkzB7lcGEZtbMw1VvUI4kg.jpeg" /><figcaption>But he does look like an Australian Shepherd</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*ghmD3J8rPPYN5bOFcMUK8g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/183/1*av-dZmmD93TyvUAA7NQ4jg.jpeg" /><figcaption>Silky Terrier, who knew?</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*1Qjhi-MMZrl1vnleiM3RZQ.png" /><figcaption>It’s got a bit confused by Pongo…</figcaption></figure><p>However if we peer into the model’s predictions we can see that Dalmation came second so not too bad.</p><pre>bottleneck_feature = extract_Resnet50(path_to_tensor(&#39;images/pongo.png&#39;))<br>predicted_vector = Resnet50_model.predict(bottleneck_feature)</pre><pre>top_predictions = np.argpartition(predicted_vector.flatten(), -4)[-4:]<br>for i in top_predictions:<br>    print(dog_names[i])</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*Wtp9uRWJ6tGm_zsb_ojhLA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*phJ2ciHr7aZKG1f57gbLsQ.png" /><figcaption>Well you can’t win them all!</figcaption></figure><h4>Potential Improvements</h4><p>There is lots more we could do here. The best models in the world get better test accuracies than me on versions of ImageNet with many more possible categories. We could get some of that improvement by renting multiple GPUs, acquiring more labelled images etc but that basically boils down to spending money and isn’t conceptually very interesting.</p><p>One way we could improve this model would be to use data augmentation. For instance, by flipping, shifting, rotating, darkening, lightening, adding noise and many more possible operations we can artificially increase the number of images the to which the model could be exposed by several times. I experimented with data augmentation during this project with disappointing results. It is possible that with some parameter tuning and longer training I would have seen some improvement.</p><p>We could alter the CNN itself. It is possible that more layers with more features, different loss functions, learning rates and all sorts of other changes would have made it perform better. A big part of deep learning is making changes to a model and only learning afterwards if it actually improved things. If I had more GPU time, I might have tried using grid search to systematically experiment with different hyperparameters overnight.</p><h4>Conclusion</h4><p>In this post we have:</p><ul><li>Loaded and preprocessed images from ImageNet.</li><li>Loaded up some pretrained haar cascade classifiers in order to detect human faces using the Viola Jones method.</li><li>Loaded a pretrained CNN to in order to detect dogs.</li><li>Wrote and trained a CNN from scratch to classify dog breeds. This was successful 3.7% of the time on the test set which sounds low but was 4 times better than chance.</li><li>Used transfer learning to radically improve the performance of the CNN so that it was accurate on the test set 84% of the time.</li><li>Tested the model on a few of my own photos.</li><li>Discussed ways to improve the model going forward.</li></ul><p>Maybe you learnt something in this post. I learnt a lot writing it. If you spot a mistake or think something could be better worded, let me know and I’ll update it!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*FmEDv3if0FnNjiUnnq7A9Q.jpeg" /><figcaption>Happy Coding!</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4feb99e1f852" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/a-dog-detector-and-breed-classifier-4feb99e1f852">A Dog Detector and Breed Classifier</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[A Look at Edinburgh Airbnb Data]]></title>
            <link>https://medium.com/@henrydashwood/a-look-at-edinburgh-airbnb-data-a10f30fd093e?source=rss-ed747f9bdc88------2</link>
            <guid isPermaLink="false">https://medium.com/p/a10f30fd093e</guid>
            <category><![CDATA[udacity]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[airbnb]]></category>
            <category><![CDATA[edinburgh]]></category>
            <category><![CDATA[pandas]]></category>
            <dc:creator><![CDATA[Henry Dashwood]]></dc:creator>
            <pubDate>Thu, 18 Oct 2018 22:01:51 GMT</pubDate>
            <atom:updated>2018-10-18T22:01:51.423Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U8bKg8SUbJ3mSJnEuxkbCw.jpeg" /><figcaption>The view from Blackford Hill</figcaption></figure><p>Edinburgh is great. It’s my favorite city in the world. When I visit I sometimes stay in places I find on AirBnb. I thought it would be fun to take a look at Airbnb data in Edinburgh since a few places on the internet offer it for free in nicely packeged csv files.</p><p>The place I went to find this data was <a href="http://insideairbnb.com/">insideairbnb.com</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c503by1AuDNr_fIwqNKgYg.png" /><figcaption>You can download all the data you need with just a single click</figcaption></figure><p><strong>Airbnb stars are not the same as hotel stars</strong></p><p>Have you ever wondered whether places that get good reviews cost more? Have you also noticed that listings on Airbnb all seem to have close to 5 stars? It seems like reviews on Airbnb serve more as a way to spot the rare dodgy listing, and thus incentivise hosts to offer a great experience.</p><p>In other words, if reviews are normally distributed, you won’t mind much if someone gives you 3 instead of 4 stars. If the most common rating is 5 stars though, then anything less than that will stand out and raise eyebrows.</p><p>In the world of official star ratings for hotels, you can make a decent price prediction based on how many stars a hotel has got. In my model though, I found no relationship at all between the average rating a listing has and how much it costs.</p><p><strong>How does price vary by neighbourhood?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*YZrwZpaQVt-nT8hS4WTx3Q.jpeg" /><figcaption>New Town, correctly rated (Edinburgh World Heritage)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kZRdM75_ajon4bVy" /><figcaption>Leith, underrated (Creator:Graeme Ross)</figcaption></figure><p>It won’t come as a surprise to see that Southside, which is close to Edinburgh University, the Royal Mile, Arthur’s Seat, Holyrood Palace and the Scottish Parliament is the the most expensive area. The New and Old Towns are both world heritage sights so their high price make sense as well.</p><p>Leith is right in the north of the city. It’s an old fishing village and port which has gradually been swallowed up. The Royal Yacht Brittania is docked up there. It’s location, about as far away from the airport and train stations as you can be, probably explains why its the cheapest place to stay. The area is beautiful, and very underrated. Hopefully they’ll extend the tram there before long!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*OKuIlnvW8CyPy5gHr9dM8Q.png" /></figure><p><strong>How correlated are changes in supply with changes in price?</strong></p><p>Let’s have a look now at how the number of listings and their prices changed between 2014 and 2017.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*gckGE-ecF7Z4bg_8ALnFgw.png" /></figure><p>Supply has been going up everywhere, and generally prices seem to have been falling. There are a few puzzles though. The supply in South Morningside went up the least and was, as we might expect, where prices went <em>up</em> the most. Meanwhile though Granton, which added the second smallest amount of supply, saw prices go <em>down </em>the most.</p><p>It turns out that there is almost no correlation between the change in supply and the change in price in one neighbourhood relative to the others.</p><p>If you would like to see my code, it can be found <a href="https://github.com/HenryDashwood/Edinburgh_Airbnb_Investigation"><strong><em>here</em></strong></a> along with the datasets I used. This has been a learning experience for me, so any and all feedback is much appreciated. And visit Edinburgh! It’s great!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a10f30fd093e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>