<?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 Mr Data Insight on Medium]]></title>
        <description><![CDATA[Stories by Mr Data Insight on Medium]]></description>
        <link>https://medium.com/@mrdatainsight?source=rss-ed77b70453f8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*tRsejOcI1pGwce2Q</url>
            <title>Stories by Mr Data Insight on Medium</title>
            <link>https://medium.com/@mrdatainsight?source=rss-ed77b70453f8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 06:35:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mrdatainsight/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[Text mining on personal data in the age of GDPR]]></title>
            <link>https://medium.com/analytics-vidhya/text-mining-on-personal-data-in-the-age-of-gdpr-f8e7a2c138c6?source=rss-ed77b70453f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/f8e7a2c138c6</guid>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[privacy]]></category>
            <category><![CDATA[gdpr]]></category>
            <category><![CDATA[text-mining]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Mr Data Insight]]></dc:creator>
            <pubDate>Wed, 16 Oct 2019 10:21:43 GMT</pubDate>
            <atom:updated>2019-10-19T14:45:43.997Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*k-HHXqr7KnE_SH8b" /><figcaption>Photo by <a href="https://unsplash.com/@alejandroescamilla?utm_source=medium&amp;utm_medium=referral">Alejandro Escamilla</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3><strong>Handling privacy sensitive text data</strong></h3><p>Text analytics is something that has proven to be very useful in enriching analytics of customers and using data that was previously very hard to exploit. So naturally, many companies want to invest in setting up a text mining pipeline. Unfortunately, many realize that using text data implies the use of personal data, and are trying to find a way to anonymize this data.</p><p>Here I will give an overview of why full data anonymization is very, very hard. But fear not, if you are at least aware of all the possible issues, you are in a good position to properly assess the risk involved and inform all stakeholders.<br> In this first article, I will start with the basics, the case where your text data is still somewhat structured. In a followup article I will deepdive in the unstructured text problems</p><h3><strong>Personal, anonymous and pseudonymous information</strong></h3><p>Before we start, it is important to understand the concept of sensitive data as defined in the GDPR rules.</p><p><strong>Personal</strong> data is the easiest one to understand. It refers to data that specifies something about a person, as well as a link to that person. For example, <em>John has been on holiday</em>. You know something about somebody. In many cases, this information will do no harm, but in others, such as <em>John has an affair</em>, people might not be happy that this data is being analyzed.</p><p><strong>Anonymous</strong> data is at the other end of the spectrum. In this case, all sensitive information is impossible to connect to a single person, and irreversible. That means that simple preprocessing functions (such as mapping whilst keeping the mapping table) does not constitute anonymizing your data.<br> The goal of preprocessing privacy sensitive data is typically to anonymize it. However, strictly speaking, it is very difficult to do so, since there will always be some kind of information leakage.</p><p><strong>Pseudonymous</strong> data is in between. The data by itself is <em>anonymized</em>, but it is still possible to connect this to a person if you include additional data, so the process is reversible. In a lot of cases though, pseudonymization makes a lot of sense and is adequate for complying with GDPR.</p><h3><strong>Text data in tabular format</strong></h3><p>This is the easy bit. Suppose you have a table like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*TXptAB83YpiMOrz7sRre3A.png" /></figure><p>Obviously, you already can identify some clear personal information. There is the name of the person, and there is customer_ID. The solution is easy, right? Just remove the columns? Sure!</p><p>Only downside is that you lose valuable information. It would be very useful to see which transactions were made by the same person (e.g. for recommendation systems). So naturally, there exist multiple techniques to handle this data.</p><p>For example, let us handle the column ‘Name’. Some techniques we could use are:</p><ul><li><strong>Masking</strong>: masking refers to making it seem like the column was never there to begin with. This is just plain old deleting the column.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*LrCP2mEkVnfvPLsv6L7RjQ.png" /></figure><ul><li><strong>Faking</strong>: Sometimes you still want reasonable data, for example during testing of your data pipelines. In this case, it makes sense to replace the data with random but plausible replacement data.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*QntS5YvAEfbWVAPJqS5lxg.png" /></figure><ul><li><strong>Mapping</strong>: In this case, we replace the attribute with an id that is recorded in another database. This is useful if you for example want to give a dataset to another team that doesn’t necessarily need access to the personal information. This way, you can still train the model on actual data, and also couple the results back to the user after the analysis</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*l5L8Xk5vrAYS1-oYYOjItQ.png" /></figure><ul><li><strong>Hashing</strong> The most secure way to handle this type of data without actually deleting the data involves hashing. In this case, we do the same as mapping, but make it impossible to retrieve the original value. A <em>hashing</em> function is a mathematical technique to convert some data into an alphanumeric identifier. The hashing function does not allow the reverse compute the value that was used as input for the hashing.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*idLOcbhKn7J96t3ioAPKmQ.png" /></figure><p><strong>Sensitive attributes</strong></p><p>Customer ID is what we call a <strong>sensitive attribute</strong>. It is not sensitive on its own (just a number), but when combined with other information it becomes sensitive information. A great example is healthcare.<br> Take this dataset for example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/187/1*H-VjNWcuOZ_x2cSWaueoBA.png" /></figure><p>As you can imagine, a list of diseases by itself is not that privacy sensitive, but when tied to a person it becomes very personal information. You can imagine Jane does not care about people knowing she had the flu, but James and Tom would probably not be happy if this data were to be leaked.</p><p>Therefore, it is very important that you also consider that a column that is not personal information in isolation can become an issue when more information is added to the database.</p><h3><strong>Leaking data through lookups</strong></h3><p>Suppose this dataset of your employees with their evaluations from last year. This is highly personal and sensitive information, so it should be stored very securely right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/673/1*VhGh18ZEaeaiQuP-Xd25RQ.png" /></figure><p>If this data leaked, sure there you could say there are no names, but if there is only one boss, people are going to be mad when they hear they do not get a raise this year. To combat this problem, you need to make sure that the data is not specific enough that a collection of the columns is enough to identify someone. The same can be said from the person in reception. He is the only me in the reception team, so everybody knows who we are talking about.</p><p><strong>k-anonymity</strong></p><p>So even with columns that do not identify a person directly, it can still be possible that a combination of those columns can be used to identify someone. For example, with <em>age</em> alone, you probably will have a hard time to identify exactly the person in the dataset, but a combination <em>age</em>,<em>city</em>,<em>gender</em>,<em>street</em> is highly likely to point to one person.</p><p>The concept of <strong>k-anonymity</strong> implies that each possible grouping of your columns with sensitive attributes (in our case the evaluation column of the employees) identifies at least <em>k</em> members.</p><p>Let’s group the ages and departments to fix this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*L_I30fKDpDThuR-8YsfyMQ.png" /></figure><p><strong>I-Diversity</strong></p><p>However, anonymity is not enough. For example, what can you tell me about Steven, a male from the reception desk? Although it is impossible to say which line exactly is Steven with our data (it could be employee ID 2 or 7), it doesn’t matter, because the value of the sensitive attribute is the same: the both got a bad evaluation.</p><p>Therefore, it is also important that within a group, there is enough diversity in the labels that you want to remain private. This concept is called <strong>I-diversity</strong>, where a group needs to contain <em>I</em> at least different values for a sensitive attribute.</p><p>Turns out in our dataset, either we need to get more data to introduce more diversity, or we need to delete some data. Let us delete the department</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*4rGi5kDDfXpXpfSnFcfirQ.png" /></figure><p>There we go! Now we have a 2-anonymous, 2-diverse dataset that we can safely pass to our analytics team for further evaluation.</p><h3><strong>Prevention technique in case of live updating data</strong></h3><p>All this is very nice to know in case your dataset is fixed and you have the time and resources to perform the redaction process before handing over the dataset for further processing.</p><p>However, in the real world it is often the case that you need to even have sensitive data anonymized directly from the source, so how do you handle this?</p><p>Well, to guarantee anything regarding sensitive information, you will need to process the information. So let us do something else instead, let’s try to introduce <strong>plausible deniability</strong></p><p>Imagine you are taking a survey among your employees ‘Have you ever taken a cup of coffee from the fancy coffeemaker reserved for management’? I imagine this is a common problem in many organizations. Naturally, if you ask this to your employees, they will be afraid that data leakage can cause them trouble and everybody will lie and say they have never used the fancy coffee machine. This is not what we want.</p><p>Instead, we can introduce a random error generator. Let us say in 95% of the cases, as defined by random chance, you store the real answer from the employee (yes or no). In the other 5%, you ignore the answer and always store <em>yes</em> in the data gathering system. This way, if there is data leakage, every employee can claim he is just part of the 5% and not get into trouble, since there is no way of finding out whether or not the employee really answered yes or not.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f8e7a2c138c6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/text-mining-on-personal-data-in-the-age-of-gdpr-f8e7a2c138c6">Text mining on personal data in the age of GDPR</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use OpenCV imshow() in a Jupyter Notebook — Quick Tip]]></title>
            <link>https://medium.com/@mrdatainsight/how-to-use-opencv-imshow-in-a-jupyter-notebook-quick-tip-ce83fa32b5ad?source=rss-ed77b70453f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce83fa32b5ad</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[jupyter-notebook]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[opencv]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Mr Data Insight]]></dc:creator>
            <pubDate>Fri, 22 Mar 2019 13:04:17 GMT</pubDate>
            <atom:updated>2019-03-22T13:04:17.429Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to use OpenCV imshow() in a Jupyter Notebook — Quick Tip</h3><p>For those of you who are trying to use OpenCV in a Jupyter notebook, it may be frustrating that you can’t do imshow out of the box. It is so easy from the interactive shell, but you still want to document your code interactively using notebooks. What to do?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*f_pWffeA96JFP1mX5TMd4Q.png" /><figcaption>Sadly an all too familiar feeling</figcaption></figure><h4>The Problem</h4><p>The solution is very simple once you understand why Jupyter crashes.</p><p>The problem is that the image box is using the same Python process as the kernel. When you execute this from an interactive shell, the shell waits for you to get back from the image display box. But Jupyter wants to claim control back after you executed a command block. Therefore it is not happy to wait for the window, and you lose control of the Python process, crashing everything.</p><h4>The Solution</h4><p>To solve this, you need to explicitly close the window when you are done with it. To accomplish this, you can use the cv2.destroyAllWindows() functionality.</p><pre>cv2.destroyAllWindows() #close the image window</pre><p>Since you probably don’t want your screen to close immediately, you can tell OpenCV to wait for a keypress. You can specify which key, but it is best to accept any key</p><pre>cv2.waitKey(0) #wait for any key</pre><h3>Full solution</h3><pre>image = cv2.imread(&#39;example/image.png&#39;)<br>cv2.imshow(&quot;test&quot;, image)<br>cv2.waitKey(0)<br>cv2.destroyAllWindows()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*AOND4SV56AePYExdTX-WIA.png" /><figcaption>Much better!</figcaption></figure><p>To exit the window, <strong>DON’T CLICK THE RED CROSS, just tap any key on your keyboard!</strong></p><p>If you do close with the cross, you won’t let OpenCV close the box for you, and Jupyter will stay waiting, causing you to have to reset the kernel yourself.</p><p>Happy imshow’ing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce83fa32b5ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Future of the Financial sector in the age of cloud — Google Next Panel Discussion]]></title>
            <link>https://medium.com/@mrdatainsight/future-of-the-financial-sector-in-the-age-of-cloud-google-next-panel-discussion-4a1a736eb4f9?source=rss-ed77b70453f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a1a736eb4f9</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[finance]]></category>
            <dc:creator><![CDATA[Mr Data Insight]]></dc:creator>
            <pubDate>Thu, 11 Oct 2018 07:55:27 GMT</pubDate>
            <atom:updated>2018-10-11T07:59:02.218Z</atom:updated>
            <content:encoded><![CDATA[<h3>Future of the Financial sector in the age of cloud — Google Next Panel Discussion</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EjXaoARo3wj9OVvQ" /><figcaption>London, the place for Google NEXT 18 Europe — “top view of city” by <a href="https://unsplash.com/@lucamicheli?utm_source=medium&amp;utm_medium=referral">Luca Micheli</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Today I attended a panel discussion about the future of finance in a world with cloud and data analytics. Some very interesting attention points sprung up, as well as some insights into how the world of finance will have to adapt the coming years. The panel consisted of speakers from ING, HSBC, HyperLedger and Blackrock and took place at Google NEXT 2018 in London.</p><h3>On the topic of migrating legacy to the cloud</h3><p>The point that was stressed the most, is that in order to be successful, it is important to introduce change gradually. Big bang changes may disrupt business, and although the impact on your bottom line may be dramatic, the worst change will be one that you can’t measure: you introduce aversion to change.</p><p>It is hard to convince the average Joe to change the way he has been working for years, it is even harder if he has had a bad experience in the past when this change was forced upon him.</p><p>When adopting the cloud, make sure to introduce change in a way that is constantly monitored, pay attention to the three key aspects: financial, human satisfaction and functionality.</p><p>When changing the technology, don’t try to replace existing processes exactly the way they are being done right now. <strong>Try to embrace the newest developments and focus on exploiting all the strong points</strong>. <em>(e.g. when modelling on the cloud, don’t collaborate using Windows fileshares, use the accompanying toolboxes)</em>. This holds true for the typical Microsoft office workflow. Should you adopt GSuite, stop mailing attachments, but share documents on GSuite.</p><h3>On the topic of adopting big data</h3><p>HSBC has made one point very clear:<strong> on-prem big data doesn’t work.</strong> The upfront cost for setting up a cluster is high and technology changes so fast that nowadays you can’t expect clusters to stick around long enough to realize proper return-on-investment. On top of that, you need to train administrators to manage your stuff, you need to introduce role management, keep on track of ever changing frameworks and patch them, update them, maintain them …</p><p>It is a mess. The fallacy that cloud is unsafe is costing lots of businesses valuable time and those that embrace the cloud first have lower risk of missing important optimization opportunities.</p><p><em>Side note: Not in the panel discussion, but elsewhere on Google Next, I heard that a typical company that has embraced the cloud has shifted about 10% of their workload on the cloud. This is very important in setting up processes and developing the correct mindset, but it means that the competition still be competitive for now. But when those companies go to 30–40%, those who didn’t embrace cloud will be left out and have a very hard time catching up.</em></p><h3>On the topic of IOT and Blockchain.</h3><p>The consensus is that both Internet of Things and Blockchain have exited the stage of <em>will they/won’t they</em> and now the question remains when and how. Most agree that they will have a very noticeable effect on the way things are being done, but they also agree that it is impossible to predict how exactly. We can only hope that companies are sufficiently agile by employing cloud techniques to adapt to demanding and fast-paced innovations. IOT will greatly accelerate the inflow of data volume.</p><p>Both technologies will force companies to become more user centric, since the data will exist to make that happen. Those who don’t, will lose customers to those that are leveraging these technologies in the long run.</p><h3>On the topic of Artificial Intelligence</h3><p>All agree that Machine Learning is changing the way they do business, but they don’t want to use the word Artificial intelligence. There is no cognitive system, no interactive learning going on. ML is where it is at right now. We may also not forget that we are handling the money of the clients, mistakes can have very big consequences. Typically ML processes should be setup so human intervention still happens near the end, so that dangerous transactions or predictions that may impact the customer directly are spotted in advance.</p><p>Another approach is doing what NASA does, let multiple teams develop the same model, and only trust the prediction when all models more or less agree.</p><p><em>Note: This is not ensemble learning, this is letting different human teams work independently and then letting their models form a committee.</em></p><h3>Conclusion</h3><p>Very important keypoints were made, and it is clear that the world of finance will need to embrace these new technologies. The end user will benefit, the impact on the big companies remains unclear.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a1a736eb4f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 best free books to get you started — Advice for beginning data scientists]]></title>
            <link>https://medium.com/@mrdatainsight/5-best-free-books-to-get-you-started-advice-for-beginning-data-scientists-353c2c53fe8?source=rss-ed77b70453f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/353c2c53fe8</guid>
            <category><![CDATA[learning-to-code]]></category>
            <category><![CDATA[self-learning]]></category>
            <category><![CDATA[data-analytics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Mr Data Insight]]></dc:creator>
            <pubDate>Fri, 05 Oct 2018 09:57:29 GMT</pubDate>
            <atom:updated>2018-10-05T09:57:29.958Z</atom:updated>
            <content:encoded><![CDATA[<h3>5 best free books to get you started — Advice for beginning data scientists</h3><p>It is easy to get lost in the thousands of books on data science that exist. To further complicate learning, new material seems to get written everyday. Where do you get started as an aspiring data scientist? I have compiled this list of great books that helped me a lot over the last few years. The order suggests the reading order as well, from absolute beginner to experienced practitioner. And best of all, every single one of them is available for free!</p><h3>R for Data Science</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*8Bra1fouU-t9AfByoVKw3A.png" /></figure><p>This book is how I got started with R. It is great if you want to learn the language and how to make great visualizations. Unlike classic programming books, this one is also easy to read if you already know programming. It doesn’t bother you with super basic details, but starts by learning you how to do visualizations and builds from there. The author of this book is also the author of the brilliant Tidyverse set of R libraries.</p><p>It gives you the building blocks you need to get started in the ecosystem, and really teaches you proper programming style. Say no to sloppy code!</p><p>You can find it at <a href="http://r4ds.had.co.nz/">http://r4ds.had.co.nz/</a></p><h3><strong>An Introduction to Statistical Learning</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/206/1*Ac7_uQB193E2compxgz6SQ.png" /></figure><p>This book takes your techniques to the next level. You will gain intuition into why some techniques are appropriate for the jobs and who others aren’t. You will learn basic mathematical concepts to really grasp the models, without needing a PHD in statistics.</p><p>The book contains lots of example code in R and has made datasets available so you can recreate every image and inference in the book. It is a must read if you want to start building complex, real-world problem solving models.</p><p>The free, regularly updated PDF version can be found at <a href="https://www-bcf.usc.edu/~gareth/ISL/">the website of the book</a>. I have to say the printed version is very beautiful as well.</p><h3>Feature engineering</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*DrpIvN_Hk1HOcpDv69oz1g.png" /></figure><p>Building models is the fancy part, but the real engineering work happens earlier on in the process: Building the features that allow the model to learn.</p><p>The book by Kuhn demystifies why certain techniques improve the performance of your models. It helps you to transition from ‘well this dataset is rubbish, I can’t predict anything with this’ into a skilled artist that combines and creates features that will drastically improve your modelling capabilities. This book truly transitions feature engineering from an art form based on gut feeling, into a great engineering approach.</p><p><a href="http://www.feat.engineering/">http://www.feat.engineering/</a></p><h3>Eisenstein NLP notes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5AG6BOiLlduIzXar" /></figure><p>The last few years, lots of focus has been on creating business value from unstructured data. In a lot of cases, this boils down to Natural Language Processing. This book is perhaps the least well known out of these 5, and you won’t encounter this one in many other lists, but trust me, it is greatest one to get started in the domain of NLP.</p><p>These notes are the basis for the readings in CS4650 and CS7650 (“Natural Language”) at Georgia Tech from professor Eisenstein, <a href="https://github.com/jacobeisenstein/gt-nlp-class/tree/master/notes">who kindly published his own textbook onto his Github account</a></p><h3>Deep Learning</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*8A-vw6W0eCe_tIlMUMUHKw.png" /></figure><p>This one is not for the faint at heart. In fact, I wouldn’t really recommend it to a real beginner. But if you already made it through the other four books I recommended, you can hardly be considered a beginner anymore. Chances are you will want to transition into the latest ground breaking techniques, namely Deep Learning. The book by Ian Goodfellow is simply the best there is. It is amazing this one is available for free.</p><p>For licensing purposes, they can’t distribute the book in easily downloadable PDF format, but for the iPad owners or digital reader enthusiasts, Chrome has a nice feature: You can press print, and then use the Save as PDF functionality to have book a quality PDF version.</p><p><a href="http://www.deeplearningbook.org/">http://www.deeplearningbook.org/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=353c2c53fe8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Asking the right question — advice for beginning data scientists]]></title>
            <link>https://medium.com/@mrdatainsight/asking-the-right-question-advice-for-beginning-data-scientists-3eae30d314f0?source=rss-ed77b70453f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/3eae30d314f0</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[business-intelligence]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[advice]]></category>
            <dc:creator><![CDATA[Mr Data Insight]]></dc:creator>
            <pubDate>Fri, 05 Oct 2018 08:37:56 GMT</pubDate>
            <atom:updated>2018-10-05T08:37:56.287Z</atom:updated>
            <content:encoded><![CDATA[<h3>Asking the right question — advice for beginning data scientists</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vzB69uGzvo-eXhj1" /></figure><p>Enthusiastic new data scientists often wonder how they can improve their models, which fancy programming language they should focus on, or how many layers they need for a deep neural network. These are all valid concerns, but hardly the most important things to worry about when you are just starting out. Not only in the beginning, but through your entire career, the most important aspect of modelling is actually the value proposition: does it make sense to spend time and resources on a given business problem?</p><p>Part of the equation is defining what you are actually trying to model and what you expect to achieve. Classic business cases such as ‘which customer will churn’, ‘what is the expected price for this house’ or ‘how many clients will buy this product’ all have one thing in common: the end goal of the business is not knowing that exact number, the end goal is optimizing revenue and to do that, they will use your model output to guide business decisions.</p><h4>You are not alone</h4><p>At this point I like to refer to my favorite quote from the Netflix series ‘Lost in Space’:</p><blockquote>Information does not exist in isolation. There’s consequences. Context.</blockquote><p>Your model will always be used in context. It is important to know which context. Your model is not the end goal, there is always a reason for its existence.</p><h4>From context understanding to asking the right questions</h4><p>So why do you need to know the context: to ask the right question. I shall clarify this point with a few examples.</p><p>Lets say you want to predict housing market prices, why? Do you want to buy low to sell high and become a realtor? In that case the question you should be modelling is the difference between how high you can expect this house to sell and the actual price you expect to buy this house for right now (hopefully before this house enters the real estate public market).</p><p>Or do you just want a house to live in yourself? Perhaps you value a garden and a close proximity to public transport. In that case you should model a cost function which takes into account the ratio of the expected price and how well it matches your preferences. Note that in this case, the actual housing price accuracy becomes less strict.</p><p>Or you could try to cluster an entire city into lower-class, middle-class and upper-class streets. In this case, the actual value of the house doesn’t even matter anymore, you only need to categorize them into buckets or clusters.</p><h4>Conclusion</h4><p>By asking the right question, you can make your model work better in the overall business context. When the question you were trying to solve closely matches the context your model will be used in, the overall performance will be so much better than if you invested a lot more resources into getting an absolute perfect model that models the wrong question.</p><p>As a side benefit, if you can reduce the accuracy requirements, you may get away with smaller datasets and use the free time you gain for doing other experiments</p><p>Happy modelling!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3eae30d314f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Performing database migrations with Django on Google App Engine and Cloud SQL]]></title>
            <link>https://medium.com/@mrdatainsight/performing-database-migrations-with-django-on-google-app-engine-and-cloud-sql-c7fd298581b4?source=rss-ed77b70453f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7fd298581b4</guid>
            <category><![CDATA[django]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[google-app-engine]]></category>
            <dc:creator><![CDATA[Mr Data Insight]]></dc:creator>
            <pubDate>Fri, 28 Sep 2018 11:04:42 GMT</pubDate>
            <atom:updated>2018-09-28T11:04:42.449Z</atom:updated>
            <content:encoded><![CDATA[<p>Google App Engine is great. It has a free tier that is sufficient for most small businesses and hobby websites, and is very easy to deploy and maintain. Some of those websites are written in Django, a recommended Python web framework.</p><p>Usually the first step is deploying your website to Google App Engine. There are great tutorials online already, but I feel they are missing one very important piece of inforation: <strong>django migrations</strong>. This blog post will help you to perform the manage.py migrate command against your App Engine Standard instance, with a Cloud SQL database</p><p>App Engine flexible is different from the standard environment and is well documented. But we are interested in App Engine Standard, the managed solution.</p><h3>Typical Django deployment steps</h3><p>What you want to do in a typical workflow is the following</p><ul><li>Write your code, test it locally until satisfied</li><li>Upload your code to source control and your servers</li><li><strong>Update your database tables if necessary</strong></li><li>Deploy</li></ul><p>I couldn’t find the update part in the online documentation, so I decided to write this blogpost so I can find it later when I need it again.</p><h3>How Django performs database migrations</h3><p>Database migrations where invented to make your life easier when changing your models in Django. In the early days, you had to write sql yourself to change the database structure before you could deploy a new instance of your codebase. A few years ago our life was made easier when Django started supporting migrations.</p><p>Updating your database happens in two steps:</p><ul><li>First you ask Django to generate the update scripts for you. Django will then check your models and look for any updates it can find. This happens with the manage.py makemigrations command.</li><li>Secondly, you need to apply your migrations to your database to actually make the changes. This happens with the manage.py migrate command.</li></ul><p>The reason there are two steps is that typically you want to create the migrations once on your development machine, but execute them multiple times: on your local environment, testing environment, production databases, … Splitting it into two steps also allows us to save the migrations in our code repository version control.</p><h3>How to perform migrations on Google Cloud SQL</h3><p>Let me explain how App Engine works: In essence, you copy paste your code to a cloud storage area with thegcloud app deploy command. The problem is that you can’t run scripts on the server, all you can do is copy paste your local environment to the server. This is not a standard way of working outside of App Engine, and Django typically assumes you can execute scripts on your production server.</p><p>So in theory, we can’t perform migrations at all. The advice I found online was to migrate my instance to the flexible environment, but I didn’t want to go through all the hassle and have the cumbersome maintenance added on top.</p><p>There is a solution/workaround: you can connect to Cloud SQL from your local machine and execute the manage.py migrate on your local machine but have the changes be made to your cloud instance.</p><p>To do this, you need to add your Cloud SQL database to your settings file. Your production instance is probably using sockets, but from your local machine you need to use the IP adress</p><pre>if False and DEBUG: <br>        # Running in development, but want to access the Google Cloud SQL instance in production.<br>        DATABASES = {<br>            &#39;default&#39;: {<br>                &#39;ENGINE&#39;: &#39;django.db.backends.postgresql_psycopg2&#39;,  <br>                &#39;NAME&#39;: &#39;cloud-database-name&#39;,  <br>                &#39;USER&#39;: &#39;dbuser&#39;,                      <br>                &#39;PASSWORD&#39;: &#39;dbpass&#39;,                  <br>                &#39;HOST&#39;: &#39;35.242.xxx.xxx&#39;, # Set to IP address <br>                &#39;PORT&#39;: &#39;&#39;,  # Set to empty string for default. <br>            }<br>        }<br> else if DEBUG:<br>  #Sqlite database<br> else:<br>     DATABASES = {<br>   &#39;default&#39;: {<br>    &#39;ENGINE&#39;: &#39;django.db.backends.postgresql_psycopg2&#39;,  <br>    &#39;NAME&#39;: &#39;cloud-database-name&#39;,  <br>    &#39;USER&#39;: &#39;dbuser&#39;,                     <br>    &#39;PASSWORD&#39;: &#39;dbpass&#39;,                  <br>    &#39;HOST&#39;: &#39;/cloudsql/instancename:zone:dbname&#39;, #Use socket                   <br>    &#39;PORT&#39;: &#39;&#39;, # Set to empty string for default.<br>        }</pre><p>This way, you can’t accidentally perform a migration without explicitly changing the if False to if True.</p><p>Now this alone won’t work, you also need to configure your SQL instance to allow connections from outside Google Cloud. Go to your console and open the <em>Connections </em>tab</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*rHQL5sZ77IUPW6x2PlUjig.png" /></figure><p>There you can add a public IP address by clicking the Add network button and give it a name to remember which machine this belongs to.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7fd298581b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>