Updated May 27, 2026 Betting Models

Python, My New Year’s Resolution?

Matthew Buchalter
By Matthew Buchalter Contributor
Published August 14, 2021
6 min read
162
Python, My New Year’s Resolution?

Yes, it’s that time of year where we look back on what we’ve accomplished and look forward to the future.

Global pandemic aside, it’s been a pretty cool year for Plus EV Analytics. I started my own blog, and I got to appear on some great podcasts including my friends at the Deep Dive, Captain Jack’s Happy Hour and the legendary Gambling With An Edge. My content is now reaching 15,000 site visitors and nearly 8,000 Twitter followers. We found a fun angle on the MLB shortened season that many readers were able to profit from.

So what will 2021 bring? For one thing, I will be turning 40 and crossing the unofficial boundary into “middle aged”. It’s the kind of thing that makes one reflect on one’s purpose in life. And of course I want to be a good husband, good father, blah blah blah but this a math blog…so what’s my purpose in math? I’m fortunate enough over the last couple years, through my day job, my betting pursuits and this blog, to have developed a pretty good sense of my purpose in math.

My purpose is to become one of the world’s leading experts in problems of “small data”.

Defining the Small Data Problem

What is “small data”? Is it a term I just made up? (Obviously, yes.) At a time when the world is increasingly focused on “big data” and machine learning, it’s just not something I have much interest in, or much ability either. You can’t teach a middle aged dog new tricks. To borrow from actuarial terminology, “small data” exists at the intersection of two distinct modeling approaches:

  • “Exposure Rating” is where you predict the value (or distribution) of an unknown outcome using a set of predictor variables (“covariates”) that are correlated with the outcome. Common techniques for exposure rating include regressions, generalized linear models, decision trees, etc.
  • “Experience rating” is where you predict the value (or distribution) of an unknown outcome using a set of previous observations from the same process. Common techniques for experience rating include means, medians, capping or filtering for outliers, interpolation, extrapolation, etc.

Experience rating works best when your sample size is high; i.e. when you have many previous observations of the thing you’re trying to predict and/or when you have few or no or weak covariates available. Exposure rating works best when you have zero previous observations of the thing you’re trying to predict and/or when you have many strong covariates available. My world is the in between: Where you have some previous observations but not enough to rely entirely on experience rating, and you have some covariates but not strong enough to rely entirely on exposure rating. Finding that balance requires a set of tools that don’t seem to exist anywhere in textbooks or academia, as far as I’ve found. So I’ve developed them myself…

Why Excel Still Works for Modeling

…which leads me to my New Year’s Resolution? (emphasis on the ?) My twitter followers know how much of a fan I am of doing data science in Excel and that I have refused to switch to R or Python despite being called a dinosaur many times by very smart people. Some of it is pure stubbornness on my part…yes Excel is clunky and slow, but I love being able to visualize each step of a complex algorithm as cells instead of as lines of code. It allows me to spot and fix errors much more quickly and thoroughly, both logic errors and coding errors. Also, pivot tables are a freaking godsend and I might cry if I lost them. But I’ve experimented a little with Python and it seems like something I would be able to get used to eventually if I put in the effort.

Here’s the main problem though. To solve “small data” problems, I need Excel solver like I need oxygen. The reason is that predefined functions exist (both in Excel and in Python) to fit exposure rating models, and predefined functions exist to fit experience rating models. There are no predefined functions to fit the kind of hybrid models that I develop. So I do it using first principles, finding the set of parameters that maximizes the loglikelihood of the data. This is where Excel shines with its cell structure and its Solver module; and this, loyal readers, is where I need your help if I’m going to make the switch to Python. I need to find a replacement.

Building a Hybrid Model with Solver

Here’s an example of the type of “small data” model I would like to build. In this made-up problem, we are trying to predict the rate of goals scored per game for a set of hockey players using this data:

In the exposure rating module, we are fitting a “prior” as a function of the salary and the rookie indicator in a form similar to a log-link GLM, except that we are adding a “floor” parameter on the salary to account for a non-linearity in the effect:

ln(prior) = P_intercept + P_logsalary * ln(max(salary, P_minsalary)) + P_rookie * (rookie indicator)

