<?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 Axel Ivanda Tanjung on Medium]]></title>
        <description><![CDATA[Stories by Axel Ivanda Tanjung on Medium]]></description>
        <link>https://medium.com/@axelivandatanjung?source=rss-6e6a1fce9627------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*7CXLX8AJrUYGIDaUB_LLnA.png</url>
            <title>Stories by Axel Ivanda Tanjung on Medium</title>
            <link>https://medium.com/@axelivandatanjung?source=rss-6e6a1fce9627------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 15:45:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@axelivandatanjung/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[How AI Can Prevent Multi-Million Dollar Stuck Pipe Incidents in Oil & Gas Drilling]]></title>
            <link>https://medium.com/@axelivandatanjung/how-ai-can-prevent-multi-million-dollar-stuck-pipe-incidents-in-oil-gas-drilling-9fa84bc839b4?source=rss-6e6a1fce9627------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fa84bc839b4</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[oil-and-gas]]></category>
            <dc:creator><![CDATA[Axel Ivanda Tanjung]]></dc:creator>
            <pubDate>Tue, 23 Jun 2026 02:39:55 GMT</pubDate>
            <atom:updated>2026-06-23T02:39:55.436Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*MzD8UhP1pHI95UPEsCLJeQ.jpeg" /></figure><p>Link GitHub : <a href="https://github.com/axeltanjung/stuck-pipe-ai">https://github.com/axeltanjung/stuck-pipe-ai</a></p><h3>Building an AI-Powered Drilling Risk Intelligence Platform</h3><p>Every hour on a drilling rig is expensive. When a drillstring becomes stuck thousands of meters below the surface, the consequences can be enormous: days of non-productive time, fishing operations, sidetracking, equipment replacement, and sometimes millions of dollars in losses. The challenge is that stuck pipe incidents rarely happen without warning.</p><p>Subtle changes in drilling parameters often emerge hours before a critical event occurs. The problem is that these signals are scattered across dozens of telemetry streams, making them difficult for humans to detect consistently in real time. This is where machine learning becomes valuable.</p><p>In this project, I built <strong>Stuck Pipe AI</strong>, an end-to-end drilling risk intelligence platform designed to predict stuck pipe incidents, provide operational recommendations, and help drilling teams make proactive decisions before costly failures occur.</p><h3>The Business Problem</h3><p>Stuck pipe remains one of the most expensive drilling problems in the oil and gas industry.</p><p>Industry studies estimate that stuck pipe contributes to approximately 25–30% of drilling non-productive time (NPT), resulting in billions of dollars in annual losses worldwide.</p><p>A single incident may lead to:</p><ul><li>$100,000–$5 million+ direct costs</li><li>Days or weeks of operational delays</li><li>Fishing and recovery operations</li><li>Bottom Hole Assembly (BHA) losses</li><li>Well sidetracking expenses</li><li>Increased safety risks</li></ul><p>Despite the financial impact, monitoring practices often remain reactive.</p><p>Many drilling decisions still depend heavily on human expertise and manual interpretation of real-time drilling parameters.</p><p>The goal of this project was straightforward:</p><blockquote><em>Detect drilling risk before the drill string becomes stuck.</em></blockquote><h3>Understanding Stuck Pipe</h3><p>Stuck pipe generally occurs in two major forms:</p><ol><li><strong>Differential Sticking</strong></li></ol><p>This happens when differential pressure forces the drillstring against a permeable formation. The pressure imbalance creates a suction effect that effectively locks the pipe against the wellbore wall.</p><p>Risk factors include:</p><ul><li>High mud weight</li><li>Thick filter cake formation</li><li>Extended static periods</li><li>High overbalance pressure</li></ul><p><strong>2. Mechanical Sticking</strong></p><p>Mechanical sticking is caused by physical restrictions in the wellbore.</p><p>Common causes include:</p><ul><li>Poor hole cleaning</li><li>Cuttings accumulation</li><li>Pack-off events</li><li>Wellbore instability</li><li>Key seating</li><li>Formation collapse</li></ul><p>Both mechanisms exhibit recognizable operational signatures that can be captured through drilling telemetry.</p><h3>The AI Opportunity</h3><p>Modern drilling rigs generate vast amounts of operational data:</p><ul><li>Weight on Bit (WOB)</li><li>Rotary Speed (RPM)</li><li>Torque</li><li>Hook Load</li><li>Standpipe Pressure</li><li>Mud Flow Rate</li><li>Equivalent Circulating Density (ECD)</li><li>Rate of Penetration (ROP)</li><li>Vibration Indicators</li><li>Stick-Slip Measurements</li></ul><p>Individually, these signals provide limited insight. Collectively, they reveal patterns that often precede drilling dysfunction. Machine learning excels at identifying these complex, nonlinear relationships.</p><p>Instead of relying solely on threshold alarms, we can train models to recognize combinations of conditions associated with elevated stuck pipe risk.</p><h3>System Architecture</h3><p>The platform was designed as a production-oriented architecture rather than a notebook-based proof of concept.</p><p><strong>Core Components</strong></p><ol><li><strong>Frontend</strong></li></ol><ul><li>React</li><li>Vite</li><li>TailwindCSS</li><li>Recharts</li></ul><p><strong>2. Backend</strong></p><ul><li>FastAPI</li><li>SQLAlchemy</li><li>Pydantic</li></ul><p><strong>3. Machine Learning Layer</strong></p><ul><li>XGBoost</li><li>LightGBM</li><li>LSTM</li><li>SHAP Explainability</li></ul><p><strong>4. Model Lifecycle</strong></p><ul><li>MLflow Experiment Tracking</li><li>Model Registry</li><li>Artifact Management</li></ul><p><strong>5. Deployment</strong></p><ul><li>Docker</li><li>Docker Compose</li><li>Nginx Reverse Proxy</li></ul><p>This architecture mirrors the structure commonly found in enterprise AI systems where monitoring, explainability, deployment, and model management are as important as model accuracy.</p><h3>Building the Machine Learning Pipeline</h3><h3>1. Data Preparation</h3><p>The first step involved transforming raw drilling telemetry into model-ready features. Key preprocessing steps included:</p><ul><li>Missing value handling</li><li>Outlier treatment</li><li>Feature scaling</li><li>Temporal alignment</li></ul><h3>2. Feature Engineering</h3><p>Domain expertise plays a significant role in drilling analytics. Instead of relying solely on raw measurements, derived indicators were created:</p><ul><li>Rolling averages</li><li>Rolling standard deviations</li><li>Rate-of-change features</li><li>Pressure differential indicators</li><li>Hole cleaning metrics</li><li>Stick-slip severity measures</li><li>Vibration trend indicators</li></ul><p>These engineered features often provide stronger predictive power than the original sensor readings.</p><h3>3. Multi-Model Architecture</h3><p>Different algorithms capture different aspects of drilling behavior.</p><h4>XGBoost</h4><p>Used as the primary classifier due to:</p><ul><li>Strong performance on tabular data</li><li>Robust handling of nonlinear relationships</li><li>Excellent interpretability</li></ul><h4>LightGBM</h4><p>Provides:</p><ul><li>Faster training</li><li>Lower memory consumption</li><li>Competitive predictive performance</li></ul><h4>LSTM Neural Network</h4><p>Unlike tree-based models, LSTMs can learn temporal patterns.</p><p>This is particularly useful because drilling problems often emerge gradually over time rather than appearing suddenly.</p><p>The LSTM analyzes sequences of operational data to detect degradation patterns that may be invisible in static snapshots.</p><h3>Risk Classification Engine</h3><p>Model outputs are translated into operational risk levels:</p><p>ProbabilityRisk Level&gt;80%Critical&gt;60%High Risk&gt;40%Warning&gt;20%Low Risk≤20%Normal</p><p>Additional rule-based logic evaluates:</p><ul><li>Torque spikes</li><li>Pressure instability</li><li>Vibration anomalies</li><li>Hole cleaning effectiveness</li></ul><p>This hybrid approach combines machine learning predictions with drilling engineering principles.</p><h3>Explainable AI for Operational Trust</h3><p>One challenge in industrial AI adoption is trust. Drilling engineers are unlikely to act on recommendations generated by a black-box model. To address this, the platform incorporates SHAP (SHapley Additive exPlanations).</p><p>For each prediction, users can see:</p><ul><li>Which variables contributed most to the risk score</li><li>Whether a feature increased or decreased risk</li><li>Relative importance of operational parameters</li></ul><p>Instead of simply displaying:</p><blockquote><em>“Risk = 78%”</em></blockquote><p>The system can explain:</p><blockquote><em>“High torque variability, increasing standpipe pressure, and declining hole-cleaning efficiency are the primary contributors to elevated risk.”</em></blockquote><p>This dramatically improves operational confidence.</p><h3>Intelligent Recommendations</h3><p>Prediction alone is not enough. The system also generates operational guidance. Examples include:</p><ol><li><strong>Hole Cleaning Issues</strong></li></ol><p>Recommendation:</p><ul><li>Increase circulation rate</li><li>Optimize mud rheology</li><li>Increase drillstring rotation</li></ul><p><strong>2. Differential Sticking Risk</strong></p><p>Recommendation:</p><ul><li>Reduce static time</li><li>Optimize mud weight</li><li>Improve wellbore conditioning</li></ul><p><strong>3. Excessive Vibration</strong></p><p>Recommendation:</p><ul><li>Adjust RPM</li><li>Modify Weight on Bit</li><li>Evaluate bit condition</li></ul><p>The objective is to move beyond monitoring toward decision support.</p><h3>Business Impact</h3><p>If deployed successfully, a platform like this could create value in several areas.</p><ol><li><strong>Reduced Non-Productive Time</strong> : Early warning systems can prevent incidents before they occur.</li><li><strong>Lower Drilling Costs : </strong>Avoiding even a single stuck pipe event may save hundreds of thousands of dollars.</li><li><strong>Improved Operational Efficiency </strong>: Optimization recommendations can improve drilling performance and Rate of Penetration (ROP).</li><li><strong>Better Knowledge Transfer : </strong>AI systems preserve operational knowledge across crews, shifts, and rigs.</li><li><strong>Enhanced Safety : </strong>Proactive risk management reduces emergency operational decisions under pressure.</li></ol><h3>Lessons Learned</h3><p>Building industrial AI systems requires much more than training a model.</p><p>Several key lessons emerged:</p><ol><li><strong>Domain Knowledge Matters : </strong>Feature engineering informed by drilling mechanics often provides greater gains than experimenting with additional algorithms.</li></ol><p><strong>2. Explainability Is Essential : </strong>Engineers need reasons, not just predictions.</p><p><strong>3. Deployment Is Part of the Product : </strong>A model that cannot be monitored, updated, or integrated into operations has limited business value.</p><p><strong>4. Hybrid Intelligence Works Best : </strong>Combining machine learning with engineering rules frequently outperforms either approach alone.</p><h3>Future Directions</h3><p>Several enhancements could make the platform even more powerful:</p><ul><li>Real-time WITS/WITSML integration</li><li>Reinforcement learning for drilling optimization</li><li>Digital twin simulation coupling</li><li>Edge deployment directly on rigs</li><li>Autonomous drilling assistants</li><li>Multi-well transfer learning</li><li>Formation-ahead prediction models</li><li>LLM-powered drilling report generation</li></ul><p>These capabilities move the industry closer to truly intelligent drilling operations.</p><h3>Final Thoughts</h3><p>The future of drilling is not about replacing engineers with AI. It is about augmenting engineering expertise with systems capable of processing thousands of signals simultaneously and identifying risks before humans can.</p><p>StuckPipe AI demonstrates how machine learning, explainable AI, and modern software engineering can be combined to transform drilling operations from reactive troubleshooting to proactive risk management.</p><p>As the energy industry continues its digital transformation, the greatest opportunities will come from solutions that connect domain expertise with practical, deployable AI. And in drilling, preventing a single stuck pipe incident may be enough to justify the entire investment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fa84bc839b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an AI-Powered Compressor Anomaly Detection Platform for Oil & Gas Operations]]></title>
            <link>https://medium.com/@axelivandatanjung/building-an-ai-powered-compressor-anomaly-detection-platform-for-oil-gas-operations-efe040fc521a?source=rss-6e6a1fce9627------2</link>
            <guid isPermaLink="false">https://medium.com/p/efe040fc521a</guid>
            <category><![CDATA[anomaly-detection]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[oil-and-gas]]></category>
            <dc:creator><![CDATA[Axel Ivanda Tanjung]]></dc:creator>
            <pubDate>Sun, 21 Jun 2026 07:33:59 GMT</pubDate>
            <atom:updated>2026-06-21T07:33:59.719Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R8LY9zxZ2bAyYKl-iXjMcg.png" /></figure><p>Link GitHub : <a href="https://github.com/axeltanjung/oil-gas-compressor-anomaly">https://github.com/axeltanjung/oil-gas-compressor-anomaly</a></p><h3>Introduction</h3><p>In the Oil &amp; Gas industry, compressors are among the most critical assets in the entire production chain. Whether operating in offshore platforms, LNG facilities, gas processing plants, or long-distance pipeline systems, compressors ensure that gas continues flowing through the network safely and efficiently.</p><p>The problem is simple:</p><blockquote>When a compressor unexpectedly fails, the consequences can be enormous.</blockquote><p>A single shutdown can result in production losses ranging from hundreds of thousands to millions of dollars per day. Beyond financial impact, failures may introduce safety hazards, environmental risks, and cascading effects on downstream equipment.</p><p>Traditionally, operators rely on alarm thresholds such as:</p><ul><li>Alert when vibration exceeds 10 mm/s</li><li>Alert when bearing temperature exceeds 90°C</li><li>Alert when pressure drops below a defined limit</li></ul><p>While effective for obvious failures, these threshold-based approaches often fail to detect gradual degradation or complex multivariate anomalies. By the time a traditional alarm activates, the equipment may already be approaching failure. This project explores how machine learning can be used to move from reactive monitoring toward predictive, intelligent condition monitoring. The result is an AI-powered Compressor Anomaly Detection Platform capable of identifying abnormal operating behavior before failures occur.</p><h3>The Challenge with Traditional Monitoring</h3><p>Most industrial monitoring systems operate using fixed thresholds.</p><p>For example:</p><ul><li>High vibration → trigger alarm</li><li>High temperature → trigger alarm</li><li>Low pressure → trigger alarm</li></ul><p>The issue is that industrial equipment rarely operates under fixed conditions. A compressor running at 40% load behaves differently from one running at 90% load. Seasonal conditions, gas composition, process changes, and operational adjustments continuously influence sensor readings.</p><p>This creates several challenges:</p><ol><li>False Alarms : Normal operational changes may trigger unnecessary alarms.</li></ol><p>2. Missed Early Warnings : Slow degradation often remains invisible because values stay below predefined limits.</p><p>3. Multivariate Failures : Many failures emerge from interactions between multiple variables rather than a single sensor. For example:</p><ul><li>Slight increase in vibration</li><li>Small pressure instability</li><li>Gradual temperature rise</li></ul><p>Individually these signals appear normal. Together they may indicate an emerging failure mode. This is where machine learning becomes valuable.</p><h3>Understanding Compressor Failure Modes</h3><p>Before building models, domain understanding is essential. Industrial compressors fail in predictable ways.</p><p><strong>1. Bearing Failure</strong></p><p>One of the most common and expensive failure mechanisms.</p><p>Typical indicators include:</p><ul><li>Increasing vibration</li><li>Rising bearing temperatures</li><li>Lubrication degradation</li><li>Abnormal acoustic signatures</li></ul><p><strong>2. Cavitation</strong></p><p>Occurs when local pressure drops cause vapor bubbles to form and collapse. Symptoms include:</p><ul><li>Pressure instability</li><li>Flow fluctuations</li><li>Elevated vibration</li></ul><p><strong>3. Surge</strong></p><p>A dangerous operating condition where flow reverses through the compressor.</p><p>Characteristics include:</p><ul><li>Oscillating pressure</li><li>Severe vibration</li><li>Rapid performance degradation</li></ul><p><strong>4. Rotor Imbalance and Misalignment</strong></p><p>Mechanical issues that introduce abnormal vibration patterns. Indicators often appear at:</p><ul><li>1X rotational frequency</li><li>2X rotational frequency</li></ul><p><strong>5. Lubrication Problems</strong></p><p>Poor lubrication leads to:</p><ul><li>Increased friction</li><li>Rising temperatures</li><li>Accelerated bearing wear</li></ul><p>The challenge is detecting these conditions early enough to prevent operational disruption.</p><h3>Why Unsupervised Learning?</h3><p>One of the biggest obstacles in industrial AI is the lack of labeled failure data. Unlike image classification problems, equipment failures are rare. A typical compressor may operate for thousands of hours without experiencing a major fault. This creates an unusual machine learning challenge:</p><blockquote>We have abundant normal operating data but very little failure data.</blockquote><p>Because of this, supervised classification is often impractical. Instead, the platform relies primarily on unsupervised and semi-supervised approaches.</p><p>The philosophy is simple:</p><blockquote>Learn what “normal” looks like.</blockquote><p>Flag anything that deviates significantly from that behavior.</p><h3>Building the AI Architecture</h3><p>To improve robustness, the platform combines multiple anomaly detection techniques rather than relying on a single model.</p><p><strong>1. Isolation Forest</strong></p><p>Isolation Forest serves as a lightweight baseline model. The algorithm isolates observations by randomly partitioning feature space. Anomalies tend to be isolated more quickly than normal observations.</p><p>Advantages:</p><ul><li>Fast training</li><li>Fast inference</li><li>Strong baseline performance</li></ul><p><strong>2. Autoencoder</strong></p><p>Autoencoders are neural networks trained to reconstruct normal operating conditions.</p><p>During inference:</p><ul><li>Normal observations reconstruct accurately</li><li>Abnormal observations generate higher reconstruction errors</li></ul><p>The reconstruction error becomes an anomaly score.</p><p>This approach is particularly effective for high-dimensional industrial telemetry.</p><p><strong>3. Variational Autoencoder (VAE)</strong></p><p>A Variational Autoencoder extends the standard Autoencoder by learning a probabilistic latent representation.</p><p>Benefits include:</p><ul><li>Better uncertainty handling</li><li>Probabilistic anomaly scoring</li><li>More stable anomaly boundaries</li></ul><p>This provides richer insights than simple reconstruction error alone.</p><p><strong>4. LSTM Forecasting</strong></p><p>Industrial telemetry is fundamentally time-series data. Many failures develop gradually over hours or days. To capture temporal behavior, the platform includes an LSTM forecasting model. The model predicts future sensor values. Large deviations between predicted and actual values indicate potential anomalies. This enables detection of operational drift and slow degradation patterns.</p><h3>Feature Engineering for Industrial Equipment</h3><p>Raw sensor values rarely provide sufficient context. Several derived features are engineered to improve anomaly detection:</p><p>1. Pressure Ratio</p><p>One of the most important compressor performance indicators.</p><p>2. Rolling Statistics</p><p>Including:</p><ul><li>Rolling mean</li><li>Rolling standard deviation</li><li>Rolling maximum</li><li>Rolling minimum</li></ul><p>These capture evolving operating behavior.</p><p>3. Rate-of-Change Features</p><p>Rapid changes often indicate abnormal conditions.</p><p>4. Vibration Magnitude</p><p>Aggregated vibration indicators provide better failure signatures than individual measurements. These engineered features allow models to learn behavior closer to the underlying physical system.</p><h3>Ensemble-Based Anomaly Detection</h3><p>Each model has strengths and weaknesses. Isolation Forest may detect point anomalies. LSTM models excel at temporal deviations. Autoencoders capture complex nonlinear relationships. To leverage these complementary strengths, the platform combines outputs using ensemble scoring.</p><p>The final anomaly score incorporates:</p><ul><li>Isolation Forest score</li><li>Autoencoder reconstruction error</li><li>VAE probability score</li><li>LSTM prediction deviation</li></ul><p>This approach significantly improves robustness compared to relying on a single model.</p><h3>Dynamic Thresholding</h3><p>Static thresholds are one of the primary limitations of traditional monitoring systems. Instead, this platform uses adaptive thresholds.</p><p>Techniques include:</p><p>1. Rolling Statistical Bands : Based on moving averages and standard deviations.</p><p>2. Percentile-Based Thresholds : Automatically adapt to changing operating conditions.</p><p>3. EWMA Monitoring : Exponentially weighted moving averages emphasize recent behavior.</p><p>As operating conditions evolve, thresholds evolve as well. This dramatically reduces false positives while maintaining sensitivity.</p><h3>Creating a Compressor Health Index</h3><p>Industrial users rarely want to interpret dozens of anomaly scores. They need a simple answer:</p><blockquote>“How healthy is this compressor right now?”</blockquote><p>To solve this, the platform generates a Health Index ranging from 0 to 100.</p><p>The score combines:</p><ul><li>Anomaly severity</li><li>Historical behavior</li><li>Trend information</li><li>Model confidence</li></ul><p>Example:</p><ul><li>95–100 → Excellent</li><li>80–95 → Healthy</li><li>60–80 → Monitor Closely</li><li>Below 60 → Maintenance Recommended</li></ul><p>This allows engineers and managers to quickly prioritize assets.</p><h3>Explainable AI for Industrial Trust</h3><p>One of the biggest barriers to industrial AI adoption is trust. Maintenance teams need to understand why a model generated an alert. The platform incorporates SHAP explainability to identify:</p><ul><li>Which sensors contributed most to an anomaly</li><li>Which variables are driving health degradation</li><li>Why a compressor received a particular risk score</li></ul><p>Instead of a black-box alert, users receive actionable explanations.</p><p>For example:</p><blockquote>“The anomaly score increased primarily due to elevated bearing temperature, increasing vibration magnitude, and declining pressure ratio.”</blockquote><p>This makes AI recommendations easier to validate and operationalize.</p><h3>System Architecture</h3><p>The platform was designed as a production-oriented application rather than a standalone notebook.</p><ol><li>Frontend</li></ol><p>Built using:</p><ul><li>React</li><li>Vite</li><li>TailwindCSS</li><li>Recharts</li><li>Framer Motion</li></ul><p>The dashboard provides:</p><ul><li>Executive KPI views</li><li>Compressor health overview</li><li>Sensor trend analysis</li><li>AI insights</li><li>Maintenance recommendations</li></ul><p>2. Backend</p><p>Built using FastAPI.</p><p>Core services include:</p><ul><li>Anomaly scoring</li><li>Health index calculation</li><li>Explainability services</li><li>Recommendation generation</li></ul><p>3. MLOps Layer</p><p>Model training and lifecycle management are handled through MLflow, providing:</p><ul><li>Experiment tracking</li><li>Model versioning</li><li>Artifact storage</li><li>Reproducibility</li></ul><p>The entire stack is containerized using Docker for simplified deployment.</p><h3>Business Impact</h3><p>Although the project uses synthetic industrial telemetry for demonstration purposes, the potential business value is significant. Organizations implementing predictive maintenance systems often report:</p><p>1. Reduced Downtime : Earlier detection allows planned interventions before failures occur.</p><p>2. Lower Maintenance Cost : Maintenance becomes condition-based rather than schedule-based.</p><p>3. Improved Safety : Hazardous conditions are identified earlier.</p><p>4. Longer Equipment Life : Gradual degradation can be addressed before severe damage occurs.</p><p>5. Better Operational Visibility : Engineers gain a clearer understanding of asset health across an entire fleet.</p><h3>Future Directions</h3><p>Several advanced capabilities could further enhance the platform:</p><p>1. Real-Time Streaming Analytics : Kafka and Flink-based architectures for near real-time monitoring.</p><p>2. Digital Twin Integration : Combining machine learning with first-principles engineering models.</p><p>3. Online Learning : Continuous adaptation as operating conditions evolve.</p><p>4. Reinforcement Learning : Optimizing maintenance decisions and operational strategies.</p><p>5. LLM-Powered Maintenance Assistant : Generating natural-language explanations and maintenance reports for engineers and plant operators.</p><h3>Final Thoughts</h3><p>Industrial facilities generate massive amounts of telemetry data, yet many maintenance decisions still rely heavily on fixed alarm thresholds and periodic inspections. Modern machine learning enables a different approach.</p><p>By combining anomaly detection, explainable AI, adaptive thresholds, and industrial domain knowledge, organizations can move from reactive maintenance toward predictive operations. This project demonstrates how AI can transform compressor monitoring from a simple alarm system into an intelligent decision-support platform capable of detecting degradation early, reducing downtime, improving safety, and extending equipment life.</p><p>While the current implementation uses synthetic data for demonstration, the architecture is designed to reflect the principles and workflows commonly found in real-world industrial predictive maintenance systems.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=efe040fc521a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an AI-Powered Drilling Optimization Platform for Oil & Gas: Predicting ROP, Detecting…]]></title>
            <link>https://medium.com/@axelivandatanjung/building-an-ai-powered-drilling-optimization-platform-for-oil-gas-predicting-rop-detecting-5729dfb670fd?source=rss-6e6a1fce9627------2</link>
            <guid isPermaLink="false">https://medium.com/p/5729dfb670fd</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[oil-and-gas]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Axel Ivanda Tanjung]]></dc:creator>
            <pubDate>Sat, 20 Jun 2026 20:59:25 GMT</pubDate>
            <atom:updated>2026-06-20T20:59:25.428Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building an AI-Powered Drilling Optimization Platform for Oil &amp; Gas: Predicting ROP, Detecting Inefficiency, and Recommending Optimal Drilling Parameters</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pYweGJH8fN-FNYbRUbS03g.png" /></figure><p>Link GitHub : <a href="https://github.com/axeltanjung/drilling-rop-platform">https://github.com/axeltanjung/drilling-rop-platform</a></p><h3>Introduction</h3><p>Drilling a single oil or gas well can cost millions of dollars. Depending on location and complexity, drilling rigs may cost anywhere from $30,000 to more than $1 million per day to operate. In such an environment, even small improvements in drilling performance can generate substantial financial savings.</p><p>One of the most critical drilling KPIs is <strong>Rate of Penetration (ROP)</strong> — a measurement of how quickly a drill bit penetrates underground formations.</p><p>A higher ROP generally means:</p><ul><li>Shorter drilling duration</li><li>Lower rig operating costs</li><li>Reduced fuel consumption</li><li>Fewer drilling-related delays</li><li>Improved overall operational efficiency</li></ul><p>However, maximizing ROP is far from simple.</p><p>Drilling engineers must continuously balance parameters such as Weight on Bit (WOB), rotational speed (RPM), and mud circulation rate while simultaneously avoiding equipment damage, excessive vibration, and costly non-productive time (NPT).</p><p>To address this challenge, I designed and built an <strong>AI-powered Drilling ROP Prediction &amp; Optimization Platform</strong> that combines machine learning, explainable AI, optimization algorithms, and modern web technologies into a single end-to-end system.</p><h3>The Business Problem</h3><p>Traditional drilling optimization relies heavily on engineering experience, offset well analysis, and operational guidelines. While these methods remain valuable, modern drilling operations generate enormous volumes of telemetry data including:</p><ul><li>Weight on Bit (WOB)</li><li>Rotary RPM</li><li>Torque</li><li>Hook Load</li><li>Pump Pressure</li><li>Mud Flow Rate</li><li>Formation Characteristics</li><li>Historical Drilling Performance</li></ul><p>The challenge is that the relationship between these variables and drilling performance is highly non-linear.</p><p>For example:</p><ul><li>Increasing WOB may improve ROP</li><li>Excessive WOB may increase vibration</li><li>Higher RPM may increase penetration rate</li><li>Excessive RPM may accelerate bit wear</li><li>Insufficient mud flow can lead to poor hole cleaning and stuck-pipe incidents</li></ul><p>Because these interactions are complex and formation-dependent, they create an ideal use case for machine learning.</p><h3>Project Goals</h3><p>The platform was designed to answer four key operational questions:</p><p><strong>1. How fast will we drill?</strong> — Predict future Rate of Penetration using historical drilling telemetry.</p><p><strong>2. Are we drilling efficiently?</strong> — Generate a drilling efficiency score based on current operating conditions.</p><p><strong>3. Are we approaching a risky operating zone?</strong></p><p>Detect potential:</p><ul><li>Stick-slip vibration</li><li>Bit damage</li><li>Poor hole cleaning</li><li>Stuck-pipe risk</li></ul><p><strong>4. What parameters should we use?</strong></p><p>Recommend optimal combinations of:</p><ul><li>Weight on Bit</li><li>RPM</li><li>Mud Flow Rate</li></ul><p>to maximize ROP while minimizing operational risk.</p><h3>Understanding Drilling Physics</h3><p>Before building any machine learning model, domain understanding is essential. A drill bit penetrates rock by applying force and rotational energy. Several operational parameters directly influence drilling performance:</p><ol><li><strong>Weight on Bit (WOB)</strong></li></ol><p>The downward force applied to the drill bit. Higher WOB generally increases drilling efficiency until an optimal point is reached.</p><p>Beyond that point:</p><ul><li>Bit damage increases</li><li>Vibrations become more severe</li><li>Mechanical efficiency declines</li></ul><p><strong>2. RPM</strong></p><p>The rotational speed of the drill bit. Higher RPM often increases penetration rates but can also accelerate wear and drilling dysfunction.</p><p><strong>3. Mud Flow Rate</strong></p><p>Drilling fluid serves multiple purposes:</p><ul><li>Hole cleaning</li><li>Cooling the bit</li><li>Pressure control</li><li>Cuttings transport</li></ul><p>Poor hydraulics frequently result in reduced drilling efficiency.</p><p><strong>4. Formation Hardness</strong></p><p>Rock hardness is often the dominant factor affecting achievable ROP. Soft formations drill quickly. Hard formations significantly reduce penetration rates regardless of operating parameters.</p><h3>AI Architecture</h3><p>To capture different patterns within drilling data, I implemented multiple model families.</p><ol><li>LightGBM</li></ol><p>The primary production model.</p><p>Advantages:</p><ul><li>Excellent performance on tabular data</li><li>Fast training</li><li>Fast inference</li><li>Native feature importance analysis</li></ul><p>2. CatBoost</p><p>Used as a benchmark model.</p><p>Advantages:</p><ul><li>Strong handling of categorical features</li><li>Robust default performance</li><li>Reduced preprocessing requirements</li></ul><p>3. Deep Learning Models</p><p>Implemented using MLP and LSTM architectures.</p><p>Advantages:</p><ul><li>Capture complex non-linear relationships</li><li>Learn sequential drilling behavior</li><li>Better utilization of time-series telemetry</li></ul><p>4. Feature Engineering</p><p>Raw telemetry data alone rarely delivers the best predictive performance.</p><p>Several domain-inspired features were engineered, including:</p><ul><li>Mechanical Specific Energy approximations</li><li>WOB × RPM interaction terms</li><li>Torque-to-WOB ratios</li><li>Rolling statistical features</li><li>Drilling trend indicators</li><li>Time-window aggregates</li></ul><p>These features help models learn operational relationships that are closer to real drilling physics.</p><p>5. Explainable AI with SHAP</p><p>One of the biggest barriers to AI adoption in industrial environments is trust. Drilling engineers rarely accept a recommendation without understanding why it was generated. To improve transparency, SHAP explainability was integrated into the platform. For every prediction, the system can identify:</p><ul><li>Which variables increased predicted ROP</li><li>Which variables decreased predicted ROP</li><li>Global feature importance</li><li>Relative contribution of each feature</li></ul><p>This allows engineers to validate model recommendations against operational expertise.</p><p>6. Optimization Engine</p><p>Prediction alone is not enough. Operational teams need actionable recommendations. To address this, the platform includes an optimization engine that searches the parameter space of:</p><ul><li>Weight on Bit</li><li>RPM</li><li>Mud Flow Rate</li></ul><p>The optimizer evaluates thousands of candidate parameter combinations using the trained surrogate model. The objective function balances:</p><ul><li>Maximum predicted ROP</li><li>Vibration penalties</li><li>Bit wear penalties</li><li>Operational constraints</li></ul><p>The output is a recommended operating window rather than a single fixed value, making recommendations more practical for field operations.</p><h3>System Architecture</h3><p>The platform follows a modern enterprise architecture.</p><ol><li>Frontend</li></ol><p>Built with:</p><ul><li>React</li><li>Vite</li><li>TailwindCSS</li><li>Plotly</li><li>Recharts</li></ul><p>The dashboard provides:</p><ul><li>Executive KPIs</li><li>Well-level analytics</li><li>Risk monitoring</li><li>Optimization recommendations</li><li>Explainability views</li></ul><p>2. Backend</p><p>Built with FastAPI.</p><p>Core services include:</p><ul><li>ROP Prediction API</li><li>Risk Scoring API</li><li>Optimization API</li><li>Explainability API</li></ul><p>4. Machine Learning Layer</p><p>Includes:</p><ul><li>LightGBM</li><li>CatBoost</li><li>Deep Learning Models</li><li>MLflow Tracking</li><li>Model Registry</li></ul><p>5. Storage Layer</p><ul><li>SQLite for demonstration</li><li>MLflow artifact storage</li><li>Model version management</li></ul><h3>MLOps Workflow</h3><p>The platform incorporates a complete machine learning lifecycle.</p><ol><li>Data generation and ingestion</li><li>Data preprocessing</li><li>Feature engineering</li><li>Model training</li><li>Hyperparameter optimization</li><li>Experiment tracking with MLflow</li><li>Model registration</li><li>Batch prediction</li><li>Dashboard serving</li></ol><p>This architecture makes the project significantly closer to a production-grade AI system than a standalone notebook experiment.</p><h3>Potential Business Impact</h3><p>Although the demonstration uses synthetic data, the business value can be substantial in real drilling operations.</p><p>Potential benefits include:</p><ol><li>Reduced Drilling Cost : Higher ROP reduces total rig days.</li></ol><p>2. Lower Non-Productive Time : Early identification of inefficient operating zones can reduce costly drilling events.</p><p>3. Improved Bit Life : Optimized drilling parameters reduce unnecessary wear.</p><p>4. Better Operational Consistency : Recommendations become data-driven rather than solely experience-driven.</p><p>5. Faster Engineering Decisions : Real-time predictions support operational teams during drilling campaigns.</p><h3>Future Enhancements</h3><p>Several exciting opportunities remain for future development:</p><ol><li>Reinforcement Learning : Closed-loop drilling optimization capable of continuously adapting to changing formation conditions.</li></ol><p>2. Real-Time Streaming : Integration with WITSML and OPC-UA telemetry streams.</p><p>3. Digital Twin Simulation : Physics-based drilling simulation for scenario testing.</p><p>4. Edge Deployment : Deploy models directly at rig sites for low-latency inference.</p><p>5. AI Drilling Assistant : An LLM-powered assistant capable of explaining drilling behavior and recommending operational actions in natural language.</p><h3>Final Thoughts</h3><p>Oil and gas drilling generates vast amounts of operational data, yet many optimization decisions remain heavily manual.</p><p>By combining machine learning, explainable AI, optimization algorithms, and modern software architecture, it is possible to transform raw drilling telemetry into actionable operational intelligence.</p><p>This project demonstrates how AI can move beyond prediction and become a practical decision-support system that helps drilling teams improve performance, reduce cost, and minimize operational risk.</p><p>While the current implementation uses synthetic data for demonstration purposes, the architecture is designed to be extensible toward real-world drilling environments and enterprise-scale deployment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5729dfb670fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Predictive Maintenance Decision System with Survival Analysis]]></title>
            <link>https://medium.com/@axelivandatanjung/building-a-predictive-maintenance-decision-system-with-survival-analysis-81031700ea76?source=rss-6e6a1fce9627------2</link>
            <guid isPermaLink="false">https://medium.com/p/81031700ea76</guid>
            <category><![CDATA[predictive-maintenance]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[survival-analysis]]></category>
            <dc:creator><![CDATA[Axel Ivanda Tanjung]]></dc:creator>
            <pubDate>Tue, 24 Mar 2026 01:30:09 GMT</pubDate>
            <atom:updated>2026-03-24T02:20:12.903Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>How I Built a Full-Stack App That Predicts Equipment Failure Using Cox Proportional Hazards — and Why It’s More Than Just a Curve</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9KKy7sDZhr2Mnh5886VLNQ.png" /></figure><p><a href="https://drive.google.com/file/d/1C5jjt8wEu-wYQ7nTmY7tV2m2InGzNkcP/view?usp=sharing">https://drive.google.com/file/d/1C5jjt8wEu-wYQ7nTmY7tV2m2InGzNkcP/view?usp=drive_link</a></p><p>If you’ve ever worked in mining, manufacturing, or any heavy-equipment industry, you know the pain: a haul truck breaks down mid-shift, an excavator’s hydraulic system fails without warning, and suddenly you’re looking at $50,000 in unplanned downtime.</p><p>What if you could see it coming?</p><p>Not with a magic crystal ball — but with <strong>survival analysis</strong>, the same statistical framework oncologists use to predict patient outcomes. Except here, the “patients” are Caterpillar 797F haul trucks and Komatsu PC800 excavators.</p><p>In this article, I’ll walk you through how I built a <strong>production-grade Predictive Maintenance web application </strong>that:</p><ul><li>Trains a <strong>Cox Proportional Hazards model</strong> on realistic equipment data</li><li>Estimates <strong>time-to-failure </strong>and <strong>failure probability</strong> for individual assets</li><li>Provides <strong>actionable maintenance recommendations </strong>(not just charts)</li><li>Lets operators run <strong>what-if simulations</strong> to see how changes affect equipment life</li><li>Deploys with Docker in one command</li></ul><h3><strong>Why Survival Analysis (and Not Classification)?</strong></h3><p>Most predictive maintenance tutorials frame the problem as binary classification: ”<strong>Will this machine fail in the next 30 days? Yes/No.</strong>”</p><p>That’s useful, but it throws away critical information. Survival analysis gives you:</p><p>1. A full survival curve — the probability of surviving past any given day<br>2. Censored data handling — equipment that hasn’t failed yet still provides valuable information<br>3. Hazard functions — how the instantaneous risk of failure changes over time<br>4. Time-to-event estimation — not just “will it fail” but “when”</p><p>This is the difference between a warning light and a fuel gauge.</p><h3>The Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*drUcdJekE0XN6aVFMx3TBA.png" /></figure><p>Tech stack:</p><ul><li><strong>Backend</strong>: Python, FastAPI, lifelines, pandas, numpy</li><li><strong>Frontend</strong>: React 18, Tailwind CSS, Recharts, Lucide icons</li><li><strong>Deployment</strong>: Docker + docker-compose</li></ul><h4>Step 1: Generating Realistic Data (The Hard Part)</h4><p>Most survival analysis demos fail here. They generate random data, fit a model, and call it a day. The model “learns” noise, and the survival curves are meaningless.</p><p>I built a hazard-based data generator that encodes real physical relationships:</p><pre>base_hazard = 0.001<br>log_hazard = (<br>     0.0003 * age<br>     + 0.00015 * usage_hours<br>     + 0.8 * load_intensity<br>     - 1.5 * maintenance_score # maintenance REDUCES risk<br>     + 0.02 * temperature<br>     + 0.3 * vibration<br>     + 0.005 * time_since_service<br>     + 0.2 * failure_count<br>)<br>hazard = base_hazard * exp(log_hazard)</pre><p><strong>Why this matters</strong>:</p><ul><li>Older equipment has higher failure risk (age coefficient is positive)</li><li>Heavy usage accelerates wear (usage coefficient is positive)</li><li>Good maintenance *reduces* the hazard (negative coefficient)</li><li>High vibration and temperature are leading indicators of failure</li></ul><p>The dataset also includes censored observations , equipment that was still running at the time of observation. This is critical for survival analysis. Without censoring, you’d systematically underestimate equipment lifetimes.</p><p>Each piece of equipment has a realistic identity drawn from actual mining equipment catalogs: Caterpillar 797F haul trucks, Sandvik DR461i drill rigs, Metso MP2500 crushers — complete with manufacturer, model, serial number, year, and location.</p><h4>Step 2: The Survival Model</h4><p>The Cox Proportional Hazards model is the workhorse here. It assumes that the hazard function for any individual is a baseline hazard multiplied by an exponential function of their features:</p><blockquote><strong>h(t|X) = h₀(t) × exp(β₁X₁ + β₂X₂ + … + βₙXₙ)</strong></blockquote><p>The beauty of Cox PH is that it’s semi-parametric — we don’t need to assume any particular distribution for the baseline hazard. The model learns the relative effect of each feature.</p><pre>from lifelines import CoxPHFitter<br>cox_model = CoxPHFitter(penalizer=0.01)<br>cox_model.fit(<br> train_df,<br> duration_col=&quot;time_to_event&quot;,<br> event_col=&quot;event_observed&quot;<br>)</pre><p>After training, the model gives us:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n68Rn34dda9zNrufgor4aQ.png" /></figure><p><strong>Interpretation</strong>: A unit increase in maintenance score reduces the hazard by 76% (exp(-1.42) = 0.24). A unit increase in vibration increases hazard by 36%.</p><p>We also fit a <strong>Kaplan-Meier estimator</strong> as a population-level baseline — useful for comparing individual equipment against the fleet average.</p><p>Model quality is evaluated using the <strong>Concordance Index (C-index)</strong>, which measures how well the model ranks pairs of observations by their predicted risk.</p><h4>Step 3: From Model to Decisions</h4><p>This is where most projects stop. They show a survival curve and say “look, data science!”</p><p>But a maintenance planner doesn’t need a curve. They need to know: What do I do?</p><p>The recommendation engine translates model output into action:</p><pre>if prob_30_day &gt; 0.5:<br> urgency = &quot;CRITICAL&quot;<br> action = &quot;Immediate maintenance required. Schedule within 7 days.&quot;<br>elif prob_30_day &gt; 0.3:<br> urgency = &quot;HIGH&quot;<br> action = &quot;Schedule maintenance within 14 days.&quot;<br>elif prob_90_day &gt; 0.5:<br> urgency = &quot;MEDIUM&quot;<br> action = &quot;Plan maintenance within 30 days.&quot;</pre><p>The system also calculates an <strong>optimal service day</strong> — the point at which maintenance cost-effectively prevents failure (set at 70% of median survival time).</p><h4>Step 4: The What-If Simulator</h4><p>This is the feature that transforms the app from a reporting tool into a thinking tool.</p><p>The simulation panel lets operators ask questions like:</p><ul><li>“What if we increase maintenance frequency on Excavator EXC-0127?”</li><li>“What if we reduce the load intensity on this haul truck?”</li><li>“How much does cooling the crusher by 10°C extend its life?”</li></ul><p>The API computes two survival curves — baseline and modified — and returns the impact:</p><pre>{<br> &quot;impact&quot;: {<br> &quot;median_change_days&quot;: +47.3,<br> &quot;risk_change_30d&quot;: -0.12,<br> &quot;risk_change_90d&quot;: -0.23<br> }<br>}</pre><p><strong>Translation</strong>: Improving maintenance on this excavator extends its expected life by 47 days and reduces 90-day failure risk by 23 percentage points.</p><p>This turns abstract statistical modeling into concrete budget and scheduling decisions.</p><h4>Step 5: The Dashboard</h4><p>The dashboard is designed for <strong>operational decision-making</strong>, not data exploration. It surfaces:</p><ul><li>Total assets being monitored</li><li>High-risk count — how many need attention right now</li><li>Average remaining useful life (RUL) across the fleet</li><li>Model C-index — so users know how much to trust the predictions</li><li>Risk distribution — pie chart showing CRITICAL/HIGH/MEDIUM/LOW/NORMAL breakdown</li><li>Alert list — the top 10 highest-risk assets with one-click drill-down</li></ul><p>Each asset row shows the equipment’s model (e.g., “CAT 797F”), location (“Pit A — North”), 30-day failure probability, and a recommended action.</p><h4>Performance Optimization</h4><p>The first version was painfully slow — every page load triggered 1000+ survival predictions. The fix: precompute everything at startup.</p><pre>@asynccontextmanager<br>async def lifespan(app: FastAPI):<br> # Generate data and train model<br> dataset, registry = generate_equipment_dataset(500, seed=42)<br> model.fit(dataset)<br># Precompute all summaries ONCE<br> _precompute_all() # Caches dashboard, asset summaries, KM curve<br> yield</pre><p>Startup takes a few extra seconds. Every subsequent request is instant — just serving cached Python dicts.</p><h4>Deployment</h4><p>One command:</p><pre>docker-compose up - build</pre><p>This spins up:<br>- Backend (Python/FastAPI on port 8000)<br>- Frontend (React/Nginx on port 3000, proxying /api to backend)</p><h4>Lessons Learned</h4><ol><li><strong>Data generation is modeling.</strong> If your synthetic data doesn’t encode real relationships, your model is useless. Spend 50% of your time here.</li><li><strong>Censoring is not optional.</strong> Without censored observations, survival models systematically underestimate equipment lifetimes. In practice, most of your data *should* be censored — most machines haven’t failed yet.</li><li><strong>numpy types will haunt you.</strong> FastAPI’s JSON serializer can’t handle `numpy.float64`. Cast everything to native Python types before caching.</li><li><strong>Precompute or die</strong>. Running lifelines predictions on-the-fly for 500 assets per request is unacceptably slow. Compute once, serve from memory.</li><li><strong>Recommendations &gt; Curves.</strong> Decision-makers don’t read survival functions. They need “schedule maintenance in 14 days” with a color-coded urgency badge.</li></ol><h4>What’s Next</h4><ul><li><strong>Cost optimization layer:</strong> compare cost of preventive maintenance vs. unplanned failure</li><li><strong>Time-dependent covariates: </strong>usage patterns change over time, the model should adapt</li><li><strong>Real-time streaming: </strong>connect to IoT sensor feeds instead of static data</li><li><strong>Model comparison:</strong> Cox PH vs. Random Survival Forest vs. DeepSurv</li></ul><h4>Try It Yourself</h4><p>The full source code is available on GitHub:</p><p>predictive-maintenance/<br>├── backend/ # FastAPI + lifelines<br>├── frontend/ # React + Tailwind + Recharts<br>├── docker-compose.yml<br>└── README.md</p><p>Clone it, run `docker-compose up — build`, and open `localhost:3000`.</p><p>Github: <a href="https://github.com/axeltanjung/survival-pred-maintenance">https://github.com/axeltanjung/survival-pred-maintenance</a></p><p>If you found this useful, follow me for more applied ML engineering content. I write about building production systems, not just training models.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81031700ea76" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quantile Regression Explained: Modeling the Full Conditional Distribution]]></title>
            <link>https://medium.com/@axelivandatanjung/quantile-regression-explained-modeling-the-full-conditional-distribution-ed6e50119227?source=rss-6e6a1fce9627------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed6e50119227</guid>
            <category><![CDATA[quantile-regression]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[model-uncertainty]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Axel Ivanda Tanjung]]></dc:creator>
            <pubDate>Mon, 02 Mar 2026 23:05:01 GMT</pubDate>
            <atom:updated>2026-03-02T23:05:01.147Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>1. The Core Problem with Mean Regression</strong></h3><p>Most regression models (Linear Regression, Ridge, Lasso, even many ML models) answer one question:</p><ul><li>What is the expected (mean) value of y∣x?</li></ul><p>Formally:</p><p>`𝐸[𝑦∣𝑥]`</p><p>This is often not what decision-makers actually care about.</p><p>Examples:</p><ul><li>Risk management → worst-case outcomes</li><li>Pricing → upper revenue bounds</li><li>Operations → service-level guarantees</li><li>Finance → Value-at-Risk</li></ul><p>All of these are quantile questions, not mean questions.</p><h3><strong>2. What Is Quantile Regression?</strong></h3><p>Quantile Regression (QR) estimates conditional quantiles of the response variable:</p><p>𝑄𝜏(𝑦∣𝑥)</p><p>Where:</p><ul><li>τ∈(0,1) is the quantile level</li><li>τ=0.5 → median</li><li>τ=0.9 → 90th percentile</li><li>τ=0.1 → 10th percentile</li></ul><p>Instead of modeling the center of the distribution, QR models its shape.</p><h3><strong>3. Why Mean Regression Fails in Asymmetric Data</strong></h3><p>Mean regression implicitly assumes:</p><ul><li>Symmetric errors</li><li>Homoscedasticity (constant variance)</li><li>Squared-error loss is appropriate</li></ul><p>But real-world data often has:</p><ul><li>Skewness</li><li>Heavy tails</li><li>Heteroskedasticity</li></ul><p>Quantile Regression does not require these assumptions.</p><h3><strong>4. How Quantile Regression Works (Key Insight)</strong></h3><p>Quantile Regression replaces squared loss with asymmetric absolute loss, known as the pinball loss.</p><p><strong>Pinball (Quantile) Loss</strong></p><p>For residual 𝑢=𝑦−𝑦:</p><p>𝜌𝜏(𝑢) =</p><p>𝜏𝑢, 𝑢 ≥ 0</p><p>(𝜏−1)𝑢, 𝑢 &lt; 0</p><p>Interpretation:</p><ul><li>Over-prediction and under-prediction are penalized unequally</li><li>The asymmetry forces predictions toward the desired quantile</li></ul><p>Special case:</p><ul><li>𝜏 = 0.5 → median regression → absolute loss</li></ul><h3><strong>5. Quantile Regression Optimization Problem</strong></h3><p>For linear quantile regression:</p><p>Compare:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*BweAyfOTgRL_Qtt37WMC7w.png" /></figure><p>This is solved via linear programming, not closed-form equations.</p><h3><strong>6. Interpreting Quantile Regression Coefficients (Subtle but Critical)</strong></h3><p>In mean regression:</p><p>“A one-unit increase in x increases the expected 𝑦 by 𝛽.”</p><p>In quantile regression:</p><p>“A one-unit increase in x shifts the τ-th quantile of 𝑦 by 𝛽𝜏.”</p><p>That means:</p><ul><li>Coefficients vary across quantiles</li><li>Effect sizes can differ between low-risk and high-risk regimes</li></ul><p>This is not noise — it’s structural information.</p><h3><strong>7. Quantile Regression vs Distributional Models</strong></h3><p>Quantile Regression:</p><ul><li>Models quantiles directly</li><li>No full distribution assumption</li><li>Robust to outliers</li></ul><p>Distributional models (e.g., Gaussian, Gamma):</p><ul><li>Assume a parametric distribution</li><li>Often wrong in practice</li><li>More efficient if assumptions hold</li></ul><p>Trade-off:</p><p>QR is robust but less statistically efficient under perfect assumptions.</p><h3><strong>8. Visual Interpretation (Why QR Is Powerful)</strong></h3><p>When you plot multiple quantiles (e.g., 0.1, 0.5, 0.9), you get:</p><ul><li>A fan chart</li><li>Direct visualization of uncertainty</li><li>Detection of heteroskedasticity without modeling variance explicitly</li></ul><p>This is something mean regression simply cannot show.</p><h3><strong>9. Strengths and Weaknesses</strong></h3><p>Strengths</p><ul><li>Robust to outliers</li><li>Captures distributional asymmetry</li><li>Works under heteroskedasticity</li><li>Directly answers risk questions</li></ul><p>Weaknesses</p><ul><li>No closed-form solution</li><li>Harder to interpret for non-technical stakeholders</li><li>Independent quantiles may cross (quantile crossing problem)</li><li>Less efficient if Gaussian assumptions truly hold</li></ul><h3><strong>10. When Should You Use Quantile Regression?</strong></h3><p>Use it when:</p><ul><li>You care about tails, not averages</li><li>Risk or service guarantees matter</li><li>Data is skewed or heavy-tailed</li><li>Variance depends on features</li></ul><p>Avoid it when:</p><ul><li>Mean prediction is the sole objective</li><li>Distribution is well-known and symmetric</li><li>You need extremely fast large-scale inference</li></ul><h3><strong>11. Linear Quantile Regression (statsmodels)</strong></h3><pre>import numpy as np<br>import statsmodels.api as sm<br>import matplotlib.pyplot as plt<br><br>## Generate Toy Data (Heteroskedastic by Design)<br>rng = np.random.default_rng(42)<br><br>n = 200<br>X = rng.uniform(0, 10, size=n)<br>noise = rng.normal(0, 0.5 + 0.3 * X, size=n)  # heteroskedastic noise<br>y = 2 + 1.5 * X + noise<br><br>## Prepare Design Matrix<br>X_design = sm.add_constant(X)  # adds intercept<br><br>## Fit Quantile Regression Models<br>quantiles = [0.1, 0.5, 0.9]<br>models = {}<br><br>for q in quantiles:<br>    mod = sm.QuantReg(y, X_design)<br>    res = mod.fit(q=q)<br>    models[q] = res<br><br>## Inspect Coefficients<br>for q, res in models.items():<br>    print(f&quot;Quantile {q}&quot;)<br>    print(res.params)<br>    print()<br><br>## Each quantile has different coefficients → this is the signal, not noise.<br><br>## Predict and Plot<br><br>X_grid = np.linspace(X.min(), X.max(), 200)<br>X_grid_design = sm.add_constant(X_grid)<br><br>plt.figure(figsize=(8, 4))<br>plt.scatter(X, y, alpha=0.4, label=&quot;Data&quot;)<br><br>for q, res in models.items():<br>    y_pred = res.predict(X_grid_design)<br>    plt.plot(X_grid, y_pred, label=f&quot;Quantile {q}&quot;)<br><br>plt.legend()<br>plt.tight_layout()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*Ox_6RvZWRtAE1obUlvcBeA.png" /></figure><h3><strong>12. Non-Linear Quantile Regression (Gradient Boosting)</strong></h3><pre>from sklearn.ensemble import GradientBoostingRegressor<br><br>## Fit Quantile Gradient Boosting<br>gb_models = {}<br><br>for q in [0.1, 0.5, 0.9]:<br>    gb = GradientBoostingRegressor(<br>        loss=&quot;quantile&quot;,<br>        alpha=q,<br>        n_estimators=200,<br>        max_depth=3,<br>        learning_rate=0.05,<br>        random_state=42<br>    )<br>    gb.fit(X.reshape(-1, 1), y)<br>    gb_models[q] = gb<br><br>## Predict and Plot<br>plt.figure(figsize=(8, 4))<br>plt.scatter(X, y, alpha=0.4)<br><br>for q, model in gb_models.items():<br>    y_pred = model.predict(X_grid.reshape(-1, 1))<br>    plt.plot(X_grid, y_pred, label=f&quot;Quantile {q}&quot;)<br><br>plt.legend()<br>plt.tight_layout()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*BxYLFSiU0cxhh8y4Au56SQ.png" /></figure><h3><strong>13. Critical Pitfalls (Most Tutorials Ignore These)</strong></h3><p><strong>Quantile Crossing</strong></p><pre># Independent estimation can cause:<br># Detection check:<br>y_q10 = gb_models[0.1].predict(X_grid.reshape(-1, 1))<br>y_q50 = gb_models[0.5].predict(X_grid.reshape(-1, 1))<br>y_q90 = gb_models[0.9].predict(X_grid.reshape(-1, 1))<br><br>print(&quot;Crossing exists:&quot;, np.any(y_q10 &gt; y_q50) or np.any(y_q50 &gt; y_q90))</pre><p><strong>Interpreting coefficients like mean regression</strong></p><p>Wrong:</p><p>“Feature X increases Y by β”</p><p>Correct:</p><p>“Feature X shifts the τ-th conditional quantile of Y by β”</p><p><strong>Expecting probabilistic calibration</strong></p><p>Quantile regression:</p><ul><li>Gives conditional quantiles</li><li>Does not give full predictive distributions</li></ul><p><strong>When to Use Which Implementation</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*fZqzR24oXr7tj3WZQHPa3Q.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed6e50119227" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Gaussian Processes Explained: A Probabilistic View of Functions]]></title>
            <link>https://medium.com/@axelivandatanjung/gaussian-processes-explained-a-probabilistic-view-of-functions-b541082cb1fa?source=rss-6e6a1fce9627------2</link>
            <guid isPermaLink="false">https://medium.com/p/b541082cb1fa</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[gaussian-process]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[uncertainty]]></category>
            <dc:creator><![CDATA[Axel Ivanda Tanjung]]></dc:creator>
            <pubDate>Sun, 15 Feb 2026 01:19:56 GMT</pubDate>
            <atom:updated>2026-02-17T06:33:17.603Z</atom:updated>
            <content:encoded><![CDATA[<p>A Gaussian Process (GP) is a probability distribution over functions, where any finite set of function values follows a multivariate Gaussian distribution.</p><p>This single sentence already tells you how GPs differ from most ML models:</p><p>- Linear regression → distribution over parameters</p><p>- Neural networks → deterministic function (unless Bayesian)</p><p>- <strong>Gaussian Process → distribution over functions</strong></p><p>That distinction drives everything else.</p><h3><strong>Why Do We Need a Distribution Over Functions?</strong></h3><p>In many real problems:</p><ul><li>Data is sparse</li><li>Noise is high</li><li>Uncertainty matters more than point predictions</li></ul><p>GPs answer:</p><blockquote>“Given limited data, what functions are plausible, and how uncertain am I?”</blockquote><p>This makes GPs especially strong for:</p><ul><li>Scientific modeling</li><li>Bayesian optimization</li><li>Active learning</li><li>Small-to-medium datasets</li></ul><p>But this same strength creates computational limits (we’ll get there).</p><h3><strong>The Mathematical Definition (Minimal but Precise)</strong></h3><p>A Gaussian Process is defined as:</p><p><strong>f(x)∼GP(m(x),k(x,x’))</strong></p><p>Where:</p><ul><li>m(x) = mean function (often assumed 0)</li><li>k(x,x’) = covariance (kernel) function</li></ul><p>Key insight:</p><ul><li>The kernel is the model.</li></ul><p>Everything you believe about smoothness, periodicity, or similarity is encoded there</p><h3><strong>Intuition: How a GP “Thinks”</strong></h3><p>Think of a GP as doing three things:</p><p><strong>Step 1: Prior over Functions</strong></p><p>Before seeing data, the GP assumes:</p><ul><li>Nearby inputs should produce similar outputs (depending on kernel)</li><li>Functions are smooth / periodic / rough (again, kernel-dependent)</li></ul><p>This is not learned from data — it’s an assumption.</p><p><strong>Step 2: Observe Data</strong></p><p>Given training data:</p><p>(X,y)</p><p>The GP conditions the prior on observed points.</p><p><strong>Step 3: Posterior over Functions</strong></p><p>After conditioning:</p><ul><li>Mean becomes the best prediction</li><li>Variance tells you how uncertain you are</li></ul><p>Crucially:</p><ul><li>Uncertainty increases away from data — unlike most neural nets.</li></ul><h3><strong>Common kernels</strong></h3><p><strong>1. RBF (Squared Exponential)</strong></p><p>Assumes:</p><ul><li>Infinite smoothness</li><li>Very strong inductive bias</li></ul><p>Great for interpolation, terrible for extrapolation.</p><p><strong>2. Matérn</strong></p><p>Controls smoothness explicitly.</p><p>Often more realistic for physical systems.</p><p><strong>3. Periodic Kernel</strong></p><p>Encodes repeating structure (seasonality, cycles).</p><p>- Critical insight:</p><p>Choosing the wrong kernel is equivalent to choosing the wrong model.</p><p>GPs don’t “discover” structure unless the kernel allows it.</p><h3><strong>Prediction: What Comes Out?</strong></h3><p>For a new input 𝑥 , GP returns:</p><ul><li>Mean → prediction</li><li>Variance → uncertainty</li></ul><p>This uncertainty is:</p><ul><li>Data-dependent</li><li>Calibrated (in theory)</li><li>Extremely valuable for decision-making</li></ul><p>This is why GPs dominate Bayesian Optimization.</p><h3><strong>Computational Reality (The Hidden Cost)</strong></h3><p>GP training involves inverting n × n covariance matrix:</p><ul><li>Time complexity: O(n³)</li><li>Memory: O(n²)</li></ul><p>This is not a detail — it’s the main limitation.</p><p>Practical Consequences</p><ul><li>n ≲ 10,000 → already painful</li><li>n ≳ 50,000 → infeasible without approximations</li></ul><p>This is why:</p><ul><li>Sparse GPs</li><li>Inducing points</li><li>Variational GPs</li></ul><p>exist at all.</p><h3><strong>Strengths vs Trade-offs</strong></h3><p>Strengths</p><ul><li>Strong uncertainty estimates</li><li>Excellent with small data</li><li>Interpretable assumptions</li><li>Bayesian by construction</li></ul><p>Weaknesses</p><ul><li>Poor scalability</li><li>Kernel engineering required</li><li>Weak extrapolation</li><li>High-dimensional inputs are hard</li></ul><p>A GP is not “better” than deep learning — it solves a different class of problems.</p><h3><strong>When Should You Use a Gaussian Process?</strong></h3><p>Use GPs when:</p><ul><li>Data is limited</li><li>You need uncertainty</li><li>Decisions are expensive</li><li>Interpretability matters</li></ul><p>Avoid GPs when:</p><ul><li>Millions of samples</li><li>High-dimensional raw inputs (images, text)</li><li>You need fast inference at scale</li></ul><h3><strong>Gaussian Process Regression — scikit-learn</strong></h3><pre>import numpy as np<br>import matplotlib.pyplot as plt<br><br>from sklearn.gaussian_process import GaussianProcessRegressor<br>from sklearn.gaussian_process.kernels import RBF, WhiteKernel<br><br>### Generate Toy Data<br>rng = np.random.default_rng(42)<br><br>X = np.linspace(0, 10, 20).reshape(-1, 1)<br>y = np.sin(X).ravel() + rng.normal(0, 0.1, size=len(X))<br><br>### Define Kernel (This is the Model)<br>kernel = (<br>    1.0 * RBF(length_scale=1.0, length_scale_bounds=(1e-2, 1e2))<br>    + WhiteKernel(noise_level=0.1, noise_level_bounds=(1e-5, 1e1))<br>)<br><br>### Fit Gaussian Process<br>gp = GaussianProcessRegressor(<br>    kernel=kernel,<br>    optimizer=&quot;fmin_l_bfgs_b&quot;,<br>    n_restarts_optimizer=5,<br>    normalize_y=True<br>)<br><br>gp.fit(X, y)<br><br>### Predict with Uncertainty<br>X_test = np.linspace(0, 10, 200).reshape(-1, 1)<br><br>y_mean, y_std = gp.predict(X_test, return_std=True)<br><br>### Plot Results<br>plt.figure(figsize=(8, 4))<br>plt.scatter(X, y, color=&quot;black&quot;, label=&quot;Observations&quot;)<br>plt.plot(X_test, y_mean, label=&quot;GP mean&quot;)<br>plt.fill_between(<br>    X_test.ravel(),<br>    y_mean - 2 * y_std,<br>    y_mean + 2 * y_std,<br>    alpha=0.3,<br>    label=&quot;95% confidence&quot;<br>)<br>plt.legend()<br>plt.tight_layout()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*9lMFki0nDBvJdLGnhUFdCw.png" /></figure><h3><strong>Gaussian Process Regression — Pure NumPy</strong></h3><pre>### Kernel Function<br>def rbf_kernel(X1, X2, length_scale=1.0, variance=1.0):<br>    sqdist = (<br>        np.sum(X1**2, axis=1).reshape(-1, 1)<br>        + np.sum(X2**2, axis=1)<br>        - 2 * X1 @ X2.T<br>    )<br>    return variance * np.exp(-0.5 / length_scale**2 * sqdist)<br><br>### GP Prediction using Custom Kernel<br>def gp_predict(X_train, y_train, X_test, noise=1e-6):<br>    K = rbf_kernel(X_train, X_train)<br>    K += noise * np.eye(len(X_train))  # numerical stability<br><br>    K_s = rbf_kernel(X_train, X_test)<br>    K_ss = rbf_kernel(X_test, X_test)<br><br>    # Cholesky decomposition (never invert directly)<br>    L = np.linalg.cholesky(K)<br><br>    # Solve for alpha<br>    alpha = np.linalg.solve(L.T, np.linalg.solve(L, y_train))<br><br>    # Posterior mean<br>    mu = K_s.T @ alpha<br><br>    # Posterior covariance<br>    v = np.linalg.solve(L, K_s)<br>    cov = K_ss - v.T @ v<br><br>    return mu, np.diag(cov)<br><br>### Run Prediction<br>mu, var = gp_predict(X, y, X_test, noise=1e-4)<br>std = np.sqrt(var)<br><br>plt.figure(figsize=(8, 4))<br>plt.scatter(X, y, color=&quot;black&quot;)<br>plt.plot(X_test, mu)<br>plt.fill_between(<br>    X_test.ravel(),<br>    mu - 2 * std,<br>    mu + 2 * std,<br>    alpha=0.3<br>)<br>plt.tight_layout()<br>plt.show()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*chEB4oQjvnJvfGpEvl32wA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b541082cb1fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Distribution-Free Uncertainty Estimation with Conformal Prediction]]></title>
            <link>https://medium.com/@axelivandatanjung/distribution-free-uncertainty-estimation-with-conformal-prediction-4fd8525ddc43?source=rss-6e6a1fce9627------2</link>
            <guid isPermaLink="false">https://medium.com/p/4fd8525ddc43</guid>
            <category><![CDATA[forecasting]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[uncertainty]]></category>
            <dc:creator><![CDATA[Axel Ivanda Tanjung]]></dc:creator>
            <pubDate>Thu, 05 Feb 2026 23:56:05 GMT</pubDate>
            <atom:updated>2026-02-06T17:40:55.862Z</atom:updated>
            <content:encoded><![CDATA[<p>Conformal Prediction (CP) is a framework that wraps around any predictive model and converts its point predictions into prediction sets (or intervals for regression) that contain the true label or value with a user-chosen probability (e.g. 90% or 95%).</p><p>The key appeal of conformal prediction is that it provides finite-sample, distribution-free coverage guarantees under very weak assumptions — primarily that the data are exchangeable.</p><p>Conformal prediction is not a predictive model itself, but a calibration layer applied on top of an existing model such as linear regression, random forests, gradient boosting, or neural networks.</p><h4><strong>Core Idea and Goal</strong></h4><p>The main goal of conformal prediction is to answer:</p><blockquote><em>How uncertain should I be about this prediction, given how wrong my model has been in the past?”</em></blockquote><p>Instead of outputting a single prediction, conformal prediction outputs a set of plausible labels such that, in repeated sampling, the true label lies inside the set with probability at least 1 — epsilon.</p><p>This guarantee:</p><ul><li>Holds in finite samples</li><li>Does not depend on the correctness of the model</li><li>Does not assume any parametric form of the noise</li></ul><h4><strong>Key Assumption: Exchangeability</strong></h4><p>Conformal prediction relies on <strong>exchangeability</strong> of the data:</p><blockquote>The joint distribution of the data does not change under permutations of the sample order.</blockquote><p>Exchangeability is slightly weaker than i.i.d., but it still excludes:</p><ul><li>Strong time dependence</li><li>Severe non-stationarity</li><li>Uncorrected distribution shift</li></ul><p>Violations of exchangeability are the most common reason conformal methods fail in practice.</p><h3><strong>Full (Transductive) Conformal Prediction</strong></h3><p><strong>High-Level Intuition</strong></p><p>For a new input (x_{n+1}), conformal prediction:</p><ol><li>Tries each possible label y</li><li>Measures how “strange” the pair (x_{n+1}, y) looks compared to past data</li><li>Keeps only labels that are not unusually strange</li></ol><h3><strong>Step-by-Step Algorithm</strong></h3><p><strong>1. Choose a nonconformity measure</strong></p><p>A nonconformity score maps a labeled example (x_i, y_i) to a real number measuring how unusual it is.</p><p>Examples:</p><ul><li>Regression:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/395/1*8j8mDHeIRhRkUYmEzShzow.png" /></figure><p>- Classification:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*pwOcDr9R_Re3n37jY9_LWA.png" /></figure><p><strong>2. Augment data with a candidate label</strong></p><p>For a new input (x_{n+1}), consider a candidate label y.</p><p>Temporarily add (x_{n+1}, y) to the dataset.</p><p><strong>3. Refit (if using full conformal) and compute scores</strong></p><p>Train or refit the underlying model on all (n+1) points and compute nonconformity scores:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*Mmmftffqk5kWnsUNlb6eOg.png" /></figure><p>Let (alpha_{n+1} be the score of the candidate example.</p><p><strong>4. Compute the conformal p-value</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yLGa0lCZOj41oUz45UBzqg.png" /></figure><p>Under exchangeability, these p-values are uniformly (or conservatively) distributed.</p><p><strong>5. Form the prediction set</strong></p><p>For a target error rate epsilon:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*I1CFzRMZvshhxHYTOQx3xA.png" /></figure><p>This set contains the true label with probability at least (1 — epsilon).</p><p><strong>Practical Limitation</strong></p><p>Full conformal prediction requires retraining or reevaluating the model for each candidate label, which is computationally expensive for modern models.</p><h3><strong>Split Conformal Prediction (Practical Variant)</strong></h3><p>Split conformal prediction avoids repeated retraining and is the most widely used version in practice.</p><p><strong>Algorithm</strong></p><p>1. Split data into:</p><ul><li>Training set</li><li>Calibration set</li></ul><p>2. Train the base model on the training set only.</p><p>3. Compute nonconformity scores on the calibration set:</p><ul><li>Regression: residuals</li><li>Classification: misclassification or probability-based scores</li></ul><p>4. Compute a quantile of calibration scores:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*N8iNk2pGekN6gdRGQ96MYg.png" /></figure><p>5. Predict for new data:</p><ul><li>Regression interval:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/491/1*iXxAaEVSYVzy7lVVGOA4dA.png" /></figure><ul><li>Classification set:</li></ul><p>include all labels whose scores are below the threshold</p><h4><strong>Why Split Conformal Works</strong></h4><p>Even without retraining, the calibration residuals remain exchangeable with future residuals, preserving finite-sample coverage guarantees.</p><p><strong>What the Guarantees Mean</strong></p><p>The main guarantee is<strong> </strong>marginal coverage<strong>:</strong></p><blockquote>Over repeated draws of the entire dataset (training, calibration, and test point), the prediction set contains the true label with probability at least (1 — epsilon).</blockquote><p>Important clarifications:</p><ul><li>Coverage is <strong>not conditional on a specific x</strong></li><li>Some subpopulations may be over- or under-covered</li><li>Guarantees are frequentist, not Bayesian</li></ul><p><strong>Online and Streaming Conformal Prediction</strong></p><p>Conformal prediction can be adapted to streaming settings:</p><ul><li>Produces approximately independent error indicators</li><li>Enables real-time monitoring of coverage</li><li>Useful for detecting concept drift and distribution shift</li></ul><h4><strong>Pros</strong></h4><p><strong>Distribution-free, finite-sample guarantees</strong></p><p>Valid coverage without assumptions on:</p><ul><li>Noise distribution</li><li>Linearity</li><li>Model correctness</li></ul><p>Only exchangeability is required.</p><p><strong>Model-agnostic</strong></p><p>Works with any predictor:</p><ul><li>Linear models</li><li>Tree-based models</li><li>Neural networks</li><li>Black-box systems</li></ul><p><strong>Simple and scalable (split conformal)</strong></p><p>Requires only:</p><ul><li>A train–calibration split</li><li>Computing empirical quantiles</li></ul><p>Easy to integrate into existing pipelines.</p><p><strong>Finite-sample validity</strong></p><p>Guarantees hold at <strong>any sample size</strong>not just asymptotically.</p><p><strong>Useful for monitoring and diagnostics</strong></p><p>Nonconformity scores and p-values can flag:</p><ul><li>Outliers</li><li>Distribution shifts</li><li>Concept drift</li></ul><h4><strong>Cons</strong></h4><p><strong>High computational cost (full conformal)</strong></p><p>Full conformal prediction is often infeasible for:</p><ul><li>Large datasets</li><li>Deep or complex models</li></ul><p><strong>Marginal, not conditional, coverage</strong></p><p>Standard conformal methods:</p><ul><li>Guarantee coverage on average</li><li>Do <strong>not</strong> ensure equal coverage across subgroups or feature regions</li></ul><p><strong>Large prediction sets when the model is weak</strong></p><p>If the base model performs poorly:</p><ul><li>Prediction intervals become wide</li><li>Classification sets include many labels</li></ul><p>This is statistically valid but may be operationally unhelpful.</p><p><strong>Exchangeability violations in real data</strong></p><p>Time series, non-stationarity, and regime changes can break assumptions unless:</p><ul><li>Adaptive conformal</li><li>Online conformal</li><li>Covariate-conditional variants are used</li></ul><p><strong>Design choices affect efficiency</strong></p><p>Choices of:</p><ul><li>Nonconformity score</li><li>Data splitting strategy</li><li>Calibration window size</li></ul><p>directly impact the tightness and usefulness of prediction sets.</p><h4><strong>Split Conformal Prediction</strong></h4><p><strong>Overview</strong></p><p>Split Conformal Prediction is a practical and scalable variant of conformal prediction.</p><p>It transforms point predictions from any base model into prediction sets or intervals with finite-sample coverage guarantees.</p><p>Given a user-chosen miscoverage level alpha (e.g. alpha = 0.1) for 90% coverage), split conformal prediction guarantees at least (1 — alpha) marginal coverage in finite samples, under the assumption of exchangeability, conditional on the training set.</p><p><strong>Intuition</strong></p><blockquote><em>Use a held-out calibration set to measure how wrong the model tends to be, and then inflate future predictions just enough to guarantee coverage.</em></blockquote><p>Split conformal avoids repeated retraining by separating model fitting and uncertainty calibration.</p><p>General Algorithm</p><p>Split conformal prediction applies to any base model and works for both regression and classification.</p><p><strong>Step 1: Split the data</strong></p><p>Divide the dataset into two disjoint parts:</p><p>- <strong>Proper training set</strong> (D_1), size (n_1)</p><p>- <strong>Calibration set</strong> (D_2), size (n_2)</p><p>A common choice is a 50/50 split, though larger calibration sets improve the stability of the coverage.</p><p><strong>Step 2: Train the base model</strong></p><p>Train the predictor f_{n1} using only the training set (D_1):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/446/1*cPWPpr3O_s1jLDXdO_Id4Q.png" /></figure><p>The calibration data must not be used for training.</p><p><strong>Step 3: Compute calibration nonconformity scores</strong></p><p>For each calibration example (X_i, Y_i) in D_2, compute a <strong>nonconformity score</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*iT9YKAe9wMYJ7lgYgy2fUg.png" /></figure><p>where V is <strong>negatively oriented</strong> (smaller values indicate better conformity).</p><p><strong>Common choices:</strong></p><p>- Regression:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*FQ2p2lc9a6tk_1xCdOAYjg.png" /></figure><p>- Classification:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*-5qF8MwJ2-SENvxfPXo7lg.png" /></figure><p><strong>Step 4: Compute the conformal quantile</strong></p><p>Let R_1, R_n_2 be the calibration scores.</p><p>Define the conformal threshold:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XA7RtxD8rF6eejrPZ65w5Q.png" /></figure><p>This quantile choice ensures finite-sample coverage.</p><p><strong>Step 5: Predict for a new input</strong></p><p>For a new input x, define the conformal prediction set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*x-9GPcNuumjD-UTVZbYd6A.png" /></figure><p>This set contains the true label with probability at least (1 — alpha).</p><p><strong>Regression Case</strong></p><p>For regression, using absolute residuals as the nonconformity score:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*seXB8DmQIZFTGuJ4_CPYMg.png" /></figure><p>the conformal prediction set becomes an <strong>interval</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*5ORIgByFZgTYTU6XNhNBsQ.png" /></figure><p><strong>Coverage Guarantee</strong></p><p>Under exchangeability, split conformal prediction satisfies:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*9w1FczvJ5_bQ3IrEXg58wQ.png" /></figure><p>Key points:</p><ul><li>The guarantee is finite-sample, not asymptotic</li><li>Coverage is marginal, not conditional on a specific x</li><li>Valid conditional on the trained model</li></ul><h3><strong>Practical Notes</strong></h3><ul><li>Larger calibration sets → more stable quantiles</li><li>Weak base models → wider prediction intervals</li><li>Exchangeability violations (e.g. time series, drift) require adaptive or online variants</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fd8525ddc43" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Linear Regression in Machine Learning]]></title>
            <link>https://medium.com/@axelivandatanjung/understanding-linear-regression-in-machine-learning-284c436c6e0f?source=rss-6e6a1fce9627------2</link>
            <guid isPermaLink="false">https://medium.com/p/284c436c6e0f</guid>
            <category><![CDATA[gradient-descent]]></category>
            <category><![CDATA[linear-regression]]></category>
            <dc:creator><![CDATA[Axel Ivanda Tanjung]]></dc:creator>
            <pubDate>Wed, 17 Sep 2025 07:38:38 GMT</pubDate>
            <atom:updated>2025-09-17T07:38:38.007Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LyK4BnfFhTLWdaD1TX4-Kw.png" /></figure><p>Linear regression is one of the most fundamental yet essential models in machine learning. It is used to model the relationship between input variables (independent variables) and an output variable (dependent variable) through a straight line. This article will cover the basics, objectives, and optimization methods used in linear regression.</p><h3>1. What Is a Linear Model?</h3><p>A linear model represents the relationship between input and output in the form of a straight-line equation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0UalYgkMg66A6PkSo5HJRQ.png" /></figure><ul><li><strong>x</strong> = input (e.g., marketing cost)</li><li><strong>y</strong> = output or target (e.g., sales)</li><li><strong>w</strong> = slope/regression coefficient</li><li><strong>b</strong> = intercept</li></ul><p>If the data forms a straight line, the relationship is called <strong>linear</strong>. If it curves, the relationship is <strong>non-linear</strong>.</p><p><strong>Example:</strong> Predicting monthly sales based on marketing budget. With historical data, we can build a linear model to estimate sales at different budget levels.</p><h3>2. Error in Linear Regression</h3><p>A linear model will never be perfectly accurate. There will always be an error (difference) between predicted and actual values:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BS8hq-VZrkoaszy5tOsaqg.png" /></figure><p>If errors are simply added up, positive and negative errors may cancel each other out. To solve this, errors are usually squared, leading to the <strong>Residual Sum of Squares (RSS):</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sr-OXSjuqEm7rZ569W2HOA.png" /></figure><p>RSS measures how far the predictions deviate from the actual data. A good model has the smallest possible RSS.</p><h3>3. Finding the Best Parameters (w and b)</h3><p>Since <strong>x</strong> (input) and <strong>y</strong> (output) are fixed, the only values we can adjust are the parameters <strong>w</strong> and <strong>b</strong>. The goal of linear regression is to find the combination of <strong>w</strong> and <strong>b</strong> that minimizes RSS.</p><p>Two common approaches:</p><ol><li><strong>Ordinary Least Squares (OLS):</strong></li></ol><ul><li>Computes a direct solution using calculus.</li><li>Takes the derivative of RSS with respect to the parameters and sets it to zero to find the minimum.</li><li>Efficient for small to medium datasets.</li></ul><p><strong>2. Gradient Descent:</strong></p><ul><li>An iterative optimization method.</li><li>Starts from an initial guess, then updates parameters step by step in the direction that reduces error.</li><li>Suitable for large datasets where OLS can be computationally expensive (due to large matrix operations).</li></ul><h3>4. Intuition Behind Gradient Descent</h3><p>Imagine walking down a mountain:</p><ul><li>If the slope (gradient) is positive → move left.</li><li>If the slope is negative → move right.</li><li>If the gradient is zero → you’ve reached the minimum point.</li></ul><p>This process repeats until the model finds the optimal parameters that minimize the error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*yeYR7htssqoYM-NtsiI7qA.png" /></figure><h3>5. Model Interpretation</h3><p>Once the best parameters are found:</p><ul><li><strong>Intercept (b):</strong> the predicted value when input = 0.</li><li><strong>Slope (w):</strong> the change in output for every 1-unit increase in input.</li></ul><p><strong>Example regression equation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pXrOBJf4dPXlgO7ZpGtBmw.png" /></figure><p>Interpretation:</p><ul><li>When the budget = 0, sales are predicted to be 5.</li><li>For every additional 1 unit in marketing budget, sales increase by 1.2.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UaoLzAb02c10bWlVAgwglA.png" /></figure><h3>Conclusion</h3><p>Linear regression is a foundational concept in machine learning:</p><ul><li><strong>Goal:</strong> find the best-fitting line that minimizes error.</li><li><strong>Error measurement:</strong> Residual Sum of Squares (RSS).</li><li><strong>Optimization methods:</strong> Ordinary Least Squares (OLS) or Gradient Descent.</li></ul><p>Despite its simplicity, linear regression is extremely useful and forms the basis for more advanced models. A solid understanding of this concept will make learning other machine learning algorithms much easier.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=284c436c6e0f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Evaluating Machine Learning Model Performance: From Regression to Classification]]></title>
            <link>https://medium.com/@axelivandatanjung/evaluating-machine-learning-model-performance-from-regression-to-classification-61462b890b9e?source=rss-6e6a1fce9627------2</link>
            <guid isPermaLink="false">https://medium.com/p/61462b890b9e</guid>
            <category><![CDATA[linear-regression]]></category>
            <dc:creator><![CDATA[Axel Ivanda Tanjung]]></dc:creator>
            <pubDate>Wed, 17 Sep 2025 07:11:57 GMT</pubDate>
            <atom:updated>2025-09-17T07:11:57.635Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DKxgmqYbIAXCJ7saROWfRw.png" /></figure><p>When building a Machine Learning model, the goal isn’t just to make an algorithm that fits the data. More importantly, we want a model that can <strong>generalize well</strong> — making accurate predictions on unseen data. That’s why evaluating model performance is essential.</p><p>This article will walk you through the fundamentals of model evaluation, covering both <strong>regression</strong> and <strong>classification</strong>, along with the most common metrics used in practice.</p><h3>Why Model Evaluation Matters</h3><p>A model is considered <strong>good</strong> not only when it performs well on training data, but also when it generalizes to testing data. Model evaluation helps us answer key questions:</p><ul><li>Is the model underfitting or overfitting?</li><li>How close are predictions to the actual values?</li><li>What’s the trade-off between one type of error and another?</li></ul><h3>Evaluating Regression Models</h3><p>In regression, the main concern is <strong>how far predictions (<em>ŷ</em>) deviate from actual values (<em>y</em>)</strong>.</p><p>Common metrics include:</p><ul><li><strong>R-Square (R²)</strong><br> Indicates how much of the variance in the data can be explained by the model. The higher, the better.</li><li><strong>Mean Squared Error (MSE)</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*n_bMd8AawOfsLfVR7D8Zew.png" /></figure><ul><li>Measures the average squared difference between predictions and actual values.</li><li><strong>Root Mean Squared Error (RMSE)</strong><br> The square root of MSE. Easier to interpret since it returns to the original unit of the target.</li><li><strong>Mean Absolute Error (MAE)</strong><br> The average of absolute differences. More robust to outliers compared to RMSE.</li></ul><p>📌 <strong>Intuition:</strong><br> Why do we square or take absolute values? Because distance can’t be negative. Why do we average? To fairly compare models regardless of dataset size.</p><h3>Evaluating Classification Models</h3><p>In classification, the focus isn’t distance but whether predictions <strong>match the actual labels</strong>.</p><h3>Confusion Matrix</h3><p>A confusion matrix summarizes predictions into four categories:</p><ul><li><strong>True Positive (TP):</strong> Actual positive, predicted positive</li><li><strong>True Negative (TN):</strong> Actual negative, predicted negative</li><li><strong>False Positive (FP):</strong> Actual negative, predicted positive</li><li><strong>False Negative (FN):</strong> Actual positive, predicted negative</li></ul><p>Example: Classifying <strong>cats (positive)</strong> vs. <strong>non-cats (negative):</strong></p><ul><li>Cat predicted as cat → TP</li><li>Non-cat predicted as non-cat → TN</li><li>Non-cat predicted as cat → FP</li><li>Cat predicted as non-cat → FN</li></ul><h3>Classification Metrics</h3><p>From the confusion matrix, we can derive several key metrics:</p><ul><li><strong>Accuracy</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*G0rZ81k0mKaA_soTshWOyw.png" /></figure><ul><li>Proportion of correct predictions overall. Best for <strong>balanced datasets</strong>.</li><li><strong>Precision</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*RQV274oGOZ9Kb1Okguw7Ww.png" /></figure><ul><li>Out of all predicted positives, how many are truly positive?<br> → Useful for tasks like <strong>search engines</strong> or <strong>spam detection</strong>, where relevance is critical.</li><li><strong>Recall</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*GyXyT-_0EqbZUwwlH6YRjg.png" /></figure><ul><li>Out of all actual positives, how many did we catch?<br> → Useful for <strong>disease detection</strong> or <strong>security systems</strong>, where missing positives can be costly.</li><li><strong>F1-Score</strong><br> The harmonic mean of Precision and Recall. A good balance when both matter.</li></ul><h3>Binary vs. Multi-class Classification</h3><ul><li><strong>Binary classification</strong> → two classes only (e.g., “default” vs. “no default”).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A7h7SIOhks8P-67W_QvazQ.jpeg" /></figure><ul><li><strong>Multi-class classification</strong> → more than two classes (e.g., digit recognition 0–9).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZjmhsBTA0XD4al3O1LjUqw.jpeg" /></figure><p>In multi-class problems, the confusion matrix becomes an <strong>n × n grid</strong>, where the diagonal entries represent correct predictions.</p><h3>Precision–Recall Trade-off</h3><p>In practice, we often have to choose: focus on <strong>precision</strong> or <strong>recall</strong>?</p><p>Examples:</p><ul><li><strong>Security system (fingerprint access):</strong><br> It’s worse if an outsider (negative) is classified as an employee (positive → FP).<br> → <strong>Precision</strong> matters more.</li><li><strong>Serious disease detection:</strong><br> It’s worse if a sick patient (positive) is classified as healthy (FN).<br> → <strong>Recall</strong> matters more.</li></ul><p>We can adjust this trade-off by tuning the <strong>probability threshold</strong> (not always 0.5). Changing the threshold lets us balance precision and recall.</p><h3>ROC Curve and Thresholds</h3><p>Another evaluation tool is the <strong>ROC Curve (Receiver Operating Characteristic)</strong>, which plots the True Positive Rate against the False Positive Rate at different thresholds.</p><p>The <strong>Area Under the Curve (AUC)</strong> reflects how well the model separates classes — higher AUC means better distinction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_AHPGivcD0VgGTHj7efynQ.jpeg" /></figure><h3>Key Takeaways</h3><ul><li>For <strong>regression</strong>, use metrics like MSE, RMSE, MAE, or R².</li><li>For <strong>classification</strong>, start with the confusion matrix, then choose metrics based on business context: Accuracy, Precision, Recall, F1-Score, or ROC-AUC.</li><li>There is no universal “best” metric — it always depends on <strong>business goals and risk tolerance</strong>.</li></ul><p>Evaluating model performance ensures your Machine Learning solution isn’t just “smart on paper,” but also <strong>reliable and impactful in the real world</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61462b890b9e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Hyperparameters, Overfitting, and Resampling in Machine Learning]]></title>
            <link>https://medium.com/@axelivandatanjung/understanding-hyperparameters-overfitting-and-resampling-in-machine-learning-6e8ebd0471b8?source=rss-6e6a1fce9627------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e8ebd0471b8</guid>
            <category><![CDATA[overfitting]]></category>
            <category><![CDATA[resampling]]></category>
            <category><![CDATA[hyperparameter-tuning]]></category>
            <dc:creator><![CDATA[Axel Ivanda Tanjung]]></dc:creator>
            <pubDate>Tue, 16 Sep 2025 20:56:30 GMT</pubDate>
            <atom:updated>2025-09-16T20:56:30.277Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UrXcP_rx1CvnvgbzSOzX6A.png" /></figure><p>When building a Machine Learning model, you’ll often hear terms like <em>hyperparameter tuning</em>, <em>overfitting</em>, and <em>resampling methods</em>. These concepts are crucial to ensure that your model doesn’t just perform well on <em>training data</em> but also stays reliable when facing <em>future data</em>.</p><p>This article breaks down these key concepts, commonly encountered when working with algorithms like <strong>K-Nearest Neighbors (KNN)</strong> or <strong>Decision Trees (DT)</strong>.</p><h3>What Are Hyperparameters?</h3><p>Hyperparameters are parameters that <strong>we set manually</strong> before the training process begins. Unlike model parameters (such as coefficients in linear regression) that are learned directly from the data, hyperparameters are chosen by us to help the model perform optimally.</p><p>Some common examples of hyperparameters include:</p><ul><li><strong>K value in KNN</strong> → determines how many nearest neighbors to consider.</li><li><strong>Distance metric</strong> → e.g., Euclidean distance or Manhattan distance.</li><li><strong>Maximum depth in Decision Trees</strong> → controls how deep the tree can grow.</li><li><strong>Splitting criteria</strong> → such as <em>Entropy</em>, <em>Information Gain</em>, or <em>Gini Index</em>.</li></ul><p>These choices have a huge influence on the model’s predictive power.</p><h3>The Exam Analogy: Training vs. Testing</h3><p>Think of preparing for an exam.</p><ul><li><strong>Training data</strong> = practice problems you solve at home.</li><li><strong>Testing data</strong> = the actual exam questions in class.</li></ul><p>If you only do well on practice problems but fail on the real test, that’s called <strong>overfitting</strong> — memorizing old patterns without being able to generalize to new ones.</p><p>Example:</p><ul><li><strong>Model A</strong>: Training accuracy = 95%, Testing accuracy = 30%.</li><li><strong>Model B</strong>: Training accuracy = 70%, Testing accuracy = 65%.</li></ul><p>At first glance, Model A looks stronger. But in reality, Model B is more reliable because its performance is consistent across unseen data.</p><h3>The Problem: Where Do We Get Testing Data?</h3><p>Ideally, you’d collect additional data through surveys or new measurements. But in practice, this takes time and resources.</p><p>That’s why we rely on <strong>resampling methods</strong> — techniques to simulate testing conditions using only the data we already have.</p><h3>Resampling Methods</h3><p>Resampling allows us to evaluate how a model would perform on new data. The most popular approaches are:</p><ol><li><strong>Train-Test Split</strong></li></ol><ul><li>Divide the dataset into two parts: training and testing.</li><li>Simple, but can be biased if the split isn’t representative.</li></ul><p><strong>2. K-Fold Cross Validation</strong></p><ul><li>Split the dataset into <em>k</em> folds. Train on <em>k-1</em> folds, test on the remaining one.</li><li>Repeat until each fold has served as the test set.</li><li>Final performance is the average across all folds.</li></ul><p><strong>3. Train-Validation-Test Split</strong></p><ul><li>Split the data into three: training, validation, and testing.</li><li>Validation is used for <em>hyperparameter tuning</em>.</li><li>Testing is used for the final evaluation.</li></ul><p>These methods help us answer the big question: is the model truly learning general patterns, or is it just memorizing?</p><h3>So, What Makes a Good Model?</h3><p>A good model isn’t just one with the highest training accuracy — it’s one that performs <strong>consistently</strong> on unseen data.</p><blockquote><em>The rule of thumb: </em>Better a model that performs steadily across datasets than one that looks perfect in training but crashes in real life.</blockquote><h3>Final Takeaways</h3><p>When building Machine Learning models, always keep these three principles in mind:</p><ol><li><strong>Hyperparameters</strong> need to be chosen carefully.</li><li><strong>Overfitting</strong> is a common trap to avoid.</li><li><strong>Resampling methods</strong> give a more realistic evaluation of your model’s performance.</li></ol><p>At the end of the day, what counts as a “good” model depends on the context of the problem. Always compare against a baseline and check existing benchmarks in your domain.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e8ebd0471b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>