Objectives
If all goes well you’ll come out of this with:
- High level understanding of ML models; what type of problems they’re suited well for solving
- Their strengths, weaknesses and limitations
- The tools and confidence to explore ML on your own should you choose to
You won’t be able to:
- Literally be able to ship an ML model from scratch in 30 minutes
- Use words like heteroscedasticity
Note: We’re gonna start with classical (“non-deep”), supervised machine learning for the sake of this demo. If none of those words make sense yet that’s okay.
Wtf is ML
A wonderful cliché is starting monologues with a definition. Let’s run it back.
“Machine learning is a subfield of artificial intelligence that gives computers the ability to learn without explicitly being programmed.”
A history of rapid scale decision-making
Let’s say I need to decide how much a house is worth. You’d go, gather a bunch of data. How much square footage the house has, how much homes nearby are worth. Maybe check whether the driveway sits at the crossroads of a railroad and an interstate.
At 1 house a day you do the math yourself. Maybe start with a spreadsheet, model it out, and apply some judgment on top.
At 10 homes a day maybe you hire a person.
At 1000/day you have a team, along with a bunch of systems in place to ensure accuracy and consistency.
At 1000/minute you probably want a computer.
Heuristics to models
The old school version of training a computer to make decisions is heuristic-based. Chain together a bunch of if-then statements. Maybe throw an equation into the mix. Think Zapier bots, most Excel functions. This is how most programming-based decisions used to work.
Algorithms are great for when the decision is relatively straightforward, and when there’s an absolute right answer.
While this approach works well enough for telling apart a squirrel from a hippo, it gets messy for more complicated things. How much is a house worth exactly? How positive was this customer’s experience? What is the likelihood they’ll convert?
Algorithmic decision making has some challenges:
- Limited inputs + complexity - even if the spreadsheet works, you end up applying “judgement” on top. As you add more inputs and rules, model complexity increases quadratically.
- Maintenance - how do you adjust to the environment as the rules of the game change?
ML to the rescue
The solution? Shove all the data that you can into a box, and ask it to predict the outcome.
How it works (kinda)
Back to predicting a house.
Let’s say you asked me to estimate the price of a home based on its square footage. You’ve got 2 variables and a target. You also have a spreadsheet with the data for 1000 homes.
You plot them on a chart. Then run a regression. The math involved is constructing a line which minimizes the error for any of the input data. The result is an equation that is your best mathematical prediction of the price, given square footage.
Now let’s say you’ve got 2 input variables. Square feet and age. Put sq ft on the x axis, age on y axis, and price on the z axis. And run the math again. You get a 3-dimensional line of best fit.
Now let’s say you have 50 input variables. It no longer makes for a cute graphic. But the end result is a line of best fit in 51-dimensional space, and an associated equation.
That’s your linear regression. Machine learning model. Magical box, pile of linear algebra.
Now that our decisions are computerized, we get a few other goodies:
- Ease of improvement - We can mess with the equation and backtest it against historical data.
- Accuracy tracking - We can measure the accuracy over time.
- Explainability - For regression models in particular, we can show the relationship between a particular variable and the output.
Back to our definition
Machine learning allows us to train computers to make decisions:
- Faster
- At infinite scale
- With more inputs
- With measurable accuracy over time
Where ML models are useful
A good way of understanding where ML models can be applied is to look at all the places you’re already interacting with them daily as a consumer.
- Feeds - Instagram, TikTok, Amazon all run ML to decide what to show you, prioritizing engagement.
- Binary decisions - Fraud alerts, credit card approvals, spam detection.
| Type of Prediction | Example |
|---|---|
| Continuous value | Flight prices / hotel prices / likelihood that customer X purchases product Y |
| Binary outcome (true vs false) | Was a transaction fraudulent? / Is a given email spam? |
| Classification | What genre does a movie belong to? |
Why you shouldn’t ship an ML model
Like all things, the decision to ship a project can roughly be the expected impact vs effort.
Where ML models work well:
- Lots of data that matches what you’re trying to predict
- That’s clean - garbage in, garbage out
- That’s reasonably homogenous - the less variation in the data, the clearer the relationships are
- With outcomes - you can’t fit a line if you don’t have the outcome data
Consider the effort to get one up and running:
- Data cleaning/gathering (and labeling if needed)
- Model training
- Validation - backtest at minimum
- Deployment - getting the model running continuously and integrating outputs
- Monitoring - tracking that the model doesn’t deteriorate with time