<?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 Daniel Solá on Medium]]></title>
        <description><![CDATA[Stories by Daniel Solá on Medium]]></description>
        <link>https://medium.com/@daniel.sola.fraire?source=rss-658807ec0b62------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*WeVrLgT9LdWYAIMywT54Rw.jpeg</url>
            <title>Stories by Daniel Solá on Medium</title>
            <link>https://medium.com/@daniel.sola.fraire?source=rss-658807ec0b62------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 13:09:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@daniel.sola.fraire/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[Predicting patient mortality with Deep Learning. I know when you’ll die.]]></title>
            <link>https://medium.com/@daniel.sola.fraire/predicting-patient-mortality-with-deep-learning-f9814bf192da?source=rss-658807ec0b62------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9814bf192da</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[healthcare]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[health-technology]]></category>
            <dc:creator><![CDATA[Daniel Solá]]></dc:creator>
            <pubDate>Tue, 17 Sep 2019 18:55:08 GMT</pubDate>
            <atom:updated>2019-09-17T19:01:29.119Z</atom:updated>
            <content:encoded><![CDATA[<p>Far from its popular association with rebellious, gun handling robots, <strong>artificial intelligence</strong> has opened our world to <strong>new possibilities</strong> unimaginable less than a decade ago. Innovations in this field leak to every application conceivable. That <strong>voice assistant</strong> that cracks a joke of dubious quality when asked for it. That <strong>spam filter</strong> in your email that keeps you from helping that Nigerian prince to move his fortune out of his country. That <strong>camera application</strong> that does its best to make you look acceptable. Everyday examples of <strong>commercial AI applications</strong> are ubiquitous in several sectors and are here to make our lives easier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*O_uMZQZ80uUTfz24.jpg" /><figcaption>It’s OK to feel sorry for her</figcaption></figure><p>The <strong>medical field</strong> is also eager to benefit from this revolution. Image analysis for <strong>automated diagnosing</strong>, AI-powered devices to <strong>assist surgeries</strong> or the ability to <strong>predict patient outcomes</strong> are some examples of what AI could bring to the table in the upcoming years.</p><p><strong>Outcome prediction</strong>, especially <strong>patient mortality</strong> during hospital stay and after, has seen great progress thanks to <strong>neural networks</strong>.</p><blockquote>To earn my bachelor’s degree in Biomedical Engineering, I used neural networks to <strong>predict patient mortality after discharge from intensive care units</strong> with great results. 43 features related to patient care were used. Here’s how I did it.</blockquote><h4>The boring part: Investigating and reading</h4><p>What has been achieved so far? How has it been done? How accurate are current models? Which methods have been used?</p><p>Current studies are able to predict different outcomes with acceptable AUROC scores. <strong>30 day mortality</strong> after cancer treatment start has been modeled with an <strong>AUROC of 0.94</strong> using Gradient Boosted Decision Trees, a machine learning algorithm. Other studies have focused on the use of normalizing neural networks to predict <strong>hospital mortality and 30 day mortality</strong>, with AUROC scores ranging <strong>between 0.84 and 0.86.</strong> Several other studies in the field achieve similar scores for similar outcomes. Most of the work done in this field uses similar features: vital signs, lab results, patient info, severity scores, administrative data, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*reAm2U1G6RoU4dxXccmERw.jpeg" /><figcaption>Better start looking for another job</figcaption></figure><p>To put it simply, <strong>AUROC </strong>(Area under the Receiver Operating Characteristic) is the most used summary statistic to assess the <strong>goodness of a predictor</strong>, where 0.5 indicates no predictive power, like flipping a coin, and a value of 1 indicates perfect predicting capabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*aytoekr-1RC8gsMWtl5eXA.png" /><figcaption>Got it?</figcaption></figure><p>It is used in lieu of other evaluation metrics, such as <strong>accuracy</strong>, because these may lead to <strong>interpretation errors</strong>. For example, if a predictive model is used to diagnose a certain condition, where the condition has a 1% positive rate, marking every observation as false would lead to an accuracy of 99%, but in truth the model would be impractical and useless.</p><h4>Finding data</h4><p>After several sleepless, red bull-fueled nights researching about the topic I came across the <strong>MIMIC III v1.4 dataset</strong>. This gift of god is an extensive database containing de-identified data about <strong>patients </strong>who stayed within the<strong> intensive care units</strong> at Beth Israel Deaconess Medical Center, Boston, Massachusetts, between 2001 and 2012. Patient’s <strong>vital signs</strong>, <strong>lab tests</strong> results, <strong>medical procedures</strong>, <strong>drugs</strong> delivered, transcriptions of medical staff notes and <strong>demographics data</strong>, are found amongst many other useful features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*jebubo6KpU5KSzqlTfbHuA.jpeg" /><figcaption>Don’t forget to write everything down</figcaption></figure><p>The price to pay to access this goldmine? Completing a short online course about data protection and privacy regulations which takes about three days.</p><p>In order to perform this project, the following features were extracted from the database:</p><ul><li><strong>Lab tests</strong>: Blood urea nitrogen, Platelet count, Hematocrit, Potassium, Sodium, Creatinine, Bicarbonate, White blood cells count, Glucose and Albumin.</li><li><strong>Vital signs</strong>: Heart rate, Respiratory rate, Systolic Pressure, Diastolic pressure, Temperature, Oxygen saturation.</li><li><strong>Administrative data</strong>: Admission medical service, ICD 9 diag code, Surgery/No Surgery undergone, ICU length of stay, total length of stay, OASIS, SAPS and SOFA severity scores, time under mechanical ventilation and medical procedure count.</li><li><strong>Demographic info: </strong>Age, gender, marital status, religion and ethnicity.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dSUockvZ4-ynJh5yDszprg.png" /><figcaption>Some beautiful plots showcasing the density distribution of the main vital signs in the dataset</figcaption></figure><p>Most of the features are self-explanatory. The less known ones are ICD-9 diagnostics codes and severity scores.</p><p><strong>ICD-9 codes</strong> are used for billing purposes and aim to <strong>classify conditions and pathologies</strong>. There are 18 main groups, such as mental diseases or diseases of the circulatory system, which are used as features. Each of these groups comprise several subgroups, which were omitted to avoid having an excessive number of classes.</p><p><strong>Severity scores</strong>, OASIS, SOFA and SAPS, are computed from several other features, such as vital signs or age, and offer an <strong>estimate of a patient health condition.</strong></p><h4>Defining our goal: multiclass classification</h4><p>After a first unsuccessful attempt trying to predict the numeric value of life expectancy after hospital discharge, I set for a <strong>multiclass classification task</strong>, grouping ICU patients in <strong>three groups</strong> according to mortality after hospital discharge:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fsheetsu.com%2Ftables%2F85d7c07bb8&amp;dntp=1&amp;url=https%3A%2F%2Fsheetsu.com%2Ftables%2F85d7c07bb8&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=sheetsu" width="700" height="248" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf17cf9f7d3c45895e29a74ca6c6a0af/href">https://medium.com/media/bf17cf9f7d3c45895e29a74ca6c6a0af/href</a></iframe><p>Given these three groups, our main goal will be to <strong>predict to which group does a patient belong to.</strong></p><h4>Cleaning and preparing the data</h4><p>Just because everything couldn’t be perfect, MIMIC III v1.4 <strong>data needs a bit of a clean up</strong> before being used. Many <strong>outliers </strong>and imperfections are present in the data. Measuring errors, human mistakes, or just data complexities and imbalances make necessary a <strong>preprocessing </strong>step in order to feed the data to a neural network. That poor guy with an average heartbeat of 200 bpm and the life expectancy of a fly is probably <strong>not relevant</strong> at all, as well as the four native americans that were admitted between 2004 and 2008.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/196/1*yMZ5FNFVmWsvbxG4ZaeY5g.jpeg" /><figcaption>Don’t take it personally, dude</figcaption></figure><p>So to make the data usable, <strong>outliers </strong>outside the 95% percentile were excluded and categorical features with many imbalanced classes were grouped into <strong>meaningful groups</strong> when possible, or ignored if no clear grouping was possible. <strong>These imperfections would</strong> <strong>hinder the network ability to extract relationships</strong> from the data and make accurate predictions.</p><p>As picky eaters, neural networks demand extra preprocessing to the data they are being fed. <strong>No missing values</strong> are allowed, categorical features must be <strong>hot encoded</strong> and numerical variables must be <strong>scaled </strong>to the same range. How do we achieve this?</p><p>Firstly, missing values were imputed using the <strong>MICE method</strong>, Multiple Imputation by Chained Equations, an algorithm that uses an iterative process of regression to <strong>fill missing values</strong> in the dataset that seemed to do its job quite well.</p><p><strong>Scikit Learn</strong>, the swiss army knife of machine learning, offers easy to use utilities to hot encode data and scale it. <strong>Scaling data</strong> to the same range makes sure all features have the same weight during the training stage of the neural network.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aqmLDPpbjE6eX-OyuF-lXg.png" /><figcaption>A cool plot showing how scaling data leads to a faster path to finding the parameters that minimize the network error.</figcaption></figure><h4>The moment of truth: training a basic network with the data</h4><p>Countless boring database queries and python scripts after, everything is ready to lift off. Data is clean and preprocessed. No outliers, no angry native americans, no missing values, everything is on the same range of values.</p><p>A simple, basic, <strong>fully connected neural network</strong> with four layers, and four neurons per layer is implemented using <strong>Keras</strong>. The first man to fly to the moon. All configurations are left to their default values. The temperature is 23 ºC and the weather is calm. The countdown starts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*GU59kLQ9hWU6opbQ92LyJA.jpeg" /><figcaption>Wish me luck</figcaption></figure><p>As my laptop starts to rev up, the network starts it’s <strong>training </strong>process and metrics are shown in the console after each training epoch. This basic, <strong>test </strong>network is able to achieve an <strong>AUROC score of about 0.65</strong>, with accuracy around 0.6. While not an astounding result, it shows that the neural network <strong>is able to extract relevant information</strong> from the data in order to predict patient mortality.</p><h4>Tuning the network</h4><p>After this initial success, the network should be tuned to increase its performance in order to make better predictions. <strong>Predictive power</strong> is determined by several factors, mostly <strong>network parameter tuning</strong>. Tuning is performed in an iterative manner, by trying out several configurations until we find an optimal one that maximizes accuracy. The following parameters were tuned:</p><ul><li>Number of hidden layers</li><li>Number of neurons in each layer</li><li>Epoch</li><li>Batch Size</li><li>Optimization algorithm</li></ul><p>Three main tuning strategies can be used to accomplish this task. The most time consuming, <strong>Grid Search</strong>, involves trying out <strong>all possible combinations</strong> of parameters. This is often unfeasible in complex scenarios, as the combinations may easily exceed 10k, which given a training time of about 5 mins would mean that we need to <strong>wait for months</strong> to find the optimal parameter configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*r-rPookwdYbkrZvvbgK95g.jpeg" /><figcaption>Waiting for Grid Search to tune our network</figcaption></figure><p>An alternative to Grid Search is <strong>Random Search</strong>, which tests a predefined number of random configurations, maybe 50 or 100, and picks the best one.</p><blockquote>However, the smart way to tune a neural network is to use <strong>Informed Search</strong> algorithms. Informed search tries to reduce the amount of search that must be done by making <strong>intelligent parameter choices </strong>in each iteration.</blockquote><p>This method is implemented with the Python package <a href="http://hyperopt.github.io/hyperopt/">Hyperopt</a>, which uses <strong>Bayesian Optimisation</strong>. A parameter space must be defined and then fed to the algorithm. After 50 iterations and around 3.5h, the optimal parameters are gifted to us: 6 hidden layers, 8 neurons per layer, a batch size of 50, epoch of 25 and Adam algorithm as optimization function. We end up getting something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*jjY91Ir5VEEaNlE2yxmTqA.png" /><figcaption>Our little beautiful creation</figcaption></figure><h4>Evaluating our network</h4><p>Using the optimal parameters obtained in the previous step, the network is trained and its performance is evaluated. We get an<strong> overall AUROC score of 0.82 </strong>which indicates <strong>good prediction capabilities</strong>, especially in the most clinically meaningful group, patients that die within <strong>30 days</strong> of leaving the medical facilities, with an AUROC score of <strong>0.89.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*CiPtB9Gf1dVatOdqZrLgJQ.png" /><figcaption>ROC curves</figcaption></figure><p>Regarding other classes, <strong>AUROC score</strong> is less astounding.</p><p>Our model has <strong>moderate success</strong> predicting patient defunction <strong>between 1 and 12 months</strong>, probably because medical conditions are <strong>less clear</strong> for this group, achieving a score of <strong>0.72</strong>. Prediction of death after <strong>more than one year</strong> has better results, with a meaningful score of <strong>0.81</strong>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fsheetsu.com%2Ftables%2F29c5a22684&amp;dntp=1&amp;url=https%3A%2F%2Fsheetsu.com%2Ftables%2F29c5a22684&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=sheetsu" width="700" height="248" frameborder="0" scrolling="no"><a href="https://medium.com/media/09b629991111558ffee809245f0a7cb1/href">https://medium.com/media/09b629991111558ffee809245f0a7cb1/href</a></iframe><p><strong>Precision </strong>and <strong>recall </strong>are evaluation metrics that account for positive and negative predictive power, respectively. Both are combined in the <strong>F1 Score</strong>, which is computed as their harmonic mean. F1 scores achieved support the conclusions obtained by analyzing AUROC scores.</p><blockquote>A common pitfall in a neural network performance is <strong>overfitting</strong>. Overfitting occurs when the model ‘<strong>memorizes</strong>’ the training data, thus being very accurate if tested on it, but becoming unable to make new predictions.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_7OPgojau8hkiPUiHoGK_w.png" /><figcaption>A simple visual representation of a model’s fit.</figcaption></figure><p>A simple way to test for <strong>overfitting </strong>is to compare the model’s overall accuracy on training data and test data. In our case, these values are 0.656 and 0.632. Training data accuracy is always expected to be slightly above test data accuracy. The similarities between these two values show that our model has a <strong>good fit</strong> on the data, it has <strong>successfully extracted meaningful relationships</strong> from the data it was training on, without memorizing it.</p><h4>Possible improvements</h4><p>Even though the main objective has been achieved, earning my bachelor’s degree, some improvements could be made to boost the model’s performance and achieve <strong>better prediction capabilities</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1qvgU6_VYghm96EMr69AcA.jpeg" /><figcaption>Finally made my grandmother proud of me</figcaption></figure><p>For example, more features could be added. <strong>Text transcriptions of medical notes</strong> were ignored due to their complexities, but could prove a useful source for <strong>new features</strong> if mined. These notes often include information about a patient’s medical history, treatment peculiarities or information about their mood and feeling. Being a ton of work, it will be left for a possible future Master’s degree thesis.</p><h4>What’s next?</h4><p>Results obtained are great, but <strong>not conclusive enough</strong> to be used in medical practice, and may never be.</p><p>Even though the mathematical reasoning behind many algorithms used in AI tools is clear, its complexity has made it <strong>difficult to comprehend</strong> what’s going on under the hood. The underlying relationships between the data being fed to the system and its outputs may not be easily understood, giving place to a <strong>black box model</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*YSBDSGv1cHa0AQHkmu5yEQ.jpeg" /><figcaption>Wake up doc, you’ve still got work to do</figcaption></figure><p>If we are willing to put our lives in the hands of AI, <strong>we must make sure we fully understand</strong> how this tool works, as well as creating a well thought out <strong>legal regulation</strong> around its use. Who is responsible if a decision taken by an AI system causes the death of a patient?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9814bf192da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Suffering Jira? Creating tickets through its REST API]]></title>
            <link>https://medium.com/tiendeo-tech/suffering-jira-creating-tickets-through-its-rest-api-cd87ae2d6c1d?source=rss-658807ec0b62------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd87ae2d6c1d</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[agile]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[jira]]></category>
            <dc:creator><![CDATA[Daniel Solá]]></dc:creator>
            <pubDate>Thu, 13 Jun 2019 11:05:19 GMT</pubDate>
            <atom:updated>2019-06-13T11:05:19.548Z</atom:updated>
            <content:encoded><![CDATA[<p>As exciting as a Product Owner role may seem, dealing with <strong>requests</strong> is part of the job. There just seems to always be something going wrong, some <strong>bug</strong> to fix, some <strong>report</strong> to submit, just even simple user’s <strong>questions</strong>. These requests often materialized in several ways. Receiving and email was usually the most pleasant, and less common, way. Often, meetings were being disrupted due to supposed ‘urgencies’. Personal interruptions were usual. And on top of that, <strong>keeping track of those demands had become a daunting task.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hBesD-wYoxrAg9JcVTRxoA.jpeg" /></figure><p><strong>Canalizing</strong> and keeping track of this kind of requests between departments had become a need to keep our PO’s sanity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*U5FwpfObloM5o41eW1-IIA.png" /><figcaption>“Yeah, my developers will take care of it”</figcaption></figure><p>In an effort to manage support requests between different teams, we built a simple yet powerful webapp for internal use, just consisting of a form to submit an issue to a specific <strong>Jira board</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*atFXyA5FdIq2esqK4B43ew.png" /><figcaption>Our webapp being used by Nick Fury to manage the Avengers</figcaption></figure><p>Hated and loved in equal parts, Jira has become the de-facto tool used in Software project management. Quirky as the product itself, its REST API allows for issue creation. I suffered through its sometimes incomplete documentation so you don’t have to. <strong>Here’s how to create tickets using Jira REST API</strong>.</p><h4>API authentication</h4><p>All request to the API must be authenticated through a user’s <strong>email</strong> and <strong>API token</strong>. This token can be created <a href="https://id.atlassian.com/manage/api-tokens">here</a>. It is important that this user has <strong>full admin rights</strong> over the board you want to create tickets in. Otherwise, some requests may fail due to missing privileges, such as setting an issue’s reporter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/1*vnI287cQB66eIJeOnB5cjg.png" /><figcaption>The only thing clear in JIRA’s documentation</figcaption></figure><p>To avoid incurring in extra costs, our webapp uses the same user credentials to create all issues. This way, there is no need to create extra Jira users, which are paid, so <strong>everybody in the organization can use it</strong>, whether they have a Jira account or not.</p><h3>Issue creation</h3><p>In order to create a JIRA ticket, a <strong>POST request</strong> must be issued to your corresponding organization Jira URL, which will probably look like this.</p><pre><a href="https://your-organization.atlassian.net/rest/api/2/issue">https://your-organization.atlassian.net/rest/api/2/issue</a></pre><p>In this case, we are using version 2 of this REST API, as the newest version seems to be buggy.</p><h4>Basic fields</h4><p>Here’s an example of how to <strong>set fields</strong> in a Jira POST request body:</p><pre>{<br>    &quot;fields&quot;: {<br>        &quot;project&quot;: { &quot;key&quot;: &quot;SPIDERMAN&quot; },<br>        &quot;summary&quot;: &quot;Pictures&quot;,<br>        &quot;description&quot;: &quot;I want pictures of Spiderman!&quot;,<br>        &quot;reporter&quot;: { &quot;name&quot;: &quot;jonh.jonah.jameson&quot; },<br>        &quot;assignee&quot;: { &quot;name&quot;: &quot;peter.parker&quot; },<br>        &quot;issuetype&quot;: { &quot;name&quot;: &quot;Task&quot; },<br>        &quot;priority&quot;: { &quot;id&quot;: &quot;1&quot; },<br>        &quot;labels&quot;: [ &quot;Superheroes&quot;, &quot;Pictures&quot;, &quot;Urgent&quot; ],<strong><br></strong>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*5e_-0DB9Qh8hPrkFhPmlzg.png" /><figcaption>“And I want them in my desk tomorrow first thing in the morning!”</figcaption></figure><p>What are we actually filling here?</p><ul><li>Project key indicates Jira which <strong>board</strong> we want to create this issue in.</li><li><strong>Summary</strong> will be the title of our issue.</li><li><strong>Description</strong> needs no description. It will apear in the body of your issue.</li><li>To set the issue’s <strong>reporter</strong>, the only working way is to send it’s name as its email, which can sometimes differ from it’s Jira username. In the following link you can search all your JIRA users and see their <strong>email</strong>.</li></ul><pre><a href="https://tiendeo.atlassian.net/people/search">https://your-organization.atlassian.net/people/search</a></pre><p>For example, if a user named John Jonah Jameson has a registered email as john.jonah.jameson@daily-bugle.com, you will have to send its name to the Jira API as <strong>john.jonah.jameson.</strong></p><ul><li><strong>Assignee</strong> can be set same way as reporter, by using its email name.</li><li><strong>issueType</strong> specifies the kind of issue you want to create, probably a ‘Task’ or ‘Bug’.</li><li><strong>Priority</strong> is a tricky one. By default, <strong>five levels are available</strong>, ranging from 5 being the lowest to 1 being the highest. Obviously, pictures of Spiderman are high priority.</li><li>Issue <strong>labels</strong> can be specified as an array of strings. Make sure your labels don’t have spaces in them, otherwise the request will fail.</li></ul><p>More fields can be set, such as issue transitions or related issue’s epic link. You can find out more <a href="https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/">here</a>.</p><h4>Custom fields</h4><p>Have you defined custom fields in your board issue screens? If so, to be able to fill these fields through your POST request, you must find their id and add a new entry in your request object as follows:</p><pre>{<br>    &quot;fields&quot;: {<br>        &quot;project&quot;: { &quot;key&quot;: &quot;SPIDERMAN&quot; },<br>        &quot;summary&quot;: &quot;Pictures&quot;,<br>        &quot;description&quot;: &quot;I want pictures of Spiderman!&quot;,<br>        &quot;reporter&quot;: { &quot;name&quot;: &quot;jonh.jonah.jameson&quot; },<br>        &quot;issuetype&quot;: { &quot;name&quot;: &quot;Task&quot; },<br>        &quot;priority&quot;: { &quot;id&quot;: &quot;1&quot; },<br>        &quot;labels&quot;: [ &quot;Superheroes&quot;, &quot;Pictures&quot;, &quot;Urgent ],<br><strong>        &quot;customfield_10082&quot;: &quot;Cover&quot;,<br></strong>    }<br>}</pre><p>In this case, <strong>customfield_10082</strong> is a <strong>custom field</strong> refering to the <strong>newspaper page</strong> the pictures must appear in. To find its id in Jira, you will need to have administrator privileges:</p><ul><li>Go to Administration / Issues / Custom Fields</li><li>Search for your field and click on configure</li><li>You’ll see your custom field Id in the URL</li></ul><p>Jira API will respond with a 200 status code if your request is successful. You fill find the ID of the issue you just created in the response body.</p><pre>{<br>    &quot;id&quot;: &quot;14294&quot;,<br>    &quot;key&quot;: &quot;SPIDERMAN-24&quot;,<br>    &quot;self&quot;: &quot;<a href="https://tiendeo.atlassian.net/rest/api/2/issue/14294">your-organization.atlassian.net/rest/api/2/issue/14294</a>&quot;<br>}</pre><h4>Adding attachments to your issues</h4><p>Finally got those pictures of spiderman?</p><p>Then attach them to your issues by submitting a <strong>POST form-data request</strong> to the following URL, where ID is the key of an already existing issue, for example, <strong>PICS-56.</strong></p><pre><a href="https://your/">your</a>-organization.atlassian.net/rest/api/2/issue/{ID}/attachments</pre><ul><li>Attach your pictures of spiderman as a field name <strong>‘file’</strong> to your request.</li><li>Set ‘X-Atlassian-Token’ : ‘nocheck’ in your request <strong>headers</strong> to avoid your request being blocked due to XSRF.</li><li>Enjoy pictures of Spiderman.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*xHlU3KrVdzKgV4teLkYvjw.png" /><figcaption>“Finally got you, Spiderman. Thanks Jira”</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd87ae2d6c1d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tiendeo-tech/suffering-jira-creating-tickets-through-its-rest-api-cd87ae2d6c1d">Suffering Jira? Creating tickets through its REST API</a> was originally published in <a href="https://medium.com/tiendeo-tech">Tiendeo Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fuzzy coordinates matching: An efficient approach]]></title>
            <link>https://medium.com/tiendeo-tech/fuzzy-coordinates-matching-an-efficient-approach-f5e7d7917f75?source=rss-658807ec0b62------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5e7d7917f75</guid>
            <category><![CDATA[geolocation]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Daniel Solá]]></dc:creator>
            <pubDate>Tue, 23 Apr 2019 13:44:39 GMT</pubDate>
            <atom:updated>2019-04-23T13:44:39.327Z</atom:updated>
            <content:encoded><![CDATA[<p>Geolocalization plays an important role in most companies today. Some of them wouldn’t even make sense without this feature. Generalised use of smartphones allow for a constant gathering of <strong>geolocated data</strong>. Where did you have dinner yesterday? Where do you work? Which stores have you visited? <strong>Business opportunities</strong> surrounding the use of this kind of data are ubiquitous.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/0*7fo-Ii1QeDRblF_q" /><figcaption>A cool stock picture about geolocation</figcaption></figure><p>When thinking about geolocation-based services, <strong>Foursquare</strong> comes easily to mind. For those who don’t know, it consists of a location-based social network where users can find nearby events, restaurants or places, and ‘check-in’ to gain score points. Other popular, and well-known apps that use geolocation services are <strong>Pokemon Go</strong> and <strong>Uber</strong>, which would be rendered useless without the ability to track their users’ positions.</p><h3>A bit of business logic</h3><p><strong>Tiendeo</strong> uses geolocated data to <strong>match retailer’s physical store locations</strong> across different sources in order to create a <strong>one-to-one link</strong> between contents.</p><p>Our sources consists of <strong>lists of stores pertaining to certain retailer</strong>. Each store has an associated geographical position represented by their latitude and coordinates. These sources are variable in size, ranging from less than 50 stores to more than 3000 in certain cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*jeHlRLc1BUAD4gQQbUbMLA.png" /><figcaption>Sample data to be manually matched. Coordinates are similar, but not identical</figcaption></figure><p>These sources’ geographical position of stores often differ slightly, on the order of tens of meters. Content matching must be done in order to <strong>avoid duplicate content</strong>: showing the same store twice in Tiendeo’s website.</p><p>Associating content was a <strong>manual</strong>, <strong>repetitive task</strong>, creating a huge time sink, as well as <strong>employee burnout</strong> from having to perform a seemingly endless mechanical task during hours at a time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/0*11KqzHDfYwocINcY.jpg" /><figcaption>How employees feel when manually matching content</figcaption></figure><h3>Coding the solution</h3><p>What used to be a resource waste was <strong>automated</strong> using the following approach. We decided to develop an <strong>efficient, one-to-one content matching algorithm based on geolocation</strong>. Our code accepts a tunable parameter, the <strong>maximum allowed distance between elements</strong>, which we empirically established in 750m according to knowledge about our sources.</p><p>A first iteration to this task involved creating a <strong>full distance matrix</strong>, computing all distances between all elements of our sources. This soon proved to be an <strong>inadequate approach</strong>, as computation cost was exponential and many distance calculations were not needed. For a 10 elements lists, 100 distance calculations where needed. But for a 1k elements lists, the number grows to a million, resulting in computations times of about 10 minutes, excessive for our intended use. Thus, a second iteration was performed.</p><p>For each element of a lists, we find <strong>nearby elements</strong> in the other source <strong>within a certain radius</strong>. We establish this radius via a simple coordinate subtraction of 0.08. Correspondence between coordinates differential and radius in meters isn’t constant. A difference of 0.08 in coordinates results in a radius of 1400m at the equator, and about 1900m in northern latitudes, such as Norway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*7eiZXq5bOBpbPC9kED6ejA.png" /><figcaption>Finding nearby elements in the matching source</figcaption></figure><p>Then we calculate the distance from each element to those nearby elements and match it to the <strong>lowest distance element</strong> in this nearby elements group. This result in <strong>computational cost reduction</strong>, as we no longer require to compute distances between all of elements, but for those in an small radius.</p><p>Thanks to this hack we are able to <strong>reduce our computation time</strong> from 10 minutes to less than 5 seconds in a worst case scenario.</p><p><strong>Calculating distances between coordinates</strong></p><p>In order to calculate distance between elements, we use <strong>‘cheap-ruler’</strong>, a Javascript library for <strong>fast geodesic calculations on a city scale</strong>. According to the authors, it is able to calculate distance <strong>100 times faster than conventional methods</strong>, such as Haversine formula, by making small assumptions and <strong>simplifications</strong> resulting in minimal error and great performance. Earth curvature is omitted for small distances and slow, heavy trigonometrical calculations are approximated.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DAmViLLXPrHwHYqO" /><figcaption>The earth according to cheap-ruler package.</figcaption></figure><p>Thanks to these tricks, <strong>precise and fast results are achieved for distances on a city scale</strong> and not on the poles. You can read more about cheap ruler <a href="https://github.com/mapbox/cheap-ruler">here</a>.</p><h3>Proof of concept</h3><p>A small script can be found at my GitHub <a href="https://github.com/DanielSola/fuzzy-coordinates-matching">repository</a>, comparing performance gains by using method described above (FastMatching) instead of computing all distances between all elements (SlowMatching). Sample results look like this:</p><pre>SlowMatching: 20637.344ms<br>Made 12000000 distance computation between elements</pre><pre>FastMatching: 66.746ms<br>Made 18699 distance computation between elements</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5e7d7917f75" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tiendeo-tech/fuzzy-coordinates-matching-an-efficient-approach-f5e7d7917f75">Fuzzy coordinates matching: An efficient approach</a> was originally published in <a href="https://medium.com/tiendeo-tech">Tiendeo Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>