Tivadar Danka Profile picture
Sep 4 16 tweets 5 min read Read on X
Logistic regression is one of the simplest models in machine learning, and one of the most revealing.

It shows how to move from geometric intuition to probabilistic reasoning. Mastering it sets the foundation for everything else.

Let’s dissect it step by step! Image
Let’s start with the most basic setup possible: one feature, two classes.

You’re predicting if a student passes or fails based on hours studied.

Your input x is a number, and your output y is either 0 or 1.

Let's build a predictive model! Image
We need a model that outputs values between 0 and 1.

Enter the sigmoid function: σ(ax + b).

If σ(ax + b) > 0.5, we predict pass (1).

Otherwise, fail (0).

It’s a clean way to represent uncertainty with math. Image
So what is logistic regression, really?

It’s just a linear regression plus a sigmoid.

We learn the best a and b from data, then use that to turn any x into a probability. Image
Let’s unpack this model.

First, we apply the linear transformation: y = ax + b.

This is just a line, our old friend from high school algebra.

But it plays a key role in shaping the output. Image
The output of ax + b is called a logit.

Positive logits suggest pass, negative suggest fail.

It's still a number on a line, not yet a probability.

That comes next.
Next, we exponentiate the logit: eᵃˣ⁺ᵇ.

This guarantees the output is always positive.

We’re preparing the value for normalization, and exponentiation bends the scale in our favor. Image
Now we flip it: e⁻⁽ᵃˣ⁺ᵇ⁾.

This inverts the curve and sets us up to approach 1 asymptotically. Image
We add 1, and obtain 1 + e⁻⁽ᵃˣ⁺ᵇ⁾.

This keeps everything above 1. It prevents division by zero in the next step, and squeezes the values of the reciprocals between 0 and 1.

This tiny change stabilizes the entire model. Image
Finally, we take the reciprocal: 1 / (1 + e⁻⁽ᵃˣ⁺ᵇ⁾).

This gives us the full sigmoid function, and maps the entire real line to (0, 1).

Now we have a proper probability. Image
We’ve seen how to turn a number into a probability.

But what about geometry? That becomes clear in higher dimensions.

Let’s level up.
In 2D, the model becomes a plane: y = a₁x₁ + a₂x₂ + b.

The decision boundary is where this equals 0. Points above the plane get one class, below get another.

The model is slicing space into two halves. Image
The logit in higher dimensions measures signed distance to the boundary.

It tells you how confidently the model classifies a point. Closer to 0 means more uncertainty.

It’s probability with geometric roots. Image
Logistic regression is a blueprint for how modern models make decisions.

It blends math, geometry, and probability in one clean package.

Understand it deeply, and you’ll see it everywhere.
Most machine learning practitioners don’t understand the math behind their models.

That's why I've created a FREE roadmap for my 27,000+ newsletter subscribers.

Get the roadmap here: thepalindrome.org/p/the-roadmap-…
The Mathematics of Machine Learning book is now at 10% on Amazon.

I have packed 20 years of math studies into 700 pages full of intuitive and application-oriented lessons, the ultimate learning resource for you.

Get it now: amazon.com/Mathematics-Ma…

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Tivadar Danka

Tivadar Danka Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @TivadarDanka

Sep 7
Behold one of the mightiest tools in mathematics: the camel principle.

I am dead serious. Deep down, this tiny rule is the cog in many methods. Ones that you use every day.

Here is what it is, how it works, and why it is essential: Image
First, the story:

The old Arab passes away, leaving half of his fortune to his eldest son, third to his middle son, and ninth to his smallest.

Upon opening the stable, they realize that the old man had 17 camels. Image
This is a problem, as they cannot split 17 camels into 1/2, 1/3, and 1/9 without cutting some in half.

So, they turn to the wise neighbor for advice. Image
Read 18 tweets
Sep 7
The way you think about the exponential function is wrong.

Don't think so? I'll convince you. Did you realize that multiplying e by itself π times doesn't make sense?

Here is what's really behind the most important function of all time: Image
First things first: terminologies.

The expression aᵇ is read "a raised to the power of b."

(Or a to the b in short.) Image
The number a is called the base, and b is called the exponent.

Let's start with the basics: positive integer exponents. By definition, aⁿ is the repeated multiplication of a by itself n times.

Sounds simple enough. Image
Read 18 tweets
Sep 5
In machine learning, we use the dot product every day.

However, its definition is far from revealing. For instance, what does it have to do with similarity?

There is a beautiful geometric explanation behind: Image
By definition, the dot product (or inner product) of two vectors is defined by the sum of coordinate products. Image
To peek behind the curtain, there are three key properties that we have to understand.

First, the dot product is linear in both variables. This property is called bilinearity. Image
Read 16 tweets
Sep 5
The single biggest argument about statistics: is probability frequentist or Bayesian?

It's neither, and I'll explain why.

Deep-dive explanation incoming: Image
First, let's look at what probability is.

Probability quantitatively measures the likelihood of events, like rolling six with a die. It's a number between zero and one.

This is independent of interpretation; it’s a rule set in stone. Image
In the language of probability theory, the events are formalized by sets within an event space.

The event space is also a set, usually denoted by Ω.) Image
Read 34 tweets
Sep 4
You have seen the famous bell curve hundreds of times before.

Contrary to popular belief, this is NOT a probability, but a probability density.

What are densities, and why do we need them? Read on: Image
First, let's talk about probability.

The gist is, probability is a function P(A) that takes an event (that is, a set), and returns a real number between 0 and 1.

The event is a subset of the so-called sample space, a set often denoted with the capital Greek omega (Ω). Image
Every probability measure must satisfy three conditions: nonnegativity, additivity, and the probability of the entire sample space must be 1.

These are called the Kolmogorov axioms of probability, named after Andrey Kolmogorov, who first formalized them. Image
Read 22 tweets
Sep 4
Neural networks are stunningly powerful.

This is old news: deep learning is state-of-the-art in many fields, like computer vision and natural language processing. (But not everywhere.)

Why are neural networks so effective? I'll explain: Image
First, let's formulate the classical supervised learning task!

Suppose that we have a dataset D, where xₖ is a data point and yₖ is the ground truth. Image
The task is simply to find a function g(x) for which

• g(xₖ) is approximately yₖ,
• and g(x) is computationally feasible.

To achieve this, we fix a parametrized family of functions.

For instance, linear regression uses this function family: Image
Read 19 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(