<?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 Jstone on Medium]]></title>
        <description><![CDATA[Stories by Jstone on Medium]]></description>
        <link>https://medium.com/@jstone1?source=rss-9c3f0a9a2e42------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3G8ZrQp1RWfsS9GQ</url>
            <title>Stories by Jstone on Medium</title>
            <link>https://medium.com/@jstone1?source=rss-9c3f0a9a2e42------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 05:04:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jstone1/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[A Floodplain Boundary Looks Precise Until the Water Arrives]]></title>
            <link>https://medium.com/@jstone1/a-floodplain-boundary-looks-precise-until-the-water-arrives-81504246104c?source=rss-9c3f0a9a2e42------2</link>
            <guid isPermaLink="false">https://medium.com/p/81504246104c</guid>
            <category><![CDATA[flood-risk]]></category>
            <category><![CDATA[urban-planning]]></category>
            <category><![CDATA[gis]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[open-data]]></category>
            <dc:creator><![CDATA[Jstone]]></dc:creator>
            <pubDate>Sat, 27 Jun 2026 05:00:02 GMT</pubDate>
            <atom:updated>2026-06-28T08:27:42.851Z</atom:updated>
            <content:encoded><![CDATA[<p>Flood maps do not only describe risk. They teach people where to stop worrying. That is why the edge of the mapped floodplain matters: to a planner, it is a regulatory and modeling boundary; to a buyer, lender, reporter, or homeowner, it can sound like a verdict.</p><p><strong>Scope note:</strong> this compares selected Harvey high-water marks with present-day FEMA NFHL context. It is not a reconstruction of 2017 effective FIRM panels, a parcel determination, a flood-depth model, or insurance advice.</p><p>Harvey is useful because it left behind an unusually strong public record. The National Hurricane Center reported rainfall above 60 inches near Nederland and Groves, Texas. USGS and FEMA later collected <strong>2,123 high-water marks</strong> and used those observations with streamgage data to produce <strong>19 flood-inundation maps</strong> for selected areas. A high-water mark is a peak clue, not a stopwatch: it can show how high water reached at one evidence location, but not how long water stayed there.</p><p>So the question here is narrower: when selected Harvey high-water marks are compared with present-day FEMA National Flood Hazard Layer (NFHL) context, where does mapped Special Flood Hazard Area (SFHA) context overlap the evidence, and where does the evidence deserve a second look?</p><p>I screened <strong>535 Houston-region USGS Harvey peak high-water marks</strong> against present-day FEMA NFHL flood-hazard context. The first result is less dramatic than a headline version would suggest: <strong>365 of 535 marks</strong>, about <strong>68%</strong>, intersect current SFHA context. The present-day map context overlaps a lot of this slice.</p><p>The harder question starts with the <strong>170 marks</strong> that fall in Zone X, reduced-risk, or minimal-context areas. But <strong>133 of those 170</strong>, about <strong>78%</strong>, were within 0.25 miles of current SFHA geometry.</p><p>The review set is smaller: <strong>9 outside-SFHA marks</strong>, <strong>1.7%</strong> of the full screen, were both at least <strong>2 ft above ground</strong> and at least <strong>0.25 miles</strong> from current SFHA geometry. Excluding estimated-stage records narrows that queue to <strong>3 records</strong>, or <strong>0.6%</strong> of the full screen. The denominator keeps the claim small: this is a short list of places where mapped context and observed evidence need to be read together.</p><p>Read the map as a comparison tool. Start wide: the regional pattern shows that much of the outside-SFHA evidence hugs the mapped boundary. Then zoom in: the question becomes local, record by record. Grid color is a low/moderate/high stress class derived from the maximum source height_above_ground_ft in each coarse cell; the point popups carry the record-level details.</p><p>Interactive evidence map. Grid color encodes a stress class from the maximum observed high-water-mark height above ground in each cell. Empty or lower-color cells do not mean no flooding; this is not a continuous flood surface, inundation extent, or parcel-risk layer.</p><p>Source HWM layerUSGS Harvey high-water mark peaks via CUAHSI HydroShare WFS, retrieved 2026–06–26.</p><p>Source count used hereThe HydroShare USGS_Harvey_HWM_Peaks WFS layer returned 1,258 peak point features before county filtering. Broader USGS/FEMA reporting cites 2,123 Harvey high-water marks across the full collection; this article does not reconcile non-peak, duplicate, supplemental, or differently published mark records.</p><p>Houston-region subset535 marks in Brazoria, Chambers, Fort Bend, Galveston, Harris, Liberty, Montgomery, and Waller counties.</p><p>FEMA contextFEMA NFHL Flood Hazard Zones point query, retrieved 2026–06–26.</p><p>Distance methodPoint-to-nearest-current-SFHA distance, calculated after projecting the data to EPSG:3083.</p><p>Height field height_above_ground_ft from the HWM peak record; no DEM-derived height was calculated for this screen.</p><p>Review thresholdsAt least 2 ft above ground, at least 0.25 miles from current SFHA, and at least 1 mile from current SFHA. These are review screens, not regulatory thresholds.</p><p>The outside-SFHA group mixes several current NFHL contexts. In this run, the 170 records break into <strong>99</strong> area-of-minimal-hazard records, <strong>66</strong> 0.2% annual-chance records, and <strong>5</strong> reduced-risk-due-to-levee records. Zero-height records were retained as source observations and remain in the 535-mark/context counts, but they do not pass any depth screen. Estimate flags are visible rather than filtered away: in this subset, <strong>393 of 535</strong> records have estimated stage and <strong>532 of 535</strong> have estimated time. That limitation is large enough to shape the tone.</p><p>The first result is ordinary, and that matters: most screened marks intersect current SFHA context.</p><p>This table does two useful things. It shows that current SFHA context overlaps most of the screened marks, and it shows that the outside-SFHA group had lower median observed height in this screen. Estimated peak time is nearly universal in this source: 532 of 535 records.</p><p>The better read is narrower: most evidence intersected the present-day mapped high-risk context, while a smaller outside-SFHA tail still deserves inspection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uq6ab7MPUocl6wJZ.png" /></figure><p><em>Distance buckets for the 170 Harvey high-water marks that intersect current Zone X / reduced / minimal context. The ≥1 mile bucket has 8 total marks, but only 4 also meet the ≥2 ft depth screen.</em></p><p>Among outside-SFHA records within 0.25 miles of current SFHA, <strong>45 of 133</strong> had at least 2 ft above ground. Among records at least 0.25 miles away, <strong>9 of 37</strong> did. The farther-out group was not proportionally deeper; it matters because distance changes the risk-communication problem.</p><p>Distance alone overstates the issue. A far mark with inches of water is a different signal from a far mark with several feet, so the useful review set is the upper-right corner of the plot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lhMmiFeoRMnNoFYW.png" /></figure><p><em>Distance alone is not the story. The upper-right quadrant marks the review set: at least 2 ft above ground and at least 0.25 miles from current SFHA geometry.</em></p><p>The threshold check matters because the tail is sensitive to how much water you require before calling a record material.</p><p><strong>The review set is real, but threshold-sensitive, so the cutoffs should be read as review choices rather than findings.</strong></p><p>The signal is visible at 1–2 ft, but it narrows quickly as the depth threshold rises. By 4 ft, it is essentially a single-record lead. At the 2 ft threshold, the nine-record review set is <strong>5.3%</strong> of the outside-SFHA group and <strong>1.7%</strong> of the full 535-record screen.</p><p>These nine records are the farther-and-deeper review set in this screen: places where observed Harvey evidence and current mapped context are far enough apart to justify closer review.</p><p>The nine-record set is not concentrated in one county: four are in Harris, two in Galveston, two in Liberty, and one in Chambers. All nine have estimated peak-time flags; six have estimated-stage flags.</p><p>If estimated-stage records are excluded from the full screen, the review set drops from <strong>9</strong> to <strong>3</strong> records at the 2 ft / 0.25 mi threshold, and from <strong>4</strong> to <strong>2</strong> records at the 2 ft / 1 mi threshold. That makes the tail narrower and more uncertain, which is why I treat these records as inspection leads.</p><p>The practical problem is simpler: for many readers, the map is the only risk language they are given. In this screened Harvey subset, “outside the high-risk zone” can sound like “safe enough.” The field evidence shows why that message needs qualifiers, especially near boundaries and in the small set of places where evidence sits well beyond them.</p><p>For insurance, planning, journalism, and public communication, the useful output is a short, inspectable list of places where mapped context and observed evidence should be read together.</p><p>The useful lesson is not that the map failed. The useful lesson is that a boundary is a communication device. The next pass should compare these records with the effective pre-Harvey FIRM panels where available, analyze the outside-SFHA subtypes separately, and add duration context from gauges or other time-aware records.</p><p>The current analysis uses present-day FEMA NFHL geometry as a reproducible screen. It does not reconstruct every effective pre-Harvey map panel, certify parcel risk, or provide insurance, engineering, emergency, or property advice.</p><p>National Hurricane Center. (2018). <em>Tropical Cyclone Report: Hurricane Harvey</em>. <a href="https://www.nhc.noaa.gov/data/tcr/AL092017_Harvey.pdf">https://www.nhc.noaa.gov/data/tcr/AL092017_Harvey.pdf</a></p><p>U.S. Geological Survey. (2018). <em>Post-Harvey Report Provides Inundation Maps and Flood Details on “Largest Rainfall Event Recorded in US History”</em>. <a href="https://www.usgs.gov/news/national-news-release/post-harvey-report-provides-inundation-maps-and-flood-details-largest">https://www.usgs.gov/news/national-news-release/post-harvey-report-provides-inundation-maps-and-flood-details-largest</a></p><p>U.S. Geological Survey. (2018). <em>Characterization of peak streamflows and flood inundation resulting from Hurricane Harvey</em>. <a href="https://pubs.usgs.gov/publication/sir20185070">https://pubs.usgs.gov/publication/sir20185070</a></p><p>CUAHSI HydroShare. <em>Hurricane Harvey flood data collection resources</em>. <a href="https://www.hydroshare.org/resource/615d426f70cc4346875c725b4b8fdc59/">https://www.hydroshare.org/resource/615d426f70cc4346875c725b4b8fdc59/</a></p><p>Federal Emergency Management Agency. <em>National Flood Hazard Layer</em>. <a href="https://www.fema.gov/flood-maps/national-flood-hazard-layer">https://www.fema.gov/flood-maps/national-flood-hazard-layer</a></p><p>National Flood Insurance Program. <em>Flood Map Zones</em>. <a href="https://www.floodsmart.gov/flood-map-zone">https://www.floodsmart.gov/flood-map-zone</a></p><p>U.S. Geological Survey. <em>High-Water Marks and Flooding</em>. <a href="https://www.usgs.gov/media/images/high-water-marks-give-evidence-peak-river-height-a-flood">https://www.usgs.gov/media/images/high-water-marks-give-evidence-peak-river-height-a-flood</a></p><p><em>Originally published at </em><a href="https://justinstone.online/posts/harvey-floodplain-boundary-problem/"><em>https://justinstone.online</em></a><em> on June 27, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81504246104c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quality, Then Area, Then Everything Else: Ames Housing with Stacked Ensembles]]></title>
            <link>https://medium.com/@jstone1/quality-then-area-then-everything-else-ames-housing-with-stacked-ensembles-d608cb9d6311?source=rss-9c3f0a9a2e42------2</link>
            <guid isPermaLink="false">https://medium.com/p/d608cb9d6311</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[kaggle]]></category>
            <category><![CDATA[regression]]></category>
            <category><![CDATA[ensemble-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Jstone]]></dc:creator>
            <pubDate>Fri, 24 Apr 2026 05:00:51 GMT</pubDate>
            <atom:updated>2026-06-28T22:21:44.566Z</atom:updated>
            <content:encoded><![CDATA[<p>Quality, Then Area, Then Everything Else: Ames Housing with Stacked Ensembles</p><p>The Ames housing dataset is the Kaggle getting-started regression benchmark. 1,460 training rows, 79 features, SalePrice target, RMSLE metric. Nearly every beginner tutorial picks two or three numeric features, fits a linear regression, and calls it a day. I wanted to see how much the harder modelling choices — proper handling of the 43 categorical columns, a stacked ensemble on top of a well-regularised baseline — actually buy on this dataset.</p><p>About 8 percent reduction in RMSLE, as it happens. The bulk of the gain comes from moving to a tree ensemble. Stacking itself adds another 3 or 4 percent on top. Nothing dramatic, nothing invisible either.</p><p>Related housing-regression read: <a href="https://justinstone.online/posts/california-housing-prices-dataset/">The California Housing Dataset Is Mostly a Geography Lesson</a>. Ames is the pipeline-and-stacking version of the lesson; California Housing is the unit-of-analysis and geography version.</p><p>The SalePrice distribution is right-skewed enough that working on log-transformed price is the standard move. It stabilises the residual variance, and the competition’s RMSLE metric directly corresponds to RMSE on the log target.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EWqDiwzLats9gVct.png" /></figure><p><em>1,460 houses. Median around 163,000 USD, mean around 181,000 USD. The log1p transform is near-optional but stabilises the upper-tail residuals.</em></p><p>The top numeric correlations with SalePrice are the features anyone who’s worked this dataset recognises. OverallQual at 0.79. GrLivArea at 0.71. GarageCars at 0.64. GarageArea at 0.62. TotalBsmtSF at 0.61.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KxziqDN2WAEDoRxE.png" /></figure><p><em>OverallQual is an integer 1–10 scale. It correlates with basically everything else that matters. It’s closer to a compressed expert judgement than a raw feature, which is both why it’s the strongest predictor and why interpreting its coefficient in isolation is a trap.</em></p><p>The 25 Ames neighborhoods span a factor-of-three median-price gap — from around 300,000 USD in NoRidge and StoneBr down to 100,000 USD in MeadowV and IDOTRR.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*yjZD9DbP0Kl7ldDJ.png" /></figure><p><em>3x across a town of 58,000 people. That’s why Neighborhood is the prime candidate for target encoding.</em></p><p>The dataset has 43 categorical columns. One-hot encoding blows that up to 250-plus features, which on 1,460 rows is a recipe for overfitting. Target encoding replaces each category with the mean of the target within that category — one numeric column in, one numeric column out.</p><p>The catch is that in-fold target encoding leaks future information. I used out-of-fold means across a 5-fold split, which gives each training row a target encoding computed without its own label. That’s a small but essential detail.</p><p>Two more preprocessing notes. Categorical NA values in Alley, BsmtQual, GarageType, and similar columns aren’t missing — they mean “this house has no alley / basement / garage”. I filled them with the string “None” to preserve the signal. Numeric NAs in LotFrontage, MasVnrArea, GarageYrBlt got median-imputed.</p><p>Ridge at alpha=5 as the baseline. XGBoost at depth 4 with 1,500 estimators. LightGBM with 31 leaves. And a Ridge stack at alpha=0.1 on out-of-fold predictions from the first three.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kM3hh7uDbI03B_-s.png" /></figure><p><em>Ridge is a respectable baseline on a target-encoded feature set. XGBoost picks up about 5 percent. LightGBM lands surprisingly close to Ridge here. The stack adds another 3 percent over XGBoost alone.</em></p><p>The meta-Ridge coefficients at alpha 0.1 land at roughly ridge=0.18, xgb=0.87, lgbm=-0.03. XGBoost does most of the work. The stacking layer is not treating all three base learners as equal voters; it mostly keeps the XGBoost signal and applies a small linear correction from the other learners.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PnVOISx-gEg5zHnA.gif" /></figure><p><em>Alpha has to climb above 10 before the weights start collapsing toward a more averaged solution. Below that, the practical takeaway is stable: the stack mostly trusts XGBoost on this split.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*--UUaZdtKjgZyxvl.png" /></figure><p><em>Mean-zero across the bulk of the distribution. Mildly heteroskedastic at the high end where there are fewer training rows. For anyone optimising further, the 500k+ sub-population is where weighted regression or a quantile approach would help most.</em></p><p>Not a Kaggle-competitive submission. The public leaderboard tops out around 0.107 RMSLE, and winning solutions use XGBoost + LightGBM + CatBoost + ElasticNet stacks with heavy feature engineering. 0.126 would land somewhere mid-pack. Respectable, not winning.</p><p>Not a causal analysis either. OverallQual is a composite. GrLivArea is partially redundant with TotalBsmtSF and 1stFlrSF. A proper causal story needs either experimental data or a structural model.</p><p>Source code, notebook, and outputs are maintained as a reproducible project bundle. Dataset is the train.csv from Kaggle&#39;s House Prices competition ( <a href="https://justinstone.online/posts/house-prices-ames-stacked-ensembles/#ref-decock">De Cock, 2011</a>).</p><p>De Cock, D. (2011). Ames, Iowa: Alternative to the Boston housing data as an end of semester regression project. <em>Journal of Statistics Education, 19</em>(3), 1–15.</p><p>Ke, G., Meng, Q., Finley, T., Wang, T., Chen, W., Ma, W., Ye, Q., &amp; Liu, T.-Y. (2017). LightGBM: A highly efficient gradient boosting decision tree. <em>Advances in Neural Information Processing Systems, 30</em>.</p><p><em>Originally published at </em><a href="https://justinstone.online/posts/house-prices-ames-stacked-ensembles/"><em>https://justinstone.online</em></a><em> on April 24, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d608cb9d6311" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Default Threshold Is the Bug: Credit Card Fraud on the ULB Benchmark]]></title>
            <link>https://medium.com/@jstone1/the-default-threshold-is-the-bug-credit-card-fraud-on-the-ulb-benchmark-d2e311b6f690?source=rss-9c3f0a9a2e42------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2e311b6f690</guid>
            <category><![CDATA[xgboost]]></category>
            <category><![CDATA[imbalanced-data]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[fraud-detection]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Jstone]]></dc:creator>
            <pubDate>Fri, 24 Apr 2026 05:00:18 GMT</pubDate>
            <atom:updated>2026-06-28T22:20:37.301Z</atom:updated>
            <content:encoded><![CDATA[<p>There are 284,807 transactions in the Kaggle ULB credit card fraud dataset. 492 of them are fraudulent. That works out to a 0.1727 percent positive rate — roughly one fraud case for every 580 legitimate charges. A classifier that predicts “legitimate” for everything is right 99.83 percent of the time, so if a coworker presents that model in a meeting and puts accuracy on the headline slide, the meeting is basically over.</p><p>The usual next step is to train something proper and report 0.98 ROC-AUC. Fine. That number is real. It’s also not the question I care about. What I want to know is whether the threshold we’d actually deploy catches fraud at a cost the business can live with. On this dataset, the 0.5 default is a policy decision almost nobody would sign off on if they looked at the confusion matrix underneath.</p><p>Every evaluation choice downstream has to be made in light of the class balance, so that’s where I start.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*z9_Rs1fVnk1SAsoB.png" /></figure><p><em>The fraud bar is small enough that a trivial classifier clears 99.83 percent accuracy without learning anything. The log scale is the only reason the positive bar is visible.</em></p><p>At that prevalence, accuracy is useless. The majority-class baseline is already past any reasonable threshold anyone would set on the metric. ROC-AUC isn’t quite useless, but it treats every misclassification the same and rewards score rank-ordering that may or may not translate into a usable operating point. Precision-recall is the diagnostic that matters here, and the final metric — the one you ship on — is the expected cost of the decisions the classifier makes at a specific threshold.</p><p>Quick profile of the dataset I worked against:</p><p>Stratification isn’t optional at this prevalence. A purely random 25 percent holdout could hand me a test set with fewer than 80 positives if the draw went badly, and recall estimates off that many positives are noisy enough that a single misclassified row shifts the number by a full percentage point.</p><p>Everything but Time and Amount is a principal component, so I can&#39;t do meaningful domain-driven feature engineering. What I can do is look at where the classes land on a few of the components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gQ95sNI8oNvwvBDc.png" /></figure><p><em>Fraud in red, legitimate in blue. V14 and V17 carry the cleanest separation on this split. The rest are overlapping distributions with a visible shift in mean.</em></p><p>V14 and V17 are where the fraud cases pile up at values two to three standard deviations away from the legitimate cluster. The others show a shift but no clean separation. That’s enough signal for a supervised classifier to work with, and it’s a useful reality check before training — if every component’s KDE were overlapping, I’d know I was about to waste my time.</p><p>Logistic regression with class_weight=&#39;balanced&#39;. XGBoost with scale_pos_weight set to the empirical negative-to-positive ratio. And an Isolation Forest trained only on the legitimate transactions, which treats fraud as an anomaly-detection problem and never sees the labels during training.</p><p>I included the Isolation Forest on purpose. The pitch for unsupervised fraud detection is that you don’t need labels, which matters for novel fraud patterns that have never been labelled in the historical data. The counter-pitch is that labels carry information geometric similarity alone can’t recover. Running both on the same split makes the tradeoff concrete instead of theoretical.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kzqjaCQJkhQT3-t6.png" /></figure><p><em>Precision-recall is the right diagnostic at this prevalence. Logistic regression hits AP 0.706, XGBoost hits 0.863, and the Isolation Forest lands at 0.113. The gap between supervised and unsupervised here is two orders of magnitude wide.</em></p><p>XGBoost has the highest average precision, which tracks with what the PCA components looked like — boosted trees with an AUC-PR objective are a good fit for geometrically separable features. Logistic regression isn’t far behind, and its scores are relatively well calibrated out of the box, which matters for the threshold conversation that follows. The Isolation Forest is not a serious contender at this prevalence. It’s in the chart to make that point visible.</p><p>The reflex is to report accuracy or F1 at the default 0.5 threshold and move on. That reflex is wrong on this dataset. The right question is what threshold minimises the total business cost, and to answer it I had to pick a cost model.</p><p>The one I used treats a missed fraud as 100 EUR and a false positive as 5 EUR. Those numbers are illustrative, not calibrated to any specific institution. They capture the order-of-magnitude asymmetry fraud teams work under: a missed fraud is a ten- or twenty-times-more-expensive error than a manual review. Swap either number for your own real cost structure and the framework doesn’t change; only the answer does.</p><p>I swept the threshold from 0.001 to 0.99 for each classifier and computed expected cost at every step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rbuoT2Qvn6eXgBQ5.png" /></figure><p><em>Missed-fraud cost in red, review cost in blue, total in black. The total-cost curve bottoms out at a decision threshold of 0.01, which is not where most tutorials point the reader.</em></p><p>0.01 is startling the first time you see it. A classifier that flags a transaction as fraud the moment it assigns a one-in-a-hundred probability isn’t the standard recommendation. But it’s exactly right for this problem. At a 0.17 percent base rate, a posterior of 0.01 is already a fifty-seven-fold lift over prior. The review cost stays shallow enough that the optimum sits further left than intuition suggests, and the missed-fraud cost is steep enough to dominate any choice of threshold to the right of the minimum.</p><p>At the XGBoost minimum-cost threshold of 0.01, the classifier catches 106 of 123 fraud cases, misses 17, and flags 79 legitimate transactions for review. Total cost: 2,095 EUR. Against a no-model baseline of 12,300 EUR — the cost of missing every fraud outright — that’s a 6x reduction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/0*VSf9ggkiqAnXyEW7.png" /></figure><p><em>The true-positive block dominates. The false-positive block isn’t trivial, but 79 flagged legitimate transactions out of 71,079 in the test set is a review rate a fraud team can actually handle.</em></p><p>Logistic regression lands in a similar spot from a different direction. Its cost curve bottoms out at 0.97 and catches 105 fraud cases for 2,310 EUR total cost. The two threshold numbers — 0.01 and 0.97 — are not comparable across models; XGBoost and logistic regression produce scores with different calibrations, so only the resulting cost and recall are.</p><p>The Isolation Forest at its own minimum-cost threshold catches 72 of 123 fraud but flags 710 legitimate transactions for review. Total cost: 8,650 EUR. At the prices I used, it does worse than either supervised baseline by a factor of four. Unsupervised anomaly detection isn’t viable on this dataset when manual review has a non-trivial cost.</p><p>The ranking of the three models isn’t robust to the cost ratio. Here’s what happens when I slide the FN-to-FP cost ratio from 2:1 up to 60:1 for XGBoost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ahv37p9stYmUbuCk.gif" /></figure><p><em>As the ratio grows, the orange vertical line (the minimum-cost threshold) walks leftward. The operating point is a function of the cost structure, not the model.</em></p><p>At 2:1 the minimum is around 0.5. At 20:1 it’s near 0.05. At 60:1 it’s below 0.01. The point of the animation isn’t that any single ratio is correct — it’s that the question “what threshold should we deploy” has no answer until the cost structure is specified.</p><blockquote><em>The threshold is not a modelling decision. It’s a policy decision.</em></blockquote><p>A fraud analytics team deploying this classifier has to know its own cost structure before it can reason about where to place the threshold. That structure is almost never 1:1, which is what the 0.5 default implicitly assumes. Reporting a single operating point as “the model’s performance” hides the decision that actually determines whether the classifier is useful in production.</p><p>This is an educational analysis on a public benchmark, not a deployable fraud system. A few honest limits before anyone takes it further.</p><p>The PCA anonymisation is the single biggest constraint. Every feature except Time and Amount is a principal component, so meaningful feature-importance analysis or domain-driven feature engineering is off the table. I can&#39;t tell you what V14 or V17 carry; I can only tell you that the supervised models extract usable signal from the combination.</p><p>The two-day observation window is short enough that seasonal effects are invisible. The geography is constrained to European cardholders from a 2013 sample, which makes generalisation to the 2026 fraud landscape an act of extrapolation. Real fraud detection moves by modelling the attacker, and the 2026 attack surface is not the 2013 attack surface.</p><p>The cost model is illustrative. I chose 100 EUR and 5 EUR because they capture the asymmetry fraud teams work under, but any institution taking this approach to production should replace those numbers with its own before the cost sweep runs.</p><p>The test set has 123 positives, which means the recall estimates have confidence intervals of a few percentage points. A ten-fold cross-validated version of the cost sweep would produce more stable estimates of the optimal threshold, and that’s the obvious next step for anyone continuing this work.</p><p>Everything here comes from one pipeline that runs end-to-end from the Kaggle CSV through preprocessing, stratified splitting, the three model fits, the cost sweep, and the figure generation. The narrative version of the pipeline is in notebooks/credit-card-fraud-analysis.ipynb, the single-script version is in src/run_analysis.py, and the figures and numeric outputs are part of the reproducible project bundle. The dataset is the creditcard.csv file from the Machine Learning Group ULB dataset on Kaggle ( <a href="https://justinstone.online/posts/credit-card-fraud-default-threshold/#ref-dalpozzolo2015">Dal Pozzolo et al., 2015</a>).</p><p>Dal Pozzolo, A., Caelen, O., Johnson, R. A., &amp; Bontempi, G. (2015). Calibrating probability with undersampling for unbalanced classification. <em>2015 IEEE Symposium Series on Computational Intelligence</em>, 159–166. <a href="https://doi.org/10.1109/SSCI.2015.33">https://doi.org/10.1109/SSCI.2015.33</a></p><p>Chen, T., &amp; Guestrin, C. (2016). XGBoost: A scalable tree boosting system. <em>Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining</em>, 785–794. <a href="https://doi.org/10.1145/2939672.2939785">https://doi.org/10.1145/2939672.2939785</a></p><p>Elkan, C. (2001). The foundations of cost-sensitive learning. <em>Proceedings of the Seventeenth International Joint Conference on Artificial Intelligence</em>, 973–978.</p><p><em>Originally published at </em><a href="https://justinstone.online/posts/credit-card-fraud-default-threshold/"><em>https://justinstone.online</em></a><em> on April 24, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2e311b6f690" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The California Housing Dataset Is Mostly a Geography Lesson]]></title>
            <link>https://medium.com/@jstone1/the-california-housing-dataset-is-mostly-a-geography-lesson-de872ff122d4?source=rss-9c3f0a9a2e42------2</link>
            <guid isPermaLink="false">https://medium.com/p/de872ff122d4</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[geospatial-data]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[housing]]></category>
            <category><![CDATA[regression]]></category>
            <dc:creator><![CDATA[Jstone]]></dc:creator>
            <pubDate>Tue, 21 Apr 2026 05:00:06 GMT</pubDate>
            <atom:updated>2026-06-28T22:19:46.503Z</atom:updated>
            <content:encoded><![CDATA[<p>The California housing dataset has the perfect shape for a machine-learning tutorial.</p><p>It is small enough to load quickly, real enough to feel less toy-like than synthetic data, and familiar enough that the target makes immediate sense. Everyone understands the idea of predicting housing prices.</p><p>But the name is misleading in a way that actually matters.</p><p>The dataset looks like a home-price dataset, but it is not house-by-house sales data. It is not current market data. It is not a Zillow clone waiting to happen. It is a 1990 census-era collection of area summaries, and the most useful thing it teaches is not “how to predict California home prices.” It teaches how quickly a regression problem becomes a data problem.</p><p>I used the StatLib / scikit-learn version of the dataset for this post because it is easy to reproduce without Kaggle credentials. Kaggle mirrors are useful if you want a CSV in the browser, but the canonical version in scikit-learn is enough for the main lesson: before modeling, understand what the rows actually are.</p><p>The geography is visible before any model shows up. That is the first clue that this is not just a clean tabular regression exercise.</p><p>Related housing-regression read: <a href="https://justinstone.online/posts/house-prices-ames-stacked-ensembles/">Quality, Then Area, Then Everything Else: Ames Housing with Stacked Ensembles</a>. If this post is about understanding what the rows mean before modeling, the Ames post is about what the preprocessing and stacking pipeline actually buys.</p><p>The most important correction is simple: one row is not one house.</p><p>In the scikit-learn version, the dataset has 20,640 rows and 8 numeric predictive attributes ( <a href="https://justinstone.online/posts/california-housing-prices-dataset/#ref-sklearn-fetch">scikit-learn, 2026</a>). The description traces it back to 1990 U.S. census block groups, where a block group is a small geographic area rather than an individual property ( <a href="https://justinstone.online/posts/california-housing-prices-dataset/#ref-sklearn-descr">scikit-learn, 2026</a>).</p><p>That changes how I read every column.</p><p>MedInc is median income for a block group. HouseAge is the median age of homes in that block group. AveRooms, AveBedrms, and AveOccup are averages over households. Latitude and Longitude locate the block group. The target is median house value for the area, expressed by scikit-learn in units of $100,000.</p><p>So the row is better read as:</p><blockquote><em>“Here is a small area in California in 1990. What was the median house value there?”</em></blockquote><p>That sounds like a small distinction, but it matters. Aggregated rows behave differently from individual transactions. You cannot reason about a single sale, a single buyer, a single floor plan, or a single listing. You are modeling neighborhood summaries.</p><p>That is still useful. It is just a different task than the name suggests.</p><p>Here is the quick profile I used while working through it:</p><p>Those numbers already tell a story. The median and mean are far apart enough to hint at a right tail. The maximum looks suspiciously round. Income is obviously important, but not perfect. And because the map has coordinates, location is going to do real work.</p><p>The strangest part of the dataset is the ceiling.</p><p>The maximum median house value is $500,001, and 965 block groups hit that exact value. That is 4.7% of the rows.</p><p>That is not a natural market pattern. It is a censoring pattern. The dataset does not tell us how far above the ceiling those expensive areas really went. A block group with a true median value of $520,000 and one with a true median value of $900,000 can both get flattened into the same visible endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QkQQdxxlAu05B1xy.png" /></figure><p><em>The spike at the far right is not a normal tail. It is a measurement limit.</em></p><p>This matters because the target is what the model is trying to learn. If the high end is flattened, then model errors near the high end are harder to interpret. A prediction of $480,000 for a capped row might look close, but we do not actually know how high the uncapped value should have been.</p><p>The ceiling is exactly what makes it a good teaching example. Real datasets often have limits like this. Sometimes values are top-coded for privacy. Sometimes collection systems have maximum fields. Sometimes business logic rounds, clips, buckets, or suppresses values. If you do not check the target distribution early, you can mistake a data-collection artifact for a market pattern.</p><p>Median income is the feature most people expect to matter, and it does.</p><p>In this dataset, the correlation between median income and median house value is about 0.688. That is strong for one variable in a messy real-world dataset. The relationship is visible immediately: higher-income block groups usually have higher median house values.</p><p>But the plot also shows why “usually” is doing work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*i_AZ8QxWWGX27B6x.png" /></figure><p><em>Income is a strong first read, but the ceiling flattens the right side and the spread stays wide.</em></p><p>The highest income quartile has a median block-group value of about $295,250. The lowest income quartile has a median of about $103,950. That is a huge difference.</p><p>Still, income is not the whole story. There are moderate-income areas with expensive housing and higher-income areas that do not reach the cap. Once location enters the picture, that spread makes more sense.</p><p>This is where I think the dataset becomes useful for beginners. It gives you one signal that is easy to understand, then immediately shows that one clean signal is not enough.</p><p>You can start with a naive rule: higher-income areas usually have higher median house values. Then the data forces you to add context: place, housing stock, occupancy, and measurement limits. That is closer to how modeling actually feels.</p><p>Latitude and longitude look like ordinary numeric features in the table, but they are carrying a lot of structure.</p><p>They are standing in for distance to jobs, coastline, climate, local scarcity, commuting patterns, local policy, and a pile of regional history that is not explicitly present in the dataset. A model that uses coordinates is not learning “longitude” in the abstract. It is using geography as a compressed proxy for things the table does not name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w7Ovmn8EBgAIzntH.png" /></figure><p><em>The simple correlation chart understates location. Latitude and longitude are weak as separate linear correlations, but together they carry spatial structure.</em></p><p>This is a good warning about feature interpretation.</p><p>If I only look at the correlation table, MedInc dominates and the coordinate columns look modest. But the map says something stronger: the high-value areas are not randomly scattered. They cluster around parts of the coast and major metro regions. A linear correlation coefficient cannot fully capture that two-dimensional spatial pattern.</p><p>The animation below makes the income story feel less one-dimensional. As the map steps through income quartiles, higher-income block groups become more common in expensive coastal and metro pockets, but geography never disappears.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dyRwwYNs1j3YP0uf.gif" /></figure><p><em>Changing the income band changes the map, but it does not turn the problem into income alone.</em></p><p>The “not current market data” issue is easier to see on a live map. The embedded Folium view below layers the original 1990 block-group value pattern against current Zillow county values. Click a county bubble to compare the median value assigned from the 1990 census-derived data with the current Zillow value used in the comparison notebook.</p><p>If the embedded map is cramped on your device, open the <a href="https://justinstone.online/assets/interactive/california-price-map.html">full interactive map</a>.</p><p>This is one of the more useful habits the dataset can teach: when a model improves after adding location, do not stop at “coordinates helped.” Ask what the coordinates are proxying for.</p><p>Sometimes that proxy is acceptable. Sometimes it is exactly the thing you need to be careful with.</p><p>I ran a simple train/test check with two models:</p><ol><li>a ridge regression baseline with scaled features</li><li>a histogram gradient boosting regressor</li></ol><p>The ridge model landed around $52,663 mean absolute error and $72,073 RMSE on the test split. The gradient boosting model did better, around $30,807 MAE and $47,380 RMSE.</p><p>The boosted model has room to use nonlinear interactions the ridge cannot: income by location, occupancy by location, age by region, and so on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zUob8w5Ke8QCKyQ9.png" /></figure><p><em>A stronger model improves the baseline, but the expensive edge remains awkward because the target is capped.</em></p><p>The point is not that gradient boosting is “the answer.” The point is that model choice is only one layer of the problem.</p><p>If I were using this dataset in a real analysis, I would spend more time on the data questions than the algorithm list:</p><p>Is the target capped? Yes.</p><p>Are these individual homes? No.</p><p>Is this current market data? No.</p><p>Do the coordinates act as a proxy for missing social and economic variables? Almost certainly.</p><p>Can the model extrapolate beyond the 1990 measurement range? Not honestly.</p><p>That is why this dataset is useful and dangerous in exactly the same way. It is simple enough to get a model running in minutes, but real enough to punish shallow interpretation.</p><p>I would use the California housing dataset to teach regression workflow, not to teach housing markets. It is a compact way to practice reading a dataset description, checking target distributions, catching capped values, and comparing a linear baseline to a nonlinear model that can exploit location. What I would not do is treat it as current real estate data, use it for individual home-price prediction, or draw fairness conclusions from it without a lot more context.</p><p>The dataset is from 1990. California changed. Prices changed. Lending changed. Zoning fights changed. The modern housing market is not contained in these 20,640 rows.</p><p>But as a teaching dataset, it still holds up because it makes the right mistakes visible: the clean table hides aggregation, the continuous target hides a ceiling, and what looks like a model problem keeps turning back into a data problem.</p><p>The figures in this post were generated from the public StatLib archive used by scikit-learn. The figure-generation script is scripts/generate_california_housing_article_images.py. It downloads the archive, recreates the scikit-learn-style derived columns, and writes the post images under assets/img/posts/california-housing-prices/.</p><p>scikit-learn developers. (2026). <em>California Housing dataset description</em>. scikit-learn source documentation.</p><p><em>Originally published at </em><a href="https://justinstone.online/posts/california-housing-prices-dataset/"><em>https://justinstone.online</em></a><em> on April 21, 2026.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de872ff122d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>