<?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 Stefano Cosentino on Medium]]></title>
        <description><![CDATA[Stories by Stefano Cosentino on Medium]]></description>
        <link>https://medium.com/@stefano-cosentino?source=rss-a1bfbff06318------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*sMNxk2k-iUPMrvxdwwx1dg.jpeg</url>
            <title>Stories by Stefano Cosentino on Medium</title>
            <link>https://medium.com/@stefano-cosentino?source=rss-a1bfbff06318------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 22:10:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@stefano-cosentino/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[Tension in tennis (it’s not what you think)]]></title>
            <link>https://stefano-cosentino.medium.com/tension-in-tennis-its-not-what-you-think-51b7037201e6?source=rss-a1bfbff06318------2</link>
            <guid isPermaLink="false">https://medium.com/p/51b7037201e6</guid>
            <category><![CDATA[tennis-string]]></category>
            <category><![CDATA[tennis]]></category>
            <category><![CDATA[tension]]></category>
            <dc:creator><![CDATA[Stefano Cosentino]]></dc:creator>
            <pubDate>Sun, 14 Jul 2024 18:38:39 GMT</pubDate>
            <atom:updated>2024-07-14T22:19:01.683Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B8aXNGLnt0uVU8NByfOjOA.png" /></figure><p>I mean the one on my racket strings. Not the pre-match jitters. <strong>Does it matter?</strong> Some days it’s everything, other days, it feels like nothing.</p><p>Curious about these shifts, I gathered some data. The findings? Completely baffling to me.</p><h3>Key results:</h3><ul><li><strong>Quick Changes:</strong> Just an hour into playing, the string tension can drop by 3–4 lbs, or 7%. So if I start a match with my racket strung at 54 lbs, I’m playing at 50 lbs before second set 🤯</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VT5SFY7GaVwjbhnIzlPrfA.png" /></figure><ul><li><strong>Asymptote at -6 lbs</strong>: After 5 hours of play, (about 3 sessions?) tension levels off at ~6 lbs (10–12%) below strung-at tension 🤷</li><li>This is true for rackets strung at 50 and at 54 lbs. Higher strung-at tensions lose tension slightly faster (exp decay rate is 5% larger)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*e4__AgviarUI-w9t09NdKQ.png" /></figure><h3><strong>So What Should You Do?</strong></h3><p>Whatever you want, duh. But if you set your racket to 50 lbs when you strung it few weeks ago, your ideal hitting is more like 44 lbs today. So:</p><ul><li><strong>Don’t sweat the small stuff:</strong> it’s not worth fussing over a pound or two.</li><li><strong>Give it time:</strong> After about a week of hitting, the tension doesn’t fluctuate much.</li></ul><h3><strong>How I Do It</strong></h3><ul><li><strong>Setup:</strong> I string my rackets with a Gamma <a href="https://www.gammasports.com/products/gamma-x-st">X-Stringer</a> and measure the tension with the <a href="https://appmaker.se/home/racquettune/">racquetTune</a> app on my iPhone 14, making sure conditions are quiet at home for consistency.</li><li><strong>Gear:</strong> I’m using two HEAD Boom MP 2023 rackets strung with Kirschbaum <a href="https://kirschbaumusa.com/products/orange-reel">Orange Super Smash</a> 1.25 strings (coPoly).</li></ul><p><strong>Is My Method Solid?</strong></p><p>Yep, it’s pretty tight. The tension readings I get after stringing are always close to the mark, within about 0.4 lbs, and they’re consistent each time.</p><p><strong>About My Game</strong></p><p>I play at a 3.5 NTRP level. I have a decent amount of topspin but don’t hit super hard. Each hour of my recorded play is typically a mix of rallies, points, and serving, all adjusted for singles play.</p><p><strong>Plan for More Testing</strong></p><p>I’m not done yet. This analysis is grossly undersampled for my likings. I plan to collect more data under different playing conditions to see what else affects string tension. I already collected more data than what I showed but some runs had very different conditions (eg different strings, type of play, rackets, etc). Here is more of it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*F7SV-QGkQe3XQax-BNUCyQ.png" /></figure><p><strong>Bottom Line</strong></p><p>For my setup, tension drops faster than I expected, but it also evens out fairly quickly. Understanding this helps me manage my expectations and maybe keep me from tweaking my strings too often (… naaah).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51b7037201e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Science for Autonomous Driving]]></title>
            <link>https://stefano-cosentino.medium.com/data-science-for-autonomous-driving-a1bf28208946?source=rss-a1bfbff06318------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1bf28208946</guid>
            <category><![CDATA[making-sense-of-big-data]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[autonomous-vehicles]]></category>
            <category><![CDATA[autonomous-cars]]></category>
            <dc:creator><![CDATA[Stefano Cosentino]]></dc:creator>
            <pubDate>Mon, 09 Nov 2020 18:54:54 GMT</pubDate>
            <atom:updated>2020-11-11T02:25:48.536Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qBz50aY0TTI8Fdv25RsYOg.jpeg" /><figcaption>image created through transfer learning (ostagram.me)</figcaption></figure><h4><a href="https://towardsdatascience.com/tagged/making-sense-of-big-data">Making Sense of Big Data</a></h4><h3><strong>Real Data Science for Autonomous Driving</strong></h3><h4>My journey to define the role of data science in self-driving cars</h4><p>Bosch and Mercedes came together in <a href="https://techcrunch.com/2017/04/04/daimler-and-bosch-fully-autonomous-cars-within-5-years/">2017</a> to build autonomous driving (AD) technology. Two large, successful companies that knew how to build cars were now combining their efforts. This sounded really, really exciting.</p><p>I joined Bosch that year as the first “Data Scientist” hired within this group. At the time, I was uncertain what my role as data scientist would mean in practice, but I had one optimistic and one pessimistic <em>guess</em>: I could be contributing to the core AI algorithms (“functional coding”), or I’d only be doing data analytics.</p><p>Fast forward two years and I am leading the Data Science team, which has now grown to 10 people, and I can attest to how naive-sounding both scenarios were.</p><p>Here are a few things I learned in the process of building this team and some of the projects we worked on.</p><p><strong>1. DS models do not run AD vehicles</strong></p><p>There is a we-gotta-sit-down-son conversion I’ve had to have with many newly-hired data scientists in my team. Yes, object prediction is very interesting and I know Coursera shows how to do this end-to-end. But I also know that, in a project with hundreds of experts, developing core features for AD is not “general DS” territory. There are teams like Perception and Fusion that have tinkered with these issues for years. Here we have PhDs with 5 years of experience alone on a topic as tiny as parked-car detection (shout out to Marc! Your work is valued!). Everything that runs in the car needs to be designed with this purpose in mind, which means: it will probably need to be written in something like C++, with limited data rates, and direct memory allocation via GPU eigenvectors. Have you worked with GPU eigenvectors? I doubt it, I just made it up. Point is: functional development for AD often requires a lot of domain knowledge and software development skills that <em>general</em> Data Scientists are not trained on; nor they’d be particularly interested in.</p><blockquote><em>So, what can DS do for AD?</em></blockquote><p><strong>2. AD vehicles do not run without DS models</strong></p><p>There is a self-definition process our team went through. We started drawing a line between algos that live <em>inside</em> the car, which is heavily domain and implementation specific, and algos that be applied after data ingest. Eventually, the question became “<strong>what are the missing data-driven approaches that can support functional teams for AD?</strong>”. We took that question and toured it around in meetings with team leads, management, and developers. We were now asking a slightly different question.<br><em>From</em>: how can we apply ML to solve your problem?<br><em>To</em>: what are the bounds around your problem space?<br>Soon after, requests started coming in. Projects were discussed and two years later I am convinced that our DS team is just as essential as any others to the success of this project.</p><p>In this time span we have set up a <em>data center</em>, which provides on-demand and routine data analyses to developers and management. We have developed rule-based and probabilistic <em>root cause analysis</em> solutions to support the Forensic team. We have created a <em>feature bank </em>that is enabling various ML projects. One is <em>scenario identification</em>, which we use for KPI estimation, verification &amp; validation, as well as issue tracking. Another use of the <em>feature bank </em>is for anomaly detection.</p><p>— &gt; All of these projects will be covered in greater detail at my talk at ODSC Boston in April 2020.</p><p><strong>3. In the end, it’s not about models.</strong></p><p>Talk to anyone in this space and you’ll hear that AD is <em>not</em> a solved problem. In an environment that learns constantly and changes fast, data scientists need to do the same. Skills that did not come up in your interview are going to make a difference to your productivity. We are using dockers, we compile, we use various robotic frameworks, and we have had to make python binders for C++. At some point we needed to make changes to the frontend of your KPI dashboard, restart your jobs on Kubernetes, troubleshoot Cuda drivers for your GPU (that, I <em>didn’t</em> make it up); and so we learnt all those skills. This is what made us iterate fast and keep up with the project. On the other hand, we also have “core scientists” in our project. They’ll spend at least few weeks on analyzing any issue, and are using the same tools they became familiar in grad school. They provide excellent reports and are invaluable, but it’s the former type of DS that helped defining our identity.</p><p>Ultimately, whether we are talking about autonomous driving or advertising, the job of a data scientist is to make themselves indispensable.</p><p>The end.</p><p><em>Disclaimer</em>: The views and opinions expressed in this article are those of the authors and do not necessarily reflect the official policy or position of any company reported here.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1bf28208946" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deep Bayesian Neural Networks.]]></title>
            <link>https://stefano-cosentino.medium.com/deep-bayesian-neural-networks-952763a9537?source=rss-a1bfbff06318------2</link>
            <guid isPermaLink="false">https://medium.com/p/952763a9537</guid>
            <category><![CDATA[bayesian-machine-learning]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[bayesian]]></category>
            <category><![CDATA[mc-dropout]]></category>
            <category><![CDATA[variational-inference]]></category>
            <dc:creator><![CDATA[Stefano Cosentino]]></dc:creator>
            <pubDate>Sun, 11 Mar 2018 20:37:48 GMT</pubDate>
            <atom:updated>2020-03-05T23:48:03.813Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kT6IDMYXLoH6brvBIzTdNQ.jpeg" /></figure><p><strong>ways and whys.</strong></p><p>Conventional neural networks aren’t well designed to model the <strong>uncertainty</strong> associated with the predictions they make. For that, one way is to go full <em>Bayesian</em>.</p><p>Here’s my take on three approaches.</p><ol><li>Approximating the integral with MCMC</li><li>Using black-box variational inference (with edward)</li><li>Using MC dropout</li></ol><p><em>But first. What are we trying to do?</em><br>Any <em>deep</em> network has parameters, often in the form of weights (w_1, w_2, …) and biases (b_1,b_2, …). The conventional (non-Bayesian) way is to learn only the optimal values via maximum likelihood estimation. These values are scalars, like w_1 = 0.8 or b_1 = 3.1.<br>On the other hand, a <em>Bayesian</em> approach is interested in the <strong>distributions</strong> associated with each parameter. For instance, the two parameters above might be described by these two Gaussian curves after a trained Bayesian network has converged.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zCgkD5l7Tyzrch13ndWOfg.png" /><figcaption>Representation of two parameters (w_1 and b_1)obtained after training a Bayesian net (which will lead to parameter distributions shown by the Gaussian curves) or a conventional net (where parameters are indicated by single lines). Note, a deep neural networks has thousands if not millions of these parameters!</figcaption></figure><p>Having a distribution instead of a single value is a powerful thing. For one, it becomes possible to <em>sample</em> from a distribution <em>many</em> <em>many</em> times and see how this affects the predictions of the model. If it gives consistent predictions, sampling after sampling, then the net is said to be “confident” about its predictions.</p><p><em>The pain point<br></em>Estimating those distributions, of course, is the hard part. These are generally referred to as <em>posterior densities</em>, and are estimated using the Bayes rule.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*zMq4VYW4P-OVkOH_IgFF4A.gif" /><figcaption>Bayes rule. <strong><em>x</em></strong> and <strong><em>y</em></strong> are input and output. The integral in the denominator requires marginalization over <strong>all</strong> possible values that the parameters “<strong>w</strong><em>” </em>can assume in the model — this become quickly too hard to compute.</figcaption></figure><p>The problem is the denominator — also known as <em>model evidence</em>. It requires integrating over all possible values of the parameters (i.e., all weights and biases space), and it is often not doable in practice.</p><p>Instead, pseudo-numerical approaches can be chosen where the solution to those integrals is approximated: option 1, 2 and 3 mentioned before.</p><p><strong>1. Approximating integrals with MCMC.</strong></p><p>Since computing exact integrals for the Bayes rule is hard, MCMC (Markov Chain Monte Carlo) is used to approximate these. The idea behind MCMC is really handsome and I’d suggest this uber-famous <a href="http://twiecki.github.io/blog/2015/11/10/mcmc-sampling/">blogpost</a> to get code and an insight behind the approach. Maths aside, however, this method is the slowest and the least sexy of the three options.</p><p><em>Pros</em>: In theory MCMC eventually leads to great results, with approximations that resemble the real thing (posteriors).<br><em>Cons</em>: In practice it takes a long time to converge, when it ever does.</p><p><strong>2. Using black-box variational inference</strong> (eg., using edward).</p><p><strong>Variational inference</strong> is an approach to estimate a density function by choosing a distribution we know (eg. Gaussian) and progressively changing its parameters until it looks like the one we want to compute, the <em>posterior</em>. Changing parameters no longer requires mad calculus; it’s an optimization process, and derivatives are usually easier to estimate than integrals. This “made-up” distribution we are optimizing is called <strong>variational distribution</strong>. There is some really elegant math that shows how choosing the optimal parameters for the variational distribution is equivalent to maximizing a lower bound, and definitely worth checking it <a href="https://xyang35.github.io/2017/04/14/variational-lower-bound/">up</a> at some point. But if you want to know how to get it to work, and leave the theory aside for now, I have prepared a short tutorial for an 8-category classification task using <a href="http://edwardlib.org/">edward</a>.</p><pre># Define:<br>#  ~ K number of classes, e.g. 8<br>#  ~ D size of input, e.g. 10 * 40<br>#  ~ BATCH_SIZE, N_TRAIN, N_TEST, STEPS (how many training steps)</pre><pre># Tensorflow Placeholders:<br>w = Normal(loc=tf.zeros([D, K]), scale=tf.ones([D, K]))<br>b = Normal(loc=tf.zeros(K),      scale=tf.ones(K))<br>x = tf.placeholder(tf.float32, [<strong>None</strong>, D])<br>y = Categorical(tf.matmul(x,w)+b)<br>y_ph = tf.placeholder(tf.int32, [BATCH_SIZE]) # For the labels</pre><p>Setting up the variational distribution. We’ll choose Gaussians. As for inference technique, we pick one based on KL divergence. The actual estimation of the KL is carried out estimating the ELBO via a ‘black-box’ variational approach (if you care about what it means &gt;&gt; <a href="http://edwardlib.org/api/ed/KLqp">read this</a>).</p><pre>qw = Normal(loc=tf.Variable(tf.random_normal([D, K])),<br>        scale=tf.nn.softplus(tf.Variable(tf.random_normal([D, K]))))<br>qb = Normal(loc=tf.Variable(tf.random_normal([K])),<br>        scale=tf.nn.softplus(tf.Variable(tf.random_normal([K]))))<br><br>inference = ed.KLqp({w: qw, b: qb}, data={y: y_ph})<br><br>inference.initialize(n_iter=STEPS, n_print=100, scale={y: N_TRAIN / BATCH_SIZE})</pre><p>Model has been defined, we’re now ready to start a <em>tf</em> session and train.</p><pre>sess = tf.InteractiveSession()<br>tf.global_variables_initializer().run()<br><br>train_data_generator = generator(train_data, BATCH_SIZE)<br>train_labs_generator = generator(train_labels, BATCH_SIZE)<br><strong>for </strong>_ <strong>in </strong>range(inference.n_iter):<br>    X_batch = next(train_data_generator)<br>    Y_batch = next(train_labs_generator)<br>    info_dict = inference.update(feed_dict={x: X_batch, y_ph: Y_batch})<br>    inference.print_progress(info_dict)</pre><p>One can now <em>sample</em> these distributions (qw for the weights, and qb for the biases) and look at the spread around each prediction, which indicates <strong>model uncertainty</strong>.</p><pre>prob_lst, samples, w_samples, b_samples = [], [], [], []<br><strong>for </strong>_ <strong>in </strong>range(1000):<br>    w_samp = qw.sample()<br>    b_samp = qb.sample()<br>    w_samples.append(w_samp)<br>    b_samples.append(b_samp)<br>    <br>    # Probability of each class for each sample.<br>    prob = tf.nn.softmax(tf.matmul( X_test, w_samp ) + b_samp)<br>    prob_lst.append(prob.eval())<br>    sample = tf.concat([tf.reshape(w_samp,[-1]),b_samp],0)<br>    samples.append(sample.eval())</pre><p>You can play with prob_lst and samples for this. In conclusion:</p><p><em>Pros</em>: it is faster than plain MCMC, and libraries like edward help getting your Bayesian net up and running in minutes.</p><p><em>Cons</em>: it might get slow for very deep Bayesian net, and performance isn’t always guaranteed to be optimal.</p><p><strong>3. Using MC dropout.</strong></p><p>MC dropout is a recent theoretical <a href="https://arxiv.org/abs/1506.02142">finding</a> that provides a Bayesian interpretation of the regularization technique known as “dropout”. The reasoning is a little as follows. Variational inference is a <em>Bayesian </em>approach to estimate posteriors using an arbitrary distribution, the “variational distribution” introduced earlier; the <em>dropout</em>, instead, is a form of regularization for neural networks where neurons are randomly turned <em>on</em> or <em>off</em> during training to prevent the network to depend on any specific neuron. And here is the key idea of <strong>MC dropout</strong>: dropout could be used to perform variational inference where the variational distribution is from a Bernoulli distribution (where the states are “on” and “off”). “MC” refers to the sampling of the dropout, which happens in a ‘Monte Carlo’ style.<br>In practice, <em>turning a conventional network into a Bayesian one via MC dropout can be as simple as using dropout for every layer during training AS WELL AS testing</em>; this is equivalent to sampling from a Bernoulli distribution and provides a measure of model’s certainty (consistency of predictions across sampling). It is also possible to experiment with <a href="https://arxiv.org/abs/1611.01639">other</a> variational distributions.</p><p><em>Pros</em>: It is easy to turn an existing deep net into a Bayesian one. it is faster than other techniques, and does not require an inference framework.</p><p><em>Cons</em>: Of course, sampling at test time might be too expensive for computationally-demanding (eg real time) applications.</p><p><em>Again, what’s the big deal?</em><br>Despite all, many researchers are still not convinced that going Bayesian is worth the hassle. Let me take one more shot at this. I work in the autonomous vehicle sector, so the following is an example close to my heart. Suppose one is driving a brand new car with the latest and greatest autopilot feature, when an unidentified objects pops in front of the driver. In fact,let’s make this example <em>unlikely</em> but entirely <em>possible</em> by saying that the unidentified object is this odd <a href="https://www.terrafugia.com/reserve-now/">flying-car</a> (which is going to be for sale soon and yes, so you might share the road with it one day). A computer vision algorithm that has never been trained to overtake such thing, and has only seen planes up in the sky, might be thinking that the plane must be far away. <br><em>What could happen? </em><br>A conventional network might <strong>over-confidently</strong> <strong>misjudge</strong> the position of the flying-car, and do the wrong thing, while a Bayesian network has access to its uncertainty and would suggest to slow down.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/642/1*4iBqE4leKeVaJyjyDu-3wQ.png" /><figcaption>An real-case example of conventional Vs Bayesian approach in neural networks with similar architectures (from some of my previous working building phoneme classifiers). The conventional approach provides only the softmax probability with every prediction (in this case, predictions of the phoneme being /EE/, /E/ or /S/) and is represented by the vertical black lines. On the other hand, the Bayesian approach provides certainty estimates in the “spreads” around the softmax values, which are represented by the Gaussian curves. For this particular example, the models were trained on a number of phonemes but <strong>not</strong> on the phoneme being presented at test time (‘/h/’), therefore there is no correct answer the models can give. Note, however, how the Bayesian approach expresses high levels of uncertainty with this prediction, whereas the conventional approach show over-confidence about the prediction of phoneme ‘/S/’ being correct.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=952763a9537" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From another Postdoc to Autonomous Cars]]></title>
            <link>https://stefano-cosentino.medium.com/from-another-postdoc-to-autonomous-cars-381d7d8dfb63?source=rss-a1bfbff06318------2</link>
            <guid isPermaLink="false">https://medium.com/p/381d7d8dfb63</guid>
            <category><![CDATA[silicon-valley]]></category>
            <category><![CDATA[postdoc]]></category>
            <category><![CDATA[job-hunting]]></category>
            <category><![CDATA[career-change]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Stefano Cosentino]]></dc:creator>
            <pubDate>Tue, 30 Jan 2018 16:40:04 GMT</pubDate>
            <atom:updated>2018-02-09T13:22:50.404Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u3botWVe5JiHslqSyLh4ag.png" /></figure><p>I like to believe I wasn’t the typical academic “misfit”. I had published consistently (2 s.d. above average already after my PhD), I had given my own lectures, and was lucky enough to have worked with top scientists in the field for 8 years straight. <br>Sure, I still felt stupid most of the times, but this isn’t unusual either for an academic.</p><p>I left academia because I aspired to have three things it couldn’t provide.</p><ul><li>I wanted to work on a different topic, based on machine learning and AI.</li><li>I wanted to have more reach, building something that thousands if not millions of people would want to use.</li><li>I wanted the healthy pressure that comes with more responsibility, and I wanted it to be a team experience more than a solo fight against the unknown.</li></ul><p>I also wanted to be paid more, which I came to realize much after my decision had been made, but that now feels important nonetheless.</p><p>My story should resonate with other academics that long for similar goals, and so I am sharing four things I learned along the way. This journey took me from a second postdoc to a job as data scientist in about 6 months. The job I eventually landed is in AI at a Silicon Valley company that builds autonomous cars, but this post isn’t about that.</p><p><strong>listen</strong> — be interested/ing — code — fail gracefully<br>I didn’t decide I wanted to give up my career in academia overnight. It ripened slowly. While my conversion took 6 to 12 months, it brewed for much longer, and it started with “listening”. I went to local meetups, watched youtube and coursera lectures, and listened to a <em>ton</em> of podcasts.</p><p>listen — <strong>be interested/ing</strong> — code — fail gracefully<br>Halfway through my first postdoc (in acoustics) I had a quarter life crisis. I felt I was in the wrong place, at the wrong time. Being too afraid to let people down, it didn’t even cross my mind my aspirations could be worth breaking a three-year postdoc commitment. Instead, I started using every spare hour of my time to create all sorts of things outside my field of work. I made several android apps, I built websites and wearables, and became a trustee for a national charity. All those projects, even the silly ones (<em>Oh boy, have I told you about the mirror that receives emails?</em>) turned out to be my secret weapon in interviews.</p><p>listen — be interested/ing — <strong>code</strong> — fail gracefully<br>As an ML/AI engineer you are expected to code at the level of a software engineer. Raise your hand if you can code the dijkstra’s algorithm to find the shortest path in a graph. I didn’t even understand what this sentence meant, but there are many resources out there that can help you. Knowing what I know now, I wish somebody had said to me: <em>Ditch matlab, use python. Teach yourself javascript, maybe C++ or JAVA, and practice on LeetCode painstakingly. There are no shortcuts.</em></p><p>listen — be interested/ing — code — <strong>fail gracefully</strong><br>Interviewing is so random. Companies are continuously walking the line between the <em>fear</em> of missing out on a good candidate and the <em>dread</em> of hiring someone who doesn’t meet their bar. The result is an imperfect hiring process that will <em>fail</em> you more than <em>help</em> you.<br>I spent a day at [insert-company-name-here] where I went through 8 interviews back to back. Before I had only interviewed once for my PhD and once for my first postdoc. Three hours total, maybe. This new interview process turned out to be a physical and emotional marathon. Days or weeks later an email would come in saying “<em>…unfortunately, the ultimate decision of the team was to pass on your candidacy at this time</em>”. One failure after another, something in you breaks and rebuilds again. By failing you get stronger, better and bla, bla, bla — point is, it’s rough out there for somebody switching careers, so be ready to pick yourself up <em>a few times</em> before learning how to walk.</p><p>Whether or not this is worth it, in the end, is something you <em>truly</em> find out along the way.</p><p><em>Special mention:<br>Joining </em><a href="http://insightdatascience.com/"><em>Insight</em></a><em> was one of the best career choices I made. Through their AI program I met amazing people, learned a ton, and got to interview at top companies in Silicon Valley. Ask me.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=381d7d8dfb63" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy a django 1.10 app to AWS beanstalk using python 3.4 and MySQL on a Mac.]]></title>
            <link>https://stefano-cosentino.medium.com/deploy-a-django-1-10-app-to-aws-beanstalk-using-python-3-4-and-mysql-on-a-mac-a46ccee2c44?source=rss-a1bfbff06318------2</link>
            <guid isPermaLink="false">https://medium.com/p/a46ccee2c44</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <category><![CDATA[amazon-beanstalk]]></category>
            <category><![CDATA[django]]></category>
            <dc:creator><![CDATA[Stefano Cosentino]]></dc:creator>
            <pubDate>Sat, 22 Apr 2017 22:35:40 GMT</pubDate>
            <atom:updated>2017-04-22T22:35:40.360Z</atom:updated>
            <content:encoded><![CDATA[<p>Tutorial to accomplish what the title suggests it would accomplish.</p><p>It is heavily inspired by this <a href="https://realpython.com/blog/python/deploying-a-django-app-and-postgresql-to-aws-elastic-beanstalk/">post</a>. But if you want to know why doing it, to what avail, and really, why not hiring somebody that does it for you. I can’t help.</p><p>Also note. These things expire soon. LAST EDITED: Apr-2017.</p><h4>1. Create virtual environment &amp; activate</h4><blockquote><em>$</em> virtualenv -p python3 venv</blockquote><blockquote><em>$</em> cd venv</blockquote><blockquote><em>$</em> source bin/activate</blockquote><p><em>venv</em> will be the name of your folder. I have used python 3.4 because currently aws supports that. Don’t use python 2 with this tutorial or things will explode.</p><h4>2. Copy a django project inside ‘venv’</h4><p>You can get a django project from wherever, as long as it uses django 1.10 and python 3. I’d suggest you use <a href="https://github.com/codingforentrepreneurs/Try-Django-1.10/tree/0dbb3b0eee655981ed642c8626bdb66da3c075a4">this one</a> from coding<em>for</em>entrepreneurs.</p><pre>venv<br>├── src<br>│   ├── kirr<br>│   ├── shortener<br>│   ├── manage.py<br>├── requirements.txt<br></pre><h4>3. Create requirements.txt and pip install</h4><blockquote><em>(venv)$</em> pip install -r requirements.txt</blockquote><h4>4. Add “.extensions” folder</h4><p>First, create the folder (src/.<em>ebextensions</em>) and open it:</p><blockquote><em>(venv)$</em> mkdir .ebextensions</blockquote><blockquote><em>(venv)$</em> cd .ebextensions</blockquote><blockquote><em>(venv)$</em> open .</blockquote><h4>5. The .config files</h4><p>Then copy the following two files:</p><p><em>project-venv</em>/.<em>ebextensions/</em><strong><em>01_packages.config</em></strong></p><pre>packages:<br>  yum:<br>     git: []<br>     mysql-server: []<br>     mysql: []</pre><p>and <em>project-venv</em>/.<em>ebextensions/</em><strong><em>02_python.config</em></strong></p><pre>container_commands:<br>  01_migrate:<br>    command: &quot;source /opt/python/run/venv/bin/activate &amp;&amp; python iotd/manage.py migrate --noinput&quot;<br>    leader_only: true<br>  02_createsu:<br>    command: &quot;source /opt/python/run/venv/bin/activate &amp;&amp; python iotd/manage.py createsu&quot;<br>    leader_only: true<br>  03_collectstatic:<br>    command: &quot;source /opt/python/run/venv/bin/activate &amp;&amp; python iotd/manage.py collectstatic --noinput&quot;</pre><pre>option_settings:<br>  &quot;aws:elasticbeanstalk:application:environment&quot;:<br>    DJANGO_SETTINGS_MODULE: &quot;iotd.settings&quot;<br>    &quot;PYTHONPATH&quot;: &quot;/opt/python/current/app/iotd:$PYTHONPATH&quot;<br>  &quot;aws:elasticbeanstalk:container:python&quot;:<br>    WSGIPath: iotd/iotd/wsgi.py<br>    NumProcesses: 3<br>    NumThreads: 20<br>  &quot;aws:elasticbeanstalk:container:python:staticfiles&quot;:<br>    &quot;/static/&quot;: &quot;www/static/&quot;</pre><p>The first file tells <em>aws</em> to install the required packages for mysql.<br>The second file contains commands (“container_commands:”) that tell <em>aws</em> to run your django app from beanstalk.</p><p>The <strong>container_commands:</strong> tell <em>aws</em> to <em>migrate</em>, <em>create super user</em>, and <em>collectstatic. </em>This works because a script to create superuser (‘admin’, password: ‘admin’) was added here src/kirr/createsu.py (see <a href="https://realpython.com/blog/python/deploying-a-django-app-and-postgresql-to-aws-elastic-beanstalk/">here</a>).</p><p>The <strong>option_settings:</strong> set (1) WSGIPath, (2) the static directory, and (3) the python path in <strong><em>02_python.config</em></strong> to match your project’s directories.</p><p>(OPTIONAL) I like to see hidden folders via finders, so in my terminal I enabled it as:<br> $ <em>defaults write com.apple.finder AppleShowAllFiles TRUE <br> </em>$<em> killall Finder</em></p><h4>6. Change settings in kirr/settings.py</h4><p>Follow this <a href="https://realpython.com/blog/python/deploying-a-django-app-and-postgresql-to-aws-elastic-beanstalk/">post</a> again.</p><pre>if &#39;RDS_DB_NAME&#39; <strong>in</strong> os<strong>.</strong>environ:     <br>     DATABASES <strong>=</strong> {         <br>         &#39;default&#39;: {             <br>            &#39;ENGINE&#39;: &#39;django.db.backends.mysql&#39;,              <br>            &#39;NAME&#39;: os<strong>.</strong>environ[&#39;RDS_DB_NAME&#39;],             <br>            &#39;USER&#39;: os<strong>.</strong>environ[&#39;RDS_USERNAME&#39;],             <br>            &#39;PASSWORD&#39;: os<strong>.</strong>environ[&#39;RDS_PASSWORD&#39;],<br>            &#39;HOST&#39;: os<strong>.</strong>environ[&#39;RDS_HOSTNAME&#39;],             <br>            &#39;PORT&#39;: os<strong>.</strong>environ[&#39;RDS_PORT&#39;],         <br>         }     <br>     } <br>else:     <br>     DATABASES <strong>=</strong> {<br>         &#39;default&#39;: {<br>             &#39;ENGINE&#39;: &#39;django.db.backends.mysql&#39;,<br>             &#39;NAME&#39;: &#39;db_name&#39;,<br>             &#39;USER&#39;: &#39;admin&#39;,<br>             &#39;PASSWORD&#39;: &#39;admin&#39;,<br>             &#39;HOST&#39;: &#39;localhost&#39;,<br>             &#39;PORT&#39;: &#39;5432&#39;,<br>         }<br>     }</pre><h4>8. Add files to git</h4><p>Aws EBS uses git to know when something has changed. From the root directory (venv):</p><blockquote><em>(venv)$:</em> git add .</blockquote><blockquote><em>(venv)$:</em> git add -f .ebextensions/</blockquote><blockquote><em>$</em> git commit -m “first commit”</blockquote><p>The -f (“force”) is to ensure that hidden folders are added.</p><h4>9. Install awsebcli for AWS Elastic Beanstalk</h4><p>Install <em>awsebcli</em> and initialise EB.</p><blockquote><em>$</em> pip install awsebcli</blockquote><blockquote><em>$</em> eb init</blockquote><blockquote><em>$</em> eb create <em>(this will take a long time)</em></blockquote><blockquote><em>$</em> eb deploy</blockquote><p>Well, good luck. Let me know how it goes, and do check this <a href="https://realpython.com/blog/python/deploying-a-django-app-and-postgresql-to-aws-elastic-beanstalk/">post</a> for more.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a46ccee2c44" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[That time we revolutionised our traditional treasure hunt (part 3/3) ~ the data science.]]></title>
            <link>https://stefano-cosentino.medium.com/treasure-hunt-part-3-of-3-data-science-e4971c5525f2?source=rss-a1bfbff06318------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4971c5525f2</guid>
            <category><![CDATA[qr-code]]></category>
            <category><![CDATA[treasure-hunt]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Stefano Cosentino]]></dc:creator>
            <pubDate>Tue, 04 Apr 2017 19:10:16 GMT</pubDate>
            <atom:updated>2017-04-04T19:10:16.323Z</atom:updated>
            <content:encoded><![CDATA[<p>In my two previous posts I described the premise and the technical aspects of the <em>web app</em> we built for a treasure hunt.<br>This post describes the data analysis I did afterwards.</p><h3>First of all, how did it go?</h3><p>It was a freaking success. 31 teams turned up (we had a cap at 30), 29 started the game, 20 completed all clues, 6 arrived after the end, only 3 retired. There were no clues that went missing, no glitch in the app.</p><h4>What else.</h4><h4>Being faster wasn’t everything</h4><p>In a multiple factor analysis, being the fastest to solve a cue was a good predictor of success, but not the <em>most</em> important. Instead, being able to complete the hunt without asking for help/solutions, which came with penalties, was the most important predictor for the final position. Unsurprisingly, the top two teams did not ask any help or solutions.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FVzEyVjr6VhM%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DVzEyVjr6VhM&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FVzEyVjr6VhM%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="640" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/54352265c4ee5491cef771e347a81b69/href">https://medium.com/media/54352265c4ee5491cef771e347a81b69/href</a></iframe><h4>A shorter path did not correlate with success</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*uJrbrhs2I4qHunFXOv8F8Q.jpeg" /></figure><p>Because the paths between clues were chosen randomly, some teams had longer journeys than others. However, <em>this advantage did not affect the performance</em>. <br>We looked at correlations between total length of journey for every team and the amount of time it took them to finish the hunt. Similarly, we looked also at the travel time predicted using google map API. Correlation were all small, negative, and statistically not significant. That said, the <em>winner</em> of the <em>caccia</em> did have a journey that was 1.2 <em>s.d. </em>lower than average.</p><h4>The quickest it took to solve a clue.</h4><p>2 minutes 47 seconds. This includes scanning a QR code, reading the clue, solving it, driving to the place, finding the QR there and scanning it. Not bad. Or maybe, some of the clues were too easy.<br>The winner completed the hunt solving the 13 clues at an average pace of 8m6s per clue. Pretty impressive. The average pace was 12 minutes per clue, and the slowest scored an equally impressive 21m7s per cue.</p><p>More you say? Here is an infographics of the <em>caccia:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CXdbXA-_Rc8wRl71uOiVaw.jpeg" /></figure><p>Want the data or more info? Drop an email.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4971c5525f2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[That time we revolutionised our traditional treasure hunt (part 2/3) ~ the web app.]]></title>
            <link>https://stefano-cosentino.medium.com/treasure-hunt-part-2-of-3-b2a36847639a?source=rss-a1bfbff06318------2</link>
            <guid isPermaLink="false">https://medium.com/p/b2a36847639a</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[treasure-hunt]]></category>
            <category><![CDATA[caccia-al-tesoro]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Stefano Cosentino]]></dc:creator>
            <pubDate>Sun, 08 Jan 2017 03:20:15 GMT</pubDate>
            <atom:updated>2017-01-08T03:20:15.387Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pz3jJ20w18e1aqhDBpF6lw.jpeg" /></figure><p>In my previous post I described the premise that lead me to build the <em>web app</em> for a treasure hunt.<br>This post describes the technical bits of the app (pretty high nerdiness level).</p><p>I used the following languages/skills:<br>JAVASCRIPT<br>HTML/CSS<br>MATLAB<br>PYTHON</p><p>Thing is, I am not a full blown expert at any of these. But I am curious and I learn quickly. All of my code is publicly available on <a href="https://github.com/joeDiHare/cacciatorre-QR">github</a>.</p><h4>The web app</h4><p>This was written using a single html file (index_cacciatorre16.html) and a bunch of individual javascript files to handle the logic. It was hosted on the public space of my domain (www.guhu.website).<br>The QR code contains the link above with a parameter identifying the place where the code was hidden. E.g.:</p><blockquote>www.guhu.website/index_cacciatorre16.html?<strong>ind=dt20fpmrvf</strong></blockquote><p>The javascript code would ask for a password, then find a match in a look-up table, and eventually display the appropriate information:</p><ul><li>The next clue, if the match was found and the order was correct.</li><li>An error message if there was a match, but it was the incorrect place.</li><li>An error message if the password was incorrect.</li></ul><p>Every user response was logged. This included:</p><ul><li>Notification of incorrect password/incorrect place</li><li>Notification of solved clue/asked for help/asked for solution</li><li>IP address, location (browser or internet, depending on browser security)</li></ul><p>All this information was logged in Spreadsheets using a service called <a href="https://sheetsu.com/">Sheetsu</a>. Sheetsu provides an interface with the google API where I can easily use the spreadsheet as a database without any SQL. <br>Handy, and fairly cheap: $12.</p><h4>Optimisation</h4><p>The clue might have been in a place with slow connection. Therefore, for the app to work smoothly, I had to reduce the size of files to its bone.<br>I stripped down all the unnecessary bits and set the browser leverage so that most files were saved on the first connection to the server. I checked the performance with Google <a href="https://developers.google.com/speed/pagespeed/">PageSpeed</a>. I received thumbs up.</p><h4>The CMS to control the execution of the hunt</h4><p>While the teams were out playing the game, I needed to be able to check their progress to<br>- monitor if there was a problem (e.g. many teams all stuck on the same cue).<br>- Find out of possible sabotaging.<br>- Know every team’s score, so to easily compute the final score &amp; the winner.</p><p>This is what the CMS looked like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m3osFeSkYxrJlgx6vXU08w.png" /></figure><p>The GUI was written in matlab and used a python wrapper to access the spreadsheet shared in google drive.<br>There is a <em>log</em> board, and a useful display showing the clue completed (in red) and those not yet completed (in black) for every team.</p><p>One of the best memories of that night? Seeing the text in the first few columns turn red: that’s when I knew that the app was working.</p><h4>The plan B</h4><p>Just in case things had gone awry with the app, I made another piece of software. Selecting the team name and current location, a button would send an email to the team captain with the clue in attachment. <br>Luckily, this turned out to be unnecessary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x39kNRczgPZSnTh3FdU_fQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b2a36847639a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[That time we revolutionised our traditional treasure hunt (part 1/3) ~ the story]]></title>
            <link>https://stefano-cosentino.medium.com/treasure-hunt-part-1-of-3-3c6fe9112bd2?source=rss-a1bfbff06318------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c6fe9112bd2</guid>
            <category><![CDATA[qr-code]]></category>
            <category><![CDATA[treasure-hunt]]></category>
            <category><![CDATA[web-apps]]></category>
            <dc:creator><![CDATA[Stefano Cosentino]]></dc:creator>
            <pubDate>Sun, 08 Jan 2017 03:05:50 GMT</pubDate>
            <atom:updated>2017-01-08T03:05:50.057Z</atom:updated>
            <content:encoded><![CDATA[<p>Christmas traditions are an important element of where I am from . The big meals with family, the odd uncle that asks <em>you’re married yet?</em>, the gift of a pair of socks. In this suburb of Naples where I am from, Torre del Greco, there’s also another tradition that is only 10 years old. We call it ‘<em>la caccia</em>’, and it’s a treasure hunt on St. Stephen’s day.</p><p>It’s a terrific event where hundreds of people gather in teams and drive around the city for hours solving puzzles and collecting clues that will eventually lead to the treasure: <br>1) a table game that is the same every year, <br>2) champaign bottles to celebrate with everyone, and <br>3) fame.</p><blockquote><strong>Also:</strong> the winners get to organise the treasure hunt the following year.</blockquote><p>Last year it was the 10th edition and our team came first. It was a great night. We celebrated for days and spoke about if for months and months. And when we stopped, we started talking about the <em>caccia </em>that was to come. It was the long chased opportunity to do it <em>our</em> way, and we wanted to organise the best <em>caccia </em>ever. <br>To me, a scientist and an engineer who had left his small hometown 8 years before, this meant doing something the grinch himself would have said “dude, maybe it’s too far”: bring a tech revolution into our very traditional, Christmas treasure hunt.</p><p>This is the first of a 3-part post describing the challenges we faced (part I), the solution that was built (part II), and the data science that came out of it (part III).</p><h4>The problem</h4><p>A treasure hunt has <strong><em>M</em></strong> teams and <strong><em>N</em></strong> clues that lead to <strong><em>N</em></strong> places. You only solve one clue at the time to ‘unlock’ the clue for the next place. In our case, we had <strong><em>M</em></strong>=30 different teams and <strong><em>N</em></strong>=13 places/clues. Since every team has a different path, with the traditional method we needed <strong><em>M</em></strong> different envelopes for every places: it’s like more than 300 envelopes and paper sheets. There’s got to be a better way to do it — I thought.</p><h4><strong>The other problem</strong></h4><p>As the <em>caccia</em> grew bigger in participation, one huge problem started happening more and more: at some point during the hunt, clues would go missing. This would happen if envelopes were moved; sometimes unintentionally (e.g. cleaners sweeping), other times it was the result of a sabotage. Plus, the system had a huge <em>caveat</em>: because in every place there were envelopes for all the teams, containing different clues depending on the individual path, a team could cheat by opening the envelopes of different teams.</p><h4><strong>Now the real problem</strong></h4><p>Torre del greco is too big to be a village, and too small to be a city. It’s still a very conservative place in the south of Italy. How do I simply make a ten-year-old game run on a smartphone? Is this going to take away part of the fun? Would people understand the benefits? Would the software work as expected?</p><p>This are the key points of the software I designed.</p><ul><li>Instead of envelopes, we used QR codes. QR codes can be secured to surfaces much more easily and are resistant. Anyone can download free QR readers on their smartphone.</li><li>Instead of multiple envelopes located at any one place, we had each team to scan the QR code AND add a private password. The unique association of team &amp; place determined the next clue.</li><li>And since they’ll be holding a phone — why not collecting data from them. Geolocation, progress, IP address. Let’s tracke down the sabotager, if they are amongst us.</li></ul><p>Hence I built a <strong>web app</strong>. Whenever a team solved a puzzle and reached the place, they would find a new QR code. After scanning it with their phone the appropriate next clue would be displayed on the screen (see Fig below).</p><p>It didn’t stop there. There were more features:</p><ul><li>A leaderboard was updated in real time and displayed.</li><li>A count-down timer was also there.</li><li>If a team was in the wrong place (e.g., was there before they were meant to be, perhaps because they saw another team stopping there), the app would tell them that that place was not the correct solution.</li><li>The teams could ask for a “help” by pressing a button within the app. This would give a hint on the solution, but subtract points to their final score.</li><li>Similarly, they could ask for the solution — big penalty here.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pz3jJ20w18e1aqhDBpF6lw.jpeg" /></figure><h3>So, how did it go?</h3><p>It was a freaking success. 31 teams turned up (we had a cap at 30), 29 started the game, 20 solved all clues, only 3 retired. There were no clues that went missing, no glitch in the app, and a great atmosphere.</p><p>Sure, there are things we could have done better, or differently. Some said several clues were too easy. But for having tried something completely different, and from the positive response we gathered, that night we couldn’t have been happier.</p><p>To our team, <strong><em>Taralli &amp; Pigne</em></strong><em>, winner of the Xth ed., organizer of the XIth ed.</em>:<br>Stefano Cosentino (myself)<br>Lorenzo Battista<br>Laura Palomba<br>Annamaria Cardella<br>Enrico Greco<br>Leandra Scarano</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c6fe9112bd2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why logging my morning banana was important as a data scientist working with Fitbug]]></title>
            <link>https://stefano-cosentino.medium.com/why-logging-my-morning-banana-was-important-as-a-data-scientist-working-with-fitbug-860028e34fac?source=rss-a1bfbff06318------2</link>
            <guid isPermaLink="false">https://medium.com/p/860028e34fac</guid>
            <category><![CDATA[fitness]]></category>
            <category><![CDATA[wearables]]></category>
            <category><![CDATA[s2ds]]></category>
            <category><![CDATA[fitbug]]></category>
            <category><![CDATA[pivigo]]></category>
            <dc:creator><![CDATA[Stefano Cosentino]]></dc:creator>
            <pubDate>Sat, 07 Jan 2017 18:08:52 GMT</pubDate>
            <atom:updated>2017-01-07T18:08:52.304Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*M2sgj_xYReYCMDhvSsAMMA.jpeg" /></figure><p>Fitbug is a company in the health &amp; fitness sector — just like Fitbit. Both companies make fitness trackers that count steps and other things.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/209/1*57aPK-a94boDe8LiA76txg.png" /></figure><p>But, unlike other companies, Fitbug is focusing on a mobile app (“<strong><em>kiqplan</em></strong>”) that combines data from all kind of fitness trackers, such as Nike fuelband, Jawbone, Samsung Health and what not. More importantly, their business model is shifting towards a B2B where large companies buy subscriptions for their employees. The employees use the app, get fit, healthy; and everyone’s happy.</p><p>In an industry where decent fitness trackers are being sold for as little as <a href="http://www.mi.com/en/miband/">15$</a>, a B2B strategy makes sense.</p><p>When I got at Fitbug, as one in a team of 4 data scientists via <a href="https://www.pivigo.com/">Pivigo</a>, the repositioning of the company played a central role in planning our first move in the project: navigating the database containing decades of user data to understand what had and hadn’t worked, and generate insights that could influence the product development going forward. <br>This post summarises one of the deliverables that were produced.</p><p>But first, one quick warning about the content of this post. When you gather 4 data scientists, and let them talk for long enough, <a href="https://en.wikipedia.org/wiki/Godwin&#39;s_law">Godwin’s Law</a> adapted to data science would predict that two magic words start recurring:</p><ol><li>Deep</li><li>Learning?</li></ol><p>Well, my warning is that this post does <strong>not</strong> describe any fancy machine learning, and it is for a simple reason:</p><blockquote>We can’t afford deep learning when what’s missing is a <em>deep </em><strong><em>understanding</em></strong>.</blockquote><p>Instead, we ended up developing a tool to track the performance of the <em>kiqplan </em>app.</p><p>Let me motivate this choice using my own data, as a user of the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*bpOjkQ7eDRoSpeBtYCQFew.png" /></figure><p>The graphs tells how often I used the app to log things like meals or gym sessions. Note: week 1 to 5 on the x-axis refers to the time we spent at Fitbug working on this project.</p><p>A voice over would narrate it like this:<br><em>“He installed the app in October for the first time. Didn’t know what to do at first, but started to enter basic information in week 1. Mid-week 1, he started logging in meals, activity, and mood. You can see he’s started a fitness challenge and he’s liking using the app very much.<br>By week 2 he is in love with the app and the concept. He is convinced this is going to be his life from now on. He’d continue to log in like crazy, get fit, monitor his health. He feels good.”</em></p><p>In fact, below is the data showing what really happened after.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/901/1*NpL8y1FIqoqVJvRmUrrE2w.png" /></figure><p>Mid week 2, I simply stopped using it.</p><p>This isn’t just me. Getting the user <em>engaged</em> is a really difficult task. And the struggle isn’t one that only Fitbug has to face. Nike, Jawbone, myFitnessPal, Fitbit; they all have to deal with similar user behaviour: people get excited at first, until they quickly give up.</p><p>Now. I have no doubts that at Fitbug there are the <em>skills</em>, <em>resources</em> and the <em>team</em> to design and implement the missing features that ought to create engagement for more users. Coming up with these features, however, could not be our goal as data scientists, at least not in the allocated time frame. Instead, we decided to build a <strong><em>performance tool</em></strong> for the app. Once these features are designed, our tool would be used to quantify their effect on the users.</p><p><em>So, what was this thing about?</em></p><p>The tool looked at 2 metrics: <strong>engagement</strong> and <strong>wellness</strong>, over 4 categories: activity, sleep, mood, nutrition. We make one key statement:</p><blockquote>“The more you use the app, the healthier you become.”</blockquote><p>The more time you spend on the app logging in meals, activity and what not, the higher your wellness score is going to be.</p><p>Is this really true?</p><p>Ha! Well. No, not necessarily. But if it *is* true, then we’d expect to see a strong correlation between engagement metrics and wellness metrics.</p><p>→ meaning, the app <em>is</em> <em>working</em>.</p><p><em>Vice versa</em>, if the correlation between the two is small, then the <em>kikplan</em> app isn’t successful in having an impact on users’ wellbeing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*F1VIs-yxUgaFKVVqhHzTwg.png" /></figure><p>Nice. The actual work at this point was defining these 8 metrics. This involved a <em>creative</em>, <em>analytical</em>, <em>meticulous</em>, <em>thoughtful</em> work. Too many adjectives you say? Fine, how about we just say ‘arbitrary<em>’</em> instead.</p><p>RESULTS: Below is a snapshot from the tool we built showing correlations between engagement and wellness scores for a random cohort.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*r8cLCsPmc-_7Fw8y_pfL9g.png" /></figure><p>Correlations are all positive and statistically significant (what? which outlier?), but. <br>They could be stronger. <br>Ideally, one day, after that ‘awesome sets of features’ are implemented, we want to see strong correlation coefficients (what we termed “k-score”).</p><p>Will this happen?</p><p>Yeah. I think so.<em> But we will need longer than 5 five weeks for this to happen.</em></p><p><em>Technical bits</em>: The tool was built in python and rendered via Jupyter. AWS was used to query the database.</p><p><em>Credits</em>: The project was set up by PIVIGO via the <a href="http://www.s2ds.org/">s2ds</a> programme. In the ‘Fitbug’ team, Alfonso Monroy and myself worked on the performance tool described here. Patrick Xian and Silvestro DeLuise, also in the team, worked on other areas. Fitbug was extremely professional and helpful throughout the project and, above all, it was a pleasure interacting with everyone in the team: Jon (Webb, CEO), Clem (Vioux, HP), Helen (Thomas, PM), Anna (Gudmundson, CEO) and Riccardo. Thank you all.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=860028e34fac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Re: Every Olympic event should include one average person competing for reference.]]></title>
            <link>https://stefano-cosentino.medium.com/https-medium-com-joedihare-every-olympic-event-should-include-one-average-person-competing-for-reference-8abce5fb1b1e?source=rss-a1bfbff06318------2</link>
            <guid isPermaLink="false">https://medium.com/p/8abce5fb1b1e</guid>
            <category><![CDATA[sports]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[olympics]]></category>
            <category><![CDATA[usain-bolt]]></category>
            <dc:creator><![CDATA[Stefano Cosentino]]></dc:creator>
            <pubDate>Tue, 16 Aug 2016 18:48:29 GMT</pubDate>
            <atom:updated>2016-08-17T13:56:56.305Z</atom:updated>
            <content:encoded><![CDATA[<p>American gymnast Simone Biles enchants with her sublime technique and strength, fastest man on Earth Usain Bolt has won again the 100 m sprint, and swimmer Michael Phelps has collected his 23rd gold medal in career (or, differently put, Michael Phelps’s <em>COUNTRY </em>has just reached 36th position in all-time gold medals).</p><p>As the Olympic Games draw to a close and I have watched loads of athletes doing extraordinary things on TV (many of which I never thought <em>possible </em>or <em>desirable</em>), web’s recent viral <a href="https://twitter.com/BiIIMurray/status/755545329563475968">quote </a>comes to mind:</p><blockquote>Every Olympic event should include one average person competing for reference.</blockquote><p>What Bolt did right there, looked amazing, but just how precise his arm swinging was— remains somewhat unclear.</p><p>If <em>Dave</em>, 27 year old barber from Essex, were there racing shoulder-to-shoulder with the gold medallist — we’d finally get it.</p><p>Powered by a passion for data science that gets inexplicably stronger with the futility of the problem, I started asking Google about average sprinters, swimmers, jumpers and whatnot. I hoped to find data from, say, a fitness app like Nike+ that I could compare with scores from pros; but an evening of searching left me empty handed and I considered abandoning the project.</p><p>Then, the average but Olympic <a href="https://www.washingtonpost.com/pb/olympics/2016/live-updates/rio-games/scores-and-latest-news/body-shamers-cant-keep-ethiopian-swimmer-from-enjoying-olympics/">Ethiopian swimmer Robel Habte</a> started racing, and I knew I had to pursue my quest for comparison. Ultimately, I focused my efforts on one discipline, the 100 metre sprint, and opted for an alternative approach to compare Bolt’s and Dave’s performance using nothing more than a set of assumptions and some questionable math.</p><p>Let’s start from Bolt’s most recent result: completing the 100 m dash in 9.81 seconds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vWCvnFrPUteOEjASyLnKMQ.png" /></figure><p><em>How quickly can the average man run 100 metres?</em></p><p>I needed to make an assumption on the type of distribution underlying population performance. A common one is to use a ‘normal distribution’ — the bell curve reflecting the assumption that most people score in the middle, some will be very good, some very bad.</p><p>To characterise this curve one needs a <em>mean</em> (the centre of the bell curve) and a <em>standard deviation</em> (<em>sd</em>,<em> </em>the width). The mean is Dave’s performance, which is unknown, but I will try to infer it using as much as ONE point on this curve (and a *cough* arbitrary *cough* choice of the <em>sd</em>).<br>The one point being Bolt’s 9.81 seconds.</p><p>This is how.</p><p>First, we need to know the probability of Usain being who he is in this competition: the number one in the world. Back to Google — how many average runners exist that Usain would beat in a competition?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*qDxnyY9nQP6krmqb8QNX1Q.png" /></figure><p>Roughly, there are 945 million (male) people aged between 20 and 35. Outside this range wouldn’t be the “average Dave” anymore. From this number we’ll drop half assuming that only every other individual is ‘run-able’, and could have had an opportunity to compete (and maybe beat) Usain.</p><p>The probability of Bolt being Bolt is then</p><p>P(x=Bolt)=0.00000002%.</p><p>I now have one point on this curve, and I can estimate how far Bolt is from the <em>mean </em>using inverse <em>cdf(x)</em>. That distance turns out to be 5.87 <em>sd</em>. <br>A lot. <br>For sake of comparison, in medicine a <em>sd</em> of 2 is often used to diagnose pathological cases from just-a-little-weird-but-OK cases.</p><p>The <em>mean</em> of the bell curve can be estimated as being 5.87 <em>sd</em> away from the performance value obtained by Mr. Bolt. This leads to <strong>15.68 s</strong>.</p><p><strong>Conclusion: the average man racing with the big guys would have arrived about 5.5 seconds after most professional runners in Rio.</strong></p><p>And here you go, the plot I was after all along:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*J8uDf1e2UK9EMAiVUAvh5Q.png" /><figcaption>(a) Inferred distribution for male sprinters (100 m). (b) Inference for the cumulative distribution function.</figcaption></figure><p>Are you curious to know how you would compare to either Bolt or Dave?<br><a href="http://guhu.website/DaveCalculatorHTML.html">I made a thing for it</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8abce5fb1b1e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>