<?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 Ivan Klenovskiy on Medium]]></title>
        <description><![CDATA[Stories by Ivan Klenovskiy on Medium]]></description>
        <link>https://medium.com/@iklenovskiy?source=rss-6480de9acc52------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*1KXrblbuVG7Nlteukxksnw.jpeg</url>
            <title>Stories by Ivan Klenovskiy on Medium</title>
            <link>https://medium.com/@iklenovskiy?source=rss-6480de9acc52------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 20:31:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@iklenovskiy/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[Data Driven Economics: Learning in the Oil Industry]]></title>
            <link>https://medium.datadriveninvestor.com/data-driven-economics-learning-in-oil-industry-5ec229807d47?source=rss-6480de9acc52------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ec229807d47</guid>
            <category><![CDATA[economics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[oil]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[learning]]></category>
            <dc:creator><![CDATA[Ivan Klenovskiy]]></dc:creator>
            <pubDate>Mon, 13 Jan 2020 16:31:30 GMT</pubDate>
            <atom:updated>2020-01-15T07:00:44.141Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Essentially, this is my very simplified summary of a recent paper by Charles Hodgson (2018) </em><a href="https://cpb-us-w2.wpmucdn.com/campuspress.yale.edu/dist/a/3019/files/2019/08/oil.pdf"><em>link</em></a><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fXblskGc2kDoWrVCt3SJkw.jpeg" /></figure><p><strong>Background</strong></p><p>In the oil industry learning is an important part of companies’ business routine. Before developing any block of land, it is necessary to conduct research and estimate the amount of oil underneath it. Since the development of oil well is excessively costly, developing a void piece of land with barely any oil underneath it can be embezzling. Therefore, digging several test wells to estimate possible future gains in oil from beneath the Earth’s crust is a reasonable idea.</p><p>Blocks of land become real options to companies since if the estimated amount of oil is high, then the development of oil well will be profitable and the company should exercise the option if the estimate is low, then the long term stream of profits will not cover large fixed costs today and oil we should not proceed with the project.</p><p><a href="https://www.datadriveninvestor.com/2019/03/08/why-inclusive-wealth-index-is-a-better-measure-of-societal-progress-than-gdp/">Why Inclusive Wealth Index is a better measure of societal progress than GDP? | DataDrivenInvestor</a></p><p>An important problem arises if there are other companies nearby, conducting those diggings simultaneously. On the one hand, “my” company can use this information to conduct less research and cut on wasteful costs, since the amount of oil underneath is spatially correlated, which means that if the neighbor’s block has substantial amounts of oil, then mine is likely to have plenty too. On the other hand, if both my company and neighboring companies are relying on each other’s research, then insufficient amounts of research would be conducted.</p><p>The described set-up calls for government intervention in case the current behavior of companies is suboptimal.<br>The question is how to decide whether the equilibrium is sub-optimal. There is no data available that would be helpful with this question because it is unclear where to get this measure of sub-optimality from. This is where economics comes handy!</p><p>To produce some reasonable discussion, we can summarize oil firm’s interactions in a parsimonious mathematical model with a set of numerical parameters, use the available data to estimate them using statistical methods and evaluate how far the current equilibrium is from the optimum. After all those steps we can work out the policy to improve the welfare as long as the model’s assumptions are correct and our estimation procedure is performed with caution. At least this sounds more persuasive than vague arguments relying on some possibly biased experts’ intuition. A paper by Charles Hodgson serves as a good example of such a line of thinking.</p><p><strong>Economist’s approach</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*LeAkZkPzXTVRu2_KyaATYg.png" /><figcaption>Drilling history visualized UK Continental Shelf</figcaption></figure><p>Given the 30 year history of oil drilling in the UK Continental Shelf, researchers can estimate a statistical model of spatial correlation in oil distribution over space. This will allow presuming how a successful exploration improves the chances of large oil reserves nearby. Assuming Gaussian process as a model for oil distribution and the following covariance function between two locations <strong><em>X</em></strong>and <strong><em>X’</em></strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*3tyZv8EMa-SALLkm9HB21A.png" /></figure><p>Author catches this spatial correlation by estimating <strong><em>w</em></strong><em> </em>and <strong><em>l</em></strong><em> </em>from the data using Maximum Likelihood. The following figure illustrates how the probability of large oil reserves underneath a block of land varies depending on successful digging nearby this particular block.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q-wGaN-y6SbjJipDLWJLyg.png" /></figure><p>Moreover, paper provides additional evidence that neighbors’ learning, indeed, affects our own decisions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m9HEGlBpjYgjx1W2ue4DGQ.png" /></figure><p>We see that successful research and oil discoveries in nearby blocks of land increase the chances of firms proceeding with a project and unsuccessful research discourages us from investing in developing an oil well. Another interesting observation is that this effect varies with how firms are currently informed about the resources in their block of land. If they have already conducted some research, then neighbors’ digging does not affect their investment decision. However, if the uncertainty level is high, then neighbors’ learning is more influential in their decisions.</p><p>Next, the paper takes a step towards evaluating whether current interactions between firms are socially optimal and whether anything can be done to improve them.</p><p>Author makes several assumptions to do that:</p><ul><li>Firms think in terms of the Gaussian model and update their beliefs about success chances of blocks of land with new information using it</li><li>Each period firms decide to undertake research and/or development of block of lands</li><li>Firms choose actions to maximize expected discounted stream of profits (something like sum: price*quantity/interest rate)</li><li>This discounted stream of profits is written in terms of value functions, like in reinforcement learning</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*MzXOGdsIc5LsBULgpTyQQg.jpeg" /></figure><ul><li>Log oil price is assumed to follow a random walk</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*aGAxsBbRGd1AaIOqnO1-DA.png" /></figure><p>Using this decision model, author can evaluate the predicted probabilities of each action:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rD8pGza1tGDRfDstpsIElQ.png" /></figure><p>and estimate the parameters of the model by finding those which solve Maximum Likelihood estimation procedure on the observed behavior. Those parameters include information spillover rates (how fast do we observe others research results) and cost function of the firms.</p><p><strong>Results</strong></p><p>Now we can take up the role of benevolent social planner and check what happens if, for instance we require more or less information spillovers than currently. Author finds that with full disclosure total surplus of the industry raises by <strong>38%</strong> as sub-optimal investment in research declines. On the other hand, ban on sharing information increases industry surplus by <strong>31%</strong> and speeds up exploration of land blocks by <strong>1 year</strong> on average, since in this case firms do not expect others to do there learning. This suggest that current equilibrium is in some sort of local minima.</p><p>Are there any other good policies available? Author discovers that a good idea would be to redistribute land blocks and implement spatial clustering across firms (each color represents ownership of different firms)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wCdHYI99gECH6wtK1D-JDw.png" /></figure><p>Of course, this is hardly imaginable, but it seems to be a good policy to eliminate the externality problem and bring industry closer to the social optimum.</p><p>I have shared with you a part of economics which I particularly like and which I think is applicable for conducting policy and making data-driven decisions. Stay tuned, I plan to share more as I dive into this.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fb2a0d6%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2Fb2a0d6%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/0707f5c806284d01a4a13c7b13a91ce3/href">https://medium.com/media/0707f5c806284d01a4a13c7b13a91ce3/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ec229807d47" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/data-driven-economics-learning-in-oil-industry-5ec229807d47">Data Driven Economics: Learning in the Oil Industry</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A simple and interpretable baseline for predictive maintenance]]></title>
            <link>https://medium.com/data-science/a-simple-and-interpretable-baseline-for-predictive-maintenance-3f94736ed99a?source=rss-6480de9acc52------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f94736ed99a</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[predictive-maintenance]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Ivan Klenovskiy]]></dc:creator>
            <pubDate>Sun, 20 Oct 2019 15:05:38 GMT</pubDate>
            <atom:updated>2022-01-13T16:33:06.068Z</atom:updated>
            <content:encoded><![CDATA[<p>A while ago I have encountered a predictive maintenance problem on my data science job. Highly unbalanced classes (since the number of breakages is typically less than 1%), huge number of non-interpretable sensors — ok, but what is next? Since I lacked any experience with such tasks, I started googling and reading everything about ‘’data science for PM’’ I could possibly find.</p><p>To my disappointment, most of the articles I have discovered did not provide me with valuable insights — they were either some complex Arxiv papers, which tested new theoretical methods on unavailable data, or some high-level blogging posts, short on reusable ideas.</p><p>After a couple of months of hands-on experience solving a predictive maintenance (set to PM further) problem with machine learning, weary with toil, I decided to share the baseline approach I have developed so far. It may be fruitful to people who, as me a couple of months ago, do not know what to do and want to have some sort of a beacon nearby.</p><p>In the post, I will explain the business side of the problem and list typical requirements to the algorithm from the client, which may significantly restrict the set of data science tools available. Next, I will explain my approach in details and underline its pros and cons. Finally, I will share some practical hacks and bits and pieces of code which can be helpful in implementing it.</p><h3><strong>Business problem</strong></h3><p><em>You can skip this part if you are interested only in technical things.</em></p><p>Every ML algorithm installed in a business process should somehow increase profits. In PM we usually have a large-scale machine, consuming expensive resources to produce some sort of final output through a complex multi-stage process. With time those machines break down unexpectedly, causing an increase in idle time and a loss of valuable resources, since a malfunctioning machine typically wastes them.</p><p>This is where an ML algorithm can enter the scene — it can predict malfunctions (I use stops, breakages, stoppages interchangeably throughout the text) in advance, using data from the sensors installed in the machine. However, even if we are able to predict those stops in advance, without knowing the cause, financial value of our prediction would be modest.</p><p>First, if the only information we report to engineers is that there is a high chance of breakage in the next 20 minutes, they cannot do much with it. Probably, they can stop the machine and do some sort of deep maintenance but this is costly. Moreover, with large-scale machines, they will not necessarily discover the cause for malfunction in such a short period of time, therefore, the value of our prediction is nullified. Second, our algorithm will have a certain amount of false positives. With the presence of false positives, stopping the machine to check for obscure malfunction will be rarely approved from the client side.</p><p>Hence, our algorithm, besides predicting the probability of stoppage, should somehow hint on the possible causes. It should provide certain guidance for the technicians searching for a malfunction during preventive maintenance. In this case, our ML algorithm truly solves client’s pain.</p><h3><strong>Data Preparation</strong></h3><p>Now let’s take a closer look at a typical predictive maintenance data. Here is how the outcome variable will look like once you have finished data preparation. <strong>Y = 1</strong> if the stop is soon happening and <strong>Y = 0</strong> if there is no stop in the next<strong> K</strong> minutes.</p><p>You can see that classes are unbalanced and machine learning models should give a higher weight for rare class in order to distinguish anomalies causing stops with stronger attention.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*muzGnQaMHhyLPLRrC1DbwQ.png" /><figcaption>Outcome variable</figcaption></figure><p>But to obtain this time series you will have to do some grunt work. Usually, they will provide you with two datasets — one with information about stops (their nature, causes, and timestamp) and a second with all the data from the sensors.</p><p>We need to merge those two files to create our data set. I advise to drop observations (code sample of data processing is available below) when machine was broken and observations near the stops, as this information might be noisy. For instance, one could drop all observations for which time to next stop is less than 5 minutes.</p><p>Next, let’s label all observations with time to next stop longer than 20 minutes as zero, while label all observations with time to next stop less than 20 minutes as one (you can vary this cut-off based on your data). This operation slightly improves your class balance.</p><p>Usually there are different types of stops occurring in different parts of the machine. I suggest to filter the data and choose the most common one and then generalize the solution to other stops. Different types of stops have distinct causes, therefore, information about each stop will be contained in distinct sets of sensors. Hence, one generic model is unlikely to perform well.</p><p>Some code which might help you with the operations described above:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f67feb030f1149dfdb1d9c4a857d1118/href">https://medium.com/media/f67feb030f1149dfdb1d9c4a857d1118/href</a></iframe><p>Second, we should deal with the explanatory variables (<strong>Xs</strong>). After we merge them with an outcome variable, we should try to reduce dimensionality in order to draw meaningful conclusions. Without any prior knowledge of the industry specifics, we can’t select which ones correspond to the important predictors based on our intuition. Just take a look at some plots of Xs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nBGqEUi4HvG-_h-vum-YOw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*noLYGr-AF0wKJpQq7FnnRg.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rk3zFFRTD8KbSv2IbxxDHQ.jpeg" /><figcaption>Examples of sensors</figcaption></figure><p>However, we have a lot of techniques at our hand to reduce dimensionality:</p><ul><li>Drop sensors with extra-low variance</li><li>Group and aggregate (via PCA or other similar techniques) sensors according to their location/role in the machine (this information can be obtained from their tags)</li><li>Aggregate changes of variables (how many sensors have just changed their regime)</li></ul><p><em>Selecting variables based on raw correlation with outcome variable would be a bad idea</em></p><p>In my task, aggregations of changes of variables was helpful since it both contained information that machine is unstable and reduced the number of variables.</p><p>Here is one such aggregated variable:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VDHEA6OrX6r66PWT_ck2uQ.jpeg" /><figcaption>Aggregated variable and Y</figcaption></figure><p>We can restrict our sensor space further.</p><p>Let’s iteratively pick each sensor and try to predict stops based on its quantiles. If the current time series quantile of the sensor is somewhat indicative of the stop, then the sensor contains information about abnormal behavior of the machine. I suggest selecting about 5–15 (this range was applicable to my particular problem) sensors whose quantile model has the strongest predictive power.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6a3ff9f62eebee258078f9a256dc9f08/href">https://medium.com/media/6a3ff9f62eebee258078f9a256dc9f08/href</a></iframe><p>The loss of predictive power from this step depends on the data and nature of the stops as sometimes complex interactions of a certain order might be crucial for prediction. However, our main goal is a simple baseline interpretability and interpretability for the client.</p><p>Another useful thing to do is to check the behavior of selected sensors right before the stop and during stable working period. If you notice anomalies in your time series plots exclusively before the stops, you have a good chance of solving the problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Td5HStqCJONV6kK3nqZhLQ.jpeg" /><figcaption>Sensors just prior to the stop (look for simultaneous jumps in certain variables)</figcaption></figure><p>The code which generates such plots:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5b2b890b691fe91c1bb37984b0fca95c/href">https://medium.com/media/5b2b890b691fe91c1bb37984b0fca95c/href</a></iframe><h3><strong>Modeling</strong></h3><p><em>Thoughts</em></p><p>Given well-behaved (<strong>X,Y</strong>) (I assume that you have done other standard data preprocessing, such as dealing with missing values) data we can start the modeling stage.</p><p>Prior to testing some models, we can hypothesize about where the signal is contained. Machines are designed in order to operate normally. Also, they are prescribed with a stable operating regime indicating an interval of values for each sensor. If for some reason (engineers did not change a certain parameter smoothly) machine deviates from the prescribed operating regime it is likely to break. With time, machine becomes less stable and the operating regime should account for that shift. Rarely does this happen — this might be our bread and butter for this task.</p><p>I expect the stops to be well predicted by deviations for each sensor from some new range of values. Also, I expect that interactions between several sensors will predict stoppages. For instance, if one sensors deviates from its normal interval while another has value <strong><em>w</em></strong>, no stoppage will occur. However, if that same sensor deviates while another has value <strong><em>z</em></strong>, the stoppage is unavoidable.</p><p>I do not expect (this assumption was good for my task) that interactions between a large number of sensors will be helpful for this task. Especially, if we quantify the aggregate number of sensors which are currently out of their standard range of values. This overall machine stability should be one of the key features in the model.</p><p><em>Approach</em></p><p>Having all this in mind, I chose to predict stops with a majority voting ensemble of small models, based on 2–3 sensors and aggregate features. This approach allows to identify which sensors signal the stop. This information can be later directed to engineers, who, based on their knowledge, can identify the cause and fix the problem.</p><p>First, I select a set of pairs (triples) of sensors from our restricted set using basic LGBM model with specifically tuned parameters. Selection is done via iterative search over pairs, according to the AUC score on k-fold time series cross-validation. Besides sensor data, those small models include aggregate features and some intuitive sensor-based features, such as:</p><ul><li>Mean</li><li>Trend</li><li>Z-score</li><li>Std</li></ul><p>Code for variable generation:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/51e92f7902861f7eba7da697ab3fb584/href">https://medium.com/media/51e92f7902861f7eba7da697ab3fb584/href</a></iframe><p>After determining the set of small models, their predictions are combined by basic ensembling. 0.5 quantile is found and if it is higher than a predefined boundary, I predict Y = 1 and the stop should soon occur. <strong>Alarm!</strong></p><p>The above approach is slightly simplified and more can be done to improve its precision, such as:</p><ul><li>Other ensembling techinques (RNN and other …)</li><li>Other first level learners</li><li>Search over leftover sensors and add them to some of the small models</li><li>Build a single model for each production regime (summer/winter substantially differ in the distributions of sensor values, this can be checked via Kolmogorov-Smirnov test)</li></ul><h3>Results</h3><p>Images, in my view, here are more revealing than words or metrics, if you see that algorithm rarely predicts stops but when in does something indeed happens with the machine — we are fine:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FQ_EooF3cFEC6I5dF3qZXA.png" /><figcaption>Good performance of the baseline</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LPKxbmak9vAjowJHTwr_fg.jpeg" /><figcaption>Bad performance</figcaption></figure><p>On my data the described framework was able to predict stops with a precision of about 40% and a recall of around 40%, which is a good result for a baseline in predictive maintenance. Moreover, it provides engineers with references to particular sensors, as they know which sensors signal a higher likelihood of stopping. Thus, they can do a narrowly focused preventive maintenance.</p><p>I will end with a short summary of the pros and cons of this approach:</p><p><em>Pros</em></p><ul><li>Simplicity and interpretability (with such a small number of sensors per model, you can emphasize what part of the machine drives the threat of stop)</li><li>Low constraints on the GPU usage and memory</li></ul><p><em>Cons</em></p><ul><li>Suboptimal in terms of accuracy (well trained NN with all the features might outperform this baseline)</li><li>Computation time constraints (all those iterative searches require time)</li><li>Human time constraints (this approach requires human guidance)</li></ul><p><strong>I will add links to the omitted code later. Also, I give credit to Kaggle Bosch competition, which I used to create all those images…</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f94736ed99a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/a-simple-and-interpretable-baseline-for-predictive-maintenance-3f94736ed99a">A simple and interpretable baseline for predictive maintenance</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>
    </channel>
</rss>