<?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 Arinpatel on Medium]]></title>
        <description><![CDATA[Stories by Arinpatel on Medium]]></description>
        <link>https://medium.com/@arinpatel1206?source=rss-505995f16438------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*XYrs4WyUY1XpUuKS</url>
            <title>Stories by Arinpatel on Medium</title>
            <link>https://medium.com/@arinpatel1206?source=rss-505995f16438------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 13:07:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arinpatel1206/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[Why 82% Accuracy Isn’t the Whole Story: Hunting for Extreme Weather in 182,600 City-Days]]></title>
            <link>https://medium.com/@arinpatel1206/why-82-accuracy-isnt-the-whole-story-hunting-for-extreme-weather-in-182-600-city-days-14654546893f?source=rss-505995f16438------2</link>
            <guid isPermaLink="false">https://medium.com/p/14654546893f</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[weather-forecasts]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[knowledge-graph]]></category>
            <category><![CDATA[logistic-regression]]></category>
            <dc:creator><![CDATA[Arinpatel]]></dc:creator>
            <pubDate>Tue, 20 Oct 2026 22:32:31 GMT</pubDate>
            <atom:updated>2026-10-20T22:32:31.845Z</atom:updated>
            <content:encoded><![CDATA[<p>I cleaned, explored and modeled a decade of daily weather data from 50 cities. The model’s headline number looked decent, and it hid most of what mattered.</p><p>Weather data has an odd property. There is a huge amount of it, and almost all of it is unremarkable. Scroll through ten years of daily observations and you pass thousands of ordinary afternoons before you meet a day that really matters.</p><p>That imbalance is what drew me to this project. I wanted to know what patterns were hiding in a large weather dataset, and whether a simple model could learn to flag the rare days that stand out. I got some useful answers. I also got a very clear lesson in why a single accuracy number can mislead.</p><h3>The question I wanted to explore</h3><p>The project started with a broad question: how do temperature, rainfall and wind behave across cities and over time, and how often do extreme days occur? I broke it into five smaller ones:</p><ul><li>How do temperature and precipitation vary by month and year?</li><li>Which cities have the most extreme days?</li><li>How are temperature, precipitation and wind related?</li><li>What share of daily records count as extreme?</li><li>How well can a model classify <em>tomorrow</em> as extreme or not?</li></ul><p>I had a few readers in mind: disaster-management teams, environmental researchers and urban planners. This is an exploratory analysis of historical data, though, not a real-time alert system. I kept that distinction in mind throughout.</p><h3>Understanding the dataset</h3><p>The data covers daily observations for <strong>50 cities from 2010 to 2019</strong>, roughly <strong>182,600 city-day records</strong>. That figure matches the arithmetic: 50 cities times 3,652 days. Each row holds a date, a city name and daily measurements:</p><ul><li>maximum, minimum and mean temperature at 2 m</li><li>total precipitation and rain</li><li>maximum wind speed and maximum wind gusts at 10 m</li><li>a weather code</li></ul><p>I worked in Python with pandas for wrangling, Matplotlib and seaborn for charts, and scikit-learn for modeling.</p><h3>Cleaning and preparing the data</h3><p>Because the notebook was built to be rerun, the cleaning steps are defensive.</p><p>I converted the date column to proper datetimes and dropped rows where the conversion failed. I trimmed whitespace from city names so the same city couldn’t appear under two spellings. I removed exact duplicate rows and checked for duplicate city-date pairs.</p><p>Missing values and outliers needed more thought. I didn’t delete rows just because a field was empty. Missing values were counted and handled later inside the modeling pipeline. For outliers I used the IQR rule, but only to <em>flag</em> unusual values, not to remove them. In weather data the strangest numbers are often the real events I’m trying to find, and deleting them would defeat the purpose.</p><h3>Exploring weather patterns</h3><h4>The shape of a typical day</h4><p>The first chart is a histogram of daily maximum temperature across all records.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*3zKdymTKYSf49Pyg1uRpSg.png" /><figcaption><em>Most daily highs cluster around 30, with a long, thin tail stretching toward the cold end. Observations below zero are rare in this dataset.</em></figcaption></figure><p>The distribution peaks at around 30 and falls away quickly past 40. It is clearly skewed. The left tail runs down to about −10 but holds very few observations, and the right side thins out near 45. A skew like this is a reminder that “average” doesn’t describe all 50 cities equally well.</p><h4>A seasonal rhythm, with a surprise</h4><p>Next I averaged mean temperature by calendar month.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*stEo0vacJPTOOGYfD4cDSQ.png" /><figcaption><em>Pooled across all cities, the average mean temperature climbs from about 17.6 °C in January to a peak of about 31.4 °C in May, then eases down through the second half of the year.</em></figcaption></figure><p>The seasonal curve is obvious, but the peak sits in <strong>May</strong>, not in mid-year. After May the average falls to roughly 27.6 °C by July and drifts down more slowly through September and October before dropping toward December. I can describe that pattern, but I can’t yet explain it. This line pools all 50 cities, so it reflects whatever mix of climates is in the dataset. Breaking it out by city is the obvious next step before I’d offer a cause.</p><h4>Rain and wind: not the relationship I expected</h4><p>Intuition says stormy days should be both wet and windy. So I plotted daily precipitation against maximum wind speed, using a random sample of 5,000 records so the chart stays readable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*LXNB5qnEfYSWlSwuMnej0g.png" /><figcaption><em>Most days pile up near zero precipitation across a wide range of wind speeds. The heaviest rainfall days, up to roughly 180 mm, do not coincide with the highest winds.</em></figcaption></figure><p>The plot shows a dense column of dry or nearly dry days and a thin scatter of heavy-rain days. The very wettest points appear at moderate wind speeds, and no clean upward pattern emerges. Rain and wind in this dataset are not tightly tied together on a daily basis.</p><h4>The correlation heatmap</h4><p>To check this more formally, I computed Pearson correlations across the seven numeric weather variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ke7I_bR18kEIQ4fJvX5MGA.png" /><figcaption><em>Strong correlations appear within families of variables (temperature with temperature, wind with gusts). Correlations across families, such as temperature with precipitation, are weak.</em></figcaption></figure><p>The heatmap showed:</p><ul><li>Mean temperature correlates at 0.94 with both maximum and minimum temperature.</li><li>Precipitation and rain are correlated at 1.00, so for this analysis they are effectively the same measurement.</li><li>Wind speed and wind gusts correlate at 0.91.</li><li>Precipitation’s correlations with temperature range from −0.12 to 0.18, and with wind from 0.13 to 0.17. All of these are weak.</li></ul><p>These are linear correlations only, and they don’t prove causation. They do show that several of my features carry overlapping information. I kept that in mind when modeling.</p><h3>Defining “extreme”</h3><p>Weather data doesn’t come with an “extreme” label, so I had to define one. My rule flags a day as extreme if it meets <strong>either</strong> condition:</p><ul><li>its weather code is one of <strong>65, 67, 75, 82, 86, 95, 96 or 99</strong>, or</li><li>daily precipitation is <strong>at least 64.5 mm</strong>.</li></ul><p>I want to be clear that this is <em>my project’s chosen rule</em>, not a universal meteorological standard. A threshold that makes sense for one climate may be meaningless in another, and the rule shouldn’t be read as an official warning level.</p><h3>Building the model</h3><p>With a label in place, the question became whether <strong>today’s weather can tell us anything about tomorrow’s extreme-event status</strong>.</p><p>For each city I sorted the records by date and shifted the label back by one day, so each row’s target is “was the <em>next</em> day extreme?” I kept only pairs of truly adjacent calendar days, so a gap in the data couldn’t be mistaken for a next-day observation. The features were today’s seven numeric measurements.</p><p>I used <strong>Logistic Regression</strong>. It’s a simple, explainable baseline for yes-or-no outcomes, and I wanted a reference point before trying anything fancier. The model sits inside a scikit-learn pipeline that:</p><ol><li>fills missing values with the median,</li><li>scales features to a common range, and</li><li>fits the classifier with class_weight=&quot;balanced&quot;, which tells the model to treat mistakes on the rare class as more costly.</li></ol><p>The split is chronological. <strong>Training data runs through December 31, 2017 (146,100 rows), and testing starts January 1, 2018 (36,450 rows).</strong> A random split would let the model learn from days that come after the ones it’s tested on. The chronological split is closer to how such a model would actually be used.</p><h3>What worked and what didn’t</h3><p>Here are the results on the test set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*noxVWkUS6g-yExUAZpc1JQ.png" /><figcaption><em>Accuracy looks respectable at about 82%, but the confusion matrix shows how many normal days were flagged as extreme.</em></figcaption></figure><ul><li><strong>Extreme-event prevalence in the test set:</strong> about 2.16%</li><li><strong>Accuracy:</strong> about 82.00%</li><li><strong>Recall:</strong> about 72.34%</li></ul><p>Predicted normalPredicted extreme<strong>Actually normal</strong>29,3206,342<strong>Actually extreme</strong>218570</p><h4>Why accuracy alone fails</h4><p>Only about 2.16% of test days were extreme. A “model” that predicted <em>normal</em> every single day would be right about 97.8% of the time (35,662 of 36,450 days) and would catch zero extreme events. That’s why 82% accuracy, taken alone, tells you very little. The balanced class weighting deliberately trades overall accuracy for sensitivity to the rare class, so a lower accuracy figure is expected.</p><h4>The good news</h4><p>The model found <strong>570 of the 788 actual extreme days</strong>, which is the 72.34% recall. For a model using only seven same-day measurements, I found that encouraging. There is some real signal in today’s weather about tomorrow’s.</p><h4>The uncomfortable part</h4><p>The same matrix shows <strong>6,342 normal days wrongly flagged as extreme</strong>, and <strong>218 real extreme days missed</strong>. Working from the confusion matrix, of the 6,912 days the model flagged, only 570 were truly extreme. Precision comes out to about 8%, meaning roughly one flag in twelve was correct. I calculated that figure from the matrix, not from a separate metric.</p><p>If you imagine this model driving alerts, people would face about twelve warnings for every genuine event. That’s a lot of alarm fatigue, and the model would still miss more than a quarter of the real events. This is not a production-ready forecasting system, and I don’t present it as one. It’s an exploratory next-day classification experiment, and it did what an experiment should: it showed me where the difficulty is.</p><h3>Challenges and lessons learned</h3><p><strong>Rare events change how you evaluate.</strong> The biggest lesson was learning to ask “accurate at what?” Recall, precision and the confusion matrix told a far more honest story than accuracy did.</p><p><strong>Defining the target is half the problem.</strong> My rule mixes weather codes with a precipitation cutoff. Change the rule and every result changes with it.</p><p><strong>Redundant features are easy to miss.</strong> The heatmap showed that several variables are nearly duplicates. Logistic Regression can tolerate that, but it makes any attempt to interpret individual coefficients less clear-cut, and I haven’t done that analysis here.</p><p><strong>Time-aware splitting matters.</strong> Splitting chronologically made the setup stricter and the evaluation more believable.</p><h3>Limitations and next steps</h3><p>The model sees only today’s seven measurements. It has no information on season, location, pressure, humidity or the days before today, all of which could plausibly help. Evaluation covers a single test window (2018 onward) and a single model, with no threshold tuning or comparison against a simple baseline such as “tomorrow looks like today.”</p><p>If I continue, I’d:</p><ul><li>plot a precision-recall curve and tune the decision threshold,</li><li>add lagged features, month and city information,</li><li>compare against a persistence baseline and a tree-based model,</li><li>evaluate performance city by city, since a pooled metric can hide uneven results.</li></ul><h3>Conclusion</h3><p>I started this project hoping to turn a large pile of weather data into insight, and I did get there, just not in the way I’d pictured. The exploratory charts gave me a clear seasonal rhythm, a skewed temperature distribution and a surprisingly weak link between rain and wind. The model gave me something more valuable: a concrete demonstration that a rare-event problem can look fine on one metric and be difficult on every other.</p><p>What I’m taking away is a habit. Before trusting a result, I want to know what a do-nothing model would score, what the errors look like, and who would pay for them. In this project, the 6,342 false alarms taught me more than the 82% ever could.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14654546893f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>