<?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[eat-pred-love - Medium]]></title>
        <description><![CDATA[Eat, Predict, Love - Medium]]></description>
        <link>https://medium.com/eatpredlove?source=rss----f6116b679a7c---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>eat-pred-love - Medium</title>
            <link>https://medium.com/eatpredlove?source=rss----f6116b679a7c---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 03:59:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/eatpredlove" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Regression Difference in Differences]]></title>
            <link>https://medium.com/eatpredlove/regression-difference-in-differences-208c2e787fd2?source=rss----f6116b679a7c---4</link>
            <guid isPermaLink="false">https://medium.com/p/208c2e787fd2</guid>
            <category><![CDATA[causal-inference]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[empirical]]></category>
            <category><![CDATA[economics]]></category>
            <category><![CDATA[econometrics]]></category>
            <dc:creator><![CDATA[Gerwyn Ng]]></dc:creator>
            <pubDate>Fri, 20 Dec 2019 16:36:48 GMT</pubDate>
            <atom:updated>2019-12-23T09:24:12.658Z</atom:updated>
            <content:encoded><![CDATA[<h3>Generalised Regression Difference in Differences</h3><h4>with Fixed Effects, Multiple Treatment Periods and Dynamic Treatment Effects</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-x5Ce3EhZS6dh7L7YLuomw.png" /></figure><h3>What is Difference in Differences?</h3><p>Difference in differences (DiD) is a non-experimental statistical technique used to estimate treatment effects by comparing the change (difference) in the differences in observed outcomes between treatment and control groups, across pre-treatment and post-treatment periods.</p><p>DiD is commonly used to recover the causal effect of interest from observational study data — where the experimental design is out of the researcher’s control (e.g. natural experiment) and usually subjected to unobserved confounders and some form of selection bias.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*KiRkxO-fUCfXSkJMR0bDig.png" /><figcaption><strong>Causal Pathway Illustration:</strong> Z (confounder) is the cause of both X (independent variable) and Y (dependent variable) and thus, obscures the relationship between X and Y.</figcaption></figure><blockquote>The DiD estimator is, in fact, a version of the Fixed Effects Model which uses aggregated data. As such, its data requirements are much less and work wells with repeated cross-sectional data. In contrast, panel data are relatively more expensive and difficult to collect.</blockquote><h4>Intuition</h4><p>DiD is a combination of time-series difference (compares outcomes across pre-treatment and post-treatment periods) and cross-sectional difference (compares outcomes between treatment and control groups).</p><p>There are two equivalent strategies to think about the two “differences”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YYT04dz8Mn80Bw3zyvTG_g.png" /><figcaption><strong>Mechanical Description</strong></figcaption></figure><p>Visually, the DiD is the difference between these two changes:</p><ol><li>changes in outcomes from pre-treatment to post-treatment</li><li>changes in outcomes between treatment and control groups</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yyVOO-oWeSPlgblipljulg.png" /><figcaption><strong>Graphical Illustration</strong></figcaption></figure><h3>Regression DiD</h3><p>While it is possible to obtain the DiD estimator by calculating the means by hand, using a regression framework may be more advantageous as it:</p><ul><li>outputs standard errors for hypothesis testing</li><li>can be easily extended to include multiple periods and groups</li><li>allows the addition of covariates</li></ul><h4>Simple DiD</h4><p>The simplest setup involves observed outcomes for two groups for two time periods:</p><ol><li>The treatment group is exposed to treatment in the second period but not the first</li><li>The control group is not exposed to treatment during either period</li></ol><p>In this case, the treatment effect can be estimated by subtracting the average change in the control group from the average change in the treatment group. Doing so removes <strong>unobserved and fixed biases</strong> in the second-period comparison that could be the result of:</p><p>a. inherent differences between the two groups and,</p><p>b. changes in trend from first to the second period that is common to both groups.</p><p>With repeated cross-sectional data, the regression model can be defined as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KbpjTgRvNLgFMDvbANpt-w.png" /></figure><p>where <em>y </em>is the outcome of interest, <em>P </em>is a dummy variable for the second time period and <em>T </em>is a dummy variable for the treatment group<em>. </em>The interaction term, <em>P </em>×<em> T</em>, is equivalent to a dummy variable equals 1 for observations in the treatment group, in the second period.</p><p>The coefficients can be interpreted as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wJItSwzDDFe-YW4C9BZ1cw.png" /><figcaption>The simple DiD estimator allows for the intercepts to vary between the treatment (β₀ + β₂) and the control group (β₀) and assumes constant outcomes within the two time periods (β₁).</figcaption></figure><ul><li><strong>β₁:</strong> Average change in <em>y</em> from the first to the second time period that is common to both groups</li><li><strong>β₂: </strong>Average difference in <em>y</em> between the two groups that is common in both time periods</li><li><strong>β₃: </strong>Average differential change in <em>y</em> from the first to the second time period of the treatment group relative to the control group</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*etuwZRKQ-0cCfFO5jkMftw.png" /><figcaption><strong>Graphical Illustration of Coefficients</strong></figcaption></figure><p>By OLS, the simple DiD estimator is given as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wxSJkeLCmsQJeeXCRReGQA.png" /></figure><h4>Generalised DiD: Fixed Effects and Multiple Treatment Periods</h4><p>Since the regression framework allows us to add more covariates, we can formulate a more general DiD regression with allows for:</p><ol><li>the intercept term to vary for each cross-sectional unit (αᵢ instead of β₂)</li><li>the common change in outcomes to vary across time (δt instead of β₁)</li><li>different timing of the treatment for different treated units, (<em>dt</em> instead <em>Pt</em>)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*32TwgqKuvkq-rl4Of422QQ.png" /></figure><ul><li><strong>αᵢ:</strong> Individual fixed effects that change across individuals (state-specific characteristics, individual’s gender, etc.)</li><li><strong>δt:</strong> Time fixed effects that change across time (e.g. year dummies to allow intercept to vary across different years)</li><li><strong><em>dt</em>:</strong> dummy variable which equals 1 if the unit of observation is in the post-treatment period (in contrast to <em>Pt</em> equals 1 in the second time period)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p1p3yCA2SzdoT8TvQ21orw.png" /><figcaption><strong>Graphical Illustration: </strong>In the generalised model, we allow the intercepts to vary across both time and individuals</figcaption></figure><h4>Generalised DiD with Dynamic Treatment Effects</h4><p>To capture dynamic treatment effects, we allow our DiD estimator, β₃, to vary across time by using a time-variant coefficient, ρt, on the interaction term, <em>Dt</em> × <em>Tᵢ.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0GQTqA1CL8H1V-4rgbb8dg.png" /></figure><p>where <em>Dt </em>= 1 in period <em>t </em>and 0 otherwise.</p><p>This specification allows us to capture leads and lags of the treatment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NlVj9rXukhkR4Rs1DzXY_g.png" /><figcaption><strong>Graphical Illustration: With dynamic treatment effects, the outcomes for the treated in the post-treatment period are no longer parallel to the assumed counterfactual</strong></figcaption></figure><h3><strong>Keeping it Causal: The Parallel Trends Assumption</strong></h3><p>For our DiD estimator to be causal, we require the parallel trends assumption to hold. This assumption allows us to use the control group as a proxy for the assumed counterfactual trend (which is unobserved) of the treatment group. That is, in the absence of treatment, both the treatment and control groups should experience the same change in outcome.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-YGByVHg0CYW-9-AnXiPIA.png" /><figcaption><strong>Graphical Illustration: </strong>In the absence of treatment, the treated should observe the same trend as the control group. If this assumption holds, we can then attribute the change in the trend of the treated, in the presence of treatment, to the treatment itself.</figcaption></figure><h3><strong>Threats to Causal Inference using DiD</strong></h3><p>Although the DiD method is intended to mitigate the effects of confounders and selection bias, it may still be subjected to threats that can invalidate its causal inference.</p><h4>Violation of the Parallel Trends Assumption</h4><p>The most important assumption is violated when there exist unobserved factors that are correlated with both treatment status and timing of the treatment. In other words, there could be factors (besides the treatment) that cause a change in one group but not the other at the same time as the treatment. Various issues that could compromise the results include autocorrelation and the Ashenfelter dips (where treatment is assigned primarily based on pre-existing differences in outcome).</p><p>While the Parallel Trends Assumption is typically untestable (since counterfactual is never observed), the following strategies are often applied to improve the credibility of results:</p><ul><li>Verify that pre-treatment trends are parallel for a reasonable timeframe</li><li>Cross validate results using alternative control or treatment groups</li><li>Test if there exists a treatment reversal effect</li></ul><h4>Compositional Difference</h4><p>Because DiD is often implemented using repeated cross-sectional data, significant changes in the composition of the samples across periods may simply reflect changes in the composition of each group, rather than the treatment effect.</p><h4><strong>Extrapolation</strong></h4><p>Depending on the setting of interest, results may be unable to generalise to other populations or even a longer timeframe.</p><h3>Implementation with R</h3><p>Since the DiD estimator is a version of the Fixed Effects Model, the DiD regression may be modeled using a Fixed Effect Linear Regression using the lfe package in R.</p><p>The dummy syntax is as follows:</p><pre>felm(causal relation of interest | fixed effects | IVs | clusters, data = your_data)</pre><p>An example:</p><ol><li>The dependent variable, y</li><li>The independent variable whose coefficient is of interest, x</li><li>Fixed effects, f1 and f2</li><li>Endogenous variables Q and W instrumented by z1 and z2</li><li>Clusters, c1 and c2, to compute standard errors which allow for correlation within all combinations of c1 and c2</li></ol><pre>#import<br>library(lfe)</pre><pre>#fit your regression<br>felm(formula = y ~ x | f1 + f2 | (Q|W ~ z1 + z2) | c1 + c2, data = df) %&gt;%<br>  summary(robust = TRUE) #display results w/ robust standard errors</pre><h3>References</h3><p>[1] Angrist and Pischke (2008). Mostly Harmless Econometrics: An Empiricist’s Companion. Princeton University Press.</p><p>[2] C. Junxing (2019). Empirical Economics Course Materials.</p><p>[3] Imbens and Woodridge (2007). <a href="http://www.nber.org/WNE/lect_10_diffindiffs.pdf">Difference-in-Differences Estimation</a>. NBER</p><p>[4] J. Pischke (2019). <a href="http://econ.lse.ac.uk/staff/spischke/ec533/did.pdf">Differences-in-Differences</a>. LSE</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=208c2e787fd2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eatpredlove/regression-difference-in-differences-208c2e787fd2">Regression Difference in Differences</a> was originally published in <a href="https://medium.com/eatpredlove">eat-pred-love</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Natural Cubic Splines Implementation with Python]]></title>
            <link>https://medium.com/eatpredlove/natural-cubic-splines-implementation-with-python-edf68feb57aa?source=rss----f6116b679a7c---4</link>
            <guid isPermaLink="false">https://medium.com/p/edf68feb57aa</guid>
            <category><![CDATA[numerical-methods]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[interpolation]]></category>
            <dc:creator><![CDATA[Gerwyn Ng]]></dc:creator>
            <pubDate>Thu, 05 Dec 2019 13:57:25 GMT</pubDate>
            <atom:updated>2019-12-06T10:18:32.452Z</atom:updated>
            <content:encoded><![CDATA[<h4>Piece-wise interpolation with a global interpretation</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DR8ihMpKQg9F9aWHObtfVg.png" /></figure><p>Before we jump into the algorithm for computing natural cubic splines, let us build some motivation for interpolation methods.</p><h3>Connect the Dots</h3><p>Interpolation is the process of using a function that fits the given data. Given a (limited) number of data points, interpolation provides a means of estimating the value of that function for any intermediate value.</p><h3>Can’t I Just Use a Pencil?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uHTzg3XPt3L_gX3--V7u2w.png" /><figcaption>Classes of Common Interpolants</figcaption></figure><p><strong>Algebraic polynomials</strong> are one of the well-known classes of functions that are able to map the set of data points into itself. The idea is to approximate arbitrary functions to fit the data points using a single polynomial. The problem, however, is that high-degree polynomials often oscillate erratically and thus, tend to overfit. This problem is often referred to as <em>Runge’s Phenomenon</em>.</p><p>A workaround would be a <strong>piecewise-polynomial approximation</strong>. That is, we divide the interval into a collection of sub-intervals and fit different polynomial on each sub-interval. In other words, we are connecting sequential data points by a series of polynomials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*4QpPyqI9AivRe_fQLuJcsQ.png" /><figcaption>Visual comparison between linear and cubic piece-wise interpolation</figcaption></figure><p>The simplest example would be to join a set of data points using straight lines. One disadvantage of using linear functions, however, is a lack of smoothness from one sub-interval to another. Mathematically, this implies that at every end-point of each sub-interval, the slope of the interpolant is likely to be undefined. <strong>Cubic spline interpolation </strong>addresses this shortcoming by using third-degree polynomials. Doing so ensures that the interpolant is not only continuously differentiable but also has a continuous second derivative.</p><h3>Connecting the Dots &amp; Reading between the Lines</h3><p>By construction, cubic spline interpolation fits a set of data points with <em>n-1</em> cubic polynomials:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OckyhZSYd3PyXgQYXfyYkQ.png" /><figcaption>A total of 3(n-1) unknowns to be solved for</figcaption></figure><p>with the following properties:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ji1wev3B5cIMyMYFvl620Q.png" /><figcaption>Property 1 imposes n-1 conditions while properties 2 and 3 impose<em> n-2 </em>conditions each</figcaption></figure><p>Property 1 guarantees that the interpolant passes through all data points while properties 2 and 3 force the slope and curvature of the splines, at the end-point of each sub-interval, to agree where they meet. The latter characteristic also creates some form of “relationship” between the data points, allowing the interpolant to have a <em>global interpretation</em>.</p><p>Because we have <em>3n-3 </em>unknowns to solve for and only <em>3n-5 </em>conditions imposed, we still need two additional conditions to construct the splines. The natural (or free) boundary condition is one way to impose the two addition conditions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*xAZmgshi-TsSzqTwGOsLFA.png" /></figure><p>When the free boundary condition is satisfied, the spline is called a <strong>natural spline</strong>. In practice, the coefficients of the natural splines are solved for as follows:</p><ol><li>Solve for <em>c</em> from:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rze5kYcjlmvcoksJ9BD8-g.png" /></figure><p>Note that since the left-most matrix is strictly diagonally dominant, it makes sense to solve this iteratively using <em>Jacobi’s Method</em>.</p><p>2. Solve for <em>b</em> and <em>d</em> from:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FSUzaye4fnh9TcnNetMeCQ.png" /></figure><h3><strong>Constructing Natural Cubic Splines with Python</strong></h3><p>Finally, let us explore how we can code the algorithm.</p><h4><strong>Step 1: Create our Own Jacobi Method</strong></h4><p>Here, we define <strong>tolerance</strong> as <em>the norm of the difference between the matrices of the current and previous iteration</em>. In addition, the Seidel technique (where we use the updated x values for the next iteration) is also applied for faster convergence.</p><pre><strong>import</strong> <strong>pandas</strong> <strong>as</strong> <strong>pd</strong><br><strong>import</strong> <strong>numpy</strong> <strong>as</strong> <strong>np</strong></pre><pre><strong>def</strong> jacobi(A, b, x0, tol, n_iterations=300):<br>    <em>&quot;&quot;&quot;</em><br><em>    Performs Jacobi iterations to solve the line system of</em><br><em>    equations, Ax=b, starting from an initial guess, ``x0``.</em><br><em>    </em><br><em>    Returns:</em><br><em>    x, the estimated solution</em><br><em>    &quot;&quot;&quot;</em><br>    <br>    n = A.shape[0]<br>    x = x0.copy()<br>    x_prev = x0.copy()<br>    counter = 0<br>    x_diff = tol+1<br>    <br>    <strong>while</strong> (x_diff &gt; tol) <strong>and</strong> (counter &lt; n_iterations): <em>#iteration level</em><br>        <strong>for</strong> i <strong>in</strong> range(0, n): <em>#element wise level for x</em><br>            s = 0<br>            <strong>for</strong> j <strong>in</strong> range(0,n): <em>#summation for i !=j</em><br>                <strong>if</strong> i != j:<br>                    s += A[i,j] * x_prev[j] <br>            <br>            x[i] = (b[i] - s) / A[i,i]<br>        <em>#update values</em><br>        counter += 1<br>        x_diff = (np.sum((x-x_prev)**2))**0.5 <br>        x_prev = x.copy() <em>#use new x for next iteration</em><br>        <br>    <br>    print(&quot;Number of Iterations: &quot;, counter)<br>    print(&quot;Norm of Difference: &quot;, x_diff)<br>    <strong>return</strong> x</pre><h4><strong>Step 2: Solve for the Unknowns</strong></h4><p>To compute the coefficients of our splines, we first define the strictly diagonally dominant matrix “A” and then apply the Jacobi Method to solve for <em>c </em>iteratively. With <em>c </em>solved,<em> b </em>and<em> d </em>can be solved arithmetically.</p><pre><strong>def</strong> cubic_spline(x, y, tol = 1e-100):<br>    <em>&quot;&quot;&quot;</em><br><em>    Interpolate using natural cubic splines.</em><br><em>    </em><br><em>    Generates a strictly diagonal dominant matrix then applies Jacobi&#39;s method.</em><br><em>    </em><br><em>    Returns coefficients:</em><br><em>    b, coefficient of x of degree 1</em><br><em>    c, coefficient of x of degree 2</em><br><em>    d, coefficient of x of degree 3</em><br><em>    &quot;&quot;&quot;</em> <br>    x = np.array(x)<br>    y = np.array(y)<br>    <em>### check if sorted</em><br>    <strong>if</strong> np.any(np.diff(x) &lt; 0):<br>        idx = np.argsort(x)<br>        x = x[idx]<br>        y = y[idx]<br><br>    size = len(x)<br>    delta_x = np.diff(x)<br>    delta_y = np.diff(y)<br>    <br>    <em>### Get matrix A</em><br>    A = np.zeros(shape = (size,size))<br>    b = np.zeros(shape=(size,1))<br>    A[0,0] = 1<br>    A[-1,-1] = 1<br>    <br>    <strong>for</strong> i <strong>in</strong> range(1,size-1):<br>        A[i, i-1] = delta_x[i-1]<br>        A[i, i+1] = delta_x[i]<br>        A[i,i] = 2*(delta_x[i-1]+delta_x[i])<br>    <em>### Get matrix b</em><br>        b[i,0] = 3*(delta_y[i]/delta_x[i] - delta_y[i-1]/delta_x[i-1])<br>        <br>    <em>### Solves for c in Ac = b</em><br>    print(&#39;Jacobi Method Output:&#39;)<br>    c = jacobi(A, b, np.zeros(len(A)), tol = tol, n_iterations=1000)<br>    <br>    <em>### Solves for d and b</em><br>    d = np.zeros(shape = (size-1,1))<br>    b = np.zeros(shape = (size-1,1))<br>    <strong>for</strong> i <strong>in</strong> range(0,len(d)):<br>        d[i] = (c[i+1] - c[i]) / (3*delta_x[i])<br>        b[i] = (delta_y[i]/delta_x[i]) - (delta_x[i]/3)*(2*c[i] + c[i+1])    <br>    <br>    <strong>return</strong> b.squeeze(), c.squeeze(), d.squeeze()</pre><h3>So, Why Natural Cubic Splines?</h3><p>In most interpolation problems, spline interpolation is often preferred to single polynomial interpolation since it produces similar results (even with low degree polynomials) while avoiding Runge’s Phenomenon for higher degrees polynomials. As for the natural boundary condition, it is a convenient way for computing the coefficients since it allows us to have an equal number of unknowns and equations to solve for.</p><h3>References</h3><p>[1] Richard L. Burden and J. Douglas Faires, <em>Numerical Analysis 9th Edition</em>, Cengage Learning</p><p>[2] Zhao Liang, <em>Numerical Methods for Economics and Finance</em> course material</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edf68feb57aa" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eatpredlove/natural-cubic-splines-implementation-with-python-edf68feb57aa">Natural Cubic Splines Implementation with Python</a> was originally published in <a href="https://medium.com/eatpredlove">eat-pred-love</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Time Series Cross-validation — a walk forward approach in python]]></title>
            <link>https://medium.com/eatpredlove/time-series-cross-validation-a-walk-forward-approach-in-python-8534dd1db51a?source=rss----f6116b679a7c---4</link>
            <guid isPermaLink="false">https://medium.com/p/8534dd1db51a</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[sklearn]]></category>
            <category><![CDATA[forecast]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[crossvalidation]]></category>
            <dc:creator><![CDATA[germayne]]></dc:creator>
            <pubDate>Thu, 05 Sep 2019 11:00:21 GMT</pubDate>
            <atom:updated>2019-11-13T03:29:39.833Z</atom:updated>
            <content:encoded><![CDATA[<h3>Time Series Cross-validation — a walk forward approach in python</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/0*-PMOUcKUsQw7XMit.png" /><figcaption><a href="https://xkcd.com/605/">https://xkcd.com/605/</a></figcaption></figure><p>When we create a machine learning model, cross-validation allows us to validate if the model is in the direction we expect it to be. A good cross-validation scheme is one that emulates the test distribution well. Because when it comes to features engineering or hyperparameter tuning, you wouldn’t want a scenario that whatever changes you are making to not be indicative of future unseen data. Typically we call them our test set.</p><p>It is very easy to succumb to the common pitfalls of creating a bad validation scheme, where you are happily making ‘improvements’ and changes based on your validation metric but in fact, your model is not going to do well on your unseen data. But remember that ultimately, we will want a model that does well in future unseen test data.</p><p>A good guide to follow is to ensure validation scheme to follow as closely as test data. We will touch on that in details later below.</p><p>Today, I will discuss a form of validation that is used in time-series. Time series data are usually trickier to handle as compared to typical cross-sectional based data (think of them like different observation). In time series, we often have to respect the order between them.</p><p>This also affects feature engineering. (but that is a topic for another day) So why do we have to treat time series differently?</p><h3><strong>No Mixture</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/0*Yy91DjWd7S6YCRCn.jpg" /><figcaption><a href="https://www.ourniche.com/2017/04/12/jelly-bean-cocktails/">https://www.ourniche.com/2017/04/12/jelly-bean-cocktails/</a></figcaption></figure><p>Most general cross-validation techniques are not correct when it comes to time-series data/problems. Bootstrapping resampling (apart from time series bootstrapping), k-fold or stratified k-fold shuffles the data and does not ensure that there is the same coherence in your validation folds as compared to your actual test set. In fact, recall that your test data will be some period from the future.</p><p>A good way to understand is by doing so, <strong>the valid vs test distribution will not be the same</strong>. Not only are you attempting to learn from future data and predicting past validation, but you will also be creating validation scores that may not be accurate.</p><p>In kaggle, we often encounter what is known as a leaderboard shakeup. This happens because of reasons like</p><p>1. overfitting on small % of the test set (Leaderboard scores)</p><p>2. test set distribution is different from validation which results in bad model selection.</p><p>(This is definitely a topic on another level) But my point is to point out the importance of doing validation, especially for time-series data. Otherwise, you would not be able to distinguish the rotten apples!</p><p>Most time-series models/problems, in reality, also grows in size. For example, our training data grows every time period. We might be predicting short term (next month) or extrapolating some horizon h depending if we are using classical time series models, machine learning or neural networks. In the subsequent period, we will gain more data and the process repeats. Also, most of the time the model needs to be fitted / train with the new data before being able to forecast horizon h again.</p><p>This makes sense to use what is known as the walk-forward cross-validation / expanding window cross-validation.</p><h3><strong>Walking- forward</strong></h3><p>With that in mind, The usual train-test split will definitely work better than the k-fold approaches. By ordering your data from past to present and splitting the later half as valid data. However, the train-test split might not be a good gauge since we might want to avoid overfitting to your particular split.</p><p>In other words, where you choose to split plays a part in your validation result. To avoid luck as a factor and have a more robust result that we can trust, we can expand on this concept by doing what is known as walk-forward validation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*k5rqfNr1RXK5BnOAGI8gRA.png" /><figcaption>Hyndman, R.J., &amp; Athanasopoulos, G. (2018) <em>Forecasting: principles and practice</em>, 2nd edition, OTexts: Melbourne, Australia. OTexts.com/fpp2.</figcaption></figure><p>Professor Rob Hyndman illustrates this concept very well with the diagram above. In fact, we are doing ‘multiple’ split across the different time period, with the training data expanding each fold. In many cases, especially the work I personally do for product demand forecasting, this provides a more robust gauge of your model performance.</p><p>We then average the performance across the different folds based on the metric you decide (I.e MAPE, WMAPE..etc)</p><p>Of course walk forward validation is not restricted to just expanding by one period. Here is where you would want to match your test data as closely as possible. Depending on your data’s frequency, model type (arima, ets, GBM…etc) or even your objective, you might want to define a different initial length, period of data gain as well as horizon to validate on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*1JVA5-KVizOuSh9uk8W2xQ.png" /><figcaption>Hyndman, R.J., &amp; Athanasopoulos, G. (2018) <em>Forecasting: principles and practice</em>, 2nd edition, OTexts: Melbourne, Australia. OTexts.com/fpp2.</figcaption></figure><h3>My <strong>Python </strong>solution — walk forward cv</h3><p>If you are using Professor Hyndman’s forecast package in R, then you can simply call the <em>tsCv </em>function which wraps around. You will need to define a function that takes in your data x as well as horizon h, which you will need to fit into <em>tsCv().</em></p><pre>#Fit an AR(2) model to each rolling origin subset far2 &lt;- <strong>function</strong>(x, h){forecast(Arima(x, order=c(2,0,0)), h=h)} </pre><pre>e &lt;- tsCV(lynx, far2, h=1)  #Fit the same model with a rolling window of length 30 e &lt;- tsCV(lynx, far2, h=1, window=30) </pre><p>But python users are out of luck. For sklearn, there is a time series split. But it does not allow customization of an initial period for training (which is important, for instance, if you would like to train with minimum 2–3 years of data to capture seasonality), define a period of data that will be added at each step forward as well as horizon h. Sklearn version only allows us to define n_splits, where the splits between train and validation are defined as follow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/449/1*ZFrIa3bKz191HtE8W_rpwA.png" /><figcaption>Based on sklearn — <a href="https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.TimeSeriesSplit.html#sklearn.model_selection.TimeSeriesSplit">https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.TimeSeriesSplit.html#sklearn.model_selection.TimeSeriesSplit</a></figcaption></figure><p>As such, I have written my own version of the expanding window that follows the grammar of sklearn below:</p><p>It works just like other sklearn CV splits which returns your data index.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d498a2d1cba652d413b792b7b363c4ca/href">https://medium.com/media/d498a2d1cba652d413b792b7b363c4ca/href</a></iframe><h3>Closing</h3><p>Time series cross-validation is not limited to walk-forward cross-validation. A rolling window approach can also be used and Professor Hyndman also discussed Time-series bootstrapping in his textbook. Perhaps I will touch on it in another post. But for now, hope that the expanding window approach will provide an easier method to back-test for time series data!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8534dd1db51a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eatpredlove/time-series-cross-validation-a-walk-forward-approach-in-python-8534dd1db51a">Time Series Cross-validation — a walk forward approach in python</a> was originally published in <a href="https://medium.com/eatpredlove">eat-pred-love</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Casino’s Big and Small — using Monte Carlo Simulation]]></title>
            <link>https://medium.com/eatpredlove/casinos-big-and-small-using-monte-carlo-simulation-3936f9bcf4bf?source=rss----f6116b679a7c---4</link>
            <guid isPermaLink="false">https://medium.com/p/3936f9bcf4bf</guid>
            <category><![CDATA[simulation]]></category>
            <category><![CDATA[casino]]></category>
            <category><![CDATA[gamblin]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[germayne]]></dc:creator>
            <pubDate>Sat, 24 Aug 2019 18:38:11 GMT</pubDate>
            <atom:updated>2020-02-13T13:25:31.175Z</atom:updated>
            <content:encoded><![CDATA[<h3>Casino’s Big and Small — using Monte Carlo Simulation</h3><h3>Background</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*E-x68jwwWr-7M7STdNJQJQ.jpeg" /><figcaption>I did not take any pictures of any casinos in Macau, so… credit: smarttravelasia</figcaption></figure><p>Back in 2018, it was my first experience at a casino in Macau (It was a dedicated day trip from Hong Kong). We chose one of the easiest (is that so?) game to play: <a href="https://en.wikipedia.org/wiki/Sic_bo">Big and Small</a> (Also known as Sic Bo). The rule is simple: choose either big or small.* The dealer will shuffle 3 dice and if the total sum is between 4 to 10, betting on small means you will win. If the total sum is between 11 to 17, betting on big means you will win. Winning net a payout of 1:1.</p><p>At this point, you might be thinking, what if I get a sum of 3?. There are special wins known as <strong><em>three of a kind</em></strong>: getting the same for all die. So 3 is one such possible combination (1,1,1) and results in a higher payout. [1]</p><p>Long story short, after watching a couple of games (maybe a little too much), we decided to bet on small after seeing that it was <strong>big for many games</strong>. This is where I fell to <a href="https://en.wikipedia.org/wiki/Gambler%27s_fallacy">gambler’s fallacy</a>. In fact, they have a monitor that outputs the result of the last 20 games (granting gamblers’ the illusion of control).</p><p>No price for getting the guess correct: I lost. Lucky for me, losing one game (100$) was bad enough and we decide to cash out and went on to visit other areas in Macau.</p><p>* There are many ways to place the bet. Big and small is one way and for simplicity, let’s stay with this.</p><h3>Applying Monte Carlo</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*7aaG6RKQSwjNPlvlxU-APg.jpeg" /><figcaption>Simulation like Black Mirror’s San Junipero</figcaption></figure><p>Wouldn’t it be good if life is like a game where we can reset whenever something goes wrong? Suppose we have infinite chance and money and if we were to continue betting in big and small, will we actually win? Was it a one-time off thing that we lost?</p><p>I am curious if I were to continue (assuming infinite wealth), what would be the outcome? Monte Carlo simulations will allow us to answer some of that.</p><h3>Assumptions and some simple math</h3><p>Big and small does have some additional rules on top of what I had described above. However, to simplify this exercise, let us simply assume:</p><ol><li>All payout will be 1:1</li><li>Let us also exclude the special wins: three of a kind (1,1,1…etc)</li><li>The choice in big and small results in the same probability, so it does not matter if we choose big or small. Mathematically, choose big all the way or small all the way gives us the small probability of winning anyway. As such, all we need to do is to simulate the same probability of the actual game in our simulation!</li></ol><p>Therefore, it is important to know what is the probability of winning. One easy way to compute this probability is to take the possible combinations for small divided by the total possible combinations of 3 dice. It is enough to focus on computing the probability of winning ‘small’. (Computing the probability for small is the same as big)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*uBNWDhX0aLv6uXsdrHQDcw.png" /><figcaption><a href="https://www.thoughtco.com/probabilities-for-rolling-three-dice-3126558">https://www.thoughtco.com/probabilities-for-rolling-three-dice-3126558</a></figcaption></figure><p>Also, remember that we should exclude three of a kind. Possible combinations are (1,1,1) to (3,3,3) for small, which we need to exclude. This will give us 107–2 = 105 combinations out of 216 = odds of winning to be 48.61% as verified [2]</p><p>In other words, this meant that the <strong>house edge</strong> is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*fxyliy7oKZGu9t1tsvxZcg.png" /><figcaption>House edge of -2.78%</figcaption></figure><p>You can also see the above as the expected value. Seems like the odds are already against us before we start betting.</p><h3>The Simulation (Actual)</h3><p>Now, for the actual simulation, all we need to do is to simulate the same odds as we derived. <em>I will post the link to the code at the end of the article.</em></p><p>Suppose I have 1000$. For each game, let us attempt to bet 100$. If we decide to go all out, we have the opportunity for 10 games. Now, in reality, we only have 10 chances. But now, in a simulated reality, we can play 10 games, reset, play 10 games..etc. So let us try to simulate 2000 instances with 10 consecutive games each.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a9gQ415FRXrde_5cDTyIFQ.png" /><figcaption>redline = expected value = $971</figcaption></figure><p>In order to visualize the results, we can simply plot the 100 instances out with each color lines representing an instance. (So there are 100 instances or lines). Let us view the distribution to have an even better idea of the 100 instances.</p><p>In order to visualize the results, we can simply plot the 2000 instances out with each color lines representing an instance. (So there are 100 instances or lines). Let us view the distribution to have an even better idea of the 2000 instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p-1N_z0Fhcrbf95Z1cutMQ.png" /></figure><p>There is near 50–50 chance of either losing or winning above your initial capital (chances moving towards losing as we can see from our expected reward). Let&#39;s repeat this with more instances (5000 instances) to see if the conclusion remains the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UaKdggU_v63bWzkE1OhZOQ.png" /><figcaption>redline = expected value = $972</figcaption></figure><p>At 5000 instances, we get a pretty similar result as 2000 instances, with expectation below our initial capital on average across all instances.</p><p><strong><em>Other analyses have shown that longer games lead to an even lower chance of winning</em></strong> [2] Is this similar for the case of sic bo? Let&#39;s see:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KTi1Lnxs-g0vfz0tobZ5ew.png" /><figcaption>redline = expected value = $715</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G3qxZ5I11wHjXxLXj2TpAQ.png" /></figure><p>The above is the histogram of 100 games per instance and we went for 2000 instances. In this scenario, we can see some instance reaching negative capital and the overall expectation is much much lower than 10 consecutive games. We definitely should not play a longer game.</p><p>** Also keep in mind, in order to play beyond your capital, we have to assume that there is some form of leverage or loan involved. But since we are in simul land, we can go beyond what we started.</p><h3>Conclusion</h3><p>It is interesting to simulate our gambling experience again using Monte Carlo with some simple loops and plotly to visualize our results. The results might not be conclusive. We can improve by adding including more accurate sic bo rules as well as setting more instances to get a better distribution. Try it yourself! You can pretty much simulate any games as long as you know the probability as well as the rules.</p><p>Keep in mind that such games are meant to bring out the gambling nature in us. Sometimes we just want to believe that we are able to overcome the odds.</p><h3>Code</h3><p>The code is available at <a href="https://github.com/germayneng/simple_monte_carlo_big-and-small">https://github.com/germayneng/simple_monte_carlo_big-and-small</a></p><h3>References</h3><p>[1] <a href="https://wizardofodds.com/games/sic-bo/">https://wizardofodds.com/games/sic-bo/</a></p><p>[2] <a href="https://towardsdatascience.com/the-house-always-wins-monte-carlo-simulation-eb82787da2a3">https://towardsdatascience.com/the-house-always-wins-monte-carlo-simulation-eb82787da2a3</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3936f9bcf4bf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eatpredlove/casinos-big-and-small-using-monte-carlo-simulation-3936f9bcf4bf">Casino’s Big and Small — using Monte Carlo Simulation</a> was originally published in <a href="https://medium.com/eatpredlove">eat-pred-love</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kaggle Home Credit, a silver solution (Top 5%)]]></title>
            <link>https://medium.com/eatpredlove/kaggle-home-credit-solution-20328c80a226?source=rss----f6116b679a7c---4</link>
            <guid isPermaLink="false">https://medium.com/p/20328c80a226</guid>
            <category><![CDATA[hackathons]]></category>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[kaggle-competition]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[germayne]]></dc:creator>
            <pubDate>Fri, 21 Dec 2018 08:07:07 GMT</pubDate>
            <atom:updated>2019-08-22T07:21:45.410Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*F9359FbLmjD_wwn2-O0Iew.png" /></figure><h3>Overview</h3><p>After the end of the competition 3 months ago, there were heavier workload as well as more commitments in real life. Therefore, this is really very overdue. But “Better to be late than never”. I briefly posted my thoughts previously <a href="https://medium.com/germayne/wrapping-up-kaggles-home-credit-competition-c660c2c55524">here</a>. In this article, I will not go through the details ( I believe there are many gold solutions out there) but instead, share what I did differently.</p><p>Back to business: This competition requires kagglers to build a credit-scoring model of sorts. The main objective is to classify if a given individual did not repay the loan (1) and otherwise (0). The fun part is that we are given lots of data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s6uRljTMIgyBCD1ok4gfrg.png" /><figcaption>Source: <a href="https://www.kaggle.com/c/home-credit-default-risk/data">https://www.kaggle.com/c/home-credit-default-risk/data</a></figcaption></figure><p>Essentially, we have the main data (application) as well as different information of the users. (credit card, previous loans, installments… etc) In order words, we have to find methods to combine them. (since the target variable is in the main application df) This also gave room for creativity when it comes to feature engineering.</p><h3>Features Engineering</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r5N3pq9D8MI617YO_Cirxg.jpeg" /><figcaption>Early whiteboarding</figcaption></figure><p>Features engineering is the place where we data scientist expresses our creativity.</p><p>The features engineering process can be split into 2 phase:<br>1) Side Data</p><p>2) Main Data</p><p>Side data includes <strong>bureau, credit, installments, cash </strong>as well as the <strong>previous loans</strong>. They have to be aggregated before merging to the main data(application_train/test). We can see, for example, multiple entries of customer A, while in the main data, we only have unique entries of a customer. (1 customer A)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ErmztgQYb0Tep33SkJIy9w.png" /><figcaption>A look at<strong> preprocessing.py</strong>. Feature engineering of side data.</figcaption></figure><p>Some of them are time series data, as such, we can take into account things like the latest or earliest K data before aggregation.</p><p>Aggregation usually involves the standard statistics: <strong>Mean, Mode, Median, Sum, Variance/Std, Kurtosis, Skew</strong>, as well as <strong>Linear regression</strong>. Linear regression involves regressing the grouped data with a time index and using the beta coefficient as features.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*vhvXVDiJS0cyzimBIx527Q.png" /><figcaption>An illustrated example of side data. Multiple entries for a customer</figcaption></figure><p>Apart from the multiple numerical entries that we need to aggregate, there are also various categorical features. Since it is a many to one mapping to the main data, we must think of some methods to aggregate them. Some methods to do so will be to one-hot-encode them and taking the average. Other methods include target-encoding and averaging the encoded categorical.</p><p>Once features engineering are done on the side data, we can apply the same to the main data.</p><h3>Features Embedding</h3><p>Similar to word2vec, we are also able to get the embedding spaces for some of the categorical variables. For more information, you can refer to this <a href="https://arxiv.org/abs/1604.06737">paper</a>. By training on all the data, with embedding layers for the categorical variables, we can later extract the embedding layer as features for our main model. (XGB/LGBM)</p><p>At the same time, the same Feed Forward NN which I used for the embedding extraction can also be used as a different model for ensembling. However, it is not really useful (Not surprising here since I did not do much tunning on its overall architecture)</p><p>Structure of the NN is as such:</p><ul><li>Multi-head input model taking in the different categorical variables</li><li>Embedding layer for each input to reduce the dimension space</li><li>Flatten layer after each embedding layer</li><li>Usually 2 super dense RELU layer (1000, 500)</li><li>End with a sigmoid</li></ul><h3>Features Interactions</h3><p>Features interaction is something that I focused on as well. There are 2 main ways in which I induced features interactions in the model: Compute <a href="http://helios.mm.di.uoa.gr/~rouvas/ssi/sigkdd/sigkdd.vol3.1/barreca.pdf">target/mean encoding</a> grouped by the collection of variables. I.e if I need the interaction of V1 and V2, I can compute the mean encoding of V1-V2 combination.</p><p>I used a custom function to do it because I want to have more flexibility and control during the genetic algorithm stage (see below). Otherwise, you can find a module to implement it here. (I have not used it personally so I am not sure if it is the same)</p><p>The target encoding will be introduced in each cross-validation layers after the splitting and before the modeling. This ensures no leakage from the valid data sets while the encoding is computed only from the train. Other measures I added is to split the train into yet another inner 20 fold before computing the encoding.</p><p>Another way to induce features-interaction is to make use of LibFM. The paper is described <a href="https://www.csie.ntu.edu.tw/~b97053/paper/Rendle2010FM.pdf">here</a>. Of course, I was inspired by <a href="https://www.kaggle.com/cpmpml">CPMP</a> for this approach. Using Keras, we can build an NN and extract its embeddings trained on the features in which we want to induce its interaction. This concept runs heavily on factorized machines for recommendation systems.</p><p>We will extract these paired interactions as:</p><blockquote><em>Factor + Bias</em></blockquote><p>Another additional point is the flexibility to define the number of latent variables we want. With the factor and bias extracted, we can add them as features to your main model. I have created several interactions and extracted the factor + bias as features for various models. I will include them later in the stacking process.</p><h3>Modeling &amp; Cross-validation</h3><p>My main go-to algorithm in this competition is <a href="https://lightgbm.readthedocs.io/en/latest/">LightGBM</a>. Due to the large dimension of the dataset (especially after Features engineering), I prefer the speed that LGBM offers. One thing that I found out late was that after LGBM version 2.1.2, there is this parameter known as boost_from_average. <a href="https://github.com/Microsoft/LightGBM/issues/1487">By default, it is True</a>. As such, most of my models from AWS are based on this parameter. I had to re-trained some of the models with the setting turned to False. But this actually provided me with even more diverse models, which added to the diversification needed in stacking later on.</p><p>I also tried Xgboost early on in the competition but ended up sticking to LightGBM throughout. Catboost was not used since I have my own encoding pipeline but I might try them out in future (Catboost’s core advantage over others is in its own encoding functions).</p><p>Not forgetting <a href="https://blog.keras.io/introducing-keras-2.html">Keras 2.0</a>, utilizing it for embedding weights as well as libFM. I kind of love the new standard way of defining the Neural network.</p><p>As for cross-validation, I am sticking it with the usual 5-fold CV. No particular reason why it is preferred over stratified 5-fold CV apart from the fact that it provides the same directional relationship with the leaderboard (positive correlation). This ensured that I can believe in my local 5-fold cv and not overfit to the public leaderboard.</p><p>An important point to note is to ensure the same validation split to have:</p><ol><li>Fair comparison across models</li><li>No leakage when staking later on (since this affects the OOF)</li></ol><p>I have also spent time setting up my own personal modeling code structure in this competition (including the validation structure). This helps in future and especially later on for my genetic selection, where you would have more control to automate the modeling process.</p><h3>Genetic Selection</h3><p>This was the main reason for my USD100 AWS cost at the end of the competition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kWJJfLTNC-IRukPUvB8J5Q.png" /><figcaption>Bot timestamp (collected on telegram) of each generic runs ran on AWS</figcaption></figure><p>This is also inspired by a fellow kaggler known as <a href="https://www.kaggle.com/jacekpoplawski">Jacek</a> who briefly described this in a previous competition (Porto). The best kagglers are often the ones who learned from the best. Based on my understanding of his description, I implemented my own version. The idea is very simple:</p><ol><li><em>Select a base of good features. I believe I started with 160 features. There are many ways to do this. Either via forwarding selection or by features importance gain. I ran a base model with LightGBM on the entire features space, extract the features importance and subset to those with importance gain &gt; 1000.</em></li><li><em>Create a master list of features (3000) as well as interactions (any possible interactions). I played pretty safe and only interacted non-cat with non-cat as well as cat with cat.</em></li><li><em>Generation 1: Randomly select features not in your base model (160) from the master list and interaction list.</em></li><li><em>Run Generation 1 over 20 times? — select the best 2 models.</em></li><li><em>Take the total distinct features of the 2 models. Simply: Distinct(Features_Model_1 + Features_Model_2)</em></li><li><em>Create a “mutation layer” for (5). and add random features from the master list of features (3000) as well as interactions (any possible interactions). </em><strong>This layer also takes a proportion of the new subset of features (I set to P= 0.8). Reason for this is that I do not want the number of the subset of features to grow for each generation. As such, I want to introduce a form of ‘dropping’ features.</strong></li><li><em>Generation 2: Repeat (3) and (4) while using the product from (6) as the base.</em></li><li><em>Run this over Nth generation, where for each generation we take a good subset of features and add some random element.</em></li></ol><p>Basically, I wanted an automatic approach to select the best features. This approach allows me to systematically try different features interactions amongst the features. Moreover, it is largely automatic. The algorithm runs in AWS while I get to monitor the progress on my phone (I ran the algorithm mostly overnight, through work..). I could disable AWS easily via the AWS mobile app.</p><h3>Final Essemble/ Stacking and fingers crossed</h3><p>I have the advantage of a diverse number of models ran on a different subset of features as well as interactions. I believe by the end of the competition, I have nearly 1000 automatically generated models.</p><p>The final solution is a blend of 2 different stacks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hNvDOOEfuJMg8roxCtac6w.jpeg" /><figcaption>Typical stacking pipeline</figcaption></figure><p>Stacking is where we train the out-of-fold predictions of each model and apply it to the test-predictions. The idea is that it will optimize the weight of each model (think regression: intersection + w1 * Model_1 + w2 * Model_2… )</p><p>In this case, I have tried using Xgboost as the stacker but through experimentation, Ridge regression/ logistic regression gave the best results (CV). In the end, I decided to use Ridge regression as the main stacker. (level 1 stacker)</p><ol><li>Stack A using Ridge regression on a myriad of Good Models (Genetic), as well as different libFM models</li><li>Stack B using Ridge regression on other sets of Good Models (Genetic) as well as different libFM models. Some of the models I ran it again using <strong>LGBM</strong>’s <em>boost_from_average = False</em></li><li>Apply a blend (weighted average) on 1 + 2. The blend weight is estimated using 5 fold CV (the same fold used in modeling) for the highest ROC-AUC.</li></ol><h3>Closing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OY_j_PGqc3hV3Q2L9e7AtA.png" /><figcaption>Final closing placement. Total of 92 submissions</figcaption></figure><p>This is definitely a good experience. Not my first solo kaggle competition and not my last. But I definitely learned a lot more when it comes to optimizing my code (as I structured it for AWS). Also pretty contented that I remained pretty stagnant in the leaderboard (no overfitting).</p><p><em>Now, when shall I begin my journey for my gold medal? (Last piece to a kaggle master)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20328c80a226" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eatpredlove/kaggle-home-credit-solution-20328c80a226">Kaggle Home Credit, a silver solution (Top 5%)</a> was originally published in <a href="https://medium.com/eatpredlove">eat-pred-love</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Wrapping up Kaggle’s Home credit competition]]></title>
            <link>https://medium.com/eatpredlove/wrapping-up-kaggles-home-credit-competition-c660c2c55524?source=rss----f6116b679a7c---4</link>
            <guid isPermaLink="false">https://medium.com/p/c660c2c55524</guid>
            <category><![CDATA[competition]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[homecredit]]></category>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[germayne]]></dc:creator>
            <pubDate>Thu, 30 Aug 2018 09:54:47 GMT</pubDate>
            <atom:updated>2018-12-27T10:26:18.535Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hgcevWk-efKZeMhJeWWL8w.png" /><figcaption>Credit: Yahoo Finance</figcaption></figure><p>Despite being busy with my schedule recently, I managed to obtain a silver medal (top 5% placement) in this competition. I did struggle because i was doing it alone, which meant that I had to juggle the entire competition pipeline with other commitments / work. But I am glad the effort did pay off eventually. :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2IbL0kR5K1bC7QSgeYqjEw.png" /><figcaption>silver placing: 344th out of 7198 participants</figcaption></figure><p>However, I felt that I could do better. I will elaborate more when I explain some of the methodologies that I have adopted in this competition in another post. At the same time, I made a costly mistake: not selecting my best submission. Luckily, this did not cost me heavily.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CCEHP-lASXG6faenBMxNWQ.png" /><figcaption>solution 0.79639 gives a 292th ranking</figcaption></figure><p>I am definitely more adventurous in this competition, utilizing more tools (LibFM as well as Keras). But due to time/ resource constraints, I am not able to do everything I had planned out.</p><p>On a side note, the cost of this silver medal is pretty hefty. Looking at how much AWS cost I racked up…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uKTx7W1G7TRul7PSXtQCEw.png" /><figcaption>101 USD</figcaption></figure><p>Most of the time, I am using t2.2xlarge since it is the most cost efficient instance in my opinion. ( If you guys have better / cheaper options, do share with me! ) If I am getting memory error or I need some of the big guns (i.e GPU), I will either use c5.4xlarge (computation), r4.2xlarge (memory) or the g3.4xlarge (cheap gpu).</p><p>In conclusion, this is definitely a competition that is very intense and fun. I definitely learned more regarding credit scoring. On hindsight, I definitely should use all the variables in the data, which should give a stronger model. I will be posting the unique strategies that I had utilized in another post once I have cleared and clean everything up.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c660c2c55524" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eatpredlove/wrapping-up-kaggles-home-credit-competition-c660c2c55524">Wrapping up Kaggle’s Home credit competition</a> was originally published in <a href="https://medium.com/eatpredlove">eat-pred-love</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Filling in gaps in time series data]]></title>
            <link>https://medium.com/eatpredlove/filling-in-gaps-in-time-series-data-50e240e1e31f?source=rss----f6116b679a7c---4</link>
            <guid isPermaLink="false">https://medium.com/p/50e240e1e31f</guid>
            <category><![CDATA[r]]></category>
            <category><![CDATA[timeseries]]></category>
            <category><![CDATA[data-cleaning]]></category>
            <category><![CDATA[pandas]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[germayne]]></dc:creator>
            <pubDate>Tue, 31 Jul 2018 09:29:13 GMT</pubDate>
            <atom:updated>2018-12-23T07:27:07.711Z</atom:updated>
            <content:encoded><![CDATA[<p>In my current job, I deal with lots of time-series based data. As opposed to cross-sectional data, the temporal ordering of each row is very important. This also makes working with time-series based data more tedious. ( you have to take extra care, else you might make some mistakes. But that is a story for another day)</p><p>Today, I will want to discuss on a particular problem: gaps in time-series data. Imagine you have a data set on 1000 stores across a time period of 2014 to 2017 monthly data. There will be scenarios where some stores, say store 1, only recorded data in certain months. For the sake of this example, let us assume that store 1 has missing data points for some months in 2016 and 2017 while everything is intact. At the same time, store 2 has missing data points for some months in 2014 and 2015. Essentially, all 1000 stores do not have a full 36 monthly data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/1*2j1PEi1-GdEGb-4nDjCJXw.png" /><figcaption>Typical missing data which you do not find in Kaggle</figcaption></figure><p>The problem arises when you want to create some time features, and a basic one that comes to mind will be ‘’previous month’’. A simple way to do so will be applying a lag of 1 period grouped by the stores. However, since the data across the 1000 stores are having different periods, doing a lag transformation will result in a wrong output.</p><p>A simple solution is to do a pivot on the data and revert back to the original form. Doing so will automatically generate the missing period. If you are a R user, it will be tidyr::separate and tidyr::gather while if you are a python user, it will be the .pivot and then .melt method from pandas. Below is an example in R. You can apply the same logic for pandas. (In fact, you can refer to another article that I have regarding pandas pivot)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4dffe0717fd3df293a3f093128fb0c40/href">https://medium.com/media/4dffe0717fd3df293a3f093128fb0c40/href</a></iframe><h3><strong>What if all the stores have incomplete data?</strong></h3><p>So the above scenario works out if one of the stores has the complete date. For example, if monthly, then one of the stores should have 12 months of data. If it is daily, then one of the stores should have 365? rows of daily data. Otherwise, one simple hack is to append a “mock data”. With this mock data, you can generate with the same headers (as your main data frame) as well as generate a sequence of date. Below I will illustrate this example for daily data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0fabe132575faa615dba65788a9b73e0/href">https://medium.com/media/0fabe132575faa615dba65788a9b73e0/href</a></iframe><p>if you are on python, You can do this similarly:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4359c3e30b1ecaed0d47da0d81df2822/href">https://medium.com/media/4359c3e30b1ecaed0d47da0d81df2822/href</a></iframe><p>Once you append it, continue pivoting (tidyr on r/ pivot on python) and undo the pivot and you should have all the respective stores with all the dates as well as NA for the sales. Now you can either leave it as such or replace them with 0.</p><p>So I hoped that these little tips helped you in manipulating these pesky time series data!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50e240e1e31f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eatpredlove/filling-in-gaps-in-time-series-data-50e240e1e31f">Filling in gaps in time series data</a> was originally published in <a href="https://medium.com/eatpredlove">eat-pred-love</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Easy guide to installing keras + Tensorflow]]></title>
            <link>https://medium.com/eatpredlove/easy-guide-to-installing-keras-tensorflow-3444b1379fed?source=rss----f6116b679a7c---4</link>
            <guid isPermaLink="false">https://medium.com/p/3444b1379fed</guid>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[germayne]]></dc:creator>
            <pubDate>Wed, 04 Jul 2018 04:47:18 GMT</pubDate>
            <atom:updated>2018-12-27T10:33:56.944Z</atom:updated>
            <content:encoded><![CDATA[<p>Getting ready for deep learning is not as hard as you might think. (minus the modelling and architecture process, underlying mathematics)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/0*T-OuwWLoSqRTt9Ax.png" /></figure><p>In this post, we will go through a simple tutorial to get started with deep learning on your pc/ laptop. Many people are freaked out at the initial set up process. It is not as complex as you think so, let us get on to it! At the end of this post, you will be able to install tensorflow with keras backend on your laptop and you will be able to start running some deep learning models like a scientist!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/0*CWqnz5fZel0yBvbK.jpg" /><figcaption><em>what i feel when i think of deep learning</em></figcaption></figure><p>I will assume you have <a href="https://www.anaconda.com/download/">anaconda3</a> environment installed, because it is really the best environment when it comes to doing data science using python.</p><p>Also, make sure you have a pretty decent Nvidia graphics card if you are using a laptop. (although this pretty much applies to desktop) Personally, I use a gaming laptop for doing much of my data science work.</p><p>With that, let us begin.</p><h3>Tutorial</h3><ul><li>There will be 2 prerequisites to be able to run deep learning. We need to have <strong>CUDA Toolkit 8.0</strong> as well as <strong>cuDNN v5.1 for CUDA 8.0</strong>. As for now, you have to exact version of the 2 programs.</li></ul><p>we will get cuDNN v5.1 <a href="https://developer.nvidia.com/rdp/cudnn-download">here</a> as well as Cuda 8.0 under the archives <a href="https://developer.nvidia.com/cuda-toolkit-archive">here</a></p><ul><li>Once you have downloaded them. Install CUDA 8.0. I believe at the point where I was installing, they also required me to install Microsoft visual studios. If during installation, you were prompt, then go ahead and <a href="https://www.visualstudio.com/downloads/">install MVS</a> then return to install Cuda. (I downloaded the community version)</li><li>Now, place your entire cuDNN file (unzipped) into your C: directory. Once that is done, you will have to add this to the environment path.</li></ul><pre>C:\cudnn-8.0-windows10-x64-v5.1\cuda\bin</pre><p>If you do not understand about environmental path, what you need to do is: Right click my computer &gt; advanced system settings &gt; environmental variables. You will see system variables. Scroll to this PATH variable and add the above line into it.</p><ul><li>Create a new python environment solely for this. To do so, open <strong>anaconda prompt</strong> and type this:</li></ul><pre>conda create -n deeplearning python=3.5 numpy scipy matplotlib spyder ipython notebook</pre><p>You can replace deeplearning with any name you want to. deeplearning is the name of the new python environment you will be creating. In this tutorial, I will be creating my environment as deeplearning</p><ul><li>Once done, you must activate this environment. In future, if you want to do your deep learning, you must first activate this environment before proceeding:</li></ul><p>Then with deeplearning environment activated,</p><pre>pip install --ignore-installed --upgrade <a href="https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.0.1-cp35-cp35m-win_amd64.whl">https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.0.1-cp35-cp35m-win_amd64.whl</a></pre><p>Once it is done, continue to install keras:</p><ul><li>At this point, you are done! <a href="https://github.com/antoniosehk/keras-tensorflow-windows-installation/blob/master/examples/mnist_mlp.py">Download this</a> sample py file and run it. It should take few minutes, indicating everything is done correctly.</li></ul><p>To run the file, again, go to anaconda prompt,</p><pre>activate deeplearning python mnist_mlp.py</pre><h3>Others</h3><ul><li>if for some reason you are not installing correctly, you can check if tensorflow is using gpu. You should see <strong>GPU</strong> appearing.</li></ul><pre>from tensorflow.python.client import device_lib print(device_lib.list_local_devices()) </pre><h3>Future</h3><p>In future, I will go through some compiled methods to set up your own cloud instances (AWS.. etc), since most people will not have a powerful local machine to go for deep learning. Moreover, there is a chance that running keras/tensor on your machine might damage it in the long run.</p><p><strong>Tags: </strong><a href="https://germayneng.github.io/tags/#deep">deep</a>, <a href="https://germayneng.github.io/tags/#keras">keras</a>, <a href="https://germayneng.github.io/tags/#learning">learning</a>, <a href="https://germayneng.github.io/tags/#python">python</a>, <a href="https://germayneng.github.io/tags/#tensorflow">tensorflow</a></p><p><strong>Categories: </strong><a href="https://germayneng.github.io/categories/#tutorial">tutorial</a></p><p><strong>Updated:</strong> October 27, 2017</p><p><em>Originally published at </em><a href="https://germayneng.github.io/Getting_started_with_deep_learning.html"><em>germayneng.github.io</em></a><em> on October 27, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3444b1379fed" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eatpredlove/easy-guide-to-installing-keras-tensorflow-3444b1379fed">Easy guide to installing keras + Tensorflow</a> was originally published in <a href="https://medium.com/eatpredlove">eat-pred-love</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The new kids on the block - Elastic net, LASSO and ridge]]></title>
            <link>https://medium.com/eatpredlove/the-new-kids-around-the-block-elastic-net-lasso-and-ridge-faf4523474db?source=rss----f6116b679a7c---4</link>
            <guid isPermaLink="false">https://medium.com/p/faf4523474db</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[germayne]]></category>
            <category><![CDATA[regularized-regression]]></category>
            <category><![CDATA[regression]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[germayne]]></dc:creator>
            <pubDate>Tue, 03 Jul 2018 14:04:28 GMT</pubDate>
            <atom:updated>2018-12-27T10:35:24.551Z</atom:updated>
            <content:encoded><![CDATA[<h3>The new kids on the block — Elastic net, LASSO and ridge</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wkgTiMP8jKFwhaSf.jpg" /><figcaption>The new kids</figcaption></figure><p>Elastic net, lasso and ridge are the new cool kids that joined your neighborhood. They provide the union of statistics and machine learning. They are known as pernalized regression models.</p><h3>“ My personal bias is this: In this day and age, if you are building linear models without any regularization, you must be really special. Always regularize. It’s required.” — <a href="https://nycdatascience.com/blog/meetup/featured-talk-1-kaggle-data-scientist-owen-zhang/">Owen Zhang, NYC data science academy</a></h3><p>Penalized regression helps to deal with 2 major issue in regression: feature selection and multicollinearity. It helps to prevent overfitting and outputs a model that fits the training data less well as compared to OLS but able to capture the generalization better and less sensitive to variation from outliers. Elastic net is a general form of ridge and lasso. Think of it as a combination of both. Recall in usual regression, we make use of OLS — minimizing the sum of squares of the difference between actual and predicted values.</p><p>Assuming we have M number of features and N number of data points:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*--CVq5KnJDldsGwpOEB_Eg.png" /><figcaption>The original OLS</figcaption></figure><p>Whereas the elastic net regularization estimate process will minimize the sum of squares and a penalty based on the size of the estimated coefficient. We call these penalties the L1 / L2 Norm</p><p>The hyperparameter lambda controls the weight of the penalty. The optimal value of alpha and lambda is obtained using a grid search method for the best cv value (k-fold cv)</p><p>Depending on which penalty is imposed, it will be known as Ridge (L2 ) or Lasso (L1).</p><h3><strong>Ridge Regression</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*HhT9Bbz3064asY2P3n-_tQ.png" /><figcaption>Residual sum of squares with additional penalty (L2)</figcaption></figure><ul><li>Ridge helps to deal with the instability of estimates of coefficient of linear models when they are collinear.</li><li>Coefficients of unimportant features will shrink to <strong>near zero</strong></li><li>Hyperparameter alpha = 0</li><li>Minimize the objective (RSS + L2 Norm)</li><li>As lambda increases, RSS increases and model complexity decreases</li></ul><h3>Lasso regression</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*iwkex__FnZYoQtF8t1wvIA.png" /><figcaption>Residual sum of squares with additional penalty (L1)</figcaption></figure><ul><li>Lasso perform feature selection that forces coefficents for some variables to be zero.</li><li>Hyperparamter alpha = 1</li><li>Minimize the objective (RSS + L1 Norm)</li><li>As lambda increases, RSS increases and model complexity decreases</li><li>Note that LASSO will remove variables (giving coefficient 0) so as lambda increases, expect high sparsity.</li></ul><p>Theoritically, if lambda = 0, then it will be minimizing only the RSS and this will be the regular regression that we know. However, as pointed out by <a href="http://ellisp.github.io/blog/2016/08/13/fitbit-lasso">peter</a>, the result output by <strong>glmnet</strong> will be different due to numerical calculation issues.</p><h3>The best of both worlds?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/845/1*IO3BTHuQz_vr24hMZUVwow.png" /></figure><p>By having both penalties together, it will give us the elastic net regularization. (2005)</p><p><em>Originally published at </em><a href="https://germayneng.github.io/Elastic_Net_Regularization.html"><em>germayneng.github.io</em></a><em> on June 22, 2017.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=faf4523474db" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eatpredlove/the-new-kids-around-the-block-elastic-net-lasso-and-ridge-faf4523474db">The new kids on the block - Elastic net, LASSO and ridge</a> was originally published in <a href="https://medium.com/eatpredlove">eat-pred-love</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[About…]]></title>
            <link>https://medium.com/eatpredlove/about-me-f70a17c7e14?source=rss----f6116b679a7c---4</link>
            <guid isPermaLink="false">https://medium.com/p/f70a17c7e14</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[germayne]]></category>
            <category><![CDATA[about]]></category>
            <category><![CDATA[data-scientist]]></category>
            <dc:creator><![CDATA[germayne]]></dc:creator>
            <pubDate>Tue, 03 Jul 2018 14:04:08 GMT</pubDate>
            <atom:updated>2018-12-24T03:14:17.273Z</atom:updated>
            <content:encoded><![CDATA[<p>Eat, Pred, Love is a medium where I express my interests in data science, computer science as well as any mathematical concepts which I find interesting from my journey in the data science magical realm.</p><p>Data science is an up and coming field in various industries or verticals. One can also argue that it is simply a rebranding of statisticians or computer scientist.</p><blockquote>So what is a data scientist?</blockquote><p>Josh Wills once quote on <a href="https://twitter.com/josh_wills/status/198093512149958656?lang=en">twitter</a>:</p><h3>Data Scientist (n.): Person who is better at statistics than any software engineer and better at software engineering than any statistician.</h3><p>Another good analogy would be to compare data scientists to chefs. The data will be equivalent to the raw ingredients. Machine learning algorithms, R, python will be similar to kitchen equipment. It is the art for data scientists/ chefs to wipe up something good from it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/0*26tLzd-yczS5bFZa.png" /></figure><h3>About myself…</h3><p>My personal interests are in state of the art machine learning and deep learning application. I feel that embarking on a data science route requires you to not be afraid of learning. The development currently is rapid and new technologies, APIs, papers are being released on a daily basis.</p><p>Since young, I have been intrigued by how artificial intelligence works (see Will Smith’s I,Robot). In my free time, I love to participate in kaggle competitions. If you are curious about the application of data science in different industries, there is no platform as extensive as kaggle.</p><p>I hope this platform can bring about some food for thoughts/ help anyone. Feel free to leave some comments in any of the posts :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f70a17c7e14" width="1" height="1" alt=""><hr><p><a href="https://medium.com/eatpredlove/about-me-f70a17c7e14">About…</a> was originally published in <a href="https://medium.com/eatpredlove">eat-pred-love</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>