In the experience rating module, we are combining our prior with our last year observed using a “ballast” approach to form a posterior:

Posterior = (last year goals + P_ballast * prior) / (last year games played + P_ballast)

That gives us 5 total parameters, that we are going to fit using maximum posterior likelihood:

Loglik = ln(poisson.dist(x = this year goals, mean = this year games played * posterior, cumulative = false))

Find {P_intercept, P_logsalary, P_minsalary, P_rookie, P_ballast} that maximizes loglik.

Here’s how to fit the model using Solver:

Here is the Excel file if you want to see the formulas:

example Download

Is there any way to do this in Python without writing hundreds of lines of custom code? If yes, please email me at PlusEVAnalytics@outlook.com or DM me on Twitter.

Thanks, and happy new year everyone!

Learn Data Science Workflows for Sports Models

This article shows the practical challenge behind many sports betting models: combining domain knowledge, small samples, custom likelihoods, priors, posteriors, and optimization into a workflow that is flexible enough to improve over time. If you want to build that modeling foundation, start with Art of Sports Betting Analytics. If you want to move from Excel-style analysis into structured data workflows, model building, and sports betting projects, continue with Data Science for Sports Betting

All Articles
Table of Contents
Defining the Small Data Problem Why Excel Still Works for Modeling Building a Hybrid Model with Solver Learn Data Science Workflows for Sports Models

Related Articles

Continue exploring sports betting analytics, quantitative methods, and market-focused strategy.
March Madness: Presenting the analytics.b(rack)et!
Betting Models 8 min read

March Madness: Presenting the analytics.b(rack)et!

First, two HUGE disclaimers. My domain knowledge as it relates to NCAA basketball is pretty much zero. It’s just not something I’ve ever gotten myself into. Colle...
14-03-2022
219
Matthew Buchalter
By Matthew Buchalter Contributor
My First Model
Betting Models 9 min read

My First Model

Hi everyone! I’m going to use this “blog” to write some articles instead of publishing through a third party. For my inaugural post, I thought I’d revisit the ver...
15-08-2021
271
Matthew Buchalter
By Matthew Buchalter Contributor
Introduction to Mixed Models
Bayesian Modeling 11 min read

Introduction to Mixed Models

Translating from Wikipedia’s nomenclature to ours: µ0 is our initial estimate of M_M σ0 is our initial estimate of M_S σ is S n is the number of games we’ve obser...
15-08-2021
205
Matthew Buchalter
By Matthew Buchalter Contributor
To The Extreme: MLB Season Props
Betting Models 13 min read

To The Extreme: MLB Season Props

So this is the functional form of the model we’re going to use in our study of MLB props: P(top score of x) = BINOM.DIST(x+0.5,n,p,TRUE)^z – BINOM.DIST(x-0.5,n,p,...
15-08-2021
605
Matthew Buchalter
By Matthew Buchalter Contributor
Horse Racing: Sport of Kings, Sport of Quants
Betting Models 15 min read

Horse Racing: Sport of Kings, Sport of Quants

This photo is currently hanging in my home office. I’ve never been to this track, and I don’t know any of these people. June 8, 2012 Shakopee, Minnesota It was a...
15-08-2021
567
Matthew Buchalter
By Matthew Buchalter Contributor
Next Generation Ticket Pricing
Betting Models 6 min read

Next Generation Ticket Pricing

Well, we’re 14 months into this pandemic and while a return to full-attendance live events is on the horizon in some parts of the world, most of North America is...
14-08-2021
176
Matthew Buchalter
By Matthew Buchalter Contributor
DIY Linear (and Nonlinear!) Regression using Maximum Likelihood
Betting Models 11 min read

DIY Linear (and Nonlinear!) Regression using Maximum Likelihood

Around the house, I am far from a handyman. I can change a light bulb, but anything more difficult than that and I’m gladly paying someone else to do it. Put me i...
14-08-2021
220
Matthew Buchalter
By Matthew Buchalter Contributor
See All Articles

Want to apply these concepts in practice?

Explore our professional betting analytics courses
Explore Courses