<?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 Mauricio Maroto on Medium]]></title>
        <description><![CDATA[Stories by Mauricio Maroto on Medium]]></description>
        <link>https://medium.com/@mauriciomaroto?source=rss-5e863bc9347------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jKUgZQHoX_0iVxmuPXjojg.png</url>
            <title>Stories by Mauricio Maroto on Medium</title>
            <link>https://medium.com/@mauriciomaroto?source=rss-5e863bc9347------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 16:22:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mauriciomaroto/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[My take on [ ].reduce( )]]></title>
            <link>https://medium.com/@mauriciomaroto/my-take-on-reduce-ed0cc01d55ef?source=rss-5e863bc9347------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed0cc01d55ef</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[methods]]></category>
            <dc:creator><![CDATA[Mauricio Maroto]]></dc:creator>
            <pubDate>Fri, 02 Mar 2018 20:04:51 GMT</pubDate>
            <atom:updated>2018-03-02T20:14:02.940Z</atom:updated>
            <content:encoded><![CDATA[<h4>Having trouble? This might help.</h4><p>I ‘ve been learning Javascript and it’s been such a wonderful endeavor.</p><p>I decided to move from Python to Javascript because I wanted to have more front-end freedom.</p><blockquote>Or should I say, to actually have front-end capabilities, because Python, as much a great language and all, it just lacks.</blockquote><h4>Pythonis great, but…</h4><p>Python is great at many things back-end (nowadays featuring Artificial Intelligence (AI) applications), and it also features nice readability, no need to compile (as it’s interpreted) and there is a huge community behind it, which boosts its posibililties.</p><p>However, JavaScript is the language to go if you want to <em>show </em>things on a web browser. Be it Chrome, Firefox, Safari, mobile browsers or any other. There may be language wrappers, but most likely, all of them are built on top of Javascript. So, it’s better, in my opinion, to learn Javascript if you need to show things in a web browser, such as a web app.</p><h4>Functional Methods</h4><p>Recently, Javascript (Js) is getting a lot of attention because of its functional programming features. With each Javascript language evolution, seems like there are more and more functional methods added.</p><p>Note that there is discussion about whether Js is a fully functional language or not, such as Haskell. You can read more about that at Eric’s blog series <a href="https://medium.com/javascript-scene/a-functional-programmers-introduction-to-javascript-composing-software-d670d14ede30">here</a>.</p><h4>Who <em>upgrades </em>Js?</h4><p>So, the committe in charge of upgrading Javascript is called <a href="http://www.ecma-international.org/memento/TC39.htm">TC9</a>. They consist of companies, including all major browser vendors, and users. The most recent upgrade is called ECMAScript 6 (June 2015) and you can access it <a href="http://www.ecma-international.org/ecma-262/6.0/">here</a>. Note: it is very long and technical.</p><blockquote>Just so you know, Javascript is actually not called Javascript, but instead ECMAScript, because of license restrictions from <a href="http://exploringjs.com/es6/ch_about-es6.html#sec_javascript-vs-ecmascript">Oracle</a>.</blockquote><p>However, <a href="https://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.21">reduce</a> (array) method was introduced in ECMAScript 5.1 (2011) and it’s this blog’s goal to <em>help</em> you understand it and hopefully <em>use</em> it.</p><h4>Reduce</h4><p>According to MDN reference, the reduce method <em>“(…) applies a function against an accumulator and each element in the array (from left to right) to reduce it to a single value.”</em></p><p>Then, it goes on to define the <em>callback</em> function and optional <em>initialValue </em>parameter, which by the way, MDN recommends to supply it.</p><h4>Mandatory Example</h4><p>Let’s start with the mandatory example: the sum.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f051efcd461ce3e0a87d0041bbd8f711/href">https://medium.com/media/f051efcd461ce3e0a87d0041bbd8f711/href</a></iframe><p>What happened? Let’s go step by step:</p><ol><li>Since no initialValue was provided, then the array’s 1st element is passed to the accumulator (<em>accum</em>), and the 2nd element is passed to current value (<em>curr</em>). If initialValue is provided, i.e. 0, then, the accumulator will start at 0 and currentValue will start at the array’s 1st element (1).</li><li>Then, reduce applies the supplied function, which is to sum the current value to the accumulator. At this step, we have in memory a result of 0 + 1 = 1.</li><li>Then, reduce iterates over the following element carring over the previous accumulator result. In this iteration we have a result of 1 + 2 = 3.</li><li>Reduce method will continue all the way until the end, where the final result will be 6 + 4 = 10.</li></ol><h4>Visual Time</h4><p>If you have trouble understanding this, here’s an illustration for you:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/847/1*AUBOqD0jbXx14WDospdHug.png" /></figure><h4>First-Class Functions</h4><p>As probably you may know, since Js functions are first class, as Eric kindly <a href="https://medium.com/javascript-scene/higher-order-functions-composing-software-5365cf2cbe99">explains</a>, then the previous example is exactly the same as:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4d756ca3c8cf3cce328157115e8e938d/href">https://medium.com/media/4d756ca3c8cf3cce328157115e8e938d/href</a></iframe><p>You can also insert any logic inside the reducer function (with or without <em>initialValue</em>) to boost more interesting reduce possibilities, but the method’s goal is to iterate over an object, accumulate, move forward, repeat and so on.</p><h4>Reduce Objects</h4><p>Reduce can also be applied to objects (indirectly), not just arrays:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3d1cb87382db29e38e441a50c6c59f1/href">https://medium.com/media/e3d1cb87382db29e38e441a50c6c59f1/href</a></iframe><p>As you can see, although using the computed property accesor and map over an array with keys and values, we may not be satisfied with the created object: and array of objects.</p><p>Albeit this may be good for some cases, you might need a pure object.</p><p>So reduce comes to the rescue, like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d2a43ba814e49b20f6502cca23d2157/href">https://medium.com/media/9d2a43ba814e49b20f6502cca23d2157/href</a></iframe><p>And there you have it! Now you have a nice object thanks to the reduce function applied right after the map method.</p><h4>Right!</h4><p>If you are wondering about the illustration, here it is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*FG0pZhY6Q8_fah8ARS-QSQ.png" /></figure><h4>Why?</h4><p>Let me outline how this worked:</p><ol><li>After the object creation, it remains iterable (an arrray of objects).</li><li>Since, we didn’t pass an <em>initialValue</em>, then the reducers’ accumulator starts at the arrays 1st element, which is the 1st object (‘dog’).</li><li>Then, the reducer’s current value starts at the array’s 2nd element, which is, the 2nd object (‘cat’).</li><li>Then, the <em>Object.assign</em> method copies an object to another object, which will assign the 2nd object to the 1st object.</li><li>Then, a similar process will happen with the array’s 3rd element (‘bear’), which will be assigned to the accumulator.</li></ol><h4>Other posibilities</h4><p>I believe reduce is a very good method, and it is suppossed to be functional, which should add to your functional programming arsenal.</p><blockquote>What do you think? Have you seen other reduce() aplications?</blockquote><blockquote>Until next one!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed0cc01d55ef" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Neural Networks = Black Box? →Part 2.]]></title>
            <link>https://medium.com/@mauriciomaroto/neural-networks-black-box-part-2-37a1f1c4498e?source=rss-5e863bc9347------2</link>
            <guid isPermaLink="false">https://medium.com/p/37a1f1c4498e</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Mauricio Maroto]]></dc:creator>
            <pubDate>Sat, 03 Jun 2017 03:44:08 GMT</pubDate>
            <atom:updated>2017-08-07T22:16:13.676Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>As you know, I have become a fan of Neural Networks and its inner workings. I believe that non-linear general rules are a big step forward into better predictions and applications.</blockquote><h4>Neural Networks’ Learning Process</h4><p><a href="https://medium.com/towards-data-science/neural-networks-black-box-b20723f9a417">Last post</a>, I talked about how internet articles seem to <em>worship </em>the Learning Process of Neural Networks (NN), but they fail to properly, and most importantly, visually show it. After all, this is how NN <em>sees </em>the world, don’t they?</p><p>In <em>general</em>, they argue that NNs <em>learn </em>from inputs and their corresponding target values, in a never-before-seen way, spanning new applications like image recognition, sequential wording, and more; only possible due to the NNs learning capabilities.</p><p>The simple NN Learning Process, in <em>short</em>, consists of non-linear relationships between inputs and corresponding target values that get more and more apparent with each feed-forward pass and with each epoch by passing information through many neurons with non-linear activations, thanks to the effort of minimizing a Loss measure, which the Neural Network <em>itself </em>takes the role (of minimizing it) with Gradient Descent (GD), and preferably, through the Backpropagation (BP) method.</p><blockquote>Phew(!?)</blockquote><p>So, I believe there are is a <em>gap </em>between the Learning Process and its inner workings. I mean, step-by-step visual inner workings.</p><blockquote>Is there a way to <strong>see </strong>step-by-step how a simple Neural Network learns? That’s my goal. So, yes now.</blockquote><h4>Visualizing a Simple Neural Network</h4><p>I have created a simple 3-neuron 1-sample 3-feature 1-(linear)-output Neural Network, shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*5SMsCeBMvcYyGSk0_8Pojw.png" /></figure><p>The abbreviations are as follows:</p><ul><li><strong>x</strong> are the inputs,</li><li><strong>w</strong> are weights: one set (3–3–2 weights) for each node (w1, w2, w3),</li><li><strong>b</strong> are biases: one for each node (b1, b2, b3),</li><li><strong>f()</strong> is the activation function: I use the logistic/sigmoid function for ease of computation, as the derivative is simply f(~)*( 1-f(~) ),</li><li><strong>Y</strong> is the corresponding target value: which, in my example, is simply 2.5,</li><li><strong>Y^</strong> is the predicted value: or, in other words, the NN output value.</li></ul><p>The underlying assumptions of the previous simple NN are the following:</p><ul><li><strong>One row of data for simplicity:</strong> Here, I am using just 1 sample (row). But, remember that the NN’s Learning Process pretty much is the same when you use batches (more rows) or the entire training dataset for each FFP.</li><li><strong>Weights randomly initialized at [-1, 1]:</strong> There are many initialization guidelines, and in turn, different learning results; however, some think that under normal situations, most conventional initializations converge to the true general rules underlying the datasets.</li><li><strong>Biases initialized like weights:</strong> I have seen NNs without biases, which I think it’s a shame, because biases provide added leverage for accurate learning, in terms of convergence.</li><li><strong>Learning rate (lr) is 0.2: </strong>which increases or decreases the <em>pace </em>at which NNs learn from data. Note that a high <em>lr </em>have disconvergence risks.</li></ul><blockquote>Note: In a few moments, I’ll add the derivative of the activations, f’().</blockquote><p>So, as you can see, for these inputs and this particular weights and biases initialization, our simple NN predicts a number (-0.76) far from the corresponding target value (2.5). Why?</p><blockquote>So, our simple Neural Network is predicting a bit… off, right?</blockquote><h4>Visualizing a Simple Neural Network Learning Process</h4><p>Yes, it is. So, we need our Neural Network to <strong><em>learn </em></strong>from our data. In theory, there are general rules governing the data generating process, and we need the NN to <em>get </em>that <em>out </em>of the data.</p><p>For that, we turn to the (Stochastic) Gradient Descent (GD) and Backpropagation (BP) algorithms.</p><p>The following are the weights and biases adjustments that will let the simple NN take a <em>step </em>towards minimizing the NN’s Loss, and with that, make <em>better </em>predictions:</p><blockquote>Note: In another post, I’ll show you the Gradient Descent and Backpropagation algorithms for this example.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*_YcW-ptowlHzGj6rgcU_LQ.png" /></figure><p>How to understand this:</p><ul><li><strong>This is the same simple NN as before</strong>, but,</li><li><strong>Each weight and bias has a corresponding adjustment:</strong> to the right, under <strong>Δw</strong> and <strong>Δb</strong> column) computed following GD and BP algorithms,</li><li><strong>We have attached the (NN prediction’s) Loss too:</strong> This tells, in its own units, how far/close the <em>current </em>prediction is from the real target value (which in the present case, it’s big because the prediction is way off).</li></ul><h4>Example:</h4><p>GD and BP indicates that by adjusting <strong>weight 1</strong> at <strong>node 1</strong> by its corresponding <strong>Δw </strong>(=0.046), the NN’s Loss will decrease a <em>bit</em>, and in turn, make <em>better </em>predictions.</p><blockquote>So, what happens if all weights and biases get adjusted? The NN appropriately learns.</blockquote><h4>Visualizing a Simple Neural Network Epoch</h4><p>If all weights and biases get adjusted in the way just described, then the Neural Network completes an epoch.</p><p>This means that, immediately after the NN computes a FFP (in which a prediction is computed at the last node), then the NN will learn from it (the data just passed), then compute the weights and biases adjustments, and then update them and start a new FFP.</p><blockquote>Note: Since I am using 1 row of data, then a complete FFP will be equal to a 1 epoch.</blockquote><p>In the simple NN, we have the following results for the new (adjusted) weights and biases and the new predicted value (using those new adjusted values):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*NHkX9tn5IW_LUSRrfgLs0g.png" /></figure><p>Key takeaways:</p><ul><li><strong>This is the same simple NN as before: </strong>look at how the inputs (0.60, 0.20, 1.30) and the corresponding target value remain unchanged (2.5),</li><li><strong>All weights and biases got adjusted:</strong> by their corresponding amount given by the GD and BP algorithms shown in the previous figure,</li><li><strong>The NN’s prediction is better:</strong> it’s 0.29, which is closer to 2.5. <em>The NN learned! Might as well make it learn more! More epochs then!</em></li><li><strong>The NN’s Loss is smaller: </strong>it is lower than in the previous pass.</li></ul><blockquote>And that’s how a Simple Neural Network learns!</blockquote><h4>Understanding a Simple Neural Network Learning Process</h4><p>Now, you understand how a simple Neural Network Learning Process works.</p><p>It’s all about the weights and biases adjustments, given by the GD and BP algorithms.</p><blockquote>Note: Of course, the formulas used to derive the GD and BP are undeniably a bit technical for this article, although I wish I could explain that to you, as it’s so interesting.</blockquote><p>For more accurate precision, you’d want to let the NN learn more epochs: passing the data many times through the NN, in order to reach an appropriate level of data understanding in the form of general rules, which are supposed to predict new values using never-before-seen data.</p><blockquote>The End.</blockquote><p>P.S.: If you want more info, go <a href="https://www.udemy.com/the-visual-guide-on-how-neural-networks-learn-from-data/?couponCode=AWESOME">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37a1f1c4498e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[You can make Forecasts too! Part 2]]></title>
            <link>https://medium.com/@mauriciomaroto/you-can-make-forecasts-too-part-2-3c409c0b7255?source=rss-5e863bc9347------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c409c0b7255</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[timeseries]]></category>
            <category><![CDATA[forecasting]]></category>
            <dc:creator><![CDATA[Mauricio Maroto]]></dc:creator>
            <pubDate>Wed, 03 May 2017 16:16:51 GMT</pubDate>
            <atom:updated>2017-05-03T16:19:03.646Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/@mauriciomaroto/smooth-to-forecast-anything-4de1948b1ef0">Part 1</a>, Part 2.</p><blockquote>I am a fan of Forecasting Time Series.</blockquote><blockquote>However, many methods out there are very complex. And some are, for worse, impractical (*cough* ARIMA *cough*).</blockquote><blockquote>So, I want to show you my quick forecasting method: <strong>Smoothing</strong>.</blockquote><h4>What if my Time Series exhibit a Trend?</h4><p>In <a href="https://medium.com/@mauriciomaroto/smooth-to-forecast-anything-4de1948b1ef0">Part 1</a>, I showed you how I quickly do my own forecasts.</p><p>However, that method is <strong>only </strong>applicable to Time Series with <strong>no </strong>trend (upward or downward slope).</p><p><strong>Caution: </strong>If you apply the previous forecast method to Time Series that exhibit a trend, you will get misleading results, unless the researcher has a strong and reasonable justification for not cosidering it.</p><h4>Forecasting via Smoothing with Trend</h4><p>Fortunately, the <a href="https://medium.com/@mauriciomaroto/smooth-to-forecast-anything-4de1948b1ef0">smoothing forecast method</a> can be <strong>extended </strong>in order to consider trends.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*eBKzUffslE8mm84hJiXTRg.png" /></figure><p>For that purpose, we need <strong>2</strong> equations: one for the <em>smoothing </em>and one for the <em>trend</em>.</p><p>Notice how the smoothing equation is almost the same than before, but it has been modified to consider the <em>b</em> (trend component).</p><p>The smoothing equation now <strong>means</strong>:</p><ul><li>a <em>bit </em>(alpha) of previous Time Series value, and,</li><li>a <em>bit </em>(1 minus alpha) of previous smoothinhg and trend values.</li></ul><h4>About the trend equation</h4><p>As you can see, in order to apply the smoothing equation with trend, you need to <strong>first</strong> apply the trend equation, because it’s inside the smoothing equation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*WzQ3mjK2aeiTdbcQwZah6g.png" /></figure><p>The trend equation means:</p><ul><li>a <em>bit</em> (beta) of the smoothing slope, and,</li><li>a <em>bit</em> (1 minus beta) of the previous trend.</li></ul><p>This equation will take care of our trend. Simple as that.</p><h4>So, what’s a bit?</h4><p>It’s <strong>alpha</strong> and <strong>beta</strong>. These values lie beyween 0 and 1. That’s why I say a bit, because it’s like saying a proportion or ratio of something.</p><p>At first, you need to initialize this values randomly. Then, you find the optimal values for the optimal forecast.</p><h4>What’s the Forecast equation?</h4><p>Once, you have computed <em>both </em>equations, you are ready to compute the Forecast equation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*soHl8PfRPill9bMEGU2h9g.png" /></figure><p>The forecast value is: the <em>sum </em>of the last smoothed value plus the <em>h-step </em>times the last computed trend.</p><h4>What’s h-step?</h4><p>Suppose you have 100 daily data points and you want to forecast for the next 20 days.</p><p>Then , your h-step is the values that goes from 1 to 20.</p><p>The first daily forecast will be h-step=1, the 2nd daily forecast will be h-step=2, and so and so forth, until 20.</p><h4>Ok, so how to Forecast with Trends?</h4><p>Same as <a href="https://medium.com/@mauriciomaroto/smooth-to-forecast-anything-4de1948b1ef0">before</a>.</p><p>Step 1: initialize alpha and beta beta with some value, say 0.5.</p><p>Step 2: Compute the trend equation (use above equation).</p><p>Step 3: Compute the smoothing equation (use above equation).</p><p>Step 4: Use Excel Solver to find the optimal values for alpha and beta.</p><blockquote>Note: you need to use a Loss function as a function of the errors to conpute the optimal values for alpha and beta.</blockquote><p>Step 5: Compute the h-steps (use above equation).</p><p>Step 6: Compute the Forecasts (use above equation).</p><h4>How will it look like?</h4><p>Here’s an example of how it can look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*XTe1Atn09xF3owD3csdETw.png" /><figcaption>Own work.</figcaption></figure><p>The smoothing forecast method with trend deemes that this Time Series (blue line)exhibit a downward slope, and it shows precisely that in the forecasted values (green line).</p><h4>More info?</h4><p><a href="https://www.udemy.com/forecast-anything-with-excel/?couponCode=AWESOME10">Here</a>.</p><blockquote>Next: How to Forecast with Trends and Seasonality!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c409c0b7255" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[You can make Forecasts too! Part 1]]></title>
            <link>https://medium.com/@mauriciomaroto/smooth-to-forecast-anything-4de1948b1ef0?source=rss-5e863bc9347------2</link>
            <guid isPermaLink="false">https://medium.com/p/4de1948b1ef0</guid>
            <category><![CDATA[timeseries]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[forecasting]]></category>
            <dc:creator><![CDATA[Mauricio Maroto]]></dc:creator>
            <pubDate>Mon, 24 Apr 2017 06:58:34 GMT</pubDate>
            <atom:updated>2017-05-03T16:18:35.258Z</atom:updated>
            <content:encoded><![CDATA[<p>Part 1, <a href="https://medium.com/@mauriciomaroto/you-can-make-forecasts-too-part-2-3c409c0b7255">Part 2</a>.</p><p>I am a fan of Forecasting Time Series.</p><p>However, many methods out there are very complex. And some are, for worse, impractical (*cough* ARIMA *cough*).</p><p>So, I want to show you my quick forecasting method: <strong>Smoothing</strong>.</p><h4>Forecasting via Smoothing</h4><p>Smoothing is the process by which you, in theory, extract the relevant information out of a Time Series.</p><p>Below is a quick example of an original Time Series and its Smoothed out version (hypothetical data).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*Vx7ezOimDozrsdH7K5WRWw.png" /><figcaption>Own work over hypothetical data</figcaption></figure><h4>How to Smooth?</h4><p>Easy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*1ASkRmvs6GiJPWMmt6o_vg.png" /><figcaption>Smoothing equation</figcaption></figure><p>Apply that equation to your Time Series.</p><p>This has to be done <strong><em>recursively</em></strong><em>: </em>do it for every row of data, starting from the beginning to the end.</p><blockquote><strong>Note</strong>: since today’s smoothed value (<em>lt</em>) depends on the previous smoothed value (<em>lt-1</em>), then you won’t be able to compute the smoothed value for the first time period. But that’s ok. It’s supposed to be like that!</blockquote><h4>How to choose α?</h4><p>Easy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*kbNoLyl2ZrdMTMROfq8z9A.png" /><figcaption>Excel Solver’s dialog box.</figcaption></figure><p>Use Excel Solver to find the best <strong><em>α </em></strong>(using the RMSE, a bit technical here, sorry)<strong><em>.</em></strong></p><p>In my example, it happened to be 0.9130.</p><h4>So then, how to FORECAST?</h4><p>Easy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/216/1*9rJOQi4CcmFUb5gRREB2Nw.png" /><figcaption>Forecast equation</figcaption></figure><p>Explanation: All <strong><em>forecast </em></strong>values will be the same as the <strong><em>last smoothed </em></strong>value</p><p>In my example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*l9lluL8Jy0CRzGxcju1RtA.png" /><figcaption>Own work over hypothetical data</figcaption></figure><p>As you can see, I decided to forecast a bit before the end of Time Series, in order to see the Forecast’s visual fit.</p><h4>Why that‘s a Valid Forecast?</h4><p>The <strong><em>fact </em></strong>that the forecast is computed out of the smoothed series, and the smoothed series is a <strong><em>combination </em></strong>of the Time Series past values, in such way that it’s an <strong><em>optimum</em></strong>, makes this a Valid Forecast.</p><h4>More info?</h4><p><a href="https://www.udemy.com/forecast-anything-with-excel/?couponCode=AWESOME10">Here</a>.</p><blockquote>Next: How to Forecast with a Positive/Negative Trend!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4de1948b1ef0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Neural Networks = Black Box?]]></title>
            <link>https://medium.com/data-science/neural-networks-black-box-b20723f9a417?source=rss-5e863bc9347------2</link>
            <guid isPermaLink="false">https://medium.com/p/b20723f9a417</guid>
            <category><![CDATA[gradient-descent]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[backpropagation]]></category>
            <category><![CDATA[neural-networks]]></category>
            <dc:creator><![CDATA[Mauricio Maroto]]></dc:creator>
            <pubDate>Thu, 20 Apr 2017 18:53:16 GMT</pubDate>
            <atom:updated>2017-05-02T17:06:08.044Z</atom:updated>
            <content:encoded><![CDATA[<p>As you know, I am a Machine Learning enthusiast. Specifically, a Neural Network (NN) one.</p><p>In the past months, I have read many articles about NNs. I have reached a conclusion:</p><blockquote>None of them actually let you see how NNs learn.</blockquote><h4>Example #1</h4><p><a href="http://news.mit.edu/2017/explained-neural-networks-deep-learning-0414">Forbes</a>, <em>Explained: Neural networks</em></p><p>In this article, the author says:</p><blockquote>“ Training data is fed to the bottom layer — the input layer — and it passes through the succeeding layers, getting multiplied and added together in complex ways, until it finally arrives, radically transformed, at the output layer.</blockquote><p>Wow, <em>complex</em> surely helps me understand how NNs learn… Then:</p><blockquote>During training, the weights and thresholds are continually adjusted until training data with the same labels consistently yield similar outputs.”</blockquote><p>I get this idea… vaguely.</p><h4>Example #2</h4><p><a href="https://hbr.org/2017/01/deep-learning-will-radically-change-the-ways-we-interact-with-technology">Harvard Business Review</a>, Deep Learning Will Radically…</p><blockquote>“ For a neural network to be useful, though, it requires training. To train a neural network, a set of virtual neurons are mapped out and assigned a random numerical “weight,” which determines how the neurons respond to new data (digitized objects or sounds).”</blockquote><p>Mmm, I guess that makes sense.</p><blockquote>“ Eventually, after sufficient training, the neural network will consistently recognize the correct patterns in speech or images.”</blockquote><p>Oh, once again, it shut down the door for properly explaining how NNs learn…</p><h4>Example #3</h4><p><a href="https://www.nytimes.com/2016/12/14/magazine/the-great-ai-awakening.html?_r=0">NYT</a>, The Great A.I. Awakening</p><blockquote>“The training is the process by which a labyrinthine series of elaborate tunnels are excavated through the blob, tunnels that connect any given input to its proper output.”</blockquote><p>I guess I am not a fan of metaphorizing math methods. In this case, a NN.</p><blockquote>“They <em>[the weights] </em>have to prove independently whether they’re also good at picking out dogs and defibrillators, (…)</blockquote><p>Right (?).</p><blockquote>(…) but one thing that makes a neural network so flexible is that each individual unit can contribute differently to different desired outcomes.”</blockquote><p>Still, no actual learning in front of my very own eyes. Anyway.</p><h3>My point is:</h3><blockquote>Learn How Machines Learn.</blockquote><p>Really!</p><p>Neural Network training (which involves Gradient Descent, Backpropagation and other methods) is very interesting. It’s also kind of magical, because the numbers start to adjust themselves trying to find the best path for maximum prediction.</p><p>I know that those articles are not meant to show you that because of their targeted audience (which is clearly not technical or educational).</p><p>But I guess, even so, I’d like to see some of it inside.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b20723f9a417" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/neural-networks-black-box-b20723f9a417">Neural Networks = Black Box?</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Neural Networks and Costa Rica’s Electricity -Part 3-]]></title>
            <link>https://medium.com/@mauriciomaroto/neural-networks-and-costa-ricas-electricity-part-3-c3fd565948d?source=rss-5e863bc9347------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3fd565948d</guid>
            <category><![CDATA[renewable-energy]]></category>
            <category><![CDATA[energy]]></category>
            <category><![CDATA[neural-networks]]></category>
            <dc:creator><![CDATA[Mauricio Maroto]]></dc:creator>
            <pubDate>Wed, 12 Apr 2017 15:28:42 GMT</pubDate>
            <atom:updated>2017-04-12T15:28:42.512Z</atom:updated>
            <content:encoded><![CDATA[<p>I want to add a bit more to the work’s motivation.</p><p>Take a look at Spain’s Hourly Demand of Electricity <em>right now </em>(12–4–17 ~3:40pm):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AAOzNTIHOVT6qLcDNwXygA.png" /><figcaption>Source: www.ree.es</figcaption></figure><ol><li>As all system dispatchers around the world do, they forecast the electricity demand ahead (green line).</li><li>As all consumers around the world do, they consume energy real-time (yellow line)</li><li>The red line shows the energy blocks traded in the market the day before (not relevant for this post).</li></ol><blockquote>Then, why the yellow line (real-time demand) does not behaves as smoothly as the green line (forecasted demand)?</blockquote><blockquote>Note: I assume throughtout that the demand of electricity is 100% matched with the supply. So, for any abrupt change of energy: a) it is the demand’s sole behavior, b) it was perfectly matched by the supply.</blockquote><p>Our interest focuses in <em>how </em>the yellow line abruptly desacelerates or acelerates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*9pDmDf7Pyen3WrY-GUPWJw.png" /></figure><h4>Zooming in around 4–10am</h4><p>a. When the yellow line was below the green line, the system had to <em>desacelerate </em>abruptly (A).</p><p>b. The other way around, the system had to <em>acelerate </em>abruptly (B).</p><p>c. Points like (C) show no abrupt change of acceleration.</p><p>Clearly, neither (A) or (B) points are desirable for the security of the system. Only points like (C).</p><p>It is now not difficult to <em>see </em>that the system had to <em>run faster</em> when the forecast did not showed in advance abrupt changes in demand. (Think about the Waze example in the previous post).</p><p><strong>Only when the system had been <em>experiencing </em>those abrupt changes in <em>real-time</em>, the system had to <em>rush</em> and follow accordingly, with a very narrow time window.</strong></p><blockquote>If only there was a way to see in advance whether the demand would experience such abrupt changes, that would prove beneficial for any system.</blockquote><p>Of course, that is the whole point of applying Artifical intelligence to Energy, which I hope to start showing it soon.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3fd565948d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[U.S. Hydro Energy]]></title>
            <link>https://medium.com/@mauriciomaroto/u-s-hydro-energy-236208d87d20?source=rss-5e863bc9347------2</link>
            <guid isPermaLink="false">https://medium.com/p/236208d87d20</guid>
            <category><![CDATA[energy]]></category>
            <category><![CDATA[hydro]]></category>
            <category><![CDATA[maps]]></category>
            <dc:creator><![CDATA[Mauricio Maroto]]></dc:creator>
            <pubDate>Wed, 12 Apr 2017 01:17:07 GMT</pubDate>
            <atom:updated>2017-04-12T01:17:07.247Z</atom:updated>
            <content:encoded><![CDATA[<p>I just wanted to share (save) an interesting map about U.S. Hydro Energy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*49t4LkmN7tyU7Cl5SsGv3A.jpeg" /></figure><p>Source: washingtonpost.com</p><p>A lot of analysis derives from this image, but to make it deeper, I’d suggest making a similar map for Costa Rica.</p><blockquote>Will try to do soon.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=236208d87d20" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Neural Networks and Costa Rica’s Electricity -Part 2-]]></title>
            <link>https://medium.com/@mauriciomaroto/costa-ricas-renewable-energy-2ce949c38347?source=rss-5e863bc9347------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ce949c38347</guid>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[costa-rica]]></category>
            <category><![CDATA[energy]]></category>
            <category><![CDATA[renewable-energy]]></category>
            <dc:creator><![CDATA[Mauricio Maroto]]></dc:creator>
            <pubDate>Mon, 10 Apr 2017 19:44:23 GMT</pubDate>
            <atom:updated>2017-04-10T19:48:16.786Z</atom:updated>
            <content:encoded><![CDATA[<p>This post serves as the motivation for my work about Neural Networks and Costa Rica’s Energy.</p><blockquote>Costa Rica’s (Yearly) Electricity Generation comes (almost) <em>entirely </em>from Renewable Sources.</blockquote><p>According to the Costarican Institute of Electricity (ICE in spanish), which is the biggest player in the country’s electricity generation, transmission and distribution sectors, in both 2015 and 2016, Costa Rica surpassed <a href="https://www.grupoice.com/wps/portal/ICE/AcercadelGrupoICE/sala-de-prensa/comunicados-oficiales/70d52ae5-3388-4eb4-b533-e1de705eac2c"><strong>98%</strong></a> of Renewable Electricity Generation (official press release april 3, 2017, ).</p><p>And for the first 2017 trimester, it accounted for <a href="https://www.grupoice.com/wps/portal/ICE/AcercadelGrupoICE/sala-de-prensa/comunicados-oficiales/70d52ae5-3388-4eb4-b533-e1de705eac2c"><strong>~99%</strong></a><strong>.</strong></p><blockquote>However; there is no free lunch. Renewable Electricity Generation comes with a cost. And not all of them are monetized. I ask you: should they be?</blockquote><p>My personal work focuses on a particular implied technical cost. Simply put: <em>pressure </em>on the system.</p><p>I have came up with a nice analogy. Suppose you go to work in your car and you don’t use Waze. Now, suppose the next day, you do the same thing but using Waze. Surely, being able to <em>see </em>what the road holds <em>ahead </em>for you, will prove beneficial, and let you reach your goal. <em>And </em>efficiently.</p><blockquote>Technically speaking, dispatching energy is not easy. And it gets harder the more renewable the system gets.</blockquote><p>Take for example wind energy. Suppose that in a given time period, there is enough wind for electricity generation. Then, the system dispatcher will let this energy enter the global flow, which in turn, will reach the general public. Suppose also, that there is no back-up energy at the moment. In this scenario, clearly if wind generators cease, most likely because of a wind flow stop, then pressure will build over the system as the supply shortage increases. If this situation doesn’t get corrected as fast as possible, i.e. by requesting more energy output of other available generators, blackouts will occur, which makes the situation worse.</p><p>It is clear that the risk just explained gets worse the more renewable the energy generation system gets. i ask you: How can you <em>mitigate </em>this?</p><p>So, in this regard:</p><blockquote>This model will let the system dispatcher <em>see </em>what the future electricity demand <em>looks </em>like ahead (hourly) in terms of significant percentage changes (grouped in categories), which will prevent sudden supply shortages and pressure over the system.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ce949c38347" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My current Goal]]></title>
            <link>https://medium.com/@mauriciomaroto/my-current-goal-3424ac65372e?source=rss-5e863bc9347------2</link>
            <guid isPermaLink="false">https://medium.com/p/3424ac65372e</guid>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[neural-networks]]></category>
            <dc:creator><![CDATA[Mauricio Maroto]]></dc:creator>
            <pubDate>Fri, 07 Apr 2017 04:20:30 GMT</pubDate>
            <atom:updated>2017-04-07T04:26:05.508Z</atom:updated>
            <content:encoded><![CDATA[<p>So, I was thinking and my Current goal is to estimate a</p><pre><strong>print (&#39;A ConvNet&#39;)</strong></pre><p>Either for personal purposes or, even better, as Kaggle competition submission.</p><p>All I need is to repeat inside my head the following:</p><blockquote>I can do it, I know I can do it.</blockquote><blockquote>I just need to understand what a convolving and flatten layers are.</blockquote><p>And I‘d be pretty much set.</p><p>Also, I need Francois Chollet and Andrew Trask Manning’s MEAP books to update soon though…</p><p>And, to read and understand pretty much all files in my “Artificial NNs” OneDrive.</p><p>That’s all.</p><p>Oh, and practice on my PyCharm. A lot. God Bless Keras.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3424ac65372e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Neural Networks and Costa Rica’s Electricity]]></title>
            <link>https://medium.com/@mauriciomaroto/neural-networks-and-costa-ricas-electricity-9aa7493b8c33?source=rss-5e863bc9347------2</link>
            <guid isPermaLink="false">https://medium.com/p/9aa7493b8c33</guid>
            <category><![CDATA[neural-networks]]></category>
            <category><![CDATA[costa-rica]]></category>
            <category><![CDATA[renewable-energy]]></category>
            <category><![CDATA[energy]]></category>
            <dc:creator><![CDATA[Mauricio Maroto]]></dc:creator>
            <pubDate>Tue, 04 Apr 2017 22:25:54 GMT</pubDate>
            <atom:updated>2017-04-10T19:48:47.248Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi. Last post I said I was getting into Machine Learning, especcially Neural Networks. They are indeed nice!</p><p>This post I want to say that I will soon share my Neural Network model applied to Electricity Demand in Costa Rica.</p><p>My Neural Network model goal is to correctly clasify Costa Rica’s future Electricity Demand into 6 categories given some variables.</p><p>These 6 categories tell whether Costa Rica’s Electricity Demand will increase (or decrease) significantly (or not) for a given hour.</p><p>In simpler words, it is a simple way of forecasting demand <em>pressure </em>in the system.</p><p>Therefore, it is of relevant interest to know how well the model did in accuracy terms, because it can serve as a new tool for the technical <em>security</em> of any electrical system.</p><p>Also, it is a good example of how Neural Networks work, since it’s such a nice modern topic.</p><p>Interesting?</p><p>Until next post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9aa7493b8c33" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>