<?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 David Gamba on Medium]]></title>
        <description><![CDATA[Stories by David Gamba on Medium]]></description>
        <link>https://medium.com/@ccontreras.gamba?source=rss-eacd96a382ae------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wLxvwS5PMvFkE2iK6Je1EQ.jpeg</url>
            <title>Stories by David Gamba on Medium</title>
            <link>https://medium.com/@ccontreras.gamba?source=rss-eacd96a382ae------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 00:11:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ccontreras.gamba/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[Combating Malaria with AI and Satellite Imagery]]></title>
            <link>https://medium.com/omdena/combating-malaria-with-ai-and-satellite-imagery-b39528962466?source=rss-eacd96a382ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/b39528962466</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[social-good]]></category>
            <category><![CDATA[malaria]]></category>
            <dc:creator><![CDATA[David Gamba]]></dc:creator>
            <pubDate>Wed, 28 Oct 2020 07:42:14 GMT</pubDate>
            <atom:updated>2020-10-28T07:42:14.950Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to adapt quickly as a team in a real-world project to maximize value generation.</h4><blockquote>One essential aspect we learned while working on this project was fluidity, or the ability to reflect broadly about the challenges, react to changes, and pivot in accordance.</blockquote><p>Omdena challenges are great opportunities for both kick-starting efforts to generate positive social impact and grow professionally.</p><blockquote>A non-zero-sum game where, the better you and your team become, the greater the positive impact you can generate in society.</blockquote><p>The primary reason is that projects start from the business context and not from the data science context, as other platforms such as Kaggle fall in. This means that rather than starting with clean data and an already defined metric to optimize, Omdena projects are fuzzier. One must figure out first how to set the problem in a data science framework, consider the availability and quality of data, and what metric would be appropriate to measure the model’s impact. In consequence, projects feel more real, and delivering one requires more than ‘hard’ technical data science skills. Here I want to talk about one I deem essential: <em>fluidity, or the ability to reflect broadly about the challenges, react to changes, and pivot in accordance.</em></p><h3>The context: AI to combat malaria</h3><p>First, however, let me introduce to you the project we developed, and mention some key aspects that made this project — and Omdena projects in general — challenging. We worked with <a href="https://www.zzappmalaria.com/">Zzapp</a>, a company that spearheads an innovative solution to combat malaria. Historically, one of the common methods to control malaria is to control the mosquito populations that are a vector for the infections. Now, when considering mosquitoes, if they are in their adult, flying forms, getting to them is an arduous endeavor. However, mosquitoes spend a good portion of their lives in larvae form, and they require stagnant water bodies to grow. Thus it is easier to look for stagnant water bodies and control the larvae populations. This is an approach that has worked before in eradication efforts. For this approach to work, it is paramount to account for most, if not all, water bodies. This is the reason you’d see campaigns to avoid leaving pots with water in the open since it might be a breeding ground for mosquitoes.</p><p>Zzapp modernizes this approach with technology. Field workers use an app to mark water bodies and track field workers who would survey an area and later testing to estimate the need for fumigating the water bodies. One of the major tasks Zzapp has to figure out is how to be efficient at surveying new; can they tell where water might be present before sending the field workers? Here is where we entered the action, and as you can see, this was quite an interesting problem we tackled. For a wonderful explanation of how we approached the technical DS aspects, I suggest you check <a href="https://omdena.com/blog/artificial-intelligence-malaria/">this article</a> by my teammates Frank, Lauren, and Tanmay.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*D8ATdoWo0Z_5VT_ktuvyVg.jpeg" /><figcaption><a href="https://www.zzappmalaria.com/">Zzapp App</a></figcaption></figure><h3>A fluid mindset</h3><p>Given this context, I would like to talk with you about challenges that are not necessarily technical in their core, or that perhaps required approaches going beyond what one might call technical or hard skills. And also why I felt to solve them we required a fluid mindset.</p><p>Our first significant challenge was the setting of the project itself. We encountered a nonstandard undertaking since there was no straightforward way to transform the business statement into a data science framework. In the beginning, we were only aware we should explore models to detect water using satellite images. In accordance, over the first stages of the project, we expected the images would let us use common deep learning techniques with some fine-tuning to detect water. Yet initial exploration of the images from multiple sources revealed an issue with this initial belief.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/168/0*j7RHQDWJxDUoPqLL" /><figcaption>Sample images that ‘allegedly’ contain water, from two different data sources</figcaption></figure><p>Can you detect water here?</p><p>Then, by reviewing the literature on the topic, we confirmed that we were dealing with an open, broad problem. For more traditional settings, one would start looking for alternatives and deciding on one that to build upon and reach the solution. In theory, if you put enough effort into the modeling, you could improve the model little by little. In our case, since the problem statement was so broad, there could be a tremendous risk in investing all our efforts in a single approach. We did not even know if the data was enough to produce some results. Thus, there was this constant looming of uncertainty with any approach, since there was no guarantee that any solution we tried would work despite our efforts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nEL0rDNK__GBvG3Z" /><figcaption>Expectation vs. reality whilst developing a single approach to the problem</figcaption></figure><h4>Exploring the space of possibilities</h4><p>In these situations, we could learn from the philosophy of Bruce Lee:</p><blockquote><em>“Empty your mind, be formless, shapeless, like water. If you put water into a cup, it becomes the cup. You put water into a bottle and it becomes the bottle. You put it in a teapot it becomes the teapot. Now, water can flow or it can crash. Be water, my friend.”</em></blockquote><p>For me, this speaks of both adaptability and being capable to tackle a problem from multiple perspectives. When we thought like this, we exploited the open nature of the problem to explore and experiment with innovative and disparate ideas. We then played with different data sources, different ways to frame the data science problem (supervised/unsupervised), and different machine learning models. Granted, attempting such a thing by oneself would be ludicrous, yet such is the beauty of having an entire team willing to try fresh stuff. So this mindset requires both a personal and collective compromise with the cause.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MuOOUcnvQiYbqzYk" /><figcaption>What a diverse team can accomplish by exploring multiple approaches</figcaption></figure><p>While pursuing parallel approaches collectively, it’s also key that the way we test the approaches remained consistent for everybody. We had many discussions only to define how the data formats could be consistent and how to have all models have uniform inputs and outputs. One thing that helped us was talking with Zzapp, since the way they operationally divide the regions gave us an idea to do the same for data. Then, our models would work in the same patches of land. Despite simple, this speaks of the importance of having clear communication while facing these projects.</p><h4>Constrains and communication</h4><p>Even for a big team, there is still a limited capacity to explore all approaches. This means that there should be a careful balance on how much we want to spend resources on each alternative. This is even more pressing in Omdena projects since you have only a little over two months to tackle the challenge, and whatever you could make is what you deliver. To handle this limitation, we learned to value constant communication with the stakeholders (for us Zzapp) as with the rest of the collaborators’ team. During the project we presented our progress to Zzapp weekly and discussed with them what they would think might work or not. This way we were also benefiting from their expertise in the field and from their previous modeling approaches to detect water. We also held another meeting internally on the same day just to talk and align. The meeting was great to check what alternatives were working, and it’s one thing that allowed us to plan and track the myriad tracks we were developing.</p><p>This — thinking broad and relying on your team to explore the possibilities — mindset also allows for some nice synergies to form. One time I reached a plateau developing auto-encoder models² to create lower-dimensional representations of the images such that we could use these representations instead of the images for model training. However, the initial results proved unsatisfactory. We contemplated scraping the idea when another teammate showed some results from his work. He used the spectral signature of pixels to discover differences in the composition of terrain through a technique called spectral unmixing¹. Then it clicked for me. Instead of trying to reconstruct the image, we could try to reconstruct the histograms of the images. Turns out the method to reconstruct images only needed some minor changes to make histogram reconstruction work. We later used these representations in our models. From the experience, it’s clear to me I would not have thought of this new angle if not for what my teammates were exploring.</p><h4>Overcoming internal conflict</h4><p>However, the greatest challenge in getting used to this fluidity mindset was learning to let go. No one wants to let their effort to waste. We recognize this behavior as the ‘sunken cost fallacy’; people see more value in things they already invested in, and the friction to change becomes greater the more has been ‘sunk’. Going back to our project, this occurred with the work of an entire team. As I mentioned, there are some standard parts that most machine learning projects follow. One of these is annotating data to train models. We set up a team at the beginning of the project for that, and in accordance, they invested heavily in learning how to do their part efficiently. Meanwhile, other teams noticed that the manual annotations would not be helpful given the approaches we had in mind, which meant that we should probably dial down our annotation efforts. Still, some teammates wanted to see what they could do with annotations and carried these efforts until the latest stages of the project. While I believe that for my teammates the learning experiences were valuable within the project’s context, the effort could have been welcome in other approaches.</p><p>There was another similar experience that completely changed the project’s landscape. After one of the weekly progress meetings, Zzapp confirmed that one part of the project was not a pressing matter to them yet. The portion in question was some additional effort to quantify the risk of actual malaria presence, if we have a water body, would it have mosquitoes carrying malaria?. Having some of us working on this addendum made sense at the beginning of the project, and we also dedicated a team of people to explore this. Here, we could move because we aimed for clear communication; the conversation with Zzapp gave us a tremendous incentive to stop working on malaria detection. However, this time, we pivoted faster and closed that research to focus on our main deliverable. We learned how to pivot faster by our experience during the project.</p><h3>Closing words</h3><p>I’m certain these learning experiences transcend this project. Because openness, uncertainty, and unpredictability will be ubiquitous in real-world endeavors. The key is learning to be fluid. It will work as long as you keep an open mind to tackle the challenges and focus on communication with your team and your stakeholders.</p><p>Finally, I would like to highlight these articles by my teammates which also revolve around the ZzappMalaria AI project:</p><ul><li><a href="https://omdena.com/blog/artificial-intelligence-malaria/">Tanmay’s article</a> on data sourcing and our technical approach</li><li><a href="https://medium.com/omdena/real-world-data-science-how-omdena-helped-me-get-out-of-my-comfort-zone-ad91614d3260">Rasha’s article</a> on her personal journey through the challenge</li></ul><p>Also <a href="https://omdena.com/projects/ai-malaria/">here’s the link</a> to the project statement on Omdena’s website.</p><h4>References</h4><p>[1] Hardy, A., Oakes, G., &amp; Ettritch, G. (2020). Tropical Wetland (TropWet) Mapping Tool: The Automatic Detection of Open and Vegetated Waterbodies in Google Earth Engine for Tropical Wetlands. <em>Remote Sensing,</em> <em>12</em>(7), 1182. doi:10.3390/rs12071182</p><p>[2] Kingma, D., &amp; Welling, M. (2019, December 11). An Introduction to Variational Autoencoders. Retrieved October 20, 2020, from <a href="https://arxiv.org/abs/1906.02691">https://arxiv.org/abs/1906.02691</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b39528962466" width="1" height="1" alt=""><hr><p><a href="https://medium.com/omdena/combating-malaria-with-ai-and-satellite-imagery-b39528962466">Combating Malaria with AI and Satellite Imagery</a> was originally published in <a href="https://medium.com/omdena">Omdena</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fraud Detection: Anticipating the fraudsters]]></title>
            <link>https://medium.com/@ccontreras.gamba/fraud-detection-anticipating-the-fraudsters-da20412ac1d2?source=rss-eacd96a382ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/da20412ac1d2</guid>
            <category><![CDATA[r-language]]></category>
            <category><![CDATA[fraud-detection]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[adversarial-attack]]></category>
            <dc:creator><![CDATA[David Gamba]]></dc:creator>
            <pubDate>Mon, 04 Mar 2019 21:38:18 GMT</pubDate>
            <atom:updated>2019-03-04T21:38:18.336Z</atom:updated>
            <content:encoded><![CDATA[<p>Welcome to part two of our short series describing the most important highlights of our analysis of the Paysim fraud detection dataset. On this occasion, we discuss how to make the machine learning model that predicts fraud robust. To get the full picture and context you’re welcome to review the <a href="https://medium.com/@ccontreras.gamba/data-science-journeys-fraud-detection-4b6618b7fb82">introduction</a> , where you can also find links to the other parts of this series. Also, the code can be found in the <a href="https://bitbucket.org/chay_80_el_resto_20/fraud_detection/">git repository</a>. The relevant file for this article is /fraud_models/robust_models.Rmd.</p><p>The results of our first iteration are bittersweet; despite the good model performance and the clear characterization of fraudulent transactions, the results are flimsy as minimal changes in behavior of the fraudsters could easily derail model predictions. Our objective is then to improve the current models considering the possible responses of the fraudsters in the system such that we can have a reliable model over time.</p><p>First, we must look back to our current characterization of fraudulent transactions and determine what could be the course of action of a fraudster once they realize that most, if not all of their transactions are being blocked. For example, practically all frauds occur in the critical line where the amount of the fraudulent transactions equals the original balance of the victims, or to put it eloquently, the fraudsters just take all the money and run. This begs the question: What would be the effect of reducing the amount just by a little? What is the result of the model in such scenario?. To answer, we have taken 100 identified fraudulent transactions by the model at random and reduce their amount by just 1, a operation that implies not only changing the maximum amount feature, but the balances and new amounts both in origin and destination account, attributes also strongly considered by the models.</p><p>Turns out that the true positive rate, <strong>TPR, is 0</strong> for models such as decision trees. This result is obvious when looking at the model generated. The first split node is maximum_transfer and on the false side of this split it predicts legitimate transactions only.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*s10nDfmSOhjhSvFHcDWukg.png" /><figcaption>Results of testing 200 altered fraudulent transactions</figcaption></figure><p>Results are similar for logistic regression and even ensembles, such as randomForests. This bleak outcome stems from the fact that the most important feature for the models represents whether in a given transaction the amount equals the original balance of the origin account. In consequence, even a minuscule difference in amount and oldbalanceOrg makes the condition of maximum_transfer false. Simply put, the models are too dependent on an easier to modify feature.</p><p>Lets review the issue at hand: from what we’ve seen in the <a href="https://medium.com/@jd.bermeo251/fraud-detection-give-me-reasons-5aab08580211">previous article of the series</a>, it is possible to train almost perfect models that can detect fraud, however, performance of these models is highly susceptible to minimal changes in the most important features (keep in mind that here we are only describing in detail one of such features, maximum_transfer). Clearly, the objective of the client is not to have a working model for only a short period of time. A method that could work is developing new models once many undetected frauds go by, yet such reactive methodology is doomed if all models can be made easily fallible, as we have seen here. In addition, following Juan’s discussion on the previous article, this approach could lead to an ultimately ineffective cat and mouse game. A better approach would be to look for more robust models, flexible enough to accommodate for variation on the attackers modus operandi.</p><p>Following the previous train of thought we tested four different ideas:</p><ol><li><strong>Changing models</strong>. Well use different, slightly more complex models that still include the feature maximum_transfer, but that we hope do not rely too much on it, as in models that include feature subsampling like randomForest or XGBoost. Or perhaps, models that constrain the parameters dependent on that feature (regularized logistic regression).</li><li><strong>No maximum_transfer</strong>.<strong> </strong>A very simple model with only maximum_transfer is no longer possible. We try to develop models without the dependency on the maximum_transfer feature by removing it, and replacing it for its original feature, amount. This also implies adding features to the models.</li><li><strong>Making maximum_transfer more robust</strong>.<strong> </strong>Change the definition of our star feature such that it becomes more robust, or replace it by a similar feature that closely relates to it.</li><li><strong>Fraudster shift simulation in train</strong>.<strong> </strong>Simulate changes in behavior of attackers in the training data, as a sort of data augmentation.</li></ol><p><strong>Approach 1: Changing models</strong></p><p>When training a simple decision tree on this data, it turns out that the maximum amount is always selected for the first split, this of course has the issue that a change to maximum_transfer completely derails what comes next on the tree. Even for for logistic regression a similar issue persists; the weight assigned to the coefficient accompanying the maximum amount term is too big, and a change in maximum_transfer affects heavily the estimation of fraud probability.</p><p>One such approach are ensemble models that use subsampling of features. Such as random forest. A random forest is a group of decision tress, each trained with a different, independant subset of data. A single tree can receive a subset of the datapoints (subsampling/bagging), and also, a subset of the features of the model (feature subsampling). The last one is key to reduce the strong dependency of the model on a single feature. Applied in the case of fraud, one tree, say A, of the forest receives the maximum_transfer feature for training while another, say B, does not. Tree B will not have any information from the maximum transfer features and is expected to form completely different patterns to determine whether a transaction is fraudulent or legitimate. This multiplicity in ways to arrive at the answer gives random forests some resilience to changes in features.</p><p>However, the results defy the expectations. We tested a group of fraudulent transactions that only had the maximum_transfer feature altered, of course, from TRUE to FALSE. When these observations were presented to the random forest, the true positive rate (fraud detection performance) dropped close to 0. From this follows that feature subsampling and ensembles are clearly not enough to make the predictions robust.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*xsWoZYhB7xvVxr3JZvqusA.png" /><figcaption>Results for random forest.</figcaption></figure><p><strong>Approach 2: No maximum_transfer</strong></p><p>Another strategy we can try to ameliorate the problem with the maximum_transfer is to remove the feature completely. This feature was engineered to encase a slightly complex pattern into a single, easily explainable feature. However, we can just remove the feature and trade simpler explanatory models, for slightly more complex alternatives that keep superb levels of predictive accuracy, that is, if the data remains unchanged. Such was the situation we found when training our first models with little feature engineering. Nonetheless, this idea ignores the underlying problem; the distribution of data for fraudulent transactions could be purposefully altered. These complex models may as well be learning the same boundary determined by maximum_transfer through the variables used to create it: the old balance of the origin account and the amount involved in the transaction.</p><p>After a test where <strong>we reduced the amount of fraudulent transactions in the test by different values ranging from 1 to 10M</strong>, we found that for various models, relatively slight reductions in amount (which imply changes in balances) effectively <strong>reduce the AUC from 0.99 to around 0.75</strong>. Some models, such as decision trees, could still handle changes in amount of less than 1k. However, an attacker that just got access to an account with more than 10M in balance would gladly reduce those 1k from the amount, given that the alternative is being detected and transferring nothing. On the chart we plot the total money lost in the test set due to fraud, which construction can be seen in the repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b-_b1H9A8krDh2hebjvM_w.png" /><figcaption>Performance of conditional inference tree with reductions in amount fro fraudulent transactions</figcaption></figure><p><strong>Approach 3: Making maximum_transfer more robust</strong></p><p>What if we still want to retain the explicability provided by the maximum transfer feature while having a model robust to changes in modus operandi of the attackers?. Accordingly, we could use an attribute that is similar, or represents the maximum transfer, or we could even modify the definition of what it means for a transaction to fulfill the condition of maximum transfer. Certainly, the notorious downside of the boolean feature maximum transfer is that only a minimum change in amount is enough to change the value of the feature. If we consider the actions of a fraudster, it makes sense to think that they will try to reduce the amount they can extract to a minimum, in other words, they would try to extract an amount as close as possible to the maximum amount without making it exactly the maximum transfer amount possible. This small change can still be quantified. Thus, we can construct a feature that encodes the difference of the amount extracted to the maximum amount allowed. There are of course various ways to encode this relationship.</p><p>One of these ways that encodes the “how close to maximum allowed transfer” is the percentage of the amount extracted with respect to the maximum transfer value allowed. However, this attribute has a few problems; as the majority of transactions for some reason have greater amounts than the oldbalance of the origin, the relevant values of percentage less than one are opacated. However, a small modification to the feature is possible: what if we send all the values grater than 1 to 0?. It is clear that fraud is unplausible for values greater than 1 or values where the amount is 0. We should stress that here we are making the assumption that this wont happen in the future, and we have yet to confirm this with the business.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ee4c2O1Dqfg5sTvQIgSHsg.png" /><figcaption>Chart of proportion of legitimate/fraudulent transactions by values of perc_max, could be interpreted as the conditional probability P(fraud|perc_max).</figcaption></figure><p>Another issue is that again we have the problem that when a given transaction the percentage is not exactly one, then the model will predict the transaction as legitimate. For a tree, we’ll have the same behavior as when the feature encoding the maximum_amount was binary. Test with a logistic regression indicates that even if the attribute is numeric, the feature is behaving as if it were only the maximum amount boolean.</p><p>Let us shift focus to logistic regression. First, without the perc_max feature. Despite keeping AUC extremely high, relatively small reductions in amount of around 10k for new test observations hit the model hard, reducing the true positive rate to only 57%. Again, this indicates that the threshold for classification is varying based on the amount reduced, this could be an issue if we need hard classes, because we don’t know the amount that is gonna be reduced beforehand in order to set the detection threshold properly. In production, a scheme that only cares about ranking — say, give me the 100 more likely fraudulent transactions — might work, however, hard classification of classes, with specific thresholds complicates.</p><p>To get details on the features and preprocessing used for this logistic model, please refer to the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kDe9y_2ytqIodS8pMZt6KA.png" /><figcaption>Performance of logistic regression without perc_max feature.</figcaption></figure><p>Now, with perc_maxincluded, AUC and TPR are more stable until values of 10k, where it behaves pretty similar to what we had before, on the downside, this models turns out to be worse when the amount that the fraudster is willing to give is grater than 1M. This in an issue if we try to protect huge accounts. We also have the issue that the TPR abruptly falls after some amount, indicating that the threshold changes with the amount that the fraudster is willing to sacrifice. For this experiments, the model without the feature encoding percentage of maximum protects better against fraud cases, a result that could potentially ease the processing of fraud claims.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P2PocH2JLWb6K-2iVtTLAA.png" /></figure><p>A slightly similar, yet different approach, is to use the difference of the amount to the maximum transfer allowed, on top, we can take any function of the difference, as for example, the difference squared, that could even make more sense to quantify the distance in amount to the maximum transfer allowed. This follows from the observation that for high balance account, it is even more unlikely that these accounts will extract all of their money, and also its the case that fraudsters have more wiggle room to reduce the amount that they are going to extract. Therefore, we can penalize larger differences in amount harder by squaring the difference. We did not test with these alternatives using the squared distance but please feel free to fork our project and try it by yourself.</p><p>Heretofore we used numeric attributes to encode the concept of being close to maximum transfer, however, we still have lost the simplicity of the first attribute maximum_transfer, a simple yet powerful indicator of fraud. To accommodate for the numerical features, models such as trees have to be a little more complex. Interpretation of results also gets some degree of complexity added, from the having or not having the condition, to the how much difference. One option that may work to keep the original boolean feature is altering the definition of the maximum percentage, such that it becomes broad, we can even use discretization of the numeric attributes that we just tested to generate this modified version of `maximum_amount`. For example we can chose certain threshold on the feature of maximum percentage, max_perc. Of course the choice of this threshold requires careful thought. We can even devise a scheme with varying thresholds to binarize the variable depending on the amount; for small amounts the threshold could be close to 1, while for large amounts, the maximum percentage threshold can increase, as to accommodate more room that an attacker has when tampering with large accounts.</p><p><strong>Approach 4: Fraudster shift simulation in train</strong></p><p>Approaches until now have a small caveat: during training, the model does not “experience” any of the changes that happen later in the test data. After model deployment, there will likely be a change in the expected behavior of attackers when they notice that their transactions are being blocked by the system, and this change in behavior is not being represented in the training data. At the beginning, an attacker might not know what features the model is looking at, however, it would be imprudent to assume that the model can be kept secret from attackers, especially with the original model involving maximum_transfer being this simple. Soon enough attackers will easily notice that the critical factor for detection of their illegitimate endeavors is if they take all the money from the account.</p><p>We could then think of letting the model see examples of future fraudulent behavior, as current models have the problem of overfitting in a sense, they will only account for training examples that transfer the maximum possible. It makes sense to include different examples in the model creation, that present frauds that do not extract the maximum amount, as a sort of data augmentation. However, we don&#39;t know what will be the distribution of change in amount that attackers may try, still, we can start with simple ones, lets assume that the distribution of the amount that an attacker is willing to give up is a uniform distribution between some number k and the maximum amount. This means that random amounts are reduced for fraudulent training data.</p><p>Under this approach, the results seem promising: the models have high AUC under different amount reductions and also maintain relatively constant TPR and TNR even when the amount is greatly reduced, this means that even attackers willing to give a lot of their bounty will be detected by the model. The results are even more encouraging considering that we tested with a logistic regression, that under the previous approaches, such as attribute changes behaved poorly, reducing the TPR to values close to 57% depending on the amount reduction, a situation that no longer occurs in this model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8v2c4bevAcr3Y-Cq00izQw.png" /></figure><p>There are nonetheless some issues with this approach. First, the model assumes certain distributions of change in amount that attackers may take, yet the real distribution of change in amount is unknown and will be until the attackers start changing their modus operandi. To test, we could try different distributions for the change in amount in the test set, to see what works. Second, the model still has some issues regarding interpretability, despite being a simple logistic regression. For the data augmentation shown, no engineered features such as perc_max were added, maybe by using these features the interpretation could be made easier while retaining high performance metrics. Keep in mind that we also only used logistic regression, it is left to see whether other models such as decision tress behave nicely with data augmentation. Regardless, this is the best approach we found in our exploration, as it gives high performance and small amounts of money lost.</p><h3>What have we done?</h3><p>Evaluating all the different approaches was an interesting journey. In conclusion, we observe that data augmentation in train goes a long way maintaining the model robust, even though it is not the definitive solution to adversarial changes. However, it is interesting to see what possibilities we could have improving the robustness of models. Maybe, the data augmentation approach can even be combined with the others that we have seen in order to have robust models that still use easily explainable variables, an experiment that you could test.</p><p>We still have to think of the shortcomings and limitations of the different approaches:</p><p>We tried to anticipate the fraudsters taking into consideration just a single change in the modus operandi, one of changing a single variable (amount). Despite the fact that this change is a highly plausible one, the attackers have to their disposal many variables they can change or ways they could try to change the modus operandi, such as the original balance of the destination account. Further analysis needs to account for changes in other variables, maybe by reaching solutions similar to the ones we have proposed. In a wider analysis, maybe simulation approaches will not work as well when many variables change at once, yet this remains to be tested.</p><p>Another shortcoming of the proposed approaches is that the models are static, even though they consider future actions, the models do not change to accommodate for changes in pattern of fraudulent transactions. Of course, this implies a very different approach for the model building , considering that some sort of retraining or online training and evaluation need to be performed regularly, How would these models accommodate for change?. Sadly, these approaches are too ample to cover in this article, but we can think of analyzing these cases in a future article.</p><p>An interesting question related to the previous idea is how to actually detect changes in the fraudsters pattern, maybe evaluation of the performance of the model in production could be used; that is, if there are again many complaints of fraud over time, that could signify that the fraudsters are fooling the model. Nonetheless, there are different approaches that look for example at the distribution of data over time to determine whether the data has changed patterns and the model have to change.</p><p>Overall, we saw that despite some shortcomings, many approaches are available to solve an issue such as lack of robustness in machine learning models, and we have only skimmed the surface of the possibilities!. We hope that you can keep on experimenting on this dataset with innovative approaches that take the models (and fraudsters) to the limit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da20412ac1d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Science Journeys: Fraud Detection]]></title>
            <link>https://medium.com/@ccontreras.gamba/data-science-journeys-fraud-detection-4b6618b7fb82?source=rss-eacd96a382ae------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b6618b7fb82</guid>
            <category><![CDATA[fraud-detection]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[business-case]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[David Gamba]]></dc:creator>
            <pubDate>Mon, 21 Jan 2019 21:41:12 GMT</pubDate>
            <atom:updated>2019-03-04T22:11:14.021Z</atom:updated>
            <content:encoded><![CDATA[<p>There is a common chasm that we as Data Science practitioners working with companies face in virtually every project; how to go from a business problem, to a data science solution, or to data science product. This gap is somewhat obvious, yet elusive and easily overlooked, and it seems that this duality stems from the way that we start learning DS. Looking at most tutorials we have a initial dataset, and a specific goal with this dataset. The data and the problem definition are airtight. For example in the famous House Pricing regression data we have the task of predicting the price of the house based on numerous attributes, and the success of our model will be evaluated under some error metric, say logloss or something of the sort. From here on, we can use our expertise on ML to solve these problems.</p><p>However, note that these tasks are already stated under a ML context. In a real world setting, we do not have these immutable definitions for the problem. Usually we have something very different, a problem the client has, and expectation of something that will happen if such problem is solved, a business objective. Looking back at the housing problem we could ask: what is the real problem that whoever gave us this data was trying to solve?, maybe we are talking about a business that buys homes, improves them and sells these improved houses for a profit, and maybe their objective is to determine, based on data, which factors give more value to houses such that they focus on those to maximize their profits. Under this new knowledge, we see that only predicting the price of a house it’s hardly the end goal we should keep in mind. and we are facing a gap.</p><p>Amending the chasm between business objectives and data science objectives marks the difference between projects that end well and projects that don’t. The reason being that a DS solution that is not aligned with the business objectives, and does not attack directly the problem that the business has, it’s doomed to be little more than a failed DS project, no matter how good the data science/machine learning development is.</p><p>This small series of articles has the aim of giving a practical look to data science under the umbrella of a business use case. We want to explore with you how to go from business problem to data science product, and what considerations have to be accounted. This case is adapted and based on the data provided by Edgar Alonso Lopez-Rojas, Ahmad Elmir, and Stefan Axelsson In their paper <em>Paysim: A Financial Mobile Money Simulator for Fraud Detection</em>¹. the data can be directly downloaded through <a href="https://www.kaggle.com/ntnu-testimon/paysim1/home">Kaggle</a>.</p><h4>The story starts like this…</h4><p>Our client is a widely recognized mobile wallet company based on an undisclosed African country. This company handles around 6 million transactions a month, and they take seriously the protection of the customers assets stored in their virtual wallets, that is why fraudulent transactions is a serious concern for our client. Our client estimates that the proposed modus operandi of an attacker is simple: an attacker seizes control of the wallet of the victim and transfers money to another wallet, in a series of one or more fraudulent transactions, the money ends up being withdrawn, and effectively stolen. This situation occurs often enough that in a single month, the staggering amount of 1200M is lost to fraud.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SrdaTf4_RAfRYGuYeaaFwQ.png" /><figcaption>Effective withdrawals in fraudulent transactions.</figcaption></figure><p>Keeping this problem in mind, the client has come to us with two main concerns.</p><ul><li>They would like to automate the process of fraud detection, as the client has none for the moment. In their status quo, frauds are reported after they have been committed, and after some time, the reports are analyzed to see if the claim was a real fraud, a process that is struggling with the current amount of fraudulent claims. Based on the automatic flagging of fraud, the client wants to implement a process that could allow them to quickly review possible frauds, holding the transaction in the meantime, while an expert of decides whether to approve or cancel the pending transaction. Keeping in mind that the experts that review cases are scarce, it is paramount that the system does not flag too many legitimate transactions as fraud.</li><li>With a similar objective, their department of fraud analysis wants us to help them understand what factors characterize a fraudulent transaction, factors that would help them develop different measures or policies to preemptively reduce fraud.</li></ul><p>The client has given data describing transactions performed in their platform, which they think will reveal valuable information about the patterns for fraudulent and legitimate transactions.</p><p>This series is divided in (tentatively) three different articles, each one with a particular objective under the umbrella of the broad business case.</p><ol><li><strong>Give me reasons </strong>(<a href="https://medium.com/@jd.bermeo251/fraud-detection-give-me-reasons-5aab08580211">link here</a>), where we present the solution we obtained in tackling the client objectives. This means developing a model for automating fraud detection and explaining what may characterize a fraudulent or non fraudulent transaction. In addition we describe what actionable insights or policies can be derive from the analysis in terms of their objective, and alongside these insights, we evaluate how difficult is for an attacker to elude these new measures. Details about the different models and techniques used are provided as well. We also emphasize the reasons to keep in mind the objectives of the client and the business context whilst developing the models.</li><li><strong>Anticipating the fraudsters </strong>(<a href="https://medium.com/@ccontreras.gamba/fraud-detection-anticipating-the-fraudsters-da20412ac1d2">link here</a>) follows the story from the first chapter, and starts from the notion that fraudsters will react to the implementation of the model, and such new behavior will impact the performance of the model. So, how can we develop a more robust model?</li><li><strong>What to do with the model?</strong>, (in progress) where we discuss different ways to deploy the models developed in the first chapter, contingent upon the client requirements and existing technological infrastructure.</li></ol><p>Despite that these articles are by no means an extensive picture of all the challenges that a real world mobile fraud detection case would encompass, they cover a good portion of the issues, and may prove useful for one who looks to integrate business and technical in their problem-solving toolbox.</p><p>As final note of the introduction, this work is a collaboration between <a href="https://medium.com/u/9f51834b531d">Juan Diego Bermeo</a> and I, so some of the articles will be posted from his account and some from mine. Regardless, you can find in this article the links to the rest.</p><h4>A little bit of data context</h4><p>For those of you who are not familiarized with the data, we would like to introduce first the context and data that we are using through this case. The dataset represents transactions during a one month period of a mobile money service or electronic wallet in a non-disclosed African country. We say represents, because in reality the dataset comes from a simulation, called <em>Paysim</em>, which nonetheless has the intent to be representative of real transactions. In addition to the paper mentioned some paragraphs back, we also used Edgar’s masters dissertation thesis document² . We will use information from this paper as proxy of domain knowledge in a normal business context, which is essential to understand the appropriateness and efficacy of the data products built.</p><p>For our practical purpose, we will assume the data as real, and try to establish a setting as close to real world practice as possible.</p><p>Now onto the data, we have a file with approximately 6 million records corresponding to a month of data capture. Each record characterizes a single transaction, including details from the accounts of origin and destination, together with their respective balances. All records are labelled as either a fraud or a legitimate transaction. In addition, these transactions can occur between two types of roles in the system, customers and merchants, think of customers as ordinary people using the platform and merchants as ATMs that allow to deposit or withdraw money. Let us describe briefly each of the fields that we will encounter in the main datafile.</p><p><strong>step</strong> describes the hour of the month, starts at 1and goes up to 720, that corresponds to 30 days.</p><p><strong>type</strong> denotes the five varieties of transactions that occur in the mobile platform, these are CASH_OUT, CASH_IN, DEBIT, PAYMENT, TRANSFER. Each of these types warrants its own explanation, citing directly the author of the data:</p><ul><li>CASH-IN is the process of increasing the balance of account by paying in cash to a merchant, like doing a deposit to the account.</li><li>CASH-OUT is the opposite process of CASH-IN, it means to withdraw cash from a merchant which decreases the balance of the account.</li><li>DEBIT is similar process than CASH-OUT and involves sending the money from the mobile money service to a bank account.</li><li>PAYMENT is the process of paying for goods or services to merchants which decreases the balance of the account and increases the balance of the receiver.</li><li>TRANSFER is the process of sending money to another user of the service through the mobile money platform.</li></ul><p><strong>amount </strong>is the money transferred in the transaction, the amount goes from a <strong>origin</strong> account to a <strong>destination</strong> account.</p><p><strong>nameOrig</strong> identifies the account originating the transaction. Ids are prefixed by a C or a M for customers and merchants respectively.</p><p><strong>oldbalanceOrg</strong> is the balance of the origin account before the transaction.</p><p><strong>newbalanceOrig</strong> is the balance of the origin account after the transaction.</p><p>In the same line, the data also contains the fields <strong>nameDest</strong>, <strong>oldbalanceDest</strong> and <strong>newbalanceDest.</strong></p><p><strong>isFraud</strong> is the indicator of the illegal activity, 1 for fraudulent and 0 for legitimate transaction. Only 0.12%, or 1 in 833 transactions are identified as fraud, a scarcity that brings additional complexity to this case.</p><p><strong>isFlaggedFraud</strong> marks whether a transaction tries to move an amount superior to 200.000, which is a policy implemented by the client to identify and discourage fraud. However, there is no guarantee that such flagging of transaction works.</p><p>[1] Lopez-Rojas, Edgar Alonso &amp; Elmir, Ahmad &amp; Axelsson, Stefan. (2016). PAYSIM: A FINANCIAL MOBILE MONEY SIMULATOR FOR FRAUD DETECTION. <a href="https://www.researchgate.net/publication/313138956_PAYSIM_A_FINANCIAL_MOBILE_MONEY_SIMULATOR_FOR_FRAUD_DETECTION">link here</a></p><p>[2]Lopez-Rojas, E. A. (2016). Applying Simulation to the Problem of Detecting Financial Fraud (PhD dissertation). Karlskrona. Retrieved from <a href="http://urn.kb.se/resolve?urn=urn:nbn:se:bth-12932">http://urn.kb.se/resolve?urn=urn:nbn:se:bth-12932</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b6618b7fb82" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>