<?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 Miguel Perez Michaus on Medium]]></title>
        <description><![CDATA[Stories by Miguel Perez Michaus on Medium]]></description>
        <link>https://medium.com/@miguelpmich?source=rss-9a0465191627------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DFHwnTLyPfPFsGF_Kmtbnw.jpeg</url>
            <title>Stories by Miguel Perez Michaus on Medium</title>
            <link>https://medium.com/@miguelpmich?source=rss-9a0465191627------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 13:09:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@miguelpmich/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[FinQBoost: Machine Learning for Portfolio Forecasting]]></title>
            <link>https://miguelpmich.medium.com/finqboost-machine-learning-for-portfolio-forecasting-55e62b00ebca?source=rss-9a0465191627------2</link>
            <guid isPermaLink="false">https://medium.com/p/55e62b00ebca</guid>
            <dc:creator><![CDATA[Miguel Perez Michaus]]></dc:creator>
            <pubDate>Mon, 20 Feb 2023 16:19:28 GMT</pubDate>
            <atom:updated>2023-03-12T09:30:51.086Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*jhfe7HbI9LonCOmyj9TyRA.png" /></figure><p><strong>The approach behind twin #2 global prizes in the M6 Financial Forecasting Competition.</strong></p><p>The <a href="https://mofc.unic.ac.cy/the-m6-competition/">M6 Financial Forecasting Competition</a> has ended and my model placed second in both the global “Forecasting Track” and “Duathlon Track,” in addition to other quarterly prizes.</p><p>I already shared preliminary insights on the results 2 weeks before competition end in <a href="https://medium.com/@miguelpmich/the-challenge-of-financial-forecasting-m6-edition-b26c20464f1b">a previous post</a>.</p><p>Following the organizers’ request I have published FinQBoost code in <a href="https://github.com/miguel-data-sc/FinQBoost">Github</a>. <strong>The script runs in just 9 seconds</strong> on a modern laptop’s CPU (preprocess + training + inference) for the M6’s 100-product portfolio. A fast optimization for rank probability forecasting.</p><p>The backbone of my approach, FinQBoost has consistently outperformed the “naive uniform” benchmark over 12 consecutive monthly forecasts.</p><h3>General Strategy</h3><p>At the start of the competition <strong>I decided to treat the Decision Track as subordinate to the Duathlon track</strong>. So many paper-money players exploring the tails of the return distribution implied that any chance to lead Decision Track would require a risk level incompatible with controlled chances in the main, Duathlon Track. For me at least, to “swing for the fences” in the Decision Track was suboptimal.</p><h3>The Decision Track</h3><p>Even it subordinate, Decision Track was not piece of cake for me, adversarial decisions were painfully difficult to take.</p><p>I mainly used<strong> risk expansion/contraction to maximize my chances for the duathlon prize given a solid forecasting score. </strong>Depending on market conditions and leaderboard projections I made <strong>discretionary </strong>use of risk neutral positioning (short SHY / long IEF) marginally benefiting from curve inversion while near-zero volatile, long only positioning, index shorting and volatility based stock selection, all of this with quite limited success. Luckily I managed to tune this limited success to be just-enough for my objectives.</p><p>A hard decision to take was neutralizing my last monthly submission knowing that it implied to give up all option of ending #1 in the Duathlon Track. I traded the 50/50 all-or-nothing #1 gamble for a very high probability of ending #2, no regrets about it.</p><p>Fun as all this may have been my main achievement in the competition has been in the Forecasting Track.</p><h3>The fundamental problem of Financial Forecasting</h3><p>In contrast to the Decision Track struggle I had a very precise idea on how to deal with the forecasting problem and the approximate upper bound of performance to expect.</p><p>My approach can be described as <strong>“common good practices on applying machine learning to time series” but with a twist</strong>, as we are dealing with financial prices time series.</p><blockquote><strong>But, what is the big deal with forecasting financial time series?</strong></blockquote><p>To put it mildly, it is not easy. Most if not all of the huge amount of money made in today’s markets doesn’t rely on directional forecasting at all. <strong>Efficient Market Hypothesis</strong> is still a very popular view with its claims about the futility of trying to outsmart the market and, in summary, the task is today somewhere between the unsolved and the unsolvable.</p><p>I made some quick assumptions when joining the competition:</p><ul><li><strong>About informed players</strong>: My belief is that EMH only applies to the majority of market participants, not to all of them. There are informed players with true forecasting capacity (think any high level strategist at ExxonMobil forecasting oil price as an example). As they just don’t spend their time showing off I was confident that none of this informed players would be joining the competition.</li><li><strong>About external data feeds: </strong>There is good quality data that some of the competing teams might have access to. I did expect such data to provide an edge but considered that most participants would not dedicate the necessary resources to obtain and integrate that data into their pipelines. (It turned out, there was at least one competitor using external data as Peter Cotton (Microprediction) <a href="https://medium.com/geekculture/the-options-market-beat-94-of-participants-in-the-m6-financial-forecasting-contest-fa4f47f57d33">has confirmed</a> to have successfully used options’ implied volatility although scoring far from the estimated upper bound of the price-only signal).</li></ul><p><strong>My initial assumption was a level playing field of forecasters and data scientists using mainly public price and volume data. </strong>And if that was the case I knew I could build a competitive baseline.</p><blockquote><strong>The biggest issue with financial time series is the lack of a reliable framework to assure some lower bound of generalization.</strong></blockquote><p>Generalization is always crucial in statistical modeling but in financial prices it is a near-intractable problem. In other domains performance degradation will cause a concept shift but usually not a concept inversion. With financial price series though, “cheap ” as input can mean cheap or expensive or something in the middle depending on a regime that only in hindsight can be identified with certainty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/383/1*HU5nhsgmPr1ZyUwya5LtdQ.jpeg" /></figure><p><strong>How to validate that?</strong> It depends. Can we make an educated guess about how much the regime will be changing during forecasting time frame? Depending on the answer there are in my view two alternatives, none of them ideal.</p><ol><li>Make a bet on the regime and optimize, or</li><li>Don’t bet on the regime, let the model learn it if it’s possible -it probably isn’t- and optimize “globally”.</li></ol><p>A <strong>“globally optimized” model</strong> refers here to a model that finds some market invariances throughout multiple regimes and periods. The performance of such forecasting model will not be stellar in any particular period but is optimal for a multi-regime period.</p><p>For short time frames in the context of a competition, gambling on the regime might have been unavoidable but a whole year can be enough to let a globally optimized model shine. Especially for a not very smooth year like 2022. Global optimization reduced the probability of winning quarterly prices while hopefully maximized the “prize expectation” for the final prizes.</p><h3>FinQBoost</h3><p>It took me about 4 months to refine a minimalist modeling pipeline and from then on I didn’t touch the forecasting model. Successful or not the model deserved enough time to proof its value in the time frame it was designed for.</p><p>Key points :</p><ul><li><strong>Training period selection</strong>: The objective is to optimize for some invariances that are valid in all regimes. To train globally requires training on multi-regime periods . I used data <strong>from 2007</strong> (included Global Financial Crisis and a bit of everything that came afterwards, money printing, low volatility, 2018 FED tightening and pivot, 2020 shocks, helicopter money, ominous 2022 first months). Not all products were available from 2007. But quintiles could be made anyway for any portfolio size and it was beneficial to have as long price history as possible inside that period.</li><li><strong>Validation:</strong> the exact validation period selection is not too important here, <strong>what truly matters is to assess the model behavior across multiple validation periods</strong>. Performance <strong>variability</strong> is what I focused on. I checked multiple 1 year periods as that was the competition time frame. Usual good practices were mandatory for this low-signal high-noise modeling, like properly <strong>“blocked” validation experiments </strong>having the<strong> </strong>datasets dynamically trimmed to avoid any feature to leak information.</li><li><strong>Inference:</strong> at each inference point (in real-time, monthly during the competition) the model is retrained and train window expanded to include up to the last point available (with unchanged hyperparameter selection).</li><li><strong>Model Selection</strong>: <strong>DT-based boosting models</strong> behave well in high noise to signal tasks and allow to control model flexibility very precisely. If properly validated they are also fantastic feature selection tools. I discarded Deep Learning in spite/because of it’s representation power and flexibility as I expected it would be harder for me to control overfitting with them given a quite noisy, effectively small, dataset.</li><li><strong>Boosting for a probability distribution</strong>. When I have the choice, especially if the task is time-series related I rely on <strong>R</strong> and the mighty <strong>data.table</strong> package. For boosting I tend to agree with the meme, “<strong>Xgboost</strong> is all you need”. But how to model a distribution probability with Xgboost? I designed a<strong> multi-label classification</strong> approach of the quintile probabilities plus a simple post processing to make them be, well, probabilities. Multi-label capacities of Xgboost are not too well known as they are not available out-of-the-box but they are powerful. It is necessary simply to reshape the data accordingly to the task. <strong>Why not use simple multi-class classification</strong> and avoid the fuss? One reason is <strong>target smoothing</strong> that I will mention later, but the main reason is that <strong>we are not really classifying. We are modeling distributions</strong>, in many cases bimodal looking, in other uniform-ish. And we want to do it precisely. <strong>Softmax is not a friend here</strong>. If we try to use out-of-the box multi-class classification models we would probably deal with softmax inside the fitting process. This is not desirable and doesn’t work well here. Multi-label is the way to go.</li><li><strong>Data preparation: <br>- </strong>Overlapping 4-weeks-ahead weekly market instances were prepared starting on Friday. This filtered any weekly seasonality while closely mimicking actual competition timing with as many (overlapping) instances as possible.<br>- VXX product was replaced by VIXY, perfectly correlated and with much longer available price history.</li><li>Target transformation/smoothing: “Don’t model the noise”. The task is to forecast <strong>a ranking 20 days ahead, on Friday, for 100 products</strong>.<strong> </strong>Ranking is determined by their returns in 20 days. How similar is the target on Thursday, after 19 days have passed, to Friday, only one day later? In other words, given a product is at a certain quintile on Thursday, what is the probability that it will finish the month in that same quintile, how stable is the target? The answer is quite shocking and depending on the quintile the probability ranges from below 40% for central quintiles to 70% for worst and best quintiles. That is the stability of the label during the last 24 hours of a 20 days ahead forecast period.<strong> This difference between Thursday and Friday was likely beyond the model’s capability to handle</strong>. Experiments confirmed this, so I modified the hard 1/0 label of day 20 to be 0.5 if it differed from the previous day’s label. This was compatible with the multi-label approach and<strong> effectively smoothed the target, improving generalization</strong>. However, smoothing more than the last 2 days was detrimental to the model’s performance.</li><li><strong>The search for the golden feature</strong>: The best representation of the world given to the model the better. In settings like this one we also want as few features as possible. But we test many of them. If it is possible to normalize or aggregate them in a meaningful way the model will have easier to focus on what matters. In this case it was apparent from the experiments that it was better to feed the model rank related features. Of course, rank was determined by returns, and returns by return sign and volatility of each asset, but in the end<strong> it was rank what we were modeling and rank itself could be fed to the model</strong>. After many experiments a feature emerged as sufficient by itself to attain better than random forecasts. A single feature. To be precise, <strong>a single feature computed over a limited number of rolling windows</strong>. This feature was the <strong>standard deviation of the percentile 1 day returns of the product </strong>computed in 9 time windows ranging from 16 previous months up to 2 months. To this 9 features from the 5th submission I added a 10th feature for marginal expected gains: the ratio of 80 day RSI vs the mean market value of same indicator, as <strong>a gauge of relative stretch of a product vs market stretch</strong>, last 4 months considered. One important note: <strong>the model is blind to product ID</strong>. In the beginning I tried different encoding schemes but product encoding seemed to be detrimental so I removed that feature altogether early in the competition. The model relies only on 10 features.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*9LSzbcnSMMgOWeVCrE_jmA.png" /><figcaption>* Model importance agrees in this case with permutation importance</figcaption></figure><ul><li><strong>Model selection (hyperparameters)</strong> considered lower bound for the performance (upper bound of RPS) instead of average performance. Expected performance was 0.15597, with standard deviation of 0.00204 <strong>what implied a 2 standard deviation upper bound of 0.16079</strong>. I was not happy about the possibility of losing to the naive forecast one month every couple of years but that was as good as it could get.</li><li><strong>Post-competition validation re-assessment</strong>: final top 3 Forecasting Track scores lay in a narrow range between 0.15645–0.15649 None of the top scores is better than my expected best approximate <strong>lower bound</strong> for the task (given price-only input) of 0.15189 RPS. FinQBoost final average RPS score has been 0.15648, which is in line with expected performance and good enough to finally win the #2 prize.</li></ul><blockquote>It remains the question of what the model is actually doing to succeed.<strong> It seems remarkable to me that (rolling) standard deviation of daily ranks can somehow condense the signal from fine grained raw data on returns, volatilies and covariance. </strong>My intuition is that this condensed signal also seamlessly exploits the link between options implied volatility and historical volatility without access to option data.</blockquote><p>Even if in hindsight there are always things to have done better I am very happy with the results. Both my forecasting approach and my tactics have worked, I have placed #2 both in Global Track and #2 in Forecasting Track and this plus some additional quarterly prices have made me the biggest accumulated prize winner in the competition.</p><p>I hope that the publication of this ML-based forecasting approach will be helpful for the competition’s purpose of advancing research. I would also like to thank the organizers and<strong> Professor Makridakis</strong> for such an interesting competition. I’m honored to be a small part in the big history of the legendary <strong>M Forecasting Competitions</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55e62b00ebca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The challenge of Financial Forecasting, M6 edition.]]></title>
            <link>https://miguelpmich.medium.com/the-challenge-of-financial-forecasting-m6-edition-b26c20464f1b?source=rss-9a0465191627------2</link>
            <guid isPermaLink="false">https://medium.com/p/b26c20464f1b</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[time-series-forecasting]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[portfolio-management]]></category>
            <category><![CDATA[financial-markets]]></category>
            <dc:creator><![CDATA[Miguel Perez Michaus]]></dc:creator>
            <pubDate>Fri, 20 Jan 2023 15:27:36 GMT</pubDate>
            <atom:updated>2023-01-28T10:43:15.150Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VO5CXluQ9tUSQ9WLYhBH7Q.png" /><figcaption>“FORECASTING IS HARD, ESPECIALLY THE FUTURE” (image generated with DALL-E)</figcaption></figure><h3><strong>An insight into the results</strong></h3><p><a href="https://en.wikipedia.org/wiki/Makridakis_Competitions">M-competitions</a> are legendary. There have been 6 editions since 1982, each with a different design and focus. Easily the most ambitious research experiment on real-life forecasting approaches. The last one, <a href="https://mofc.unic.ac.cy/the-m6-competition/">M6</a>, is about to end after almost 1 year of monthly updates, and both my forecasting and global ranking are looking good.</p><p>What was the competition about? In a nutshell, both about ranking and trading a portfolio of 100 financial products, evaluated in real-time, monthly, throughout a year, with <strong>three tracks</strong>:</p><ul><li>A <strong>forecasting track</strong> for monthly performance ranking probability distribution of the products.</li><li>A <strong>decision track </strong>of investment decisions<strong> </strong>constrained to 100 products monthly rebalance, accounting for volatility of returns.</li><li>A <strong>“duathlon” track</strong>, the equally weighted average of the previous two, with double money prizes than each of the individual tracks.</li></ul><p>A lot of money prizes are awarded in this research competition, <strong>crucially won not only at the end of the competition but also quarterly</strong> for each of the three tracks. This multi-horizon evaluation heavily conditions any price maximization strategy and keeps incentives high for the participants.</p><p>There are some genius aspects to this design. The dilemma of optimizing for quarterly prizes vs. global mimics real life situation of different relevant timeframes for different agents and noisy interaction of the two scores make adversarial tactics quite difficult.</p><blockquote><strong>Overall, the competition design builds a simplified but valid instance of financial markets competitive environment.</strong></blockquote><p>By rewarding much more heavily duathlon track<strong> the organizers made clear their research objectives is not only forecasting performance but also forecasting applicability and impact</strong>. The question is not only “Can you forecast markets?” but, mainly, “Does that forecasting edge make a difference on the bottom line?”</p><p>My personal bias as a problem solver makes me favor robust, non-parametric solutions, especially if the task at hand is noisy. And noisy is an understatement for this task. So my path to answering the question has implied asking another one: <strong>“How can you apply Machine Learning to Portfolio Optimization?”</strong></p><p>It is hard to correctly depict how hard the task at hand is. A hint might be the fact that Nobel prizes have been awarded related to the topic. Even for Machine Learning practitioners, if not used to dealing with financial time series it is easy to understate the difficulty. <strong>Let’s see the results of the competition after almost 1 year of monthly rebalanced submissions</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*DYKuPzje0-TTjzTLUz9hUQ.jpeg" /><figcaption>“DART-THROWING MONKEY” (image generated with stable-difussion-2)</figcaption></figure><p>Regarding the <strong>forecasting task</strong>, let’s compare the performance with the rank-probability version of the famous “dart-throwing monkey”, this is, a very <strong>naive RPS score of 0.16</strong> given by predicting “I don’t know” and giving equal probabilities for the ranking of the products 1 month ahead.</p><p>How many teams are beating the naive “monkey’ forecasting benchmark after one year? Only 20% of forecasters.</p><p>And it gets worse. How many beat the naive forecast <strong>on a monthly basis</strong>, consistently forecasting better than random <strong>each and every of the 12 months of the competition?</strong> With 12th month score still open, only 3 teams, that is, <strong>less than 2% of the teams</strong>. Those 3 teams consistently better than random at a monthly level are “Dan”, “invest to get rich” and “Miguel Pérez Michaus” (me). I optimized my model for low variance in score, keeping that “monkey” 0.16 threshold about 2 standard deviations over mean expected score, what still implies it will eventually lose to the monkey benchmark one month every two years, on average.</p><blockquote>Let that sink in. <strong>For 98% of the competitors, in 2023, no AI tool or statistical model has been able to provide a consistent hedge over a random forecast on a monthly basis</strong>. In the most famous international forecasting competition. With the motivation of big money prizes. That says something about the difficulty of the task.</blockquote><p>How much has the naive benchmark been improved? At the time of writing two weeks before the end of the competition the best score is 0.1566 but it keeps moving. It seems that first positions in the forecasting leaderboard will be contested until the very last moment.</p><p><strong>The question about predictability of markets is a disputed one</strong>. In the “Efficient Market Hypothesis” line of reasoning usable forecasts, if public, lead to actions that front-run the very events forecasted. My personal view on the topic is that the this doesn’t negate the possibility of forecasting to a limited extent by a small subset of players.</p><p><strong>What about the decisions track?</strong></p><p>It is harder to reach conclusions regarding the decisions track and it is still moving. The organizers provided dummy submission of simple 1/n product selection that only about 38% are currently beating. This benchmark can be seen as a “long only” benchmark and as most portfolio components are quite correlated with overall market the decision IR score for this dummy is negative.</p><p>How many teams are currently showing positive returns? Only 23% of teams achieve positive IR as of today.</p><p><strong>I am much more cautions to jump to conclusions regarding this track</strong>, given the adversarial nature of the contest environment, the condition of “paper money” of the investments, the lack of comissions and the idiosincrasy of the chosen IR metric that made it advisable -conditional to initial outperformance- the adoption of market neutral strategies as a competition risk minimization tool.</p><p>Still, it is easy to build <strong>an alternative randomized naive benchmark</strong> by randomly choosing both a product and a sign(long/short) and observing the distributions of constantly sticking to those 200 bets throughout the competition year.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*QTuWuYZCtJotclSnaEs3Pg.png" /><figcaption>RISK AVERSION FOR POSITIVE IR SCORES ? LONG BIAS?</figcaption></figure><p>Tails of the distribution look compatible but the <strong>IR performance distribution seems to cluster at/below zero score with an overall underperformance relative to the randomized benchmark</strong>. Why can this be? The main suspects to explain this underperformance are, in my opinion:</p><ul><li>a possible <strong>bias of investors favouring long positioning over short</strong>. This might explain the underperformance given the period when the competition has taken place and the positive correlation to overall market of the portfolio.</li><li>the adversarial nature of the decision track, the incentive either to increase risk to maximal levels or neutralize it with <strong>market neutral positioning </strong>dependent of proximity to quarterly milestones.</li><li>The big impact of decision risk management on duathlon score that might make decision track a subordinate tool to maximize probability of success in the duatlon score.</li></ul><p>Still two weeks to the end of the competition and the leaderboard is still moving. But I think some insights are already apparent:</p><ul><li>Prediction of financial markets is possible only <strong>to a very limited extent</strong> without using exogenous, non public, alternative data. (Given that my forecasting model uses exclusively historical end of day price data to consistently outperform I am assuming no relevant information was extracted from external data in the competition that wasn’t implicit in historical prices)</li><li><strong>Portfolio ranking forecasting is as difficult as returns forecasting</strong> (at its core, forecasting relative performance implies directional forecast as well as volatility).</li><li><strong>Machine Learning can help</strong> to optimize to the limit of what is feasible but giving the model some generalization capacity is not trivial for this task.</li><li>Competitive environments can influence <strong>risk management decisions</strong>, potentially making them, on average, suboptimal.</li></ul><p>And that was all about takeaways from the competition general results, I hope it was of some interest.<strong>I will be sharing more details about my approach in the near future.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b26c20464f1b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Are Zillow’s losses an AI failure?]]></title>
            <link>https://miguelpmich.medium.com/are-zillows-losses-an-ai-failure-65fd96120078?source=rss-9a0465191627------2</link>
            <guid isPermaLink="false">https://medium.com/p/65fd96120078</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[time-series-analysis]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Miguel Perez Michaus]]></dc:creator>
            <pubDate>Wed, 24 Nov 2021 15:44:58 GMT</pubDate>
            <atom:updated>2021-11-24T20:04:00.301Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>About regimes, optimization and compasses</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*_wcfdu6PG2w9XSh9y_xOKg.jpeg" /></figure><p>In my mid 20’s I was facing an unusual opportunity for someone my age. There it was, the detailed plan for the next two years on how I intended to manage a huge amount of other people’s money and develop some nice buildings in the process. All fit to the budget and timeline I myself had estimated. All looked great. I felt like a philharmonic orchestra conductor before a well prepared concert.</p><p>The opportunity was unusual as that decision level is not where you usually are without much more experience, and for a good reason. But those were the crazy real-estate bubble years, pre-2007, add a couple of random events and there I was, with just my Architecture studies and a “Very Large Crude Oil Tanker” to sail home, so to speak. Nervous? Not really. That much I trusted my capacity. Even today, I smile remembering it.</p><p>But even if overconfident I knew some advice might be good. The problem was there were not that many people I could access to with a proven successful track record in the field. In fact there was only one. Near his 60’s, the man had fought all battles. After my humble approach he agreed to have a look, asked a couple of tricky questions, seemed satisfied with the answers. I felt relieved, but then came the sentence:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wgh3n4uGzbmpzO9-TdGrBw.jpeg" /></figure><blockquote>“But this is not what will happen, you better keep that very present”</blockquote><ul><li>“ Uh, What do you mean, is it about the estimated timeline? ”</li><li>“ Nah, the timeline is reasonable. ”</li><li>“ So, is it about the budget, is anyone here using mistaken numbers or, worse, deceiving info? ”</li><li>“ Nope, everyone is probably reporting according to their beliefs ” I still was not getting it.</li><li>“ But this will just not happen. It never does. You are not planning buying a yogurt in the corner shop. In two years anything can and will happen. The companies, the laws, the project scope, hidden constraints… it’s all dynamic. Your plan is an incomplete draft. ”</li></ul><blockquote>You need a better draft with an additional layer, your layer. And then you will have a compass and nothing more…</blockquote><ul><li>… a compass to locate North this next 2 years. It might seem a compass is not much but there’s no more you can aim to at this scale. It will put you ahead of most”.</li></ul><p>The conversation lasted more, an instance of successful “human transfer learning” that generalized well to many situations in the following decade.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UV33pPedUUyq8wsOUu3qmw.jpeg" /></figure><p>Enough about past lifes. How does this little story fit with <strong>Zillow</strong>’s problem?</p><p>As you probably know, ending 2021 Zillow has reported huge losses and cut 25% of their workforce <strong>in what is being published as a “Machine Learning” failure</strong>. But I don’t think algorithms are to blame here.</p><p>The sad truth is that some problems in Machine Learning applied to markets are far from solved, namely <strong>regime changes</strong> (radical concept shift) and <strong>adversarial activity.</strong> In its current state Machine Learning can be seen as optimization and interpolation. Can you see the problem of this tool for dealing with price time series?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YdsZp9pnkC8yYTc7OLIldg.jpeg" /></figure><p>In markets sometimes “ cheap ” (or any other feature) can mean “ it’s a bargain, buy now ” but also in a different regime “ cheap ” can mean exactly the opposite, “ tomorrow will be cheaper sell asap! ”. If regime is decided by latent factors then no Transformer of LSTM will serve you. <strong>Modeling will just optimize whatever objective you define for the training dataset</strong>.</p><p>In other words, sometimes markets are white and other times are black but unless you can tell which one applies Machine Learning will just either bet blindly on one color or more frequently optimize a gray for the dataset.</p><p><strong>What about online learning?</strong> Won’t that be better for dealing with regime changes? Well… maybe. But if features dont contain information about regime the most you can hope for is to minimize the reaction lag based on recent observations’ loss structure. <strong>But optimality will again depend on the training dataset and the regime change structure it contains </strong>so you better got the correct data!</p><p>My point here is that as this problems are not currently solved you can not rely on models to behave well under market regime changes.</p><blockquote>We shouldn’t call a “Machine Learning failure” what is a risk management failure.</blockquote><p><strong>To me Zillow’s losses say not so much about “Artificial Intelligence” as about the difficulty of risk management when you are a human.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=65fd96120078" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Boosting is already “explainable AI”]]></title>
            <link>https://miguelpmich.medium.com/boosting-is-already-explainable-ai-b8897eb1f2b0?source=rss-9a0465191627------2</link>
            <guid isPermaLink="false">https://medium.com/p/b8897eb1f2b0</guid>
            <category><![CDATA[microsoft-research]]></category>
            <category><![CDATA[boosting]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[explainable-ai]]></category>
            <dc:creator><![CDATA[Miguel Perez Michaus]]></dc:creator>
            <pubDate>Fri, 23 Apr 2021 11:30:27 GMT</pubDate>
            <atom:updated>2021-04-24T17:12:37.574Z</atom:updated>
            <content:encoded><![CDATA[<p>A criticism on Microsoft Research’s EBM</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D9xM0LaY28Wy04NuDi4PKA.jpeg" /></figure><p>The quest for more “explainable AI” has become one of today’s main topics among Machine Learning practitioners and end users, governments included.</p><p>Recently one interesting proposal came from Microsoft Research of a <a href="https://github.com/interpretml/interpret">unified framework for explainability</a> with a especial focus in boosting. The proposed tool, named Explainable Boosting Machine (EBM) is a mixed bag of good and not so good ideas.</p><h3><strong>Why is boosting important?</strong></h3><p>Humble, less hyped than other algorithms, boosting is today as relevant as ever. Described by Trevor Hastie et al. as <em>“one of the most powerful learning ideas introduced in the last twenty years”</em>, <strong>boosting works incredibly well</strong>. From a pure pragmatic point of view it is today the most competitive algorithm for dealing with structured data (unless non explicit feature interactions dominate the problem making NNets a better option).</p><p><strong>But what is boosting really doing?</strong> When Decision Trees are boosted with depth 1 (“stumps”) boosting fits a generalized additive model, or GAM. In practice, though, boosting outperforms GAMs in the majority of cases (unless the ground truth lacks interactions and goes well with smoothness). So, boosting &gt; GAMs. But why? Because with optimal depth it does:</p><ul><li><strong>sparse feature selection</strong></li><li><strong>interaction detection and selection</strong></li></ul><p>What is the closest thing to magic I can think of. Explainable magic. At least that is what boosting <em>tries</em> to do. Like always, those feature importances have to be confirmed through surefire tools like permutation importance, but let’s leave that aside by now.</p><blockquote>Given a proper validation setup you can trust boosting will optimize the choice of task-relevant features with a remarkable resistance to noise. Almost “out of the box”.</blockquote><h3><strong>What is MR’s Explainable Boosting?</strong></h3><p>It starts from the capability of boosting with depth 1 to fit a GAM, but not in the usual way: model is trained sequentially in a round robin way, one feature by one. They use a very small learning rate (small enough to make the order irrelevant) and a huge number of rounds.The result: a pure GAM model. No interactions so they get rid of the trees and keep the vectorized predictions per feature that you can plot as a interpretable Partial Dependence Plot.</p><p>To account for the main interactions they use a clever “cheap” heuristic (FAST) applied to the residuals of the GAM model. This allows ranking of all pairwise interactions by their strength. Top-n interactions specified can then be included , as detailed <a href="https://www.microsoft.com/en-us/research/wp-content/uploads/2017/06/kdd13.pdf">here</a>.</p><p>According to MR the algorithm seems to work as well as boosting for low-ish dimensionality datasets and it is argued that interpretability is enhanced by the additive fitting on features and main pairwise interactions.</p><h3><strong>Is this a viable idea?</strong></h3><p>The positive:</p><ul><li>Boosting deserves to be recognized as one of the most powerful tools compatible with explainability nowadays.</li><li>The link Boosting-GAMS is important to understand and really helps to think of boosting as and additive modelling that accounts for interactions.</li><li>Round robin boosting way of fitting GAMs is interesting and potentially useful in itself</li></ul><p>The problems:</p><ul><li>Boosting capacity for <strong>sparse feature selection is priceless</strong>. Even if it is not enough by itself (permutation importance assessment is unavoidable in all real life noisy setups) this capacity is something that you can not give away<strong> </strong>when dealing<strong> </strong>with most real life medium-dimensional data. Interpreting hundreds of features modelled in a round robin way doesn’t sound like the best idea.</li><li><strong>How many interactions are relevant? </strong>With regular boosting this is reduced to a hyperparameter that can be efficiently explored : depth. I very rarely have found the optimal boosting depth to be 2. In my experience boosting is not that picky with exact depth, as long as it is above a minimum that almost always is bigger than 2. Expect limiting to pairwise interactions to be suboptimal. So, how many of those top interactions? Again, boosting will optimize that decision for you and no firesafe heuristic can warranty that you manually choose the best one.</li></ul><blockquote><strong>As a conclusion, it is very likely that previous points make the choice of “regular” boosting over the EBM a better choice, specially considering that regular boosting already takes you very close to model explainability if properly used.</strong></blockquote><p>The future will say, anyway, if the algorithm is adopted and used more successfully than boosting in demanding real life datasets it will mean that either previous points were not that relevant or that were addressed in future versions (current release is an Alpha Release).</p><p>This is already a long post so will leave it here by now, I hope it was of some interest. There is more to say about “Machine Learning Explainability”, I will try to find the time in the future for sharing some more ideas about it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b8897eb1f2b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Was this your face, Vincent?]]></title>
            <link>https://miguelpmich.medium.com/was-this-your-face-vincent-48e4059ace69?source=rss-9a0465191627------2</link>
            <guid isPermaLink="false">https://medium.com/p/48e4059ace69</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[art]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[style-reversion]]></category>
            <category><![CDATA[style-transfer]]></category>
            <dc:creator><![CDATA[Miguel Perez Michaus]]></dc:creator>
            <pubDate>Wed, 19 Sep 2018 09:39:01 GMT</pubDate>
            <atom:updated>2018-09-19T09:39:01.209Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Style Reversion, with Fast.ai tools</strong></p><p><em>Note: This post assumes some familiarity with basics of Neural Style Transfer. If new to the topic it will help to get a grasp of it before going on. I recommend this post by a former student of Fast.ai course Cutting Edge Deep Learning for Coders: </em><a href="https://medium.com/@shivamgoel1791/everything-you-need-to-know-about-neural-style-transfer-994530cc9a6e"><em>https://medium.com/@shivamgoel1791/everything-you-need-to-know-about-neural-style-transfer-994530cc9a6e</em></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*0Icma7KWmzDSWfpJt6Vwnw.png" /></figure><h3>A successful idea</h3><p>When I first discovered Neural Style Transfer I was fascinated but also a bit uncomfortable.</p><p>Such a powerful tool with such a simple idea. Results in many cases were so original that could be named art by their own merit. Plus, it was popular, lots of people were using their smartphones to make Monet-like portraits of their favorite selfie. The topic became so successful that it reached a certain saturation point.</p><p>Why did the thing work so well? Nobody seemed to know.</p><p>But there was one claim often made about the algorithm that I knew for sure was not true. Most explanations about it sooner or later would include the sentence “This is like having Monet painting for you” or something of the kind. And that claim, by design, is not true, and I can tell you why:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*cgEHC5R4lW_Hvv6EfJ6HOQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/15/1*Lz4_bUmevq_3T5F-uPettw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*NMytIN0IasNplqCgvbpevg.png" /></figure><p>The reason, <strong>STYLE of most works of art is CONTENT DEPENDENT</strong>,<strong> </strong>that “Starry Night” style made sense in that moment, for that landscape, but Van Gogh would never use it to portrait your cat in a Sunday morning. He would choose a proper style but we just can not know… or can we?</p><h3><strong>Impossible, but…</strong></h3><p>This implies that classical Style Transfer is a cool way of transferring the style of a single painting, not of an author.</p><p>So… what could we do to “learn” how a painter did what he did? We need the content. The original one. And we need to observe the options taken, the style chosen to abstract that content. After that provided we have enough examples a CNN could learn the patterns that make an author different from another.</p><p>All right… it’s almost certainly impossible. In my opinion the unsolvable part is “enough examples”. But what about step one, recovering original models? It was tempting to try.</p><p>How to recover original content or at least something close to it? My idea was to use the same approach of Style Transfer, just the other way around. <strong>Reverting style by defining content as the painting and style as a photo</strong>. I needed a proof of concept.</p><p>Of all the implementations of Style Transfer there was one I was more familiar with from <strong>Fast.ai part2</strong> Course that I had attended as international fellow months ago so I would use that. As content picture I chose a famous self portrait of Van Gogh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*6FvqC2m56_sLJki163uB7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*767owColWYpXF1qMGjmizw.png" /></figure><p>What about the style photo? It could be any portrait photo, as long as it shared general physical properties with Van Gogh, this is, red hair and blue-green eyes. It also had to be copyright -free. Also, as different as possible in content, for the sake of clarity.</p><p>A quick search on the web gave me a couple of candidates, both of them women. That was ok even if Vincent was a man because style, I thought, was captured in a locality independent way. (This intuition is not completely true as I was about to discover but using the picture of a woman for a man’s style did work fine).</p><p>It should have been question of hours to make it work. Only parameters to touch were levels of the CNN at which content and style were extracted and content loss vs. style loss weight.</p><p>For some reason, it didn’t work at first. Here is a sample of the kind of result I got initially with different parameters:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*91_hyqsCWndZssZRpYRqXA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*HBp-iUD-0PjHNsh6GgKLjw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*95Sbi6JOFAUgP-K2smntlA.png" /></figure><p>Quite horrible. But still in almost all of the pictures there was a part that looked as “real Vincent”. An eye, the nose… what was going on here? It took me a while to discover.</p><h3><strong>“Partial locality” of Style Gram Matrixes</strong></h3><p>I finally realized what was going on. And I did so by thinking about how actually does the Gram Matrix of filters, layer-wise, keep spatial information of the style image.</p><p>(If you don’t care about what Gram matrix do in NST you can skip next paragraph but in case you want to try style reversion on your own you will have to understand this because it turned out to be critically important for getting a minimally viable proof of concept)</p><p>Realize that for each convolutional layer a Gram matrix captures the “fingerprint” of filters activations in the image individually as well as correlating in space with other filters. In my specific example this implies that if, for example, we take only half of the woman’s photo or the proportion of hair vs. skin changes… the style also changes. <strong>There is a spatial component in style</strong>. This insight made me inspect style photo trying to find out what strong spatial component was damaging style reversion and creating all those dark parts.</p><p>The most promising suspect was<strong> contrast</strong>. If style is not independent of the existence of, say, a big dark zone in the photo then the algorithm will try to transfer that contrast quality of global image at any prize, creating big darker zones. Just an intuition but easy to find out. I made a simple contrast reduction of the style photo, like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R3SpWmtdhDZtv7nWndCtNw.png" /></figure><p>Reproducing it here because this modification was critical for the approach to work. First image would never work, no matter the settings. Contrast lowered image did work. There are much accurate ways of balancing contrast of source and target but in this case just lowering it worked well enough.</p><p>After that I rerun exactly the same code. You can see the result below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*APKLBGEtdIS_DAoXqVlHug.png" /></figure><p>Much better, isn’t it? I would say the “style-reverted” image looks quite well, some steps have been given towards “realistic” face of Vincent. Sure it can be improved in many ways but I consider it enough for a proof of concept.</p><h3><strong>The “recipe” and some take home ideas</strong></h3><p>The general approach should work with any “clasic” implementation of Style Transfer , you can find the <strong>Fast.ai notebook I used</strong> in Github here: <a href="https://github.com/fastai/fastai/blob/master/courses/dl2/style-transfer.ipynb">https://github.com/fastai/fastai/blob/master/courses/dl2/style-transfer.ipynb</a></p><p><strong>Exact parameters will be dependent on implementation and CNN architecture but the main tricks to make it work were:</strong></p><p>- Unless working with really big sizes choose <strong>content layer lower than in normal approach</strong>. Realize that the higher you cut the more pooling has happened and more distortion will occur.</p><p>- Choose a <strong>compatible “style” photo</strong>. And remember that compatibility includes not only theme but also scale/masses and contrast cause Gram matrix of filters will be sensitive to that.</p><p>- <strong>Weight style loss more than content</strong>, optimal weight here was 10x content loss (try different proportions)</p><p>- I used size = 432, the max size my laptop GPU could handle. Results were worse with smaller size, it is quite possible that bigger size and proper tuning will give even better results.</p><h3><strong>Final thoughts</strong></h3><p>It can be argued that picking a photo to revert style of a painting is just as arbitrary as was doing the opposite. True, but there is one difference. There is much more variation in style in one artist’s works and among artists than variation of, for example, skin texture among physically similar persons or plants of the of same species. This makes much easier to pick “sensible” candidates for style photos just as in the example above.</p><p>If we just had enough examples — but we don’t have!- we could use that material with DL to abstract at least some of the options individual artists made when creating.</p><p>I have exposed the simple but appealing idea of <strong>using Style Transfer algorithm to revert style in a painting and approximate it to a more realistic image of the original content</strong>. Also hinted the possibility of using this artificial original to feed a Neural Net and abstract an author’s style, even though almost certainly lack of enough examples makes that approach unfeasible.</p><p>So glad I found the time to put in words this intuitions. I hope it was of some interest. Maybe someone with time and curiosity in further exploring will achieve some more interesting results on other themes and authors.</p><p><em>Non DL bonus: For those interested in Art who would like to understand why Van Gogh painted how he did, there is a book in which he will tell you about it. His “Letters to Theo” (his dear brother who supported him all his life) contain many hints of what he wanted to achieve. The search of a style more real than reality. Definitely worth reading.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48e4059ace69" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>