<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Python on Volundarhus</title><link>http://www.volundarhus.com/tags/python/</link><description>Recent content in Python on Volundarhus</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Sun, 29 Nov 2026 00:00:00 +0000</lastBuildDate><atom:link href="http://www.volundarhus.com/tags/python/index.xml" rel="self" type="application/rss+xml"/><item><title>Small-Data MLOps: Fresh, Warm, and Greedy Hyperparameter Optimization</title><link>http://www.volundarhus.com/posts/small_data_hpo/</link><pubDate>Sun, 29 Nov 2026 00:00:00 +0000</pubDate><guid>http://www.volundarhus.com/posts/small_data_hpo/</guid><description>&lt;p&gt;&lt;a href="https://github.com/huntermills707/small_ml_hpo" class="external-link" target="_blank" rel="noopener"&gt;GitHub Repo&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="the-model-is-small-the-refresh-policy-is-still-interesting"&gt;&#10; The model is small; the refresh policy is still interesting&#10; &lt;a class="heading-link" href="#the-model-is-small-the-refresh-policy-is-still-interesting"&gt;&#10; &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;&#10; &lt;/a&gt;&#10;&lt;/h2&gt;&#10;&lt;p&gt;A lot of hyperparameter optimization examples stop after one search. They find a good configuration, save the model, and leave the next training run as an exercise for the reader. Production systems have to answer a harder question: when new data arrives, how much of that search should happen again?&lt;/p&gt;</description></item><item><title>Counting Dice Instead of Rolling Them: Exact Probabilities for TTRPG Mechanics</title><link>http://www.volundarhus.com/posts/exact_dice_math/</link><pubDate>Mon, 23 Nov 2026 11:12:00 -0800</pubDate><guid>http://www.volundarhus.com/posts/exact_dice_math/</guid><description>&lt;h2 id="introduction"&gt;&#10; Introduction&#10; &lt;a class="heading-link" href="#introduction"&gt;&#10; &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;&#10; &lt;/a&gt;&#10;&lt;/h2&gt;&#10;&lt;p&gt;Two older posts on this site cover the &lt;a href="http://www.volundarhus.com/posts/dice_rolls" &gt;dice-roll visualizer&lt;/a&gt; and the &lt;a href="http://www.volundarhus.com/posts/stat_rolling" &gt;stat-generation tool&lt;/a&gt; I built on top of it. Both of them promised &amp;ldquo;exact probability calculation, no Monte Carlo sampling&amp;rdquo; and then promptly got distracted by the GM-facing parts.&lt;/p&gt;&#10;&lt;p&gt;This post is the math I skipped. What &amp;ldquo;deterministic&amp;rdquo; actually means when a computer says it, when I&amp;rsquo;d rather simulate than count, and two results I use at the table: the 20 × 20 grid that completely explains 5e advantage and disadvantage, and the combinations-versus-permutations trick that turns &amp;ldquo;roll seven stats, drop the lowest&amp;rdquo; from 268 million ordered arrays into 170,544 weighted multisets.&lt;/p&gt;</description></item><item><title>When Monster Stats Interact: Modeling 4e and 5e on Their Own Terms</title><link>http://www.volundarhus.com/posts/monster_modeling/</link><pubDate>Sun, 22 Nov 2026 07:45:33 -0800</pubDate><guid>http://www.volundarhus.com/posts/monster_modeling/</guid><description>&lt;h2 id="introduction"&gt;&#10; Introduction&#10; &lt;a class="heading-link" href="#introduction"&gt;&#10; &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;&#10; &lt;/a&gt;&#10;&lt;/h2&gt;&#10;&lt;p&gt;The first three posts in this series walked the monster tools from &lt;a href="http://www.volundarhus.com/posts/monster_matching" &gt;parsing and matching&lt;/a&gt;, through &lt;a href="http://www.volundarhus.com/posts/monster_conversion" &gt;cross-edition conversion&lt;/a&gt;, to &lt;a href="http://www.volundarhus.com/posts/monster_scaling" &gt;scaling within an edition&lt;/a&gt;. If you only skimmed the fitted rules, they look almost boring: a counterpart stat, the level or CR, maybe a role adjustment, and an intercept.&lt;/p&gt;&#10;&lt;p&gt;Most of the real work is hiding in the decisions around those short equations. Which stats earn a place in a rule? When does a role need its own slope instead of a flat bonus? Why does a source stat survive in one conversion direction but vanish in the other? And what should the fit do with a monster that&amp;rsquo;s real, official, and nothing like its peers?&lt;/p&gt;</description></item><item><title>Scaling D&amp;D Monsters Without Making Them Generic</title><link>http://www.volundarhus.com/posts/monster_scaling/</link><pubDate>Sat, 21 Nov 2026 22:26:18 -0800</pubDate><guid>http://www.volundarhus.com/posts/monster_scaling/</guid><description>&lt;h2 id="introduction"&gt;&#10; Introduction&#10; &lt;a class="heading-link" href="#introduction"&gt;&#10; &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;&#10; &lt;/a&gt;&#10;&lt;/h2&gt;&#10;&lt;p&gt;The &lt;a href="http://www.volundarhus.com/posts/monster_conversion" &gt;edition converter&lt;/a&gt; answers a cross-edition question: what might this 4e monster look like in 5e, or vice versa? A different problem comes up just as often during encounter prep:&lt;/p&gt;&#10;&lt;p&gt;&lt;strong&gt;I like this monster, but I need it a few levels or challenge ratings higher.&lt;/strong&gt;&lt;/p&gt;&#10;&lt;p&gt;The obvious approach is to find an average stat block at the new difficulty and copy its numbers. That works, but it throws away useful information. If the original monster was unusually tough for its level, I want the scaled version to stay unusually tough. If it had great DEX but poor STR, I don&amp;rsquo;t want a generic higher-CR stat block reversing that personality.&lt;/p&gt;</description></item><item><title>Converting D&amp;D Monsters with Formulas a GM Can Actually Use</title><link>http://www.volundarhus.com/posts/monster_conversion/</link><pubDate>Fri, 20 Nov 2026 22:25:18 -0800</pubDate><guid>http://www.volundarhus.com/posts/monster_conversion/</guid><description>&lt;h2 id="introduction"&gt;&#10; Introduction&#10; &lt;a class="heading-link" href="#introduction"&gt;&#10; &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;&#10; &lt;/a&gt;&#10;&lt;/h2&gt;&#10;&lt;p&gt;In the &lt;a href="http://www.volundarhus.com/posts/monster_matching" &gt;previous post&lt;/a&gt;, I built a dataset of matched monsters from the 4e and 5e Monster Manuals. Now for the obvious question: given a monster from one edition, what should its numbers look like in the other?&lt;/p&gt;&#10;&lt;p&gt;The naive answer is to fit the most flexible model available and let it spit out a stat block. But that misses what I actually want at the table. I don&amp;rsquo;t just need a number; I need a starting point I can understand, question, and adjust.&lt;/p&gt;</description></item><item><title>Matching Monsters Across Editions: Building a Dataset from Messy PDFs</title><link>http://www.volundarhus.com/posts/monster_matching/</link><pubDate>Thu, 19 Nov 2026 22:24:18 -0800</pubDate><guid>http://www.volundarhus.com/posts/monster_matching/</guid><description>&lt;h2 id="introduction"&gt;&#10; Introduction&#10; &lt;a class="heading-link" href="#introduction"&gt;&#10; &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;&#10; &lt;/a&gt;&#10;&lt;/h2&gt;&#10;&lt;p&gt;In my earlier posts on &lt;a href="http://www.volundarhus.com/posts/dice_rolls" &gt;dice-rolling probabilities&lt;/a&gt; and &lt;a href="http://www.volundarhus.com/posts/stat_rolling" &gt;stat generation&lt;/a&gt;, the data was the easy part: define some dice, enumerate the outcomes, compute the distribution. Converting monsters between D&amp;amp;D editions starts with a less glamorous problem. Before I could model anything, I had to answer two questions:&lt;/p&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Can I reliably turn two Monster Manual PDFs into structured stat blocks?&lt;/li&gt;&#10;&lt;li&gt;Which stat blocks actually describe the same creature?&lt;/li&gt;&#10;&lt;/ol&gt;&#10;&lt;p&gt;Those two questions became a project of their own. The eventual converter trains on 154 cross-edition pairs, but every pair sits at the end of a pipeline involving page geometry, OCR repair, parsers, aliases, metadata, and a final name-similarity check:&lt;/p&gt;</description></item><item><title>A Full-Loop MLOps Platform on Two Homelab Kubernetes Clusters</title><link>http://www.volundarhus.com/posts/basic_mlops_pipeline/</link><pubDate>Mon, 20 Jul 2026 18:46:00 -0700</pubDate><guid>http://www.volundarhus.com/posts/basic_mlops_pipeline/</guid><description>&lt;p&gt;&lt;a href="https://github.com/huntermills707/haterade" class="external-link" target="_blank" rel="noopener"&gt;GitHub Repo&lt;/a&gt;&lt;/p&gt;&#10;&lt;h2 id="why-i-built-this"&gt;&#10; Why I built this&#10; &lt;a class="heading-link" href="#why-i-built-this"&gt;&#10; &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;&#10; &lt;/a&gt;&#10;&lt;/h2&gt;&#10;&lt;p&gt;Most MLOps tutorials stop at &amp;ldquo;model in a notebook, Dockerfile around it.&amp;rdquo; The hard part is everything after: how a trained artifact moves from a training run into a production-grade serving topology, how a new model version earns its way into production, and what it costs to serve. I wanted that whole path to be concrete and reproducible on hardware I own, so I built it: a text-toxicity classifier that goes train → register → export → serve → canary → promote (or roll back), with a feedback loop that routes user corrections back into training data.&lt;/p&gt;</description></item><item><title>pymargins: A Ground-Up Redesign of Marginal Effects for Python</title><link>http://www.volundarhus.com/posts/pymargins_package/</link><pubDate>Sun, 31 May 2026 00:00:00 +0000</pubDate><guid>http://www.volundarhus.com/posts/pymargins_package/</guid><description>&lt;p&gt;A while back I wrote about &lt;a href="http://www.volundarhus.com/posts/smmargins/" &gt;marginal effects for StatsModels&lt;/a&gt;&#10;and then &lt;a href="http://www.volundarhus.com/posts/smmargins_package/" &gt;released that work as &lt;strong&gt;smmargins&lt;/strong&gt;&lt;/a&gt;,&#10;a package that brought Stata-style &lt;code&gt;margins&lt;/code&gt; to the StatsModels&#10;ecosystem. This post is about its successor, &lt;strong&gt;pymargins&lt;/strong&gt;, which is&#10;not a new version of smmargins but a complete, ground-up redesign.&lt;/p&gt;&#10;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#d8dee9;background-color:#2e3440;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pip install pymargins&#10;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="where-this-came-from"&gt;&#10; Where this came from&#10; &lt;a class="heading-link" href="#where-this-came-from"&gt;&#10; &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;&#10; &lt;/a&gt;&#10;&lt;/h2&gt;&#10;&lt;p&gt;smmargins started as research code. I was doing population-study work&#10;at UCSF, and the recurring need was to turn fitted models into&#10;quantities people could actually act on: a risk difference in&#10;percentage points, an adjusted prediction at a representative patient&#10;profile, a subgroup average marginal effect. StatsModels'&#10;&lt;code&gt;get_margeff()&lt;/code&gt; covered a sliver of that, so I kept accreting helpers&#10;until the helpers were the size of a package. smmargins was me carving&#10;the useful parts out of that research code and giving them a public&#10;API.&lt;/p&gt;</description></item><item><title>Introducing smmargins: Stata-Style Margins for Python StatsModels</title><link>http://www.volundarhus.com/posts/smmargins_package/</link><pubDate>Sun, 03 May 2026 21:46:31 -0700</pubDate><guid>http://www.volundarhus.com/posts/smmargins_package/</guid><description>A new Python package bringing Stata&amp;rsquo;s margins command to the StatsModels ecosystem.</description></item><item><title>Marginal Effects for StatsModels: A Stata-style `margins` in Python</title><link>http://www.volundarhus.com/posts/smmargins/</link><pubDate>Wed, 22 Apr 2026 00:00:00 +0000</pubDate><guid>http://www.volundarhus.com/posts/smmargins/</guid><description>&lt;blockquote&gt;&#10;&lt;p&gt;&lt;strong&gt;Archived.&lt;/strong&gt; The module described here grew into the &lt;strong&gt;smmargins&lt;/strong&gt;&#10;package, which has since been superseded by &lt;strong&gt;pymargins&lt;/strong&gt;, a&#10;ground-up redesign with JAX-native autodiff, a κ curvature diagnostic,&#10;unified delta/simulation/bootstrap inference, and many more model&#10;backends. The write-up below is kept for the math and design notes,&#10;but new development happens on pymargins. See &lt;a href="http://www.volundarhus.com/posts/pymargins_package/" &gt;pymargins: A Ground-Up&#10;Redesign of Marginal Effects for Python&lt;/a&gt;.&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;p&gt;If you&amp;rsquo;ve ever moved from Stata to Python and reached for &lt;code&gt;margins, dydx(*) at(age=(25 45 65))&lt;/code&gt;, you know the feeling. StatsModels has &lt;code&gt;get_margeff&lt;/code&gt;, but it&amp;rsquo;s narrow: average or at-means, continuous variables, a couple of model classes. The moment you want a marginal effect &lt;em&gt;at a specific covariate profile&lt;/em&gt;, or a discrete change for a factor, or a difference-in-differences on the probability scale of a logit, you&amp;rsquo;re on your own.&lt;/p&gt;</description></item><item><title>Beyond the Roll: Deep Dive into Rolling Stat Generation in TTRPGs</title><link>http://www.volundarhus.com/posts/stat_rolling/</link><pubDate>Tue, 10 Mar 2026 08:22:41 -0700</pubDate><guid>http://www.volundarhus.com/posts/stat_rolling/</guid><description>&lt;p&gt;In my previous post, &lt;a href="http://www.volundarhus.com/posts/dice_rolls" &gt;Dice-Rolling Probabilities in TTRPGs – Why a Little Math Makes Your Game Feel Fairer&lt;/a&gt;, I introduced a Dash app that visualizes the probability distributions of common dice rolling methods. We looked at 3d6, 4d6 drop lowest, and the convergence toward Gaussian distributions with larger pools.&lt;/p&gt;&#10;&lt;p&gt;Since then, I&amp;rsquo;ve expanded the simulator to handle full stat generation workflows, including modification rules like dropping or replacing specific stats.&lt;/p&gt;</description></item><item><title>Dice-Rolling Probabilities in TTRPGs – Why a Little Math Makes Your Game Feel Fairer (and More Fun)</title><link>http://www.volundarhus.com/posts/dice_rolls/</link><pubDate>Wed, 04 Mar 2026 20:35:11 -0800</pubDate><guid>http://www.volundarhus.com/posts/dice_rolls/</guid><description>&lt;h2 id="introduction"&gt;&#10; Introduction&#10; &lt;a class="heading-link" href="#introduction"&gt;&#10; &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;&#10; &lt;/a&gt;&#10;&lt;/h2&gt;&#10;&lt;p&gt;Every tabletop RPG (TTRPG) starts with a roll of the dice. Whether you’re generating heroic ability scores for a new character or handing out modest stats to a legion of NPC followers, the distribution of those rolls shapes the entire campaign. Too much variance can leave players feeling under-powered; too little can make every character feel the same.&lt;/p&gt;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&lt;a class="app-demo" href="https://py.cafe/app/huntermills707/dash-dice-roll-probability" target="_blank" rel="noopener"&gt;&#10; &#10; &lt;img class="app-demo-logo" src="https://py.cafe/logos/pycafe_logo.png" alt="Py.Cafe"&gt;&#10; &#10; &lt;span class="app-demo-text"&gt;&#10; &lt;strong&gt;Try the interactive app&lt;/strong&gt;&#10; &lt;span&gt;Explore dice-roll probabilities on Py.Cafe&lt;/span&gt;&#10; &lt;/span&gt;&#10; &lt;i class="fa-solid fa-arrow-up-right-from-square" aria-hidden="true"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;(opens in a new tab)&lt;/span&gt;&#10;&lt;/a&gt;&#10;&#10;&lt;p&gt;To explore the impact of different rolling procedures I built a Plotly Dash app (see the source files app.py, stats.py, modifiers.py, moments.py, etc.). The app lets you:&lt;/p&gt;</description></item><item><title>Visualizing Social Determinants of Health at the County Level</title><link>http://www.volundarhus.com/posts/pdi_visualizer/</link><pubDate>Mon, 23 Feb 2026 17:34:46 -0800</pubDate><guid>http://www.volundarhus.com/posts/pdi_visualizer/</guid><description>&lt;p&gt;Social determinants of health (SDoH) shape outcomes just as much as clinical care, but most public-health data is hard to grok as a table or a static chart. The granular patterns that drive disparities get lost. I recently built a Plotly/Dash visualizer for the Principled Deprivation Index that lets anyone explore a suite of deprivation indexes alongside CDC-reported condition rates, all mapped to U.S. counties.&lt;/p&gt;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&#10;&lt;a class="app-demo" href="https://pdi-visualizer.onrender.com/" target="_blank" rel="noopener"&gt;&#10; &#10; &lt;img class="app-demo-logo" src="http://www.volundarhus.com/images/render.svg" alt="Render"&gt;&#10; &#10; &lt;span class="app-demo-text"&gt;&#10; &lt;strong&gt;PDI Visualizer live demo&lt;/strong&gt;&#10; &lt;span&gt;Explore county deprivation indexes and health outcomes on Render&lt;/span&gt;&#10; &lt;/span&gt;&#10; &lt;i class="fa-solid fa-arrow-up-right-from-square" aria-hidden="true"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;(opens in a new tab)&lt;/span&gt;&#10;&lt;/a&gt;&#10;&#10;&lt;p&gt;&lt;img src="preview.png" alt="Preview"&gt;&lt;/p&gt;</description></item><item><title>Updating Plotly’s Choropleth Example with Current US Census Data</title><link>http://www.volundarhus.com/posts/geojson_plotly/</link><pubDate>Sat, 21 Feb 2026 19:44:23 -0800</pubDate><guid>http://www.volundarhus.com/posts/geojson_plotly/</guid><description>&lt;h2 id="introduction"&gt;&#10; Introduction&#10; &lt;a class="heading-link" href="#introduction"&gt;&#10; &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;&#10; &lt;/a&gt;&#10;&lt;/h2&gt;&#10;&lt;p&gt;Plotly/Dash makes it easy to build interactive dashboards, and its choropleth maps are a great way to visualize geographic data. Unfortunately, the &lt;a href="https://plotly.com/python/choropleth-maps/#choropleth-map-using-geojson" class="external-link" target="_blank" rel="noopener"&gt;official example&lt;/a&gt; uses outdated unemployment data and an old GeoJSON file. Since U.S. county boundaries change over time, those IDs no longer line up with the latest Census data.&lt;/p&gt;&#10;&lt;p&gt;&lt;img src="plotly_choropleth.png" alt="Choropleth"&gt;&lt;/p&gt;&#10;&lt;p&gt;In this post I’ll show how to replace the stale assets with fresh data pulled directly from the U.S. Census Bureau.&lt;/p&gt;</description></item></channel></rss